Files
shadow/docs/man/gpasswd.1.md
T
Jocelyn Le SageandPierre Warnier 8361bf512b gpasswd: added implementation of gpasswd (#282)
* gpasswd: added implementation of gpasswd

* gpasswd: rebase onto main and port to the current APIs

Rebases jlesage's implementation onto a main that moved a long way under
it, and carries it onto the interfaces that landed since the branch was
cut. The tool's behaviour is unchanged and still matches GNU on every
path probed.

What the rebase had to resolve:

  - shadow-rs.spec and debian/ were revived by the merge; both were
    deleted because neither could build.
  - The standalone dispatch() and hand-written --list predate the single
    applets() table, which now drives both. gpasswd joins the table.
  - The five shadow-core parser features it asked for no longer exist.
  - The fourteen [[test]] targets are one; test_gpasswd joins it.
  - README, Makefile and PLATFORM-SUPPORT described the pre-#239
    privilege model, in which every applet ran with euid 0.

What changed beyond the rebase:

  - gpasswd keeps its privilege in the multicall build. It is setuid in
    GNU and the branch marks it setuid for the per-tool install, but
    SETUID_APPLETS still listed four names, so the multicall build would
    have dropped privilege and no group administrator could have used it
    -- silently.
  - Comments in /etc/group survive. It read entries only and wrote them
    back, which erases every comment, blank line and NIS compatibility
    line in the file. The locked-file transaction keeps them, and commits
    group and gshadow together so a bad value cannot leave the pair
    disagreeing.
  - The duplicated EchoGuard and password reader are gone, replaced by
    shadow_core::tty, which blocks interrupts for the read so Ctrl-C at
    the prompt cannot leave the terminal with echo off.
  - The print macros are replaced. They panic when the stream is closed,
    which a setuid-root tool must not do part way through a change.
    These were the only five in the repository and no lint caught them,
    so clippy::print_stdout and print_stderr are now denied
    workspace-wide, with the test crate exempt.

The GNU comparison suite gains gpasswd: the unknown-group, unknown-user
and non-member exit codes, all three of which match.

CONTRIBUTING's licence list also said ISC, BSD-2-Clause, CC0-1.0, Zlib
and MPL-2.0 were acceptable, which stopped being true when deny.toml was
narrowed to the graph. It now says what deny.toml enforces.

---------

Co-authored-by: Pierre Warnier <pierre@warnier.net>
2026-09-06 11:03:53 +02:00

2.8 KiB

gpasswd(1) - administer /etc/group and /etc/gshadow

NAME

gpasswd - administer /etc/group and /etc/gshadow

SYNOPSIS

gpasswd [options] group

DESCRIPTION

The gpasswd command administers /etc/group and /etc/gshadow. Every group can have administrators, members, and a password.

System administrators can use the -A option to define group administrator(s) and the -M option to define members. They have all rights of group administrators and members.

gpasswd called by a group administrator with a group name only prompts for the new password of the group.

If a password is set the members can still use newgrp(1) without a password, and non-members must supply the password.

This tool is installed setuid-root so that a group administrator (a user named in the gshadow administrators field) can add and remove members and change the group password without being root. -A and -M remain root-only.

Notes about group passwords

Group passwords are an inherent security problem since more than one person is permitted to know the password. However, groups are a useful tool for permitting co-operation between different users.

OPTIONS

Except for the -A and -M options, the options cannot be combined.

-a, --add USER
Add USER to the named group.
-d, --delete USER
Remove USER from the named group.
-A, --administrators USER,...
Set the list of administrative users. Root only. Requires /etc/gshadow. An empty list clears the administrators.
-M, --members USER,...
Set the list of group members. Root only. An empty list clears the members.
-r, --remove-password
Remove the password from the named group. The group password will be empty. Only group members will be allowed to use newgrp to join the named group.
-R, --restrict
Restrict access to the named group. The group password is set to "!". Only group members will be allowed to use newgrp to join the named group.
-Q, --root CHROOT_DIR
Locate the system files under CHROOT_DIR instead of /. Only absolute paths are supported. Root only.
-P, --prefix PREFIX_DIR
Use PREFIX_DIR as a prefix for system file paths. Root only.

EXIT STATUS

0
Success.
1
Permission denied.
2
Invalid command syntax.
3
Invalid argument to option, or specified group doesn't exist.
10
Can't update group file.
17
Shadow group file required for -A.

FILES

/etc/group
Group account information.
/etc/gshadow
Secure group account information.
/etc/login.defs
Shadow password suite configuration (ENCRYPT_METHOD, SHA_CRYPT_MIN_ROUNDS, SHA_CRYPT_MAX_ROUNDS).

SEE ALSO

newgrp(1), groupadd(8), groupdel(8), groupmod(8), grpck(8), group(5), gshadow(5)