In sudo_mkdir_parents() inherit the gid of / instead of using gid
0 for the first component.
This commit is contained in:
@@ -40,13 +40,18 @@ bool
|
|||||||
sudo_mkdir_parents(char *path, uid_t uid, gid_t *gidp, mode_t mode, bool quiet)
|
sudo_mkdir_parents(char *path, uid_t uid, gid_t *gidp, mode_t mode, bool quiet)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
gid_t parent_gid;
|
gid_t parent_gid = 0;
|
||||||
char *slash = path;
|
char *slash = path;
|
||||||
bool rval = true;
|
bool rval = true;
|
||||||
debug_decl(sudo_mkdir_parents, SUDOERS_DEBUG_UTIL)
|
debug_decl(sudo_mkdir_parents, SUDOERS_DEBUG_UTIL)
|
||||||
|
|
||||||
|
/* If no gid specified, inherit from parent dir. */
|
||||||
|
if (*gidp != (gid_t)-1)
|
||||||
|
parent_gid = *gidp;
|
||||||
|
else if (stat("/", &sb) == 0)
|
||||||
|
parent_gid = sb.st_gid;
|
||||||
|
|
||||||
/* Create parent directories as needed. */
|
/* Create parent directories as needed. */
|
||||||
parent_gid = *gidp != (gid_t)-1 ? *gidp : 0;
|
|
||||||
while ((slash = strchr(slash + 1, '/')) != NULL) {
|
while ((slash = strchr(slash + 1, '/')) != NULL) {
|
||||||
*slash = '\0';
|
*slash = '\0';
|
||||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
||||||
|
Reference in New Issue
Block a user