Merge pull request #272 from ikerexxe/useradd_covscan

useradd: check return value from chmod and log it
This commit is contained in:
Christian Brauner 2020-08-10 12:34:52 +02:00 committed by GitHub
commit 994a3b463c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2247,7 +2247,10 @@ static void create_home (void)
(void) chown (prefix_user_home, user_id, user_gid); (void) chown (prefix_user_home, user_id, user_gid);
mode_t mode = getdef_num ("HOME_MODE", mode_t mode = getdef_num ("HOME_MODE",
0777 & ~getdef_num ("UMASK", GETDEF_DEFAULT_UMASK)); 0777 & ~getdef_num ("UMASK", GETDEF_DEFAULT_UMASK));
chmod (prefix_user_home, mode); if (chmod (prefix_user_home, mode)) {
fprintf (stderr, _("%s: warning: chown on '%s' failed: %m\n"),
Prog, path);
}
home_added = true; home_added = true;
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,