/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1992-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* David Korn
* Glenn Fowler
* AT&T Research
*
* id
*/
static const char usage[] =
"[-?\n@(#)$Id: id (AT&T Research) 2004-06-11 $\n]"
"[+NAME?id - return user identity]"
"[+DESCRIPTION?If no \auser\a operand is specified \bid\b writes user and "
"group IDs and the corresponding user and group names of the "
"invoking process to standard output. If the effective and "
"real IDs do not match, both are written. Any supplementary "
"groups the current process belongs to will also be written.]"
"[+?If a \auser\a operand is specified and the process has permission, "
"the user and group IDs and any supplementary group IDs of the "
"selected user will be written to standard output.]"
"[+?If any options are specified, then only a portion of the information "
"is written.]"
"[n:name?Write the name instead of the numeric ID.]"
"[r:real?Writes real ID instead of the effective ID.]"
"[[a?This option is ignored.]"
"[g:group?Writes only the group ID.]"
"[u:user?Writes only the user ID.]"
"[G:groups?Writes only the supplementary group IDs.]"
"[s:fair-share?Writes fair share scheduler IDs and groups on systems that "
"support fair share scheduling.]"
"\n"
"\n[user]\n"
"\n"
"[+EXIT STATUS?]{"
"[+0?Successful completion.]"
"[+>0?An error occurred.]"
"}"
"[+SEE ALSO?\blogname\b(1), \bwho\b(1), \bgetgroups\b(2)]"
;
#include <cmd.h>
#include <grp.h>
#include <pwd.h>
#if _lib_fsid
#if _sys_fss
#endif
#if _hdr_fsg
#include <fsg.h>
#endif
#if !_lib_isfsg && !defined(isfsg)
#endif
#else
#endif
#endif
#if _lib_fsid
static void
{
register char* s;
register char** p;
char** x;
if (lastchar)
{
else flags = 0;
}
else flags = -1;
setfsgent();
{
{
if (flags > 0) x = 0;
else
{
register char** q;
register char* t;
register int n;
n = 0;
q = p;
while (s = *q++)
n += strlen(s) + 1;
if (!(x = newof(0, char*, q - p, n)))
break;
s = (char*)(x + (q - p));
q = x;
while (t = *p++)
{
*q++ = s;
while (*s++ = *t++);
}
*q = 0;
p = x;
}
while (s = *p++)
{
if (lastchar == '=')
{
lastchar = ',';
}
else
{
setfsgent();
{
break;
}
}
}
if (x) free(x);
}
break;
}
endfsgent();
}
#endif
static void
{
{
}
else
{
}
}
static int
{
register int i;
register int j;
register int k;
#if _lib_fsid
const char* fs_name;
int fs_id;
#endif
char** p;
char* s;
int lastchar;
int ngroups = 0;
const char* gname;
{
static int maxgroups;
/*
* get supplemental groups if required
*/
if (!maxgroups)
{
/*
* first time
*/
}
for (i = j = 0; i < ngroups; i++)
{
}
ngroups = j;
}
if (name)
{
{
{
}
}
#if _lib_fsid
{
setfsgent();
do
{
}
#endif
}
else
{
#if _lib_fsid
#endif
}
ngroups = 0;
#if _lib_fsid
{
setfsgent();
}
#endif
{
{
#if _lib_getgrent
#if _lib_setgrent
setgrent();
#endif
lastchar = '=';
while (s = *p++)
{
if (lastchar == '=')
lastchar = ',';
}
#if _lib_endgrent
endgrent();
#endif
#endif
#if _lib_fsid
#endif
}
else
{
if (ngroups > 0)
{
lastchar = '=';
for (i = 0; i < ngroups; i++)
{
{
}
lastchar = ',';
}
}
#if _lib_fsid
#endif
}
return(0);
}
{
}
{
}
{
{
#if _lib_getgrent
#if _lib_setgrent
setgrent();
#endif
i = 0;
while (s = *p++)
{
}
#if _lib_endgrent
endgrent();
#endif
#endif
}
else if (ngroups > 0)
{
for (i = 0;;)
{
if (++i >= ngroups) break;
}
}
}
#if _lib_fsid
{
}
#endif
return(0);
}
int
{
register int flags = 0;
register int n;
for (;;)
{
{
case 'a':
continue;
case 'G':
continue;
case 'g':
continue;
case 'n':
continue;
case 'r':
continue;
case 's':
continue;
case 'u':
continue;
case ':':
break;
case '?':
break;
}
break;
}
if (!power2(n))
{
}
return(error_info.errors);
}