From 689f0001c2d5c883715c3f748170bbff2fc891b1 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 7 Apr 2007 19:44:08 +0000 Subject: [PATCH] Fixed failing hunks. --- fake-super.diff | 176 +++++++++++++++++++++++------------------------- 1 file changed, 84 insertions(+), 92 deletions(-) diff --git a/fake-super.diff b/fake-super.diff index 05a3bf1..a70b890 100644 --- a/fake-super.diff +++ b/fake-super.diff @@ -5,21 +5,13 @@ to the manpages for details. To use this patch, run these commands for a successful build: - patch -p1 = rel) { /* Try to transfer the directory settings of the * actual dir that the files are coming from. */ @@ -28,7 +20,7 @@ above: rsyserr(FERROR, errno, "make_bak_dir stat %s failed", full_fname(rel)); -@@ -199,7 +199,7 @@ static int keep_backup(const char *fname +@@ -200,7 +200,7 @@ static int keep_backup(const char *fname int ret_code; /* return if no file to keep */ @@ -53,7 +45,7 @@ above: --- old/flist.c +++ new/flist.c -@@ -194,12 +194,12 @@ static int readlink_stat(const char *pat +@@ -196,12 +196,12 @@ static int readlink_stat(const char *pat rprintf(FINFO,"copying unsafe symlink \"%s\" -> \"%s\"\n", path, linkbuf); } @@ -68,7 +60,7 @@ above: #endif } -@@ -207,17 +207,17 @@ int link_stat(const char *path, STRUCT_S +@@ -209,17 +209,17 @@ int link_stat(const char *path, STRUCT_S { #ifdef SUPPORT_LINKS if (copy_links) @@ -90,7 +82,7 @@ above: #endif } -@@ -252,26 +252,6 @@ static int is_excluded(char *fname, int +@@ -254,26 +254,6 @@ static int is_excluded(char *fname, int return 0; } @@ -117,7 +109,7 @@ above: static void send_directory(int f, struct file_list *flist, int ndx, char *fbuf, int len, int flags); -@@ -925,7 +905,7 @@ struct file_struct *make_file(const char +@@ -954,7 +934,7 @@ struct file_struct *make_file(const char if (save_errno == ENOENT) { #ifdef SUPPORT_LINKS /* Avoid "vanished" error if symlink points nowhere. */ @@ -126,7 +118,7 @@ above: && S_ISLNK(st.st_mode)) { io_error |= IOERR_GENERAL; rprintf(FERROR, "symlink has no referent: %s\n", -@@ -1097,7 +1077,7 @@ struct file_struct *make_file(const char +@@ -1126,7 +1106,7 @@ struct file_struct *make_file(const char int save_mode = file->mode; file->mode = S_IFDIR; /* Find a directory with our name. */ if (flist_find(dir_flist, file) >= 0 @@ -137,7 +129,7 @@ above: file->mode = st2.st_mode; --- old/loadparm.c +++ new/loadparm.c -@@ -150,6 +150,7 @@ typedef struct +@@ -149,6 +149,7 @@ typedef struct int syslog_facility; int timeout; @@ -145,7 +137,7 @@ above: BOOL ignore_errors; BOOL ignore_nonreadable; BOOL list; -@@ -197,6 +198,7 @@ static service sDefault = +@@ -196,6 +197,7 @@ static service sDefault = /* syslog_facility; */ LOG_DAEMON, /* timeout; */ 0, @@ -153,7 +145,7 @@ above: /* ignore_errors; */ False, /* ignore_nonreadable; */ False, /* list; */ True, -@@ -298,6 +300,7 @@ static struct parm_struct parm_table[] = +@@ -297,6 +299,7 @@ static struct parm_struct parm_table[] = {"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress, NULL,0}, {"exclude from", P_STRING, P_LOCAL, &sDefault.exclude_from, NULL,0}, {"exclude", P_STRING, P_LOCAL, &sDefault.exclude, NULL,0}, @@ -161,7 +153,7 @@ above: {"filter", P_STRING, P_LOCAL, &sDefault.filter, NULL,0}, {"gid", P_STRING, P_LOCAL, &sDefault.gid, NULL,0}, {"hosts allow", P_STRING, P_LOCAL, &sDefault.hosts_allow, NULL,0}, -@@ -412,6 +415,7 @@ FN_LOCAL_INTEGER(lp_max_connections, max +@@ -411,6 +414,7 @@ FN_LOCAL_INTEGER(lp_max_connections, max FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity) FN_LOCAL_INTEGER(lp_timeout, timeout) @@ -169,7 +161,7 @@ above: FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors) FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable) FN_LOCAL_BOOL(lp_list, list) -@@ -815,7 +819,7 @@ BOOL lp_load(char *pszFname, int globals +@@ -814,7 +818,7 @@ BOOL lp_load(char *pszFname, int globals if (pszFname) pstrcpy(n2,pszFname); @@ -180,7 +172,7 @@ above: pstrcpy(n2,RSYNCD_SYSCONF); --- old/options.c +++ new/options.c -@@ -73,7 +73,7 @@ int protocol_version = PROTOCOL_VERSION; +@@ -72,7 +72,7 @@ int protocol_version = PROTOCOL_VERSION; int sparse_files = 0; int do_compression = 0; int def_compress_level = Z_DEFAULT_COMPRESSION; @@ -199,7 +191,7 @@ above: rprintf(F," -S, --sparse handle sparse files efficiently\n"); rprintf(F," -n, --dry-run show what would have been transferred\n"); rprintf(F," -W, --whole-file copy files whole (without rsync algorithm)\n"); -@@ -451,6 +454,7 @@ static struct poptOption long_options[] +@@ -455,6 +458,7 @@ static struct poptOption long_options[] {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 }, {"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 }, {"no-super", 0, POPT_ARG_VAL, &am_root, 0, 0, 0 }, @@ -207,7 +199,7 @@ above: {"owner", 'o', POPT_ARG_VAL, &preserve_uid, 1, 0, 0 }, {"no-owner", 0, POPT_ARG_VAL, &preserve_uid, 0, 0, 0 }, {"no-o", 0, POPT_ARG_VAL, &preserve_uid, 0, 0, 0 }, -@@ -1183,6 +1187,14 @@ int parse_arguments(int *argc, const cha +@@ -1187,6 +1191,14 @@ int parse_arguments(int *argc, const cha } #endif @@ -224,7 +216,16 @@ above: "--write-batch and --read-batch can not be used together\n"); --- old/rsync.c +++ new/rsync.c -@@ -299,7 +299,9 @@ int set_file_attrs(char *fname, struct f +@@ -261,6 +261,8 @@ int set_file_attrs(const char *fname, st + #ifdef SUPPORT_XATTRS + if (preserve_xattrs && fnamecmp) + set_xattr(fname, file, fnamecmp, sxp); ++ if (am_root < 0) ++ set_stat_xattr(fname, file); + #endif + + if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && omit_dir_times)) +@@ -300,7 +302,9 @@ int set_file_attrs(const char *fname, st (long)sxp->st.st_gid, (long)F_GID(file)); } } @@ -235,7 +236,7 @@ above: change_uid ? F_UID(file) : sxp->st.st_uid, change_gid ? F_GID(file) : sxp->st.st_gid) != 0) { /* shouldn't have attempted to change uid or gid -@@ -308,7 +310,7 @@ int set_file_attrs(char *fname, struct f +@@ -309,7 +313,7 @@ int set_file_attrs(const char *fname, st change_uid ? "chown" : "chgrp", full_fname(fname)); goto cleanup; @@ -244,16 +245,7 @@ above: /* a lchown had been done - we have to re-stat if the * destination had the setuid or setgid bits set due * to the side effect of the chown call */ -@@ -325,6 +327,8 @@ int set_file_attrs(char *fname, struct f - #ifdef SUPPORT_XATTRS - if (preserve_xattrs && set_xattr(fname, file, sxp) == 0) - updated = 1; -+ if (am_root < 0) -+ set_stat_xattr(fname, file); - #endif - #ifdef SUPPORT_ACLS - /* It's OK to call set_acl() now, even for a dir, as the generator -@@ -339,7 +343,7 @@ int set_file_attrs(char *fname, struct f +@@ -336,7 +340,7 @@ int set_file_attrs(const char *fname, st #ifdef HAVE_CHMOD if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) { @@ -264,7 +256,7 @@ above: "failed to set permissions on %s", --- old/rsync.h +++ new/rsync.h -@@ -813,6 +813,12 @@ typedef struct { +@@ -805,6 +805,12 @@ typedef struct { #include "proto.h" @@ -277,7 +269,7 @@ above: /* We have replacement versions of these if they're missing. */ #ifndef HAVE_ASPRINTF int asprintf(char **ptr, const char *format, ...); -@@ -1031,6 +1037,26 @@ int inet_pton(int af, const char *src, v +@@ -1023,6 +1029,26 @@ int inet_pton(int af, const char *src, v const char *get_panic_action(void); #endif @@ -314,7 +306,7 @@ above: -S, --sparse handle sparse files efficiently -n, --dry-run show what would have been transferred -W, --whole-file copy files whole (without rsync algorithm) -@@ -846,7 +847,7 @@ permission value can be applied to the f +@@ -859,7 +860,7 @@ permission value can be applied to the f dit(bf(-o, --owner)) This option causes rsync to set the owner of the destination file to be the same as the source file, but only if the receiving rsync is being run as the super-user (see also the bf(--super) @@ -323,7 +315,7 @@ above: Without this option, the owner is set to the invoking user on the receiving side. -@@ -869,7 +870,7 @@ default, but may fall back to using the +@@ -882,7 +883,7 @@ default, but may fall back to using the dit(bf(--devices)) This option causes rsync to transfer character and block device files to the remote system to recreate these devices. This option has no effect if the receiving rsync is not run as the @@ -332,7 +324,7 @@ above: dit(bf(--specials)) This option causes rsync to transfer special files such as named sockets and fifos. -@@ -899,6 +900,33 @@ also for ensuring that you will get erro +@@ -912,6 +913,33 @@ also for ensuring that you will get erro being running as the super-user. To turn off super-user activities, the super-user can use bf(--no-super). @@ -382,7 +374,7 @@ above: This is only superficially equivalent to the client specifying these --- old/syscall.c +++ new/syscall.c -@@ -28,6 +28,7 @@ +@@ -27,6 +27,7 @@ #endif extern int dry_run; @@ -390,7 +382,7 @@ above: extern int read_only; extern int list_only; extern int preserve_perms; -@@ -79,6 +80,15 @@ int do_mknod(const char *pathname, mode_ +@@ -78,6 +79,15 @@ int do_mknod(const char *pathname, mode_ { if (dry_run) return 0; RETURN_ERROR_IF_RO_OR_LO; @@ -408,7 +400,7 @@ above: return mkfifo(pathname, mode); --- old/t_unsafe.c +++ new/t_unsafe.c -@@ -24,7 +24,11 @@ +@@ -23,7 +23,11 @@ #include "rsync.h" @@ -433,7 +425,7 @@ above: int preserve_perms = 0; --- old/trimslash.c +++ new/trimslash.c -@@ -23,6 +23,7 @@ +@@ -22,6 +22,7 @@ /* These are to make syscall.o shut up. */ int dry_run = 0; @@ -441,9 +433,9 @@ above: int read_only = 1; int list_only = 0; int preserve_perms = 0; ---- old/xattr.c -+++ new/xattr.c -@@ -42,11 +42,16 @@ extern int list_only; +--- old/xattrs.c ++++ new/xattrs.c +@@ -53,11 +53,16 @@ extern int checksum_seed; #define SPRE_LEN ((int)sizeof SYSTEM_PREFIX - 1) #ifdef HAVE_LINUX_XATTRS @@ -462,7 +454,7 @@ above: typedef struct { char *datum, *name; -@@ -147,6 +152,10 @@ static int rsync_xal_get(const char *fna +@@ -218,6 +223,10 @@ static int rsync_xal_get(const char *fna continue; #endif @@ -470,13 +462,13 @@ above: + && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0) + continue; + - datum_len = sys_lgetxattr(fname, name, NULL, 0); - if (datum_len < 0) { - if (errno == ENOTSUP) -@@ -176,6 +185,13 @@ static int rsync_xal_get(const char *fna - return -1; - } - } + datum_len = name_len; /* Pass extra size to get_xattr_data() */ + if (!(ptr = get_xattr_data(fname, name, &datum_len, 0))) + return -1; +@@ -236,6 +245,14 @@ static int rsync_xal_get(const char *fna + } else + name_offset = datum_len; + +#ifdef HAVE_LINUX_XATTRS + if (am_root < 0 && name_len > RPRE_LEN + && HAS_PREFIX(name, RSYNC_PREFIX)) { @@ -484,31 +476,32 @@ above: + name_len -= RPRE_LEN; + } +#endif ++ rxas = EXPAND_ITEM_LIST(xalp, rsync_xa, RSYNC_XAL_INITIAL); - rxas->name = ptr + datum_len; - rxas->datum = ptr; -@@ -296,13 +312,9 @@ void receive_xattr(struct file_struct *f - rsync_xa *rxa; - size_t name_len = read_int(f); - size_t datum_len = read_int(f); + rxas->name = ptr + name_offset; + memcpy(rxas->name, name, name_len); +@@ -576,13 +593,9 @@ void receive_xattr(struct file_struct *f + size_t name_len = read_abbrevint(f); + size_t datum_len = read_abbrevint(f); + size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len; -#ifdef HAVE_LINUX_XATTRS -- size_t extra_len = 0; +- size_t extra_len = 0; -#else -- size_t extra_len = am_root ? RPRE_LEN : 0; -+ size_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0; - if (datum_len + extra_len < datum_len) - out_of_memory("receive_xattr"); /* overflow */ +- size_t extra_len = am_root ? RPRE_LEN : 0; ++ size_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0; + if (dget_len + extra_len < dget_len) + out_of_memory("receive_xattr"); /* overflow */ -#endif - if (name_len + datum_len + extra_len < name_len) - out_of_memory("receive_xattr"); /* overflow */ - ptr = new_array(char, name_len + datum_len + extra_len); -@@ -313,9 +325,14 @@ void receive_xattr(struct file_struct *f - read_buf(f, ptr, datum_len); + if (dget_len + extra_len + name_len < dget_len) + out_of_memory("receive_xattr"); /* overflow */ + ptr = new_array(char, dget_len + extra_len + name_len); +@@ -598,9 +611,14 @@ void receive_xattr(struct file_struct *f + } #ifdef HAVE_LINUX_XATTRS - /* Non-root can only save the user namespace. */ -- if (!am_root && !HAS_PREFIX(name, USER_PREFIX)) { -- free(ptr); -- continue; + /* Non-root can only save the user namespace. */ +- if (!am_root && !HAS_PREFIX(name, USER_PREFIX)) { +- free(ptr); +- continue; + if (am_root <= 0 && !HAS_PREFIX(name, USER_PREFIX)) { + if (!am_root) { + free(ptr); @@ -517,24 +510,23 @@ above: + name -= RPRE_LEN; + name_len += RPRE_LEN; + memcpy(name, RSYNC_PREFIX, RPRE_LEN); - } + } #else - /* This OS only has a user namespace, so we either -@@ -333,6 +350,12 @@ void receive_xattr(struct file_struct *f - continue; - } + /* This OS only has a user namespace, so we either +@@ -618,6 +636,11 @@ void receive_xattr(struct file_struct *f + continue; + } #endif -+ if (am_root < 0 && name_len == XSTAT_LEN + 1 -+ && name[RPRE_LEN] == '%' -+ && strcmp(name, XSTAT_ATTR) == 0) { -+ free(ptr); -+ continue; -+ } - rxa = EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count); - rxa->name = name; - rxa->datum = ptr; -@@ -410,4 +433,150 @@ int set_xattr(const char *fname, const s - return rsync_xal_set(fname, lst + ndx); /* TODO: This needs to return 1 if no xattrs changed! */ ++ if (am_root < 0 && name_len == XSTAT_LEN + 1 ++ && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0) { ++ free(ptr); ++ continue; ++ } + rxa = EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, 1); + rxa->name = name; + rxa->datum = ptr; +@@ -772,4 +795,150 @@ int set_xattr(const char *fname, const s + return rsync_xal_set(fname, lst + ndx, fnamecmp, sxp); } +int get_stat_xattr(const char *fname, int fd, STRUCT_STAT *fst, STRUCT_STAT *xst) -- 2.34.1