X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/3696674bc62b0c1250027dbeedafdd7ebafdcf8b..0d5ebab1d6df5169c5834c02c978fd5bb67421ca:/util.c diff --git a/util.c b/util.c index bad2faed..4d58dc41 100644 --- a/util.c +++ b/util.c @@ -34,7 +34,7 @@ extern char *module_dir; extern unsigned int module_dirlen; extern mode_t orig_umask; extern char *partial_dir; -extern struct filter_list_struct daemon_filter_list; +extern filter_rule_list daemon_filter_list; int sanitize_paths = 0; @@ -534,24 +534,32 @@ void kill_all(int sig) } } -/** Turn a user name into a uid */ -int name_to_uid(const char *name, uid_t *uid_p) +/* 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; 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; 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; 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;