Skip to content

Commit

Permalink
usermod: Small optimization using memmove for password unlock
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kletzander <[email protected]>
  • Loading branch information
nertpinx authored and hallyn committed May 26, 2023
1 parent e3b7058 commit 8665fe1
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/usermod.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,6 @@ static char *new_pw_passwd (char *pw_pass)
strcat (buf, pw_pass);
pw_pass = buf;
} else if (Uflg && pw_pass[0] == '!') {
char *s;

if (pw_pass[1] == '\0') {
fprintf (stderr,
_("%s: unlocking the user's password would result in a passwordless account.\n"
Expand All @@ -445,11 +443,7 @@ static char *new_pw_passwd (char *pw_pass)
"updating password", user_newname, user_newid, 0);
#endif
SYSLOG ((LOG_INFO, "unlock user '%s' password", user_newname));
s = pw_pass;
while ('\0' != *s) {
*s = *(s + 1);
s++;
}
memmove(pw_pass, pw_pass + 1, strlen(pw_pass));
} else if (pflg) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
Expand Down

0 comments on commit 8665fe1

Please sign in to comment.