Skip to content

Commit

Permalink
pam_passwdqc: extend enforce=users setting to support chpasswd
Browse files Browse the repository at this point in the history
Before this change, enforce=users was handled like enforce=everyone for
all PAM services except passwd.  Now, in addition to passwd, chpasswd
is another PAM service for which enforce=users setting will enforce
strong passwords for invocations by non-root users only.

The reason why the effect of enforce=users is limited to these two
services is that login services invoke the PAM stack as root, so if
change of expired password is forced then with enforce=users and no
service name check a non-root user would bypass password policy.

Suggested-by: Solar Designer <[email protected]>
Resolves: #27
  • Loading branch information
ldv-alt authored and solardiz committed Jun 22, 2023
1 parent 4d1742b commit 6c5d51c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Added pkg-config file.

Changed enforce=users to support "chpasswd" PAM service in addition to
traditionally supported "passwd".


Significant changes between 2.0.1 and 2.0.2.

Expand Down
6 changes: 4 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ The "only" modifier can be used to disallow user-chosen passwords.
enforce=none|users|everyone [enforce=everyone]

The module can be configured to warn of weak passwords only, but not
actually enforce strong passwords. The "users" setting will enforce
strong passwords for invocations by non-root users only.
actually enforce strong passwords. The "users" setting is like
"everyone" for all PAM services except "chpasswd" and "passwd".
For these two PAM services "users" will enforce strong passwords
for invocations by non-root users only.

non-unix []

Expand Down
2 changes: 1 addition & 1 deletion pam_passwdqc.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static int am_root(pam_handle_t *pamh)
return 0;
service = item;

return !strcmp(service, "passwd");
return !strcmp(service, "passwd") || !strcmp(service, "chpasswd");
}

PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
Expand Down
10 changes: 9 additions & 1 deletion passwdqc.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,15 @@ The PAM module can be configured to warn of weak passwords only, but not
actually enforce strong passwords.
The
.Cm users
setting will enforce strong passwords for invocations by non-root users only.
setting is like
.Cm everyone
for all PAM services except
.Cm chpasswd
and
.Cm passwd .
For these two PAM services
.Cm users
will enforce strong passwords for invocations by non-root users only.
.It Cm non-unix
Normally, the PAM module uses
.Xr getpwnam 3
Expand Down

0 comments on commit 6c5d51c

Please sign in to comment.