Skip to content

Commit 6c5d51c

Browse files
ldv-altsolardiz
authored andcommitted
pam_passwdqc: extend enforce=users setting to support chpasswd
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
1 parent 4d1742b commit 6c5d51c

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Added pkg-config file.
44

5+
Changed enforce=users to support "chpasswd" PAM service in addition to
6+
traditionally supported "passwd".
7+
58

69
Significant changes between 2.0.1 and 2.0.2.
710

README

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ The "only" modifier can be used to disallow user-chosen passwords.
140140
enforce=none|users|everyone [enforce=everyone]
141141

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

146148
non-unix []
147149

pam_passwdqc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int am_root(pam_handle_t *pamh)
296296
return 0;
297297
service = item;
298298

299-
return !strcmp(service, "passwd");
299+
return !strcmp(service, "passwd") || !strcmp(service, "chpasswd");
300300
}
301301

302302
PAM_EXTERN int pam_sm_chauthtok(pam_handle_t *pamh, int flags,

passwdqc.conf.5

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,15 @@ The PAM module can be configured to warn of weak passwords only, but not
228228
actually enforce strong passwords.
229229
The
230230
.Cm users
231-
setting will enforce strong passwords for invocations by non-root users only.
231+
setting is like
232+
.Cm everyone
233+
for all PAM services except
234+
.Cm chpasswd
235+
and
236+
.Cm passwd .
237+
For these two PAM services
238+
.Cm users
239+
will enforce strong passwords for invocations by non-root users only.
232240
.It Cm non-unix
233241
Normally, the PAM module uses
234242
.Xr getpwnam 3

0 commit comments

Comments
 (0)