[SCM] The rsync repository. - branch b3.0.x updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Sat Jan 29 23:24:13 MST 2011


The branch, b3.0.x has been updated
       via  83b94ef Switch over to Matt's idea of using FLAG_OWNED_BY_US.
      from  2064c28 Move FLAG_DEL_NEEDS_UID into the "not stored" section.

;a=shortlog;h=b3.0.x


- Log -----------------------------------------------------------------
commit 83b94efa6b60a3ff5eee4c5f7812c617a90a03f6
Author: Wayne Davison <wayned at samba.org>
Date:   Sat Jan 29 22:10:43 2011 -0800

    Switch over to Matt's idea of using FLAG_OWNED_BY_US.

-----------------------------------------------------------------------

Summary of changes:
 flist.c     |   15 ++++++---------
 generator.c |   10 ++++------
 rsync.h     |   12 ++++--------
 3 files changed, 14 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/flist.c b/flist.c
index 59109bc..7dec152 100644
--- a/flist.c
+++ b/flist.c
@@ -67,6 +67,7 @@ extern int use_safe_inc_flist;
 extern int need_unsorted_flist;
 extern int sender_symlink_iconv;
 extern int unsort_ndx;
+extern uid_t our_uid;
 extern struct stats stats;
 extern char *filesfrom_host;
 
@@ -1227,9 +1228,6 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
 	linkname_len = 0;
 #endif
 
-	if (!uid_ndx && flags & FLAG_DEL_NEEDS_UID)
-		extra_len += EXTRA_LEN;
-
 #if SIZEOF_CAPITAL_OFF_T >= 8
 	if (st.st_size > 0xFFFFFFFFu && S_ISREG(st.st_mode))
 		extra_len += EXTRA_LEN;
@@ -1286,12 +1284,12 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
 	}
 #endif
 	file->mode = st.st_mode;
-	if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */
+	if (preserve_uid)
 		F_OWNER(file) = st.st_uid;
-	else if (flags & FLAG_DEL_NEEDS_UID)
-		F_DEL_OWNER(file) = st.st_uid;
-	if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
+	if (preserve_gid)
 		F_GROUP(file) = st.st_gid;
+	if (am_generator && st.st_uid == our_uid)
+		file->flags |= FLAG_OWNED_BY_US;
 
 	if (basename != thisname)
 		file->dirname = lastdir;
@@ -3066,8 +3064,7 @@ struct file_list *get_dirlist(char *dirname, int dlen, int flags)
 
 	recurse = 0;
 	xfer_dirs = 1;
-	send_directory(senddir_fd, dirlist, dirname, dlen,
-		       FLAG_CONTENT_DIR | (flags & GDL_DEL_NEEDS_UID ? FLAG_DEL_NEEDS_UID : 0));
+	send_directory(senddir_fd, dirlist, dirname, dlen, FLAG_CONTENT_DIR);
 	xfer_dirs = save_xfer_dirs;
 	recurse = save_recurse;
 	if (do_progress)
diff --git a/generator.c b/generator.c
index dd23100..0c30604 100644
--- a/generator.c
+++ b/generator.c
@@ -251,7 +251,7 @@ static enum delret delete_dir_contents(char *fname, uint16 flags)
 	save_filters = push_local_filters(fname, dlen);
 
 	non_perishable_cnt = 0;
-	dirlist = get_dirlist(fname, dlen, GDL_DEL_NEEDS_UID);
+	dirlist = get_dirlist(fname, dlen, 0);
 	ret = non_perishable_cnt ? DR_NOT_EMPTY : DR_SUCCESS;
 
 	if (!dirlist->used)
@@ -273,7 +273,6 @@ static enum delret delete_dir_contents(char *fname, uint16 flags)
 
 	for (j = dirlist->used; j--; ) {
 		struct file_struct *fp = dirlist->files[j];
-		uid_t fp_owner = uid_ndx ? F_OWNER(fp) : F_DEL_OWNER(fp);
 
 		if (fp->flags & FLAG_MOUNT_DIR && S_ISDIR(fp->mode)) {
 			if (verbose > 1) {
@@ -286,7 +285,7 @@ static enum delret delete_dir_contents(char *fname, uint16 flags)
 		}
 
 		strlcpy(p, fp->basename, remainder);
-		if (!(fp->mode & S_IWUSR) && !am_root && fp_owner == our_uid)
+		if (!(fp->mode & S_IWUSR) && !am_root && fp->flags & FLAG_OWNED_BY_US)
 			do_chmod(fname, fp->mode | S_IWUSR);
 		/* Save stack by recursing to ourself directly. */
 		if (S_ISDIR(fp->mode)) {
@@ -495,7 +494,7 @@ static void delete_in_dir(char *fbuf, struct file_struct *file, dev_t *fs_dev)
 			return;
 	}
 
-	dirlist = get_dirlist(fbuf, dlen, GDL_DEL_NEEDS_UID);
+	dirlist = get_dirlist(fbuf, dlen, 0);
 
 	/* If an item in dirlist is not found in flist, delete it
 	 * from the filesystem. */
@@ -514,8 +513,7 @@ static void delete_in_dir(char *fbuf, struct file_struct *file, dev_t *fs_dev)
 		 * a delete_item call with a DEL_MAKE_ROOM flag. */
 		if (flist_find_ignore_dirness(cur_flist, fp) < 0) {
 			int flags = DEL_RECURSE;
-			uid_t fp_owner = uid_ndx ? F_OWNER(fp) : F_DEL_OWNER(fp);
-			if (!(fp->mode & S_IWUSR) && !am_root && fp_owner == our_uid)
+			if (!(fp->mode & S_IWUSR) && !am_root && fp->flags & FLAG_OWNED_BY_US)
 				flags |= DEL_NO_UID_WRITE;
 			f_name(fp, delbuf);
 			if (delete_during == 2) {
diff --git a/rsync.h b/rsync.h
index f7b208b..e6238de 100644
--- a/rsync.h
+++ b/rsync.h
@@ -65,6 +65,7 @@
 /* These flags are used in the live flist data. */
 
 #define FLAG_TOP_DIR (1<<0)	/* sender/receiver/generator */
+#define FLAG_OWNED_BY_US (1<<0) /* generator: set by make_file() for aux flists only */
 #define FLAG_FILE_SENT (1<<1)	/* sender/receiver/generator */
 #define FLAG_DIR_CREATED (1<<1)	/* generator */
 #define FLAG_CONTENT_DIR (1<<2)	/* sender/receiver/generator */
@@ -83,13 +84,12 @@
 
 /* These flags are passed to functions but not stored. */
 
-#define FLAG_DIVERT_DIRS (1<<16)/* sender, but must be unique */
-#define FLAG_DEL_NEEDS_UID (1<<17)/* generator, but must be unique */
+#define FLAG_DIVERT_DIRS (1<<16)   /* sender, but must be unique */
 
 /* These flags are for get_dirlist(). */
 #define GDL_IGNORE_FILTER_RULES (1<<0)
-#define GDL_DEL_NEEDS_UID (1<<1)
 
+/* Some helper macros for matching bits. */
 #define BITS_SET(val,bits) (((val) & (bits)) == (bits))
 #define BITS_SETnUNSET(val,onbits,offbits) (((val) & ((onbits)|(offbits))) == (onbits))
 #define BITS_EQUAL(b1,b2,mask) (((unsigned)(b1) & (unsigned)(mask)) \
@@ -100,7 +100,7 @@
 
 /* This is used when working on a new protocol version in CVS, and should
  * be a new non-zero value for each CVS change that affects the protocol.
- * It must ALWAYS be 0 when the protocol goes final! */
+ * It must ALWAYS be 0 when the protocol goes final (and NEVER before)! */
 #define SUBPROTOCOL_VERSION 0
 
 /* We refuse to interoperate with versions that are not in this range.
@@ -700,10 +700,6 @@ extern int xattrs_ndx;
 #define F_SUM(f) ((char*)OPT_EXTRA(f, LEN64_BUMP(f) + HLINK_BUMP(f) \
 				    + SUM_EXTRA_CNT - 1))
 
-/* When deleting w/o --owner, we put the UID info last (like F_SUM(), but smaller).
- * This is OK, because delete lists never need checksums. */
-#define F_DEL_OWNER(f) OPT_EXTRA(f, LEN64_BUMP(f) + HLINK_BUMP(f))->unum
-
 /* Some utility defines: */
 #define F_IS_ACTIVE(f) (f)->basename[0]
 #define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)


-- 
The rsync repository.


More information about the rsync-cvs mailing list