Skip to content

Add option --ignore-permissions #17

Merged
merged 1 commit into from
Jun 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cmirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ static int opt_nice;
static int unix_socket;
static char *unix_socket_name;
static int noatime;
static int ignore_permissions;

/* globals */

Expand Down Expand Up @@ -457,7 +458,7 @@ static void check_perm(FileInfo *is, FileInfo *want) {
warn("chown %d:%d %s\n", want->uid, want->gid, is->name);
fileop_lchown(want->uid, want->gid, is->name);
}
if (want->perm != is->perm) {
if (!ignore_permissions && want->perm != is->perm) {
if (!quiet)
warn("chmod %03o %s\n", want->perm, is->name);
fileop_chmod(want->perm, is->name);
Expand Down Expand Up @@ -591,7 +592,8 @@ static void usage(char *argv0) {
" --nice EXPERIMENTAL nice\n"
" --unix-socket EXPERIMENTAL establish data channel over ssh via AF unix sockets\n"
" --socket-name PATH EXPERIMENTAL use PATH as name for AF unix sockets\n"
" --noatime don't touch atime on sender\n",
" --noatime don't touch atime on sender\n"
" --ignore-permissions do not attempt to change file permissions\n",
argv0, argv0);
_exit(1);
}
Expand Down Expand Up @@ -621,6 +623,7 @@ static struct option options[] = {
{ "unix-socket", 0, &unix_socket, 1 },
{ "socket-name", 1, NULL, 104 },
{ "noatime", 0, &noatime, 1 },
{ "ignore-permissions", 0, &ignore_permissions, 1 },
{ NULL }
};

Expand Down Expand Up @@ -1232,6 +1235,8 @@ static void master(char *master_path, char *target) {
}
if (slave_unprivileged || strcmp(slave_user, "root"))
g_ptr_array_add(args, "--unprivileged");
if (ignore_permissions)
g_ptr_array_add(args, "--ignore-permissions");
g_ptr_array_add(args, slave_path);

g_ptr_array_add(args, NULL);
Expand Down