|
|
1.1 root 1: /*
2: * Coherent I/O Library
3: * getpw -- get line from password file for a given `uid'.
4: */
5: #include <stdio.h>
6:
7:
8: getpw(uid, buf)
9: short uid;
10: char *buf;
11: {
12: register int c;
13: register char *cp;
14: register FILE *fp;
15:
16: fp = fopen("/etc/passwd", "r");
17: if (fp == NULL)
18: return (1);
19: while (!feof(fp)) {
20: for (cp=buf; (c=getc(fp)) != EOF && c != '\n';)
21: *cp++ = c;
22: *cp = '\0';
23: for (cp=buf; *cp != ':' && *cp != '\0'; ++cp)
24: ;
25: if (*cp == '\0')
26: continue;
27: do {
28: ++cp;
29: } while (*cp != ':' && *cp != '\0');
30: if (*cp++ != '\0' && uid == atoi(cp)) {
31: fclose(fp);
32: return (0);
33: }
34: }
35: fclose(fp);
36: return (1);
37: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.