init: Fix mkdir command when using ISUID or ISGID bit

On first boot, the directory is created with root:root ownership and
then chowned. chown clears the ISUID and ISGID bits, so we need to chmod
the directory again after chown.

Change-Id: I02dfe7a19a637678256b4e7cc09e6b5431e6f11e
This commit is contained in:
Benoit Goby 2012-08-14 15:43:46 -07:00
parent 90b80de5a7
commit 5c8574b512

View file

@ -322,6 +322,14 @@ int do_mkdir(int nargs, char **args)
if (_chown(args[1], uid, gid) < 0) {
return -errno;
}
/* chown may have cleared S_ISUID and S_ISGID, chmod again */
if (mode & (S_ISUID | S_ISGID)) {
ret = _chmod(args[1], mode);
if (ret == -1) {
return -errno;
}
}
}
return 0;