MCPcopy Index your code
hub / github.com/RsyncProject/rsync / user_to_uid

Function user_to_uid

uidlist.c:144–167  ·  view source on GitHub ↗

Parse a user name or (optionally) a number into a uid */

Source from the content-addressed store, hash-verified

142
143/* Parse a user name or (optionally) a number into a uid */
144int user_to_uid(const char *name, uid_t *uid_p, BOOL num_ok)
145{
146 if (!name || !*name)
147 return 0;
148
149 if (num_ok && name[strspn(name, "0123456789")] == '\0') {
150 *uid_p = id_parse(name);
151 return 1;
152 }
153
154 if (namecvt_pid) {
155 id_t id;
156 if (!namecvt_call("usr", &name, &id))
157 return 0;
158 *uid_p = id;
159 } else {
160 struct passwd *pass = getpwnam(name);
161 if (!pass)
162 return 0;
163 *uid_p = pass->pw_uid;
164 }
165
166 return 1;
167}
168
169/* Parse a group name or (optionally) a number into a gid */
170int group_to_gid(const char *name, gid_t *gid_p, BOOL num_ok)

Callers 6

recv_add_idFunction · 0.85
parse_name_mapFunction · 0.85
auth_serverFunction · 0.85
become_copy_as_userFunction · 0.85
rsync_moduleFunction · 0.85
start_daemonFunction · 0.85

Calls 2

id_parseFunction · 0.85
namecvt_callFunction · 0.85

Tested by

no test coverage detected