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:
parent
90b80de5a7
commit
5c8574b512
1 changed files with 8 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue