|
|
4fb1b2 |
Index: shadow-4.5/src/usermod.c
|
|
|
4fb1b2 |
===================================================================
|
|
|
4fb1b2 |
--- shadow-4.5.orig/src/usermod.c
|
|
|
4fb1b2 |
+++ shadow-4.5/src/usermod.c
|
|
|
4fb1b2 |
@@ -455,14 +455,17 @@ static char *new_pw_passwd (char *pw_pas
|
|
|
4fb1b2 |
strcat (buf, pw_pass);
|
|
|
4fb1b2 |
pw_pass = buf;
|
|
|
4fb1b2 |
} else if (Uflg && pw_pass[0] == '!') {
|
|
|
4fb1b2 |
- char *s;
|
|
|
4fb1b2 |
+ char *s = pw_pass;
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
- if (pw_pass[1] == '\0') {
|
|
|
4fb1b2 |
+ while ('!' == *s)
|
|
|
4fb1b2 |
+ ++s;
|
|
|
4fb1b2 |
+
|
|
|
4fb1b2 |
+ if (*s == '\0') {
|
|
|
4fb1b2 |
fprintf (stderr,
|
|
|
4fb1b2 |
_("%s: unlocking the user's password would result in a passwordless account.\n"
|
|
|
4fb1b2 |
"You should set a password with usermod -p to unlock this user's password.\n"),
|
|
|
4fb1b2 |
Prog);
|
|
|
4fb1b2 |
- return pw_pass;
|
|
|
4fb1b2 |
+ return NULL;
|
|
|
4fb1b2 |
}
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
#ifdef WITH_AUDIT
|
|
|
4fb1b2 |
@@ -471,12 +474,15 @@ static char *new_pw_passwd (char *pw_pas
|
|
|
4fb1b2 |
user_newname, (unsigned int) user_newid, 1);
|
|
|
4fb1b2 |
#endif
|
|
|
4fb1b2 |
SYSLOG ((LOG_INFO, "unlock user '%s' password", user_newname));
|
|
|
4fb1b2 |
- s = pw_pass;
|
|
|
4fb1b2 |
- while ('\0' != *s) {
|
|
|
4fb1b2 |
- *s = *(s + 1);
|
|
|
4fb1b2 |
- s++;
|
|
|
4fb1b2 |
- }
|
|
|
4fb1b2 |
+ memmove (pw_pass, s, strlen (s) + 1);
|
|
|
4fb1b2 |
} else if (pflg) {
|
|
|
4fb1b2 |
+ if (strchr (user_pass, ':') != NULL) {
|
|
|
4fb1b2 |
+ fprintf (stderr,
|
|
|
4fb1b2 |
+ _("%s: The password field cannot contain a colon character.\n"),
|
|
|
4fb1b2 |
+ Prog);
|
|
|
4fb1b2 |
+ return NULL;
|
|
|
4fb1b2 |
+
|
|
|
4fb1b2 |
+ }
|
|
|
4fb1b2 |
#ifdef WITH_AUDIT
|
|
|
4fb1b2 |
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
|
|
4fb1b2 |
"updating-password",
|
|
|
4fb1b2 |
@@ -525,6 +531,8 @@ static void new_pwent (struct passwd *pw
|
|
|
4fb1b2 |
if ( (!is_shadow_pwd)
|
|
|
4fb1b2 |
|| (strcmp (pwent->pw_passwd, SHADOW_PASSWD_STRING) != 0)) {
|
|
|
4fb1b2 |
pwent->pw_passwd = new_pw_passwd (pwent->pw_passwd);
|
|
|
4fb1b2 |
+ if (pwent->pw_passwd == NULL)
|
|
|
4fb1b2 |
+ fail_exit (E_PW_UPDATE);
|
|
|
4fb1b2 |
}
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
if (uflg) {
|
|
|
4fb1b2 |
@@ -639,6 +647,8 @@ static void new_spent (struct spwd *spen
|
|
|
4fb1b2 |
* + aging has been requested
|
|
|
4fb1b2 |
*/
|
|
|
4fb1b2 |
spent->sp_pwdp = new_pw_passwd (spent->sp_pwdp);
|
|
|
4fb1b2 |
+ if (spent->sp_pwdp == NULL)
|
|
|
4fb1b2 |
+ fail_exit(E_PW_UPDATE);
|
|
|
4fb1b2 |
|
|
|
4fb1b2 |
if (pflg) {
|
|
|
4fb1b2 |
spent->sp_lstchg = (long) gettime () / SCALE;
|