* cygcheck.cc (pretty_id): Make more robust in absence of id.exe.

This commit is contained in:
Christopher Faylor 2004-01-23 23:04:27 +00:00
parent f892e76346
commit 7dddf53f5c
2 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2004-01-23 Christopher Faylor <cgf@redhat.com>
* cygcheck.cc (pretty_id): Make more robust in absence of id.exe.
2004-01-22 Corinna Vinschen <corinna@vinschen.de>
* cygpath.cc (dowin): Revert accidental checkin from November.

View File

@ -780,14 +780,27 @@ pretty_id (const char *s, char *cygwin, size_t cyglen)
*p = '\\';
if (access (id, X_OK))
fprintf (stderr, "`id' program not found\n");
{
fprintf (stderr, "`id' program not found\n");
return;
}
FILE *f = popen (id, "rt");
char buf[16384];
static char empty[] = "";
buf[0] = '\0';
fgets (buf, sizeof (buf), f);
char *uid = strtok (buf, ")") + strlen ("uid=");
char *gid = strtok (NULL, ")") + strlen ("gid=") + 1;
char *uid = strtok (buf, ")");
if (uid)
uid += strlen ("uid=");
else
uid = empty;
char *gid = strtok (NULL, ")");
if (gid)
gid += strlen ("gid=") + 1;
else
gid = empty;
char **ng;
size_t sz = 0;
for (ng = groups; (*ng = strtok (NULL, ",")); ng++)