Importing usr.bin/id

Replaces commands/id. No Minix-specific changes needed.

Change-Id: I307ae0fa3f41ade398ee9be12c1b4d78e8b59e95
This commit is contained in:
Thomas Cort 2013-11-12 08:40:59 -05:00
parent a0e6850f82
commit 4b9cc932b7
9 changed files with 21 additions and 16 deletions

View File

@ -11,7 +11,7 @@ SUBDIR= add_route arp ash at backup btrace \
eject factor fbdctl \
find fix format fortune fsck.mfs \
gcore gcov-pull getty grep host \
hostaddr id ifconfig ifdef \
hostaddr ifconfig ifdef \
intr ipcrm ipcs irdpd isoread last \
less loadkeys loadramdisk logger look lp \
lpd lspci mail MAKEDEV \

View File

@ -176,6 +176,7 @@
2012/10/17 12:00:00,usr.bin/genassym
2013/03/09 12:00:00,usr.bin/getopt
2012/10/17 12:00:00,usr.bin/gzip
2012/10/17 12:00:00,usr.bin/id
2012/10/17 12:00:00,usr.bin/indent
2012/10/17 12:00:00,usr.bin/infocmp
2012/10/17 12:00:00,usr.bin/join

View File

@ -12,11 +12,7 @@ TESTS_SH+= t_whoami
BINDIR= ${TESTSDIR}
PROG= h_id
.if defined(__MINIX)
.PATH: ${NETBSDSRCDIR}/commands/id
.else
.PATH: ${NETBSDSRCDIR}/usr.bin/id
.endif # defined(__MINIX)
SRCS= id.c pwgr.c
COPTS.id.c += -Wno-format-nonliteral

View File

@ -12,7 +12,7 @@ SUBDIR= asa \
env expand \
finger fold from \
fsplit ftp genassym getopt \
head hexdump indent infocmp join jot \
head hexdump id indent infocmp join jot \
lam ldd leave \
lock login logname lorder m4 \
machine make man menuc mesg \

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.11 2006/10/08 17:52:28 peter Exp $
# $NetBSD: Makefile,v 1.13 2011/08/16 10:37:21 christos Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= id
@ -6,4 +6,6 @@ MAN= id.1 groups.1 whoami.1
LINKS= ${BINDIR}/id ${BINDIR}/groups
LINKS+= ${BINDIR}/id ${BINDIR}/whoami
COPTS.id.c += -Wno-format-nonliteral
.include <bsd.prog.mk>

View File

@ -28,6 +28,18 @@
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1991, 1993\
The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)id.c 8.3 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: id.c,v 1.32 2011/09/16 15:39:26 joerg Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
@ -43,7 +55,7 @@
static void current(void);
static void pretty(struct passwd *);
static void group(struct passwd *, int);
static void usage(void);
__dead static void usage(void);
static void user(struct passwd *);
static struct passwd *who(char *);
@ -229,7 +241,6 @@ current(void)
if ((gr = getgrgid(egid)) != NULL)
(void)printf("(%s)", gr->gr_name);
}
#ifndef __minix
if ((ngroups = getgroups(maxgroups, groups)) != 0) {
for (fmt = " groups=%ju", lastid = -1, cnt = 0; cnt < ngroups;
fmt = ",%ju", lastid = gid, cnt++) {
@ -241,7 +252,6 @@ current(void)
(void)printf("(%s)", gr->gr_name);
}
}
#endif
(void)printf("\n");
}
@ -259,12 +269,10 @@ user(struct passwd *pw)
if ((gr = getgrgid(pw->pw_gid)) != NULL)
(void)printf("(%s)", gr->gr_name);
ngroups = maxgroups + 1;
#ifndef __minix
if (getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups) == -1) {
glist = malloc(ngroups * sizeof(gid_t));
(void) getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups);
}
#endif
for (fmt = " groups=%u", lastid = -1, cnt = 0; cnt < ngroups;
fmt=",%u", lastid = id, cnt++) {
id = glist[cnt];
@ -283,21 +291,19 @@ static void
group(struct passwd *pw, int nflag)
{
struct group *gr;
int cnt, id, lastid, ngroups;
int cnt, ngroups;
gid_t id, lastid;
const char *fmt;
gid_t *glist = groups;
if (pw) {
ngroups = maxgroups;
#ifndef __minix
if (getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups)
== -1) {
glist = malloc(ngroups * sizeof(gid_t));
(void) getgrouplist(pw->pw_name, pw->pw_gid, glist,
&ngroups);
}
#endif
} else {
glist[0] = getgid();
ngroups = getgroups(maxgroups, glist + 1) + 1;