Annotation of researchv10no/cmd/ap/apkeys/fuser.c, revision 1.1.1.1

1.1       root        1: # include "stdio.h"
                      2: # include "ctype.h"
                      3: # include "assert.h"
                      4: main(argc,argv)
                      5:        char *argv[];
                      6: {
                      7: /*
                      8:  * looks through password for people with file argv[1]
                      9:  * prints lines with full file name, userid, home directory
                     10:  */
                     11: FILE *f;
                     12: char pline[250], fname[100];
                     13: char *p, *s, *strchr();
                     14: assert(argc>1);
                     15: f = fopen("/etc/passwd", "r");
                     16: assert(f!=NULL);
                     17: while (fgets(pline, 250, f))
                     18:        {
                     19:        p = strchr(pline, ':');
                     20:        assert(p!=0);
                     21:        *p= 0; /* end of userid */
                     22:        p = strchr(p+1, ':'); assert(p!=0); /* end of password */
                     23:        p = strchr(p+1, ':'); assert(p!=0); /* end of user number */
                     24:        p = strchr(p+1, ':'); assert(p!=0); /* end of group number */
                     25:        p = strchr(p+1, ':'); assert(p!=0); /* end of gcos account */
                     26:        p = strchr(s=p+1, ':'); assert(p!=0); /* end of home directory */
                     27:        *p=0;
                     28:        sprintf(fname, "%s/%s", s, argv[1]);
                     29:        if (access(fname, 04)==0)
                     30:                printf("%s %s %s\n", fname, pline, s);
                     31:        }
                     32: fclose(f);
                     33: }

unix.superglobalmegacorp.com

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