[hackers] [ubase] Implement -g and -u for id(1) || sin

From: <git_AT_suckless.org>
Date: Wed, 11 Jun 2014 16:47:27 +0200

commit db0ea785f0231be4315aa4c5af37e64841ce48f2
Author: sin <sin_AT_2f30.org>
Date: Wed Jun 11 15:42:33 2014 +0100

    Implement -g and -u for id(1)

diff --git a/id.1 b/id.1
index 9dca2d3..cd83326 100644
--- a/id.1
+++ b/id.1
_AT_@ -2,13 +2,19 @@
 .SH NAME
  Bid R - Print real and effective user and group IDs
 .SH SYNOPSIS
- Bid R [ B-G R] R[ Iuser R| Iuid R]
+ Bid R [ B-g R] [ B-u R] [ B-G R] R[ Iuser R| Iuid R]
 .SH DESCRIPTION
  Bid R 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
 user is displayed.
 .SH OPTIONS
 .TP
+ B-g R
+Print only the effective group ID.
+.TP
+ B-u R
+Print only the effective user ID.
+.TP
  B-G R
 Display group information as whitespace separated numbers, in no particular order.
 .SH SEE ALSO
diff --git a/id.c b/id.c
index 225c254..1efadbc 100644
--- a/id.c
+++ b/id.c
_AT_@ -18,7 +18,7 @@ static void usernam(const char *nam);
 static void
 usage(void)
 {
- eprintf("usage: %s [-G] [user | uid]
", argv0);
+ eprintf("usage: %s [-g] [-u] [-G] [user | uid]
", argv0);
 }
 
 static int Gflag = 0;
_AT_@ -27,6 +27,12 @@ int
 main(int argc, char *argv[])
 {
         ARGBEGIN {
+ case 'g':
+ printf("%d
", getegid());
+ return EXIT_SUCCESS;
+ case 'u':
+ printf("%d
", geteuid());
+ return EXIT_SUCCESS;
         case 'G':
                 Gflag = 1;
                 break;
Received on Wed Jun 11 2014 - 16:47:27 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 11 2014 - 16:48:08 CEST