MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / user2uid

Function user2uid

ut.c:76–96  ·  view source on GitHub ↗

converts a username into uid:gid, * returns -1 on error & 0 on success */

Source from the content-addressed store, hash-verified

74/* converts a username into uid:gid,
75 * returns -1 on error & 0 on success */
76int user2uid(int* uid, int* gid, char* user)
77{
78 char* tmp;
79 struct passwd *pw_entry;
80
81 if (user){
82 *uid=strtol(user, &tmp, 10);
83 if ((tmp==0) ||(*tmp)){
84 /* maybe it's a string */
85 pw_entry=getpwnam(user);
86 if (pw_entry==0){
87 goto error;
88 }
89 *uid=pw_entry->pw_uid;
90 if (gid) *gid=pw_entry->pw_gid;
91 }
92 return 0;
93 }
94error:
95 return -1;
96}
97
98
99int group2gid(int* gid, char* group)

Callers 3

mainFunction · 0.85
mi_mod_initFunction · 0.85
mi_mod_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected