X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/fc5573623194fab2a331d1ffc8d284c9e25e06e7..c1ff70aa47e11c5b37634479a0facee775a7b6d9:/nameconverter.diff diff --git a/nameconverter.diff b/nameconverter.diff index 9ee9720..368e03e 100644 --- a/nameconverter.diff +++ b/nameconverter.diff @@ -20,11 +20,11 @@ To use this patch, run these commands for a successful build: ./configure (optional if already run) make +based-on: a01e3b490eb36ccf9e704840e1b6683dab867550 diff --git a/clientserver.c b/clientserver.c -index b6afe00..568a121 100644 --- a/clientserver.c +++ b/clientserver.c -@@ -67,6 +67,7 @@ extern iconv_t ic_send, ic_recv; +@@ -66,6 +66,7 @@ extern iconv_t ic_send, ic_recv; char *auth_user; int read_only = 0; int module_id = -1; @@ -32,7 +32,7 @@ index b6afe00..568a121 100644 struct chmod_mode_struct *daemon_chmod_modes; /* module_dirlen is the length of the module_dir string when in daemon -@@ -78,6 +79,7 @@ unsigned int module_dirlen = 0; +@@ -77,6 +78,7 @@ unsigned int module_dirlen = 0; char *full_module_path; static int rl_nulls = 0; @@ -40,16 +40,16 @@ index b6afe00..568a121 100644 #ifdef HAVE_SIGACTION static struct sigaction sigact; -@@ -649,7 +651,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char +@@ -668,7 +670,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char log_init(1); #ifdef HAVE_PUTENV - if (*lp_prexfer_exec(i) || *lp_postxfer_exec(i)) { + if (*lp_prexfer_exec(i) || *lp_postxfer_exec(i) || *lp_name_converter(i)) { - char *modname, *modpath, *hostaddr, *hostname, *username; int status; -@@ -738,6 +740,44 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char + umask(orig_umask); +@@ -740,6 +742,44 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char set_blocking(fds[1]); pre_exec_fd = fds[1]; } @@ -94,7 +94,7 @@ index b6afe00..568a121 100644 umask(0); } #endif -@@ -965,6 +1005,44 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char +@@ -971,6 +1011,44 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char return 0; } @@ -140,10 +140,9 @@ index b6afe00..568a121 100644 with "list = False". */ static void send_listing(int fd) diff --git a/loadparm.c b/loadparm.c -index 8e48e6d..c623689 100644 --- a/loadparm.c +++ b/loadparm.c -@@ -121,6 +121,7 @@ typedef struct { +@@ -122,6 +122,7 @@ typedef struct { char *log_file; char *log_format; char *name; @@ -151,7 +150,7 @@ index 8e48e6d..c623689 100644 char *outgoing_chmod; char *path; char *postxfer_exec; -@@ -195,6 +196,7 @@ static const all_vars Defaults = { +@@ -196,6 +197,7 @@ static const all_vars Defaults = { /* log_file; */ NULL, /* log_format; */ "%o %h [%a] %m (%u) %f %l", /* name; */ NULL, @@ -159,7 +158,7 @@ index 8e48e6d..c623689 100644 /* outgoing_chmod; */ NULL, /* path; */ NULL, /* postxfer_exec; */ NULL, -@@ -337,6 +339,7 @@ static struct parm_struct parm_table[] = +@@ -338,6 +340,7 @@ static struct parm_struct parm_table[] = {"max verbosity", P_INTEGER,P_LOCAL, &Vars.l.max_verbosity, NULL,0}, {"munge symlinks", P_BOOL, P_LOCAL, &Vars.l.munge_symlinks, NULL,0}, {"name", P_STRING, P_LOCAL, &Vars.l.name, NULL,0}, @@ -167,7 +166,7 @@ index 8e48e6d..c623689 100644 {"numeric ids", P_BOOL, P_LOCAL, &Vars.l.numeric_ids, NULL,0}, {"outgoing chmod", P_STRING, P_LOCAL, &Vars.l.outgoing_chmod, NULL,0}, {"path", P_PATH, P_LOCAL, &Vars.l.path, NULL,0}, -@@ -414,6 +417,7 @@ FN_LOCAL_STRING(lp_outgoing_chmod, outgoing_chmod) +@@ -465,6 +468,7 @@ FN_LOCAL_STRING(lp_outgoing_chmod, outgoing_chmod) FN_LOCAL_STRING(lp_path, path) FN_LOCAL_STRING(lp_postxfer_exec, postxfer_exec) FN_LOCAL_STRING(lp_prexfer_exec, prexfer_exec) @@ -176,10 +175,9 @@ index 8e48e6d..c623689 100644 FN_LOCAL_STRING(lp_secrets_file, secrets_file) FN_LOCAL_STRING(lp_temp_dir, temp_dir) diff --git a/rsyncd.conf.yo b/rsyncd.conf.yo -index d4978cd..fd0f7d9 100644 --- a/rsyncd.conf.yo +++ b/rsyncd.conf.yo -@@ -163,10 +163,11 @@ if the module is not read-only). +@@ -183,10 +183,11 @@ if the module is not read-only). When this parameter is enabled, rsync will not attempt to map users and groups by name (by default), but instead copy IDs as though bf(--numeric-ids) had @@ -193,7 +191,7 @@ index d4978cd..fd0f7d9 100644 process in the chroot hierarchy will need to have access to the resources used by these library functions (traditionally /etc/passwd and /etc/group, but perhaps additional dynamic libraries as well). -@@ -232,6 +233,27 @@ path elements that rsync believes will allow a symlink to escape the module's +@@ -252,6 +253,27 @@ path elements that rsync believes will allow a symlink to escape the module's hierarchy. There are tricky ways to work around this, though, so you had better trust your users if you choose this combination of parameters. @@ -223,7 +221,6 @@ index d4978cd..fd0f7d9 100644 the daemon will use the value of the "charset" parameter regardless of the diff --git a/support/nameconvert b/support/nameconvert new file mode 100755 -index 0000000..d01f593 --- /dev/null +++ b/support/nameconvert @@ -0,0 +1,42 @@ @@ -270,7 +267,6 @@ index 0000000..d01f593 + print $ans, $eol; +} diff --git a/t_stub.c b/t_stub.c -index 02cfa69..eaaf8a9 100644 --- a/t_stub.c +++ b/t_stub.c @@ -30,6 +30,7 @@ mode_t orig_umask = 002; @@ -278,10 +274,10 @@ index 02cfa69..eaaf8a9 100644 char *partial_dir; char *module_dir; +pid_t namecvt_pid; - struct filter_list_struct daemon_filter_list; + filter_rule_list daemon_filter_list; void rprintf(UNUSED(enum logcode code), const char *format, ...) -@@ -75,6 +76,11 @@ struct filter_list_struct daemon_filter_list; +@@ -70,6 +71,11 @@ filter_rule_list daemon_filter_list; return -1; } @@ -294,7 +290,6 @@ index 02cfa69..eaaf8a9 100644 { return NULL; diff --git a/uidlist.c b/uidlist.c -index 7e8cbd7..472aeb9 100644 --- a/uidlist.c +++ b/uidlist.c @@ -33,6 +33,7 @@ extern int preserve_uid; @@ -302,12 +297,12 @@ index 7e8cbd7..472aeb9 100644 extern int preserve_acls; extern int numeric_ids; +extern pid_t namecvt_pid; + extern gid_t our_gid; extern char *usermap; extern char *groupmap; - -@@ -75,8 +76,12 @@ static struct idlist *add_to_list(struct idlist **root, id_t id, const char *nam +@@ -76,8 +77,12 @@ static struct idlist *add_to_list(struct idlist **root, id_t id, const char *nam /* turn a uid into a user name */ - static const char *uid_to_name(uid_t uid) + char *uid_to_user(uid_t uid) { - struct passwd *pass = getpwuid(uid); - if (pass) @@ -320,9 +315,9 @@ index 7e8cbd7..472aeb9 100644 return strdup(pass->pw_name); return NULL; } -@@ -84,8 +89,12 @@ static const char *uid_to_name(uid_t uid) +@@ -85,8 +90,12 @@ char *uid_to_user(uid_t uid) /* turn a gid into a group name */ - static const char *gid_to_name(gid_t gid) + char *gid_to_group(gid_t gid) { - struct group *grp = getgrgid(gid); - if (grp) @@ -335,31 +330,20 @@ index 7e8cbd7..472aeb9 100644 return strdup(grp->gr_name); return NULL; } -diff --git a/util.c b/util.c -index 0cafed6..dc1647b 100644 ---- a/util.c -+++ b/util.c -@@ -31,9 +31,10 @@ extern int modify_window; - extern int relative_paths; - extern int preserve_xattrs; - extern char *module_dir; --extern unsigned int module_dirlen; - extern mode_t orig_umask; - extern char *partial_dir; -+extern pid_t namecvt_pid; -+extern unsigned int module_dirlen; - extern struct filter_list_struct daemon_filter_list; - - int sanitize_paths = 0; -@@ -497,24 +498,44 @@ void kill_all(int sig) - /** Turn a user name into a uid */ - int name_to_uid(const char *name, uid_t *uid_p) +@@ -94,32 +103,54 @@ char *gid_to_group(gid_t gid) + /* Parse a user name or (optionally) a number into a uid */ + int user_to_uid(const char *name, uid_t *uid_p, BOOL num_ok) { - struct passwd *pass; + uid_t uid; + if (!name || !*name) return 0; ++ + if (num_ok && name[strspn(name, "0123456789")] == '\0') { + *uid_p = atol(name); + return 1; + } - if (!(pass = getpwnam(name))) - return 0; - *uid_p = pass->pw_uid; @@ -378,14 +362,19 @@ index 0cafed6..dc1647b 100644 return 1; } - /** Turn a group name into a gid */ - int name_to_gid(const char *name, gid_t *gid_p) + /* Parse a group name or (optionally) a number into a gid */ + int group_to_gid(const char *name, gid_t *gid_p, BOOL num_ok) { - struct group *grp; + gid_t gid; + if (!name || !*name) return 0; ++ + if (num_ok && name[strspn(name, "0123456789")] == '\0') { + *gid_p = atol(name); + return 1; + } - if (!(grp = getgrnam(name))) - return 0; - *gid_p = grp->gr_gid; @@ -404,3 +393,18 @@ index 0cafed6..dc1647b 100644 return 1; } +diff --git a/util.c b/util.c +--- a/util.c ++++ b/util.c +@@ -31,9 +31,10 @@ extern int modify_window; + extern int relative_paths; + extern int preserve_xattrs; + extern char *module_dir; +-extern unsigned int module_dirlen; + extern mode_t orig_umask; + extern char *partial_dir; ++extern pid_t namecvt_pid; ++extern unsigned int module_dirlen; + extern filter_rule_list daemon_filter_list; + + int sanitize_paths = 0;