Annotation of researchv8dc/cmd/id.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include <pwd.h>
                      3: #include <grp.h>
                      4: 
                      5: main()
                      6: {
                      7:        int uid, gid, euid, egid;
                      8:        static char stdbuf[BUFSIZ];
                      9: 
                     10:        setbuf (stdout, stdbuf);
                     11: 
                     12:        uid = getuid();
                     13:        gid = getgid();
                     14:        euid = geteuid();
                     15:        egid = getegid();
                     16: 
                     17:        puid ("uid", uid);
                     18:        pgid (" gid", gid);
                     19:        if (uid != euid)
                     20:                puid (" euid", euid);
                     21:        if (gid != egid)
                     22:                pgid (" egid", egid);
                     23:        putchar ('\n');
                     24:        return 0;
                     25: }
                     26: 
                     27: puid (s, id)
                     28:        char *s;
                     29:        int id;
                     30: {
                     31:        struct passwd *pw;
                     32:        struct passwd *getpwuid();
                     33: 
                     34:        printf ("%s=%d", s, id);
                     35:        setpwent();
                     36:        pw = getpwuid(id);
                     37:        if (pw)
                     38:                printf ("(%s)", pw->pw_name);
                     39: }
                     40: 
                     41: pgid (s, id)
                     42:        char *s;
                     43:        int id;
                     44: {
                     45:        struct group *gr;
                     46:        struct group *getgrgid();
                     47: 
                     48:        printf ("%s=%d", s, id);
                     49:        setgrent();
                     50:        gr = getgrgid(id);
                     51:        if (gr)
                     52:                printf ("(%s)", gr->gr_name);
                     53: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.