Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- `chage -E`/`-d`, `usermod -e` and `useradd -e` take the date forms upstream reads
with its date parser, not only `YYYY-MM-DD`: `01/02/2030`, `2030/01/02`, `1/2/30`,
`2 Jan 2030`, `January 2, 2030`, `tomorrow`, with any time of day dropped. They are
read with `parse_datetime`, a new dependency of `shadow-core`. `YYYY-MM-DD`, a day
count and `-1` behave as before, and an impossible `YYYY-MM-DD` such as
`2023-02-29` is still refused where upstream rolls it over (#365)

- `chfn` writes the "other" GECOS sub-field, and the comma before it, only when it is
not empty, as upstream does. `chfn -f NewName` on an empty GECOS wrote
`NewName,,,,` instead of `NewName,,,`, so every change left a trailing empty field
Expand Down
131 changes: 128 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ uucore = "0.12"
# Error handling
thiserror = "2"

# Dates
parse_datetime = "0.17"
jiff = { version = "0.2", default-features = false, features = ["std"] }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zoned::now() needs jiff's tz-system to read the local zone, no?
here it only works because parse_datetime turns it on, could you please enable it explicitly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was only on through parse_datetime. 70d9375 enables tz-system and tzdb-zoneinfo (for a named zone such as TZ=Europe/Paris) on shadow-core's jiff. cargo tree -e features -i jiff now lists uu_shadow_core under both; cargo deny check is clean. chage -E today gives 20765 under TZ=Pacific/Kiritimati and 20764 under TZ=Etc/GMT+12.


# Unix/Linux
rustix = { version = "1", features = ["event", "fs", "param", "process", "pty", "rand", "termios"] }
libc = "0.2"
Expand Down
13 changes: 9 additions & 4 deletions docs/man/chage.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ nothing is written. This is for root only.

**-d**, **--lastday** *LAST_DAY*
: Record *LAST_DAY* as the date of the last password change. Accepts
**YYYY-MM-DD** or a number of days since the epoch. **-1** clears the
field. A last day of **0** forces a password change at the next login.
**YYYY-MM-DD**, a number of days since the epoch, or another date form
**date**(1) **-d** reads, such as **01/02/2030**, **2030/01/02**,
**2 Jan 2030**, **January 2, 2030** or **tomorrow**, read in the local time
zone with any time of day dropped. A **YYYY-MM-DD** date that does not
exist, such as **2025-02-29**, is refused rather than rolled over, and so is
a date before 1970. **-1** clears the field. A last day of **0** forces a
password change at the next login.

**-E**, **--expiredate** *EXPIRE_DATE*
: Expire the account on *EXPIRE_DATE*, in the same two forms. **-1** removes
the expiry. An expired account is refused a login even with a valid
: Expire the account on *EXPIRE_DATE*, in the same forms as **-d**. **-1**
removes the expiry. An expired account is refused a login even with a valid
password.

**-I**, **--inactive** *INACTIVE*
Expand Down
4 changes: 3 additions & 1 deletion docs/man/useradd.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ default values used for creating new accounts.

**-e**, **--expiredate** *EXPIRE_DATE*
: Set the expiration date of the new account (YYYY-MM-DD). **-1** leaves it
unset.
unset. A number of days since the epoch, and the other date forms
**date**(1) **-d** reads (**01/02/2030**, **2 Jan 2030**, **tomorrow**),
are accepted as for **chage**(1) **-E**.

**-f**, **--inactive** *INACTIVE*
: Set the password inactivity period of the new account. **-1** leaves it
Expand Down
4 changes: 3 additions & 1 deletion docs/man/usermod.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ changes that are specified on the command line.

**-e**, **--expiredate** *EXPIRE_DATE*
: Set the account expiration date, as YYYY-MM-DD or a number of days since the
epoch. **-1** removes the date.
epoch, or another date form **date**(1) **-d** reads (**01/02/2030**,
**2 Jan 2030**, **tomorrow**), as for **chage**(1) **-E**. **-1** removes the
date.

**-f**, **--inactive** *INACTIVE*
: Set the password inactive period, in days. **-1** removes it.
Expand Down
5 changes: 5 additions & 0 deletions src/shadow-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ path = "src/lib.rs"

[dependencies]
clap = { workspace = true }
# `Zoned::now()` reads the local zone: `tz-system` reads TZ and /etc/localtime,
# and `tzdb-zoneinfo` resolves a zone name such as TZ=Europe/Paris against
# /usr/share/zoneinfo. Without them the zone silently behaves as UTC.
jiff = { workspace = true, features = ["tz-system", "tzdb-zoneinfo"] }
libc = { workspace = true }
parse_datetime = { workspace = true }
rustix = { workspace = true }
thiserror = { workspace = true }
uucore = { workspace = true }
Expand Down
Loading
Loading