Merge pull request #458 from edneville/434_usermod_home_dir_trailing_slash

Remove tailing slash on home dir
This commit is contained in:
Serge Hallyn 2021-12-17 08:41:26 -06:00 committed by GitHub
commit 0f31dc5c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -584,6 +584,12 @@ static void new_pwent (struct passwd *pwent)
SYSLOG ((LOG_INFO,
"change user '%s' home from '%s' to '%s'",
pwent->pw_name, pwent->pw_dir, user_newhome));
if (strlen(user_newhome) > 1
&& '/' == user_newhome[strlen(user_newhome)-1]) {
user_newhome[strlen(user_newhome)-1]='\0';
}
pwent->pw_dir = user_newhome;
}
if (sflg) {