summaryrefslogtreecommitdiff
path: root/uidlist.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-05-10 08:05:56 +0000
committerAndrew Tridgell <tridge@samba.org>1998-05-10 08:05:56 +0000
commit8ef4ffd6987bb566c268d2a353d5fea1cfd9e430 (patch)
tree586af037ed7042f44b1c31710924d649e04895dc /uidlist.c
parentc596dad1d12bdec9e2c38e7a439612dd4d855a5b (diff)
downloadrsync-8ef4ffd6987bb566c268d2a353d5fea1cfd9e430.tar.gz
change to allow names or numbers to be used for uid and gid.
Diffstat (limited to 'uidlist.c')
-rw-r--r--uidlist.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/uidlist.c b/uidlist.c
index 4aa098f8..eff8749b 100644
--- a/uidlist.c
+++ b/uidlist.c
@@ -67,38 +67,19 @@ static char *gid_to_name(gid_t gid)
return NULL;
}
-
-/* turn a user name into a uid */
-static uid_t name_to_uid(char *name)
-{
- struct passwd *pass;
- if (!name || !*name) return 0;
- pass = getpwnam(name);
- if (pass) return(pass->pw_uid);
- return 0;
-}
-
-/* turn a group name into a gid */
-static gid_t name_to_gid(char *name)
-{
- struct group *grp;
- if (!name || !*name) return 0;
- grp = getgrnam(name);
- if (grp) return(grp->gr_gid);
- return 0;
-}
-
static int map_uid(int id, char *name)
{
- uid_t uid = name_to_uid(name);
- if (uid != 0) return uid;
+ uid_t uid;
+ if (name_to_uid(name, &uid) && uid != 0)
+ return uid;
return id;
}
static int map_gid(int id, char *name)
{
- gid_t gid = name_to_gid(name);
- if (gid != 0) return gid;
+ gid_t gid;
+ if (name_to_gid(name, &gid) && gid != 0)
+ return gid;
return id;
}