X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/3d3ad7f1cd5fa8fbcf4d38ec98dc129171945a4c..a302c04819c87d365481d9a8b516d3c20df8bf46:/acls.diff diff --git a/acls.diff b/acls.diff index dd27e40..c86aa66 100644 --- a/acls.diff +++ b/acls.diff @@ -21,9 +21,9 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. + lib/permstring.o lib/pool_alloc.o lib/sysacls.o @LIBOBJS@ ZLIBOBJ=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \ zlib/trees.o zlib/zutil.o zlib/adler32.o zlib/compress.o zlib/crc32.o - OBJS1=rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o \ - main.o checksum.o match.o syscall.o log.o backup.o - OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o \ + OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \ + util.o main.o checksum.o match.o syscall.o log.o backup.o + OBJS2=options.o io.o compat.o hlink.o token.o uidlist.o socket.o \ - fileio.o batch.o clientname.o chmod.o + fileio.o batch.o clientname.o chmod.o acls.o OBJS3=progress.o pipe.o @@ -31,7 +31,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \ --- old/acls.c +++ new/acls.c -@@ -0,0 +1,1096 @@ +@@ -0,0 +1,1093 @@ +/* + * Handle passing Access Control Lists between systems. + * @@ -63,9 +63,6 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. +extern int read_only; +extern int list_only; +extern int orig_umask; -+extern int preserve_acls; -+extern int flist_extra_ndx; -+extern unsigned int file_struct_len; + +/* === ACL structures === */ + @@ -1221,9 +1218,20 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. /* If someone has hard-linked the file into the backup * dir, rename() might return success but do nothing! */ robust_unlink(fname); /* Just in case... */ +--- old/compat.c ++++ new/compat.c +@@ -50,6 +50,8 @@ void setup_protocol(int f_out,int f_in) + preserve_uid = ++file_extra_cnt; + if (preserve_gid) + preserve_gid = ++file_extra_cnt; ++ if (preserve_acls && !am_sender) ++ preserve_acls = ++file_extra_cnt; + + if (remote_protocol == 0) { + if (!read_batch) --- old/configure.in +++ new/configure.in -@@ -537,6 +537,11 @@ if test x"$ac_cv_func_strcasecmp" = x"no +@@ -542,6 +542,11 @@ if test x"$ac_cv_func_strcasecmp" = x"no AC_CHECK_LIB(resolv, strcasecmp) fi @@ -1235,7 +1243,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. dnl At the moment we don't test for a broken memcmp(), because all we dnl need to do is test for equality, not comparison, and it seems that dnl every platform has a memcmp that can do at least that. -@@ -801,6 +806,78 @@ AC_SUBST(OBJ_RESTORE) +@@ -806,6 +811,78 @@ AC_SUBST(OBJ_RESTORE) AC_SUBST(CC_SHOBJ_FLAG) AC_SUBST(BUILD_POPT) @@ -1316,7 +1324,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. --- old/flist.c +++ new/flist.c -@@ -40,6 +40,7 @@ extern int filesfrom_fd; +@@ -41,6 +41,7 @@ extern int filesfrom_fd; extern int one_file_system; extern int copy_dirlinks; extern int keep_dirlinks; @@ -1333,21 +1341,21 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. #ifdef SUPPORT_LINKS if (preserve_links && S_ISLNK(f->mode)) { rprintf(FINFO, "%s %11.0f %s %s -> %s\n", -@@ -624,6 +627,12 @@ static struct file_struct *recv_file_ent +@@ -662,6 +665,12 @@ static struct file_struct *recv_file_ent } #endif +#ifdef SUPPORT_ACLS + /* We need one or two index int32s when we're preserving ACLs. */ + if (preserve_acls) -+ extra_len += (S_ISDIR(mode) ? 2 : 1) * sizeof (union flist_extras); ++ extra_len += (S_ISDIR(mode) ? 2 : 1) * EXTRA_LEN; +#endif + if (always_checksum && S_ISREG(mode)) extra_len += SUM_EXTRA_CNT * EXTRA_LEN; -@@ -736,6 +745,11 @@ static struct file_struct *recv_file_ent - read_buf(f, bp, checksum_len); +@@ -799,6 +808,11 @@ static struct file_struct *recv_file_ent + read_buf(f, bp, checksum_len); } +#ifdef SUPPORT_ACLS @@ -1358,8 +1366,8 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. return file; } -@@ -996,6 +1010,9 @@ static struct file_struct *send_file_nam - unsigned short flags) +@@ -1068,6 +1082,9 @@ static struct file_struct *send_file_nam + int flags) { struct file_struct *file; +#ifdef SUPPORT_ACLS @@ -1368,7 +1376,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. file = make_file(fname, flist, stp, flags, f == -2 ? SERVER_FILTERS : ALL_FILTERS); -@@ -1005,11 +1022,24 @@ static struct file_struct *send_file_nam +@@ -1077,12 +1094,26 @@ static struct file_struct *send_file_nam if (chmod_modes && !S_ISLNK(file->mode)) file->mode = tweak_mode(file->mode, chmod_modes); @@ -1385,11 +1393,14 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. flist_expand(flist); flist->files[flist->count++] = file; - send_file_entry(file, f); +- if (f >= 0) ++ if (f >= 0) { + send_file_entry(file, f, flist->count - 1); +#ifdef SUPPORT_ACLS -+ if (preserve_acls && f >= 0) -+ send_acl(&sx, f); ++ if (preserve_acls) ++ send_acl(&sx, f); +#endif ++ } return file; } @@ -1796,7 +1807,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. } #ifdef SUPPORT_HARD_LINKS - if (preserve_hard_links && F_NOT_HLINK_FIRST(file) + if (preserve_hard_links && F_HLINK_NOT_FIRST(file) - && hard_link_check(file, ndx, fname, statret, &st, itemizing, code)) - return; + && hard_link_check(file, ndx, fname, statret, &sx, itemizing, code)) @@ -2026,7 +2037,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. @@ -1558,16 +1627,20 @@ static void recv_generator(char *fname, /* pretend the file didn't exist */ #ifdef SUPPORT_HARD_LINKS - if (preserve_hard_links && F_NOT_HLINK_LAST(file)) + if (preserve_hard_links && F_HLINK_NOT_LAST(file)) - return; + goto cleanup; #endif @@ -2082,7 +2093,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. + get_acl(fnamecmp, &real_sx); +#endif + itemize(file, -1, real_ret, &real_sx, iflags, fnamecmp_type, - fuzzy_file ? F_BASENAME(fuzzy_file) : NULL); + fuzzy_file ? fuzzy_file->basename : NULL); +#ifdef SUPPORT_ACLS + if (preserve_acls) + free_acl(&real_sx); @@ -2144,9 +2155,9 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. extern int link_dest; +extern int preserve_acls; extern int make_backups; + extern int protocol_version; extern int remove_source_files; - extern int stdout_format_has_i; -@@ -119,15 +120,19 @@ void match_hard_links(void) +@@ -268,15 +269,19 @@ void match_hard_links(void) } static int maybe_hard_link(struct file_struct *file, int ndx, @@ -2170,7 +2181,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS, 0, ""); } -@@ -148,7 +153,11 @@ static int maybe_hard_link(struct file_s +@@ -297,7 +302,11 @@ static int maybe_hard_link(struct file_s if (hard_link_one(file, fname, oldname, 0)) { if (itemizing) { @@ -2183,7 +2194,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS, 0, realname); } -@@ -162,7 +171,7 @@ static int maybe_hard_link(struct file_s +@@ -311,7 +320,7 @@ static int maybe_hard_link(struct file_s /* Only called if FLAG_HLINKED is set and FLAG_HLINK_FIRST is not. Returns: * 0 = process the file, 1 = skip the file, -1 = error occurred. */ int hard_link_check(struct file_struct *file, int ndx, const char *fname, @@ -2192,7 +2203,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. enum logcode code) { STRUCT_STAT prev_st; -@@ -213,18 +222,20 @@ int hard_link_check(struct file_struct * +@@ -362,18 +371,20 @@ int hard_link_check(struct file_struct * if (statret < 0 && basis_dir[0] != NULL) { /* If we match an alt-dest item, we don't output this as a change. */ char cmpbuf[MAXPATHLEN]; @@ -2218,7 +2229,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. if (verbose < 2 || !stdout_format_has_i) { itemizing = 0; code = FNONE; -@@ -233,16 +244,36 @@ int hard_link_check(struct file_struct * +@@ -382,16 +393,36 @@ int hard_link_check(struct file_struct * } break; } @@ -2259,7 +2270,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. realname, itemizing, code) < 0) return -1; -@@ -277,7 +308,8 @@ void finish_hard_link(struct file_struct +@@ -426,7 +457,8 @@ void finish_hard_link(struct file_struct STRUCT_STAT *stp, int itemizing, enum logcode code, int alt_dest) { @@ -2269,7 +2280,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. char alt_name[MAXPATHLEN], *prev_name; const char *our_name; int prev_statret, ndx, prev_ndx = F_HL_PREV(file); -@@ -301,14 +333,24 @@ void finish_hard_link(struct file_struct +@@ -450,14 +482,24 @@ void finish_hard_link(struct file_struct } else our_name = fname; @@ -5619,7 +5630,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. int preserve_perms = 0; int preserve_executability = 0; int preserve_devices = 0; -@@ -199,6 +200,7 @@ static void print_rsync_version(enum log +@@ -198,6 +199,7 @@ static void print_rsync_version(enum log char const *got_socketpair = "no "; char const *have_inplace = "no "; char const *hardlinks = "no "; @@ -5627,7 +5638,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. char const *links = "no "; char const *ipv6 = "no "; STRUCT_STAT *dumstat; -@@ -215,6 +217,10 @@ static void print_rsync_version(enum log +@@ -214,6 +216,10 @@ static void print_rsync_version(enum log hardlinks = ""; #endif @@ -5638,7 +5649,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. #ifdef SUPPORT_LINKS links = ""; #endif -@@ -233,8 +239,8 @@ static void print_rsync_version(enum log +@@ -232,8 +238,8 @@ static void print_rsync_version(enum log (int)(sizeof (int64) * 8)); rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n", got_socketpair, hardlinks, links, ipv6, have_inplace); @@ -5649,7 +5660,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. #ifdef MAINTAINER_MODE rprintf(f, "Panic Action: \"%s\"\n", get_panic_action()); -@@ -280,7 +286,7 @@ void usage(enum logcode F) +@@ -279,7 +285,7 @@ void usage(enum logcode F) rprintf(F," -q, --quiet suppress non-error messages\n"); rprintf(F," --no-motd suppress daemon-mode MOTD (see manpage caveat)\n"); rprintf(F," -c, --checksum skip based on checksum, not mod-time & size\n"); @@ -5658,7 +5669,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. rprintf(F," --no-OPTION turn off an implied OPTION (e.g. --no-D)\n"); rprintf(F," -r, --recursive recurse into directories\n"); rprintf(F," -R, --relative use relative path names\n"); -@@ -302,6 +308,9 @@ void usage(enum logcode F) +@@ -301,6 +307,9 @@ void usage(enum logcode F) rprintf(F," -p, --perms preserve permissions\n"); rprintf(F," -E, --executability preserve the file's executability\n"); rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n"); @@ -5668,7 +5679,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); -@@ -422,6 +431,9 @@ static struct poptOption long_options[] +@@ -421,6 +430,9 @@ static struct poptOption long_options[] {"no-perms", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, {"no-p", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 }, {"executability", 'E', POPT_ARG_NONE, &preserve_executability, 0, 0, 0 }, @@ -5678,7 +5689,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, -@@ -1087,6 +1099,24 @@ int parse_arguments(int *argc, const cha +@@ -1086,6 +1098,24 @@ int parse_arguments(int *argc, const cha usage(FINFO); exit_cleanup(0); @@ -5703,16 +5714,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. default: /* A large opt value means that set_refuse_options() * turned this option off. */ -@@ -1223,6 +1253,8 @@ int parse_arguments(int *argc, const cha - preserve_uid = ++flist_extra_cnt; - if (preserve_gid) - preserve_gid = ++flist_extra_cnt; -+ if (preserve_acls) -+ preserve_acls = ++flist_extra_cnt; - - *argv = poptGetArgs(pc); - *argc = count_args(*argv); -@@ -1534,6 +1566,10 @@ void server_options(char **args,int *arg +@@ -1528,6 +1558,10 @@ void server_options(char **args,int *arg if (preserve_hard_links) argstr[x++] = 'H'; @@ -5953,7 +5955,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. --- old/rsync.h +++ new/rsync.h -@@ -502,6 +502,14 @@ struct idev { +@@ -532,6 +532,14 @@ struct idev_node { #define IN_LOOPBACKNET 127 #endif @@ -5967,21 +5969,29 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. + #define GID_NONE ((gid_t)-1) - struct file_struct { -@@ -553,10 +561,12 @@ extern int preserve_gid; + union file_extras { +@@ -551,6 +559,7 @@ struct file_struct { + extern int file_extra_cnt; + extern int preserve_uid; + extern int preserve_gid; ++extern int preserve_acls; + + #define FILE_STRUCT_LEN (offsetof(struct file_struct, basename)) + #define EXTRA_LEN (sizeof (union file_extras)) +@@ -583,10 +592,12 @@ extern int preserve_gid; /* When the associated option is on, all entries will have these present: */ - #define F_UID(f) REQ_EXTRA(f, preserve_uid)->uid - #define F_GID(f) REQ_EXTRA(f, preserve_gid)->gid + #define F_UID(f) REQ_EXTRA(f, preserve_uid)->unum + #define F_GID(f) REQ_EXTRA(f, preserve_gid)->unum +#define F_ACL(f) REQ_EXTRA(f, preserve_acls)->unum /* These items are per-entry optional and mutally exclusive: */ - #define F_HL_IDEV(f) OPT_EXTRA(f, LEN64_BUMP(f))->idev + #define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num #define F_HL_PREV(f) OPT_EXTRA(f, LEN64_BUMP(f))->num +#define F_DEF_ACL(f) OPT_EXTRA(f, LEN64_BUMP(f))->unum /* This optional item might follow an F_HL_*() item. * (Note: a device doesn't need to check LEN64_BUMP(f).) */ -@@ -692,6 +702,17 @@ struct stats { +@@ -722,6 +733,17 @@ struct stats { struct chmod_mode_struct; @@ -5999,7 +6009,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. #include "byteorder.h" #include "lib/mdfour.h" #include "lib/wildmatch.h" -@@ -710,6 +731,16 @@ struct chmod_mode_struct; +@@ -740,6 +762,16 @@ struct chmod_mode_struct; #define NORETURN __attribute__((__noreturn__)) #endif @@ -6061,7 +6071,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. dit(bf(-E, --executability)) This option causes rsync to preserve the executability (or non-executability) of regular files when bf(--perms) is -@@ -805,6 +810,15 @@ quote(itemization( +@@ -805,6 +810,14 @@ quote(itemization( If bf(--perms) is enabled, this option is ignored. @@ -6069,15 +6079,14 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. +ACLs to be the same as the source ACLs. This nonstandard option only +works if the remote rsync also supports it. bf(--acls) implies bf(--perms). + -+Note also that an optimization of the ACL-sending protocol used by this -+version makes it incompatible with sending files to an older ACL-enabled -+rsync unless you double the bf(--acls) option (e.g. bf(-AA)). This -+doubling is not needed when pulling files from an older rsync. ++The ACL-sending protocol used by this version was first introduced in ++the patch that was shipped with 2.6.8. Sending ACLs to an older version ++of the ACL patch is not supported. + dit(bf(--chmod)) This option tells rsync to apply one or more comma-separated "chmod" strings to the permission of the files in the transfer. The resulting value is treated as though it was the permissions -@@ -1402,8 +1416,8 @@ if the receiving rsync is at least versi +@@ -1402,8 +1415,8 @@ if the receiving rsync is at least versi with older versions of rsync, but that also turns on the output of other verbose messages). @@ -6088,7 +6097,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync. type of update being done, bf(X) is replaced by the file-type, and the other letters represent attributes that may be output if they are being modified. -@@ -1452,7 +1466,11 @@ quote(itemization( +@@ -1452,7 +1465,11 @@ quote(itemization( sender's value (requires bf(--owner) and super-user privileges). it() A bf(g) means the group is different and is being updated to the sender's value (requires bf(--group) and the authority to set the group).