Ownership

Wayne Davison wayned at samba.org
Wed Sep 8 16:28:52 GMT 2004


On Wed, Sep 08, 2004 at 10:30:44AM +0200, Essyug wrote:
> Rsync seems to work as if I had used the --numeric-ids

If rsync doesn't find a username match, it will fall-back to using the
ID directly, so I would assume that the problem is that the ID names on
your cygwin system aren't matching the ID names on your linux system
(and perhaps they aren't what you think).

I had originally misread your question as one wanting to get the cygwin
rsync to set ownership of the files.  Towards this goal, I think we need
a better "am I root" check for cygwin.  The attached patch attempts to
provide this.  Is anyone familiar enough with cygwin to be able to
comment on the appropriateness of this idiom?

..wayne..
-------------- next part --------------
--- clientserver.c	31 Jul 2004 19:55:42 -0000	1.131
+++ clientserver.c	8 Sep 2004 16:08:20 -0000
@@ -269,7 +269,7 @@ static int rsync_module(int f_in, int f_
 
 	module_id = i;
 
-	am_root = (MY_UID() == 0);
+	am_root = running_with_root_privs();
 
 	if (am_root) {
 		p = lp_uid(i);
@@ -389,7 +389,7 @@ static int rsync_module(int f_in, int f_
 			return -1;
 		}
 
-		am_root = (MY_UID() == 0);
+		am_root = running_with_root_privs();
 	}
 
 	io_printf(f_out, "@RSYNCD: OK\n");
--- main.c	5 Aug 2004 18:17:44 -0000	1.216
+++ main.c	8 Sep 2004 16:08:20 -0000
@@ -1044,7 +1044,7 @@ int main(int argc,char *argv[])
 #endif /* def MAINTAINER_MODE */
 
 	starttime = time(NULL);
-	am_root = (MY_UID() == 0);
+	am_root = running_with_root_privs();
 
 	memset(&stats, 0, sizeof(stats));
 
--- uidlist.c	28 Apr 2004 17:31:31 -0000	1.24
+++ uidlist.c	8 Sep 2004 16:08:20 -0000
@@ -348,3 +348,13 @@ void recv_uid_list(int f, struct file_li
 			flist->files[i]->gid = match_gid(flist->files[i]->gid);
 	}
 }
+
+int running_with_root_privs()
+{
+#ifdef __CYGWIN__
+	/* For CYGWIN, check if we're in the Aministrators group. */
+	return is_in_group(544);
+#else
+	return MY_UID() == 0;
+#endif
+}


More information about the rsync mailing list