Add missing chmod()

During shadowtcb_move() the directory is temporarily changed to be
owned by root:root with permissions 0700.  After the change is done,
the ownership and permissions were supposed to be restored.  The
call for chown() was there, but the chmod() call was missing.  This
resulted in the broken TCB functionality.  The added chmod() fixes
the issue.
This commit is contained in:
(GalaxyMaster) 2021-10-28 11:16:59 +11:00
parent 7d02af944f
commit a97399dd0a

View File

@ -523,6 +523,12 @@ shadowtcb_status shadowtcb_move (/*@NULL@*/const char *user_newname, uid_t user_
Prog, tcbdir, strerror (errno)); Prog, tcbdir, strerror (errno));
goto out_free; goto out_free;
} }
if (chmod (tcbdir, dirmode.st_mode & 07777) != 0) {
fprintf (shadow_logfd,
_("%s: Cannot change mode of %s: %s\n"),
Prog, tcbdir, strerror (errno));
goto out_free;
}
ret = SHADOWTCB_SUCCESS; ret = SHADOWTCB_SUCCESS;
out_free: out_free:
free (tcbdir); free (tcbdir);