void pline(struct passwd *);
void pretty(struct passwd *);
void auditid(void);
+void fullname(struct passwd *);
void group(struct passwd *, int);
void maclabel(void);
void usage(void);
struct passwd *pw;
int Gflag, Mflag, Pflag, ch, gflag, id, nflag, pflag, rflag, uflag;
int Aflag;
+ int Fflag;
const char *myname;
Gflag = Mflag = Pflag = gflag = nflag = pflag = rflag = uflag = 0;
Aflag = 0;
+ Fflag = 0;
myname = strrchr(argv[0], '/');
myname = (myname != NULL) ? myname + 1 : argv[0];
}
while ((ch = getopt(argc, argv,
- (isgroups || iswhoami) ? "" : "APGMagnpru")) != -1)
+ (isgroups || iswhoami) ? "" : "AFPGMagnpru")) != -1)
switch(ch) {
#ifdef USE_BSM_AUDIT
case 'A':
Aflag = 1;
break;
#endif
+ case 'F':
+ Fflag = 1;
+ break;
case 'G':
Gflag = 1;
break;
if (iswhoami && argc > 0)
usage();
- switch(Aflag + Gflag + Mflag + Pflag + gflag + pflag + uflag) {
+ switch(Aflag + Fflag + Gflag + Mflag + Pflag + gflag + pflag + uflag) {
case 1:
break;
case 0:
}
#endif
+ if (Fflag) {
+ fullname(pw);
+ exit(0);
+ }
+
if (gflag) {
id = pw ? pw->pw_gid : rflag ? getgid() : getegid();
if (nflag && (gr = getgrgid(id)))
uid_t uid, euid;
int cnt, ngroups;
#ifdef __APPLE__
- gid_t *groups;
+ gid_t *groups = NULL;
#else
gid_t groups[NGROUPS + 1];
#endif
}
else {
#ifdef __APPLE__
- groups = malloc(NGROUPS + 1);
+ groups = malloc((NGROUPS + 1) * sizeof(gid_t));
#endif
ngroups = getgroups(NGROUPS + 1, groups);
}
+#ifdef __APPLE__
+ if (ngroups < 0)
+ warn("failed to retrieve group list");
+#endif
+
if (pw != NULL)
printf("uid=%u(%s)", uid, pw->pw_name);
else
void
auditid(void)
{
- auditinfo_t auditinfo;
+ auditinfo_addr_t auditinfo;
- if (getaudit(&auditinfo) < 0)
+ if (getaudit_addr(&auditinfo, sizeof(auditinfo)) < 0)
err(1, "getaudit");
printf("auid=%d\n", auditinfo.ai_auid);
printf("mask.success=0x%08x\n", auditinfo.ai_mask.am_success);
printf("mask.failure=0x%08x\n", auditinfo.ai_mask.am_failure);
- printf("termid.port=0x%08x\n", auditinfo.ai_termid.port);
+ printf("termid.port=0x%08x\n", auditinfo.ai_termid.at_port);
printf("asid=%d\n", auditinfo.ai_asid);
}
#endif
+void
+fullname(struct passwd *pw)
+{
+
+ if (!pw) {
+ if ((pw = getpwuid(getuid())) == NULL)
+ err(1, "getpwuid");
+ }
+
+ (void)printf("%s\n", pw->pw_gecos);
+}
+
void
group(struct passwd *pw, int nflag)
{
struct group *gr;
int cnt, id, lastid, ngroups;
#ifdef __APPLE__
- gid_t *groups;
+ gid_t *groups = NULL;
#else
gid_t groups[NGROUPS + 1];
#endif
#endif
} else {
#ifdef __APPLE__
- groups = malloc(NGROUPS + 1);
+ groups = malloc((NGROUPS + 1) * sizeof(gid_t));
#endif
groups[0] = getgid();
ngroups = getgroups(NGROUPS, groups + 1) + 1;
else if (iswhoami)
(void)fprintf(stderr, "usage: whoami\n");
else
- (void)fprintf(stderr, "%s\n%s%s\n%s\n%s\n%s\n%s\n%s\n",
+ (void)fprintf(stderr, "%s\n%s%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: id [user]",
#ifdef USE_BSM_AUDIT
" id -A\n",
#else
"",
#endif
+ " id -F [user]",
" id -G [-n] [user]",
" id -M",
" id -P [user]",