diff --git a/cmirror.c b/cmirror.c index cc626cb..64466a1 100644 --- a/cmirror.c +++ b/cmirror.c @@ -318,15 +318,6 @@ static void fileop_mknod(char *path, char type, dev_t rdev) { die("%s: %m\n", path); } -static void fileop_chown(uid_t uid, gid_t gid, char *path) { - if (fileop_debug) - warn("fileop: chown %d:%d %s\n", uid, gid, path); - if (fileop_noop) - return; - if (lchown(path, uid, gid) == -1) - die("%s: %m\n", path); -} - static void fileop_chmod(mode_t perm, char *path) { if (fileop_debug) warn("fileop: chmod 0%03o %s\n", perm, path); @@ -466,7 +457,7 @@ static void check_perm(FileInfo *is, FileInfo *want) { if (!slave_unprivileged && (is->uid != want->uid || is->gid != want->gid) ) { if (!quiet) warn("chown %d:%d %s\n", want->uid, want->gid, is->name); - fileop_chown(want->uid, want->gid, is->name); + fileop_lchown(want->uid, want->gid, is->name); } if (want->perm != is->perm) { if (!quiet) @@ -480,7 +471,7 @@ static void make_dir(char *path, mode_t perm, uid_t uid, gid_t gid) { warn("mkdir %s owner %d:%d mode 0%03o\n", path, uid, gid, perm); fileop_mkdir(path); if (!slave_unprivileged) - fileop_chown(uid, gid, path); + fileop_lchown(uid, gid, path); fileop_chmod(perm, path); } @@ -815,7 +806,7 @@ static void slave(char *slave_path) { close(fd); } if (!slave_unprivileged) { - fileop_chown(fi_want->uid, fi_want->gid, tmpfile); + fileop_lchown(fi_want->uid, fi_want->gid, tmpfile); fileop_chmod(fi_want->perm, tmpfile); } if (fi_is && fi_is->type == 'D') @@ -868,7 +859,7 @@ static void slave(char *slave_path) { warn("mknod %s P\n", filename); fileop_mknod(filename, fi_want->type, 0); if (!slave_unprivileged) - fileop_chown(fi_want->uid, fi_want->gid, filename); + fileop_lchown(fi_want->uid, fi_want->gid, filename); fileop_chmod(fi_want->perm, filename); } } else if (fi_want->type== 'S') { @@ -881,7 +872,7 @@ static void slave(char *slave_path) { warn("mknod %s %c\n", filename, fi_want->type); fileop_mknod(filename, fi_want->type, fi_want->rdev); if (!slave_unprivileged) - fileop_chown(fi_want->uid, fi_want->gid, filename); + fileop_lchown(fi_want->uid, fi_want->gid, filename); fileop_chmod(fi_want->perm, filename); } else { check_perm(fi_is, fi_want);