Updated patches to work with the current trunk.
[rsync/rsync-patches.git] / fileflags.diff
index 6f60dca..5668f56 100644 (file)
@@ -8,7 +8,7 @@ To use this patch, run these commands for a successful build:
     ./configure
     make
 
-based-on: 3b8f8192227b14e708bf535072485e50f4362270
+based-on: 24079e988fc31af4eba56cd2701fdc5a4154980d
 diff --git a/Makefile.in b/Makefile.in
 --- a/Makefile.in
 +++ b/Makefile.in
@@ -33,7 +33,7 @@ diff --git a/Makefile.in b/Makefile.in
 diff --git a/compat.c b/compat.c
 --- a/compat.c
 +++ b/compat.c
-@@ -42,9 +42,11 @@ extern int checksum_seed;
+@@ -40,9 +40,11 @@ extern int checksum_seed;
  extern int basis_dir_cnt;
  extern int prune_empty_dirs;
  extern int protocol_version;
@@ -45,7 +45,7 @@ diff --git a/compat.c b/compat.c
  extern int preserve_acls;
  extern int preserve_xattrs;
  extern int need_messages_from_generator;
-@@ -62,7 +64,7 @@ extern char *iconv_opt;
+@@ -60,7 +62,7 @@ extern char *iconv_opt;
  #endif
  
  /* These index values are for the file-list's extra-attribute array. */
@@ -54,7 +54,7 @@ diff --git a/compat.c b/compat.c
  
  int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
  int sender_symlink_iconv = 0; /* sender should convert symlink content */
-@@ -139,6 +141,8 @@ void setup_protocol(int f_out,int f_in)
+@@ -136,6 +138,8 @@ void setup_protocol(int f_out,int f_in)
                uid_ndx = ++file_extra_cnt;
        if (preserve_gid)
                gid_ndx = ++file_extra_cnt;
@@ -66,9 +66,9 @@ diff --git a/compat.c b/compat.c
 diff --git a/configure.in b/configure.in
 --- a/configure.in
 +++ b/configure.in
-@@ -574,7 +574,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
+@@ -583,7 +583,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
      setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
-     strerror putenv iconv_open locale_charset nl_langinfo getxattr \
+     seteuid strerror putenv iconv_open locale_charset nl_langinfo getxattr \
      extattr_get_link sigaction sigprocmask setattrlist getgrouplist \
 -    initgroups utimensat)
 +    initgroups utimensat chflags)
@@ -126,7 +126,7 @@ diff --git a/delete.c b/delete.c
 diff --git a/flist.c b/flist.c
 --- a/flist.c
 +++ b/flist.c
-@@ -51,6 +51,7 @@ extern int preserve_links;
+@@ -50,6 +50,7 @@ extern int preserve_links;
  extern int preserve_hard_links;
  extern int preserve_devices;
  extern int preserve_specials;
@@ -134,7 +134,7 @@ diff --git a/flist.c b/flist.c
  extern int missing_args;
  extern int uid_ndx;
  extern int gid_ndx;
-@@ -407,6 +408,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -406,6 +407,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  {
        static time_t modtime;
        static mode_t mode;
@@ -144,7 +144,7 @@ diff --git a/flist.c b/flist.c
  #ifdef SUPPORT_HARD_LINKS
        static int64 dev;
  #endif
-@@ -450,6 +454,14 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -449,6 +453,14 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
                xflags |= XMIT_SAME_MODE;
        else
                mode = file->mode;
@@ -159,7 +159,7 @@ diff --git a/flist.c b/flist.c
  
        if (preserve_devices && IS_DEVICE(mode)) {
                if (protocol_version < 28) {
-@@ -591,6 +603,10 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -590,6 +602,10 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
                write_varint(f, F_MOD_NSEC(file));
        if (!(xflags & XMIT_SAME_MODE))
                write_int(f, to_wire_mode(mode));
@@ -170,7 +170,7 @@ diff --git a/flist.c b/flist.c
        if (preserve_uid && !(xflags & XMIT_SAME_UID)) {
                if (protocol_version < 30)
                        write_int(f, uid);
-@@ -678,6 +694,9 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+@@ -677,6 +693,9 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
  {
        static int64 modtime;
        static mode_t mode;
@@ -180,7 +180,7 @@ diff --git a/flist.c b/flist.c
  #ifdef SUPPORT_HARD_LINKS
        static int64 dev;
  #endif
-@@ -823,6 +842,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+@@ -822,6 +841,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
  
        if (chmod_modes && !S_ISLNK(mode) && mode)
                mode = tweak_mode(mode, chmod_modes);
@@ -191,7 +191,7 @@ diff --git a/flist.c b/flist.c
  
        if (preserve_uid && !(xflags & XMIT_SAME_UID)) {
                if (protocol_version < 30)
-@@ -974,6 +997,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+@@ -973,6 +996,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
        }
  #endif
        file->mode = mode;
@@ -202,7 +202,7 @@ diff --git a/flist.c b/flist.c
        if (preserve_uid)
                F_OWNER(file) = uid;
        if (preserve_gid) {
-@@ -1371,6 +1398,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1370,6 +1397,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
        }
  #endif
        file->mode = st.st_mode;
@@ -227,7 +227,7 @@ diff --git a/generator.c b/generator.c
  extern int uid_ndx;
  extern int gid_ndx;
  extern int delete_mode;
-@@ -407,6 +409,11 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
+@@ -406,6 +408,11 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
         && ((sxp->st.st_mode & 0111 ? 1 : 0) ^ (file->mode & 0111 ? 1 : 0)))
                return 0;
  
@@ -239,7 +239,7 @@ diff --git a/generator.c b/generator.c
        if (am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file))
                return 0;
  
-@@ -472,6 +479,11 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
+@@ -471,6 +478,11 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
                if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
                    && sxp->st.st_gid != (gid_t)F_GROUP(file))
                        iflags |= ITEM_REPORT_GROUP;
@@ -251,7 +251,7 @@ diff --git a/generator.c b/generator.c
  #ifdef SUPPORT_ACLS
                if (preserve_acls && !S_ISLNK(file->mode)) {
                        if (!ACL_READY(*sxp))
-@@ -1266,6 +1278,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1265,6 +1277,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                        file->mode = dest_mode(file->mode, sx.st.st_mode,
                                               dflt_perms, statret == 0);
                }
@@ -262,7 +262,7 @@ diff --git a/generator.c b/generator.c
                if (statret != 0 && basis_dir[0] != NULL) {
                        int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
                                              itemizing, code);
-@@ -1306,10 +1322,15 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1305,10 +1321,15 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                /* We need to ensure that the dirs in the transfer have writable
                 * permissions during the time we are putting files within them.
                 * This is then fixed after the transfer is done. */
@@ -279,7 +279,7 @@ diff --git a/generator.c b/generator.c
                                rsyserr(FERROR_XFER, errno,
                                        "failed to modify permissions on %s",
                                        full_fname(fname));
-@@ -1344,6 +1365,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+@@ -1343,6 +1364,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
                file->mode = dest_mode(file->mode, sx.st.st_mode, dflt_perms,
                                       exists);
        }
@@ -290,10 +290,10 @@ diff --git a/generator.c b/generator.c
  
  #ifdef SUPPORT_HARD_LINKS
        if (preserve_hard_links && F_HLINK_NOT_FIRST(file)
-@@ -1918,13 +1943,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
+@@ -1920,13 +1945,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
                        continue;
                fname = f_name(file, NULL);
-               if (!(file->mode & S_IWUSR))
+               if (fix_dir_perms)
 -                      do_chmod(fname, file->mode);
 +                      do_chmod(fname, file->mode, 0);
                if (need_retouch_dir_times) {
@@ -313,7 +313,7 @@ diff --git a/generator.c b/generator.c
 diff --git a/log.c b/log.c
 --- a/log.c
 +++ b/log.c
-@@ -715,7 +715,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
+@@ -733,7 +733,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
                        c[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
                        c[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
                        c[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
@@ -420,7 +420,7 @@ diff --git a/options.c b/options.c
    {"ignore-errors",    0,  POPT_ARG_VAL,    &ignore_errors, 1, 0, 0 },
    {"no-ignore-errors", 0,  POPT_ARG_VAL,    &ignore_errors, 0, 0, 0 },
    {"max-delete",       0,  POPT_ARG_INT,    &max_delete, 0, 0, 0 },
-@@ -2401,6 +2427,9 @@ void server_options(char **args, int *argc_p)
+@@ -2420,6 +2446,9 @@ void server_options(char **args, int *argc_p)
        if (xfer_dirs && !recurse && delete_mode && am_sender)
                args[ac++] = "--no-r";
  
@@ -430,7 +430,7 @@ diff --git a/options.c b/options.c
        if (do_compression && def_compress_level != Z_DEFAULT_COMPRESSION) {
                if (asprintf(&arg, "--compress-level=%d", def_compress_level) < 0)
                        goto oom;
-@@ -2488,6 +2517,16 @@ void server_options(char **args, int *argc_p)
+@@ -2507,6 +2536,16 @@ void server_options(char **args, int *argc_p)
                        args[ac++] = "--delete-excluded";
                if (force_delete)
                        args[ac++] = "--force";
@@ -458,7 +458,7 @@ diff --git a/rsync.c b/rsync.c
  extern int preserve_executability;
  extern int preserve_times;
  extern int am_root;
-@@ -428,6 +429,39 @@ mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
+@@ -445,6 +446,39 @@ mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
        return new_mode;
  }
  
@@ -498,7 +498,7 @@ diff --git a/rsync.c b/rsync.c
  int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
                   const char *fnamecmp, int flags)
  {
-@@ -476,7 +510,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -493,7 +527,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
                flags |= ATTRS_SKIP_MTIME;
        if (!(flags & ATTRS_SKIP_MTIME)
            && cmp_time(sxp->st.st_mtime, file->modtime) != 0) {
@@ -507,7 +507,7 @@ diff --git a/rsync.c b/rsync.c
                if (ret < 0) {
                        rsyserr(FERROR_XFER, errno, "failed to set times on %s",
                                full_fname(fname));
-@@ -512,7 +546,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -529,7 +563,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
                if (am_root >= 0) {
                        if (do_lchown(fname,
                            change_uid ? (uid_t)F_OWNER(file) : sxp->st.st_uid,
@@ -517,7 +517,7 @@ diff --git a/rsync.c b/rsync.c
                                /* We shouldn't have attempted to change uid
                                 * or gid unless have the privilege. */
                                rsyserr(FERROR_XFER, errno, "%s %s failed",
-@@ -546,7 +581,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -563,7 +598,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
  
  #ifdef HAVE_CHMOD
        if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) {
@@ -526,7 +526,7 @@ diff --git a/rsync.c b/rsync.c
                if (ret < 0) {
                        rsyserr(FERROR_XFER, errno,
                                "failed to set permissions on %s",
-@@ -558,6 +593,19 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+@@ -575,6 +610,19 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
        }
  #endif
  
@@ -546,7 +546,7 @@ diff --git a/rsync.c b/rsync.c
        if (INFO_GTE(NAME, 2) && flags & ATTRS_REPORT) {
                if (updated)
                        rprintf(FCLIENT, "%s\n", fname);
-@@ -622,7 +670,8 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -639,7 +687,8 @@ int finish_transfer(const char *fname, const char *fnametmp,
  
        /* Change permissions before putting the file into place. */
        set_file_attrs(fnametmp, file, NULL, fnamecmp,
@@ -556,7 +556,7 @@ diff --git a/rsync.c b/rsync.c
  
        /* move tmp file over real file */
        if (DEBUG_GTE(RECV, 1))
-@@ -641,6 +690,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
+@@ -658,6 +707,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
        }
        if (ret == 0) {
                /* The file was moved into place (not copied), so it's done. */
@@ -578,7 +578,7 @@ diff --git a/rsync.h b/rsync.h
  
  /* These flags are used in the live flist data. */
  
-@@ -158,6 +159,7 @@
+@@ -160,6 +161,7 @@
  
  #define ATTRS_REPORT          (1<<0)
  #define ATTRS_SKIP_MTIME      (1<<1)
@@ -586,7 +586,7 @@ diff --git a/rsync.h b/rsync.h
  
  #define FULL_FLUSH    1
  #define NORMAL_FLUSH  0
-@@ -184,6 +186,7 @@
+@@ -186,6 +188,7 @@
  #define ITEM_REPORT_GROUP (1<<6)
  #define ITEM_REPORT_ACL (1<<7)
  #define ITEM_REPORT_XATTR (1<<8)
@@ -594,7 +594,7 @@ diff --git a/rsync.h b/rsync.h
  #define ITEM_BASIS_TYPE_FOLLOWS (1<<11)
  #define ITEM_XNAME_FOLLOWS (1<<12)
  #define ITEM_IS_NEW (1<<13)
-@@ -490,6 +493,28 @@ typedef unsigned int size_t;
+@@ -494,6 +497,28 @@ typedef unsigned int size_t;
  #endif
  #endif
  
@@ -623,7 +623,7 @@ diff --git a/rsync.h b/rsync.h
  /* Find a variable that is either exactly 32-bits or longer.
   * If some code depends on 32-bit truncation, it will need to
   * take special action in a "#if SIZEOF_INT32 > 4" section. */
-@@ -660,6 +685,7 @@ extern int file_extra_cnt;
+@@ -664,6 +689,7 @@ extern int file_extra_cnt;
  extern int inc_recurse;
  extern int uid_ndx;
  extern int gid_ndx;
@@ -631,7 +631,7 @@ diff --git a/rsync.h b/rsync.h
  extern int acls_ndx;
  extern int xattrs_ndx;
  
-@@ -701,6 +727,11 @@ extern int xattrs_ndx;
+@@ -705,6 +731,11 @@ extern int xattrs_ndx;
  /* When the associated option is on, all entries will have these present: */
  #define F_OWNER(f) REQ_EXTRA(f, uid_ndx)->unum
  #define F_GROUP(f) REQ_EXTRA(f, gid_ndx)->unum
@@ -732,7 +732,7 @@ diff --git a/rsync.yo b/rsync.yo
  bf(--recursive) option was also enabled.
  
  dit(bf(--max-delete=NUM)) This tells rsync not to delete more than NUM
-@@ -1874,7 +1903,7 @@ with older versions of rsync, but that also turns on the output of other
+@@ -1875,7 +1904,7 @@ with older versions of rsync, but that also turns on the output of other
  verbose messages).
  
  The "%i" escape has a cryptic output that is 11 letters long.  The general
@@ -741,7 +741,7 @@ diff --git a/rsync.yo b/rsync.yo
  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.
-@@ -1930,7 +1959,7 @@ quote(itemization(
+@@ -1931,7 +1960,7 @@ 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).