util: set uid/gid of created directory even when zero

Call chown() in create_dir() even when the specified uid/gid is zero.
This is needed on BSD systems, where directories are created with gid
of the parent directory.
This commit is contained in:
Miroslav Lichvar
2015-08-13 17:04:10 +02:00
parent b6a27df5b9
commit 30b6213910
2 changed files with 5 additions and 5 deletions

4
util.c
View File

@@ -945,8 +945,8 @@ create_dir(char *p, mode_t mode, uid_t uid, gid_t gid)
return 0;
}
/* Change its ownership if requested */
if ((uid || gid) && chown(p, uid, gid) < 0) {
/* Set its owner */
if (chown(p, uid, gid) < 0) {
LOG(LOGS_ERR, LOGF_Util, "Could not change ownership of %s : %s", p, strerror(errno));
/* Don't leave it there with incorrect ownership */
rmdir(p);