Skip to content

Commit

Permalink
Remove fileop_chown
Browse files Browse the repository at this point in the history
After the last commit, fileop_chown and fileop_lchown are the same.
Remove fileop_chown and use fileop_lchown everywhere.
  • Loading branch information
donald committed Sep 10, 2022
1 parent 7532145 commit b5b3521
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions cmirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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') {
Expand All @@ -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);
Expand Down

0 comments on commit b5b3521

Please sign in to comment.