From 4b9cc932b7efaa73ee38ffe96aaefe8d5cd30735 Mon Sep 17 00:00:00 2001 From: Thomas Cort Date: Tue, 12 Nov 2013 08:40:59 -0500 Subject: [PATCH] Importing usr.bin/id Replaces commands/id. No Minix-specific changes needed. Change-Id: I307ae0fa3f41ade398ee9be12c1b4d78e8b59e95 --- commands/Makefile | 2 +- releasetools/nbsd_ports | 1 + tests/usr.bin/id/Makefile | 4 ---- usr.bin/Makefile | 2 +- {commands => usr.bin}/id/Makefile | 4 +++- {commands => usr.bin}/id/groups.1 | 0 {commands => usr.bin}/id/id.1 | 0 {commands => usr.bin}/id/id.c | 24 +++++++++++++++--------- {commands => usr.bin}/id/whoami.1 | 0 9 files changed, 21 insertions(+), 16 deletions(-) rename {commands => usr.bin}/id/Makefile (64%) rename {commands => usr.bin}/id/groups.1 (100%) rename {commands => usr.bin}/id/id.1 (100%) rename {commands => usr.bin}/id/id.c (95%) rename {commands => usr.bin}/id/whoami.1 (100%) diff --git a/commands/Makefile b/commands/Makefile index 4754ecbf4..99bc45def 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -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 \ diff --git a/releasetools/nbsd_ports b/releasetools/nbsd_ports index 5082b3f92..ca05b4b6e 100644 --- a/releasetools/nbsd_ports +++ b/releasetools/nbsd_ports @@ -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 diff --git a/tests/usr.bin/id/Makefile b/tests/usr.bin/id/Makefile index 8ceff408d..3d09019ef 100644 --- a/tests/usr.bin/id/Makefile +++ b/tests/usr.bin/id/Makefile @@ -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 diff --git a/usr.bin/Makefile b/usr.bin/Makefile index 5f719b50b..04c9916df 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -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 \ diff --git a/commands/id/Makefile b/usr.bin/id/Makefile similarity index 64% rename from commands/id/Makefile rename to usr.bin/id/Makefile index 4e11db3ca..ce0d24dc5 100644 --- a/commands/id/Makefile +++ b/usr.bin/id/Makefile @@ -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 diff --git a/commands/id/groups.1 b/usr.bin/id/groups.1 similarity index 100% rename from commands/id/groups.1 rename to usr.bin/id/groups.1 diff --git a/commands/id/id.1 b/usr.bin/id/id.1 similarity index 100% rename from commands/id/id.1 rename to usr.bin/id/id.1 diff --git a/commands/id/id.c b/usr.bin/id/id.c similarity index 95% rename from commands/id/id.c rename to usr.bin/id/id.c index 86797fb54..720cc4954 100644 --- a/commands/id/id.c +++ b/usr.bin/id/id.c @@ -28,6 +28,18 @@ */ #include +#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 @@ -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; diff --git a/commands/id/whoami.1 b/usr.bin/id/whoami.1 similarity index 100% rename from commands/id/whoami.1 rename to usr.bin/id/whoami.1 -- 2.44.0