tree-wide: port various places over to use chmod_and_chown()

Doing this properly is hard, hence let's unify the code.
This commit is contained in:
Lennart Poettering
2019-05-24 15:07:55 +02:00
parent f8a8579e84
commit 4b3b5bc71b
6 changed files with 32 additions and 58 deletions
+1 -7
View File
@@ -359,13 +359,7 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
* something fchown(), fchmod(), futimensat() don't allow. */
xsprintf(fdpath, "/proc/self/fd/%i", fd);
if (mode != MODE_INVALID)
if (chmod(fdpath, mode) < 0)
ret = -errno;
if (uid_is_valid(uid) || gid_is_valid(gid))
if (chown(fdpath, uid, gid) < 0 && ret >= 0)
ret = -errno;
ret = fchmod_and_chown(fd, mode, uid, gid);
if (stamp != USEC_INFINITY) {
struct timespec ts[2];