mirror of
git://git.suckless.org/ubase
synced 2025-04-28 22:07:57 +00:00
Implement -g and -u for id(1)
This commit is contained in:
parent
d3e332c72d
commit
db0ea785f0
8
id.1
8
id.1
@ -2,13 +2,19 @@
|
|||||||
.SH NAME
|
.SH NAME
|
||||||
\fBid\fR - Print real and effective user and group IDs
|
\fBid\fR - Print real and effective user and group IDs
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
\fBid\fR [\fB-G\fR] \fR[\fIuser\fR|\fIuid\fR]
|
\fBid\fR [\fB-g\fR] [\fB-u\fR] [\fB-G\fR] \fR[\fIuser\fR|\fIuid\fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
\fBid\fR prints user and group information of the calling process to standard output.
|
\fBid\fR prints user and group information of the calling process to standard output.
|
||||||
If a login name or uid is specified, the user and group information of that
|
If a login name or uid is specified, the user and group information of that
|
||||||
user is displayed.
|
user is displayed.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
|
\fB-g\fR
|
||||||
|
Print only the effective group ID.
|
||||||
|
.TP
|
||||||
|
\fB-u\fR
|
||||||
|
Print only the effective user ID.
|
||||||
|
.TP
|
||||||
\fB-G\fR
|
\fB-G\fR
|
||||||
Display group information as whitespace separated numbers, in no particular order.
|
Display group information as whitespace separated numbers, in no particular order.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
|
8
id.c
8
id.c
@ -18,7 +18,7 @@ static void usernam(const char *nam);
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
eprintf("usage: %s [-G] [user | uid]\n", argv0);
|
eprintf("usage: %s [-g] [-u] [-G] [user | uid]\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int Gflag = 0;
|
static int Gflag = 0;
|
||||||
@ -27,6 +27,12 @@ int
|
|||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
|
case 'g':
|
||||||
|
printf("%d\n", getegid());
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
case 'u':
|
||||||
|
printf("%d\n", geteuid());
|
||||||
|
return EXIT_SUCCESS;
|
||||||
case 'G':
|
case 'G':
|
||||||
Gflag = 1;
|
Gflag = 1;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user