Importing usr.bin/id
Replaces commands/id. No Minix-specific changes needed. Change-Id: I307ae0fa3f41ade398ee9be12c1b4d78e8b59e95
This commit is contained in:
parent
a0e6850f82
commit
4b9cc932b7
9 changed files with 21 additions and 16 deletions
|
@ -11,7 +11,7 @@ SUBDIR= add_route arp ash at backup btrace \
|
||||||
eject factor fbdctl \
|
eject factor fbdctl \
|
||||||
find fix format fortune fsck.mfs \
|
find fix format fortune fsck.mfs \
|
||||||
gcore gcov-pull getty grep host \
|
gcore gcov-pull getty grep host \
|
||||||
hostaddr id ifconfig ifdef \
|
hostaddr ifconfig ifdef \
|
||||||
intr ipcrm ipcs irdpd isoread last \
|
intr ipcrm ipcs irdpd isoread last \
|
||||||
less loadkeys loadramdisk logger look lp \
|
less loadkeys loadramdisk logger look lp \
|
||||||
lpd lspci mail MAKEDEV \
|
lpd lspci mail MAKEDEV \
|
||||||
|
|
|
@ -176,6 +176,7 @@
|
||||||
2012/10/17 12:00:00,usr.bin/genassym
|
2012/10/17 12:00:00,usr.bin/genassym
|
||||||
2013/03/09 12:00:00,usr.bin/getopt
|
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/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/indent
|
||||||
2012/10/17 12:00:00,usr.bin/infocmp
|
2012/10/17 12:00:00,usr.bin/infocmp
|
||||||
2012/10/17 12:00:00,usr.bin/join
|
2012/10/17 12:00:00,usr.bin/join
|
||||||
|
|
|
@ -12,11 +12,7 @@ TESTS_SH+= t_whoami
|
||||||
|
|
||||||
BINDIR= ${TESTSDIR}
|
BINDIR= ${TESTSDIR}
|
||||||
PROG= h_id
|
PROG= h_id
|
||||||
.if defined(__MINIX)
|
|
||||||
.PATH: ${NETBSDSRCDIR}/commands/id
|
|
||||||
.else
|
|
||||||
.PATH: ${NETBSDSRCDIR}/usr.bin/id
|
.PATH: ${NETBSDSRCDIR}/usr.bin/id
|
||||||
.endif # defined(__MINIX)
|
|
||||||
SRCS= id.c pwgr.c
|
SRCS= id.c pwgr.c
|
||||||
|
|
||||||
COPTS.id.c += -Wno-format-nonliteral
|
COPTS.id.c += -Wno-format-nonliteral
|
||||||
|
|
|
@ -12,7 +12,7 @@ SUBDIR= asa \
|
||||||
env expand \
|
env expand \
|
||||||
finger fold from \
|
finger fold from \
|
||||||
fsplit ftp genassym getopt \
|
fsplit ftp genassym getopt \
|
||||||
head hexdump indent infocmp join jot \
|
head hexdump id indent infocmp join jot \
|
||||||
lam ldd leave \
|
lam ldd leave \
|
||||||
lock login logname lorder m4 \
|
lock login logname lorder m4 \
|
||||||
machine make man menuc mesg \
|
machine make man menuc mesg \
|
||||||
|
|
|
@ -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
|
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
|
|
||||||
PROG= id
|
PROG= id
|
||||||
|
@ -6,4 +6,6 @@ MAN= id.1 groups.1 whoami.1
|
||||||
LINKS= ${BINDIR}/id ${BINDIR}/groups
|
LINKS= ${BINDIR}/id ${BINDIR}/groups
|
||||||
LINKS+= ${BINDIR}/id ${BINDIR}/whoami
|
LINKS+= ${BINDIR}/id ${BINDIR}/whoami
|
||||||
|
|
||||||
|
COPTS.id.c += -Wno-format-nonliteral
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
|
@ -28,6 +28,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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>
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
@ -43,7 +55,7 @@
|
||||||
static void current(void);
|
static void current(void);
|
||||||
static void pretty(struct passwd *);
|
static void pretty(struct passwd *);
|
||||||
static void group(struct passwd *, int);
|
static void group(struct passwd *, int);
|
||||||
static void usage(void);
|
__dead static void usage(void);
|
||||||
static void user(struct passwd *);
|
static void user(struct passwd *);
|
||||||
static struct passwd *who(char *);
|
static struct passwd *who(char *);
|
||||||
|
|
||||||
|
@ -229,7 +241,6 @@ current(void)
|
||||||
if ((gr = getgrgid(egid)) != NULL)
|
if ((gr = getgrgid(egid)) != NULL)
|
||||||
(void)printf("(%s)", gr->gr_name);
|
(void)printf("(%s)", gr->gr_name);
|
||||||
}
|
}
|
||||||
#ifndef __minix
|
|
||||||
if ((ngroups = getgroups(maxgroups, groups)) != 0) {
|
if ((ngroups = getgroups(maxgroups, groups)) != 0) {
|
||||||
for (fmt = " groups=%ju", lastid = -1, cnt = 0; cnt < ngroups;
|
for (fmt = " groups=%ju", lastid = -1, cnt = 0; cnt < ngroups;
|
||||||
fmt = ",%ju", lastid = gid, cnt++) {
|
fmt = ",%ju", lastid = gid, cnt++) {
|
||||||
|
@ -241,7 +252,6 @@ current(void)
|
||||||
(void)printf("(%s)", gr->gr_name);
|
(void)printf("(%s)", gr->gr_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
(void)printf("\n");
|
(void)printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,12 +269,10 @@ user(struct passwd *pw)
|
||||||
if ((gr = getgrgid(pw->pw_gid)) != NULL)
|
if ((gr = getgrgid(pw->pw_gid)) != NULL)
|
||||||
(void)printf("(%s)", gr->gr_name);
|
(void)printf("(%s)", gr->gr_name);
|
||||||
ngroups = maxgroups + 1;
|
ngroups = maxgroups + 1;
|
||||||
#ifndef __minix
|
|
||||||
if (getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups) == -1) {
|
if (getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups) == -1) {
|
||||||
glist = malloc(ngroups * sizeof(gid_t));
|
glist = malloc(ngroups * sizeof(gid_t));
|
||||||
(void) getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups);
|
(void) getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
for (fmt = " groups=%u", lastid = -1, cnt = 0; cnt < ngroups;
|
for (fmt = " groups=%u", lastid = -1, cnt = 0; cnt < ngroups;
|
||||||
fmt=",%u", lastid = id, cnt++) {
|
fmt=",%u", lastid = id, cnt++) {
|
||||||
id = glist[cnt];
|
id = glist[cnt];
|
||||||
|
@ -283,21 +291,19 @@ static void
|
||||||
group(struct passwd *pw, int nflag)
|
group(struct passwd *pw, int nflag)
|
||||||
{
|
{
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
int cnt, id, lastid, ngroups;
|
int cnt, ngroups;
|
||||||
|
gid_t id, lastid;
|
||||||
const char *fmt;
|
const char *fmt;
|
||||||
gid_t *glist = groups;
|
gid_t *glist = groups;
|
||||||
|
|
||||||
if (pw) {
|
if (pw) {
|
||||||
ngroups = maxgroups;
|
ngroups = maxgroups;
|
||||||
#ifndef __minix
|
|
||||||
if (getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups)
|
if (getgrouplist(pw->pw_name, pw->pw_gid, glist, &ngroups)
|
||||||
== -1) {
|
== -1) {
|
||||||
glist = malloc(ngroups * sizeof(gid_t));
|
glist = malloc(ngroups * sizeof(gid_t));
|
||||||
(void) getgrouplist(pw->pw_name, pw->pw_gid, glist,
|
(void) getgrouplist(pw->pw_name, pw->pw_gid, glist,
|
||||||
&ngroups);
|
&ngroups);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
glist[0] = getgid();
|
glist[0] = getgid();
|
||||||
ngroups = getgroups(maxgroups, glist + 1) + 1;
|
ngroups = getgroups(maxgroups, glist + 1) + 1;
|
Loading…
Reference in a new issue