Commit 29cb3e8f by Serge Hallyn Committed by Stéphane Graber

use non-thread-safe getpwuid and getpwgid for android

We only call it (so far) after doing a fork(), so this is fine. If we ever need such a thing from threaded context, we'll simply need to write our own version for android. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 6affb6ef
...@@ -4579,56 +4579,31 @@ err: ...@@ -4579,56 +4579,31 @@ err:
return -1; return -1;
} }
/* not thread-safe, do not use from api without first forking */
static char* getuname(void) static char* getuname(void)
{ {
struct passwd pwd, *result; struct passwd *result;
char *buf, *ret = NULL;
size_t bufsize;
int s;
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); result = getpwuid(geteuid());
if (bufsize == -1) if (!result)
bufsize = 16384;
buf = malloc(bufsize);
if (!buf)
return NULL; return NULL;
s = getpwuid_r(geteuid(), &pwd, buf, bufsize, &result); return strdup(result->pw_name);
if (s || result == NULL)
goto out;
ret = strdup(pwd.pw_name);
out:
free(buf);
return ret;
} }
/* not thread-safe, do not use from api without first forking */
static char *getgname(void) static char *getgname(void)
{ {
struct group grp, *result; struct group *result;
char *buf, *ret = NULL;
size_t bufsize;
int s;
bufsize = sysconf(_SC_GETGR_R_SIZE_MAX); result = getgrgid(getegid());
if (bufsize == -1) if (!result)
bufsize = 16384;
buf = malloc(bufsize);
if (!buf)
return NULL; return NULL;
s = getgrgid_r(geteuid(), &grp, buf, bufsize, &result); return strdup(result->gr_name);
if (s || result == NULL)
goto out;
ret = strdup(grp.gr_name);
out:
free(buf);
return ret;
} }
/* not thread-safe, do not use from api without first forking */
void suggest_default_idmap(void) void suggest_default_idmap(void)
{ {
FILE *f; FILE *f;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment