Gary Fernandez
2002-Sep-09 16:23 UTC
[PATCH] change rsync to allow root operations if setuid
I made some changes to rsync so that it would recognize it was running as root when run as a setuid root program. This allows the same operations as when running as root (preserving ownership, for example). I've attached the diffs. *** patch follows *** *** main.c@@/main/original/1 Tue Apr 9 14:03:06 2002 --- main.c Wed Jul 10 10:19:42 2002 *************** *** 855,861 **** #endif /* def MAINTAINER_MODE */ starttime = time(NULL); ! am_root = (getuid() == 0); memset(&stats, 0, sizeof(stats)); --- 860,866 ---- #endif /* def MAINTAINER_MODE */ starttime = time(NULL); ! am_root = (getuid() == 0 || geteuid() == 0); memset(&stats, 0, sizeof(stats)); *** clientserver.c@@/main/original/1 Tue Apr 9 14:02:24 2002 --- clientserver.c Tue Apr 9 14:34:26 2002 *************** *** 220,226 **** module_id = i; ! am_root = (getuid() == 0); if (am_root) { p = lp_uid(i); --- 220,226 ---- module_id = i; ! am_root = (getuid() == 0 || geteuid() == 0); if (am_root) { p = lp_uid(i); *************** *** 332,338 **** return -1; } ! am_root = (getuid() == 0); } io_printf(fd,"@RSYNCD: OK\n"); --- 332,338 ---- return -1; } ! am_root = (getuid() == 0 || geteuid() == 0); } io_printf(fd,"@RSYNCD: OK\n");