|
|
1.1 ! root 1: /* @(#)getpw.c 4.1 (Berkeley) 12/21/80 */ ! 2: #include <stdio.h> ! 3: ! 4: getpw(uid, buf) ! 5: int uid; ! 6: char buf[]; ! 7: { ! 8: static FILE *pwf; ! 9: register n, c; ! 10: register char *bp; ! 11: ! 12: if(pwf == 0) ! 13: pwf = fopen("/etc/passwd", "r"); ! 14: if(pwf == NULL) ! 15: return(1); ! 16: rewind(pwf); ! 17: ! 18: for (;;) { ! 19: bp = buf; ! 20: while((c=getc(pwf)) != '\n') { ! 21: if(c == EOF) ! 22: return(1); ! 23: *bp++ = c; ! 24: } ! 25: *bp++ = '\0'; ! 26: bp = buf; ! 27: n = 3; ! 28: while(--n) ! 29: while((c = *bp++) != ':') ! 30: if(c == '\n') ! 31: return(1); ! 32: while((c = *bp++) != ':') { ! 33: if(c<'0' || c>'9') ! 34: continue; ! 35: n = n*10+c-'0'; ! 36: } ! 37: if(n == uid) ! 38: return(0); ! 39: } ! 40: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.