Commit | Line | Data |
---|---|---|
48435ab0 WJ |
1 | /* baduser.c - check file of bad users */ |
2 | ||
3 | #ifndef lint | |
4 | static char *rcsid = "$Header: /f/osi/compat/RCS/baduser.c,v 7.1 91/02/22 09:14:56 mrose Interim $"; | |
5 | #endif | |
6 | ||
7 | /* | |
8 | * $Header: /f/osi/compat/RCS/baduser.c,v 7.1 91/02/22 09:14:56 mrose Interim $ | |
9 | * | |
10 | * | |
11 | * $Log: baduser.c,v $ | |
12 | * Revision 7.1 91/02/22 09:14:56 mrose | |
13 | * Interim 6.8 | |
14 | * | |
15 | * Revision 7.0 89/11/23 21:22:54 mrose | |
16 | * Release 6.0 | |
17 | * | |
18 | */ | |
19 | ||
20 | /* | |
21 | * NOTICE | |
22 | * | |
23 | * Acquisition, use, and distribution of this module and related | |
24 | * materials are subject to the restrictions of a license agreement. | |
25 | * Consult the Preface in the User's Manual for the full terms of | |
26 | * this agreement. | |
27 | * | |
28 | */ | |
29 | ||
30 | ||
31 | /* LINTLIBRARY */ | |
32 | ||
33 | #include <stdio.h> | |
34 | #include "general.h" | |
35 | #include "manifest.h" | |
36 | #include "tailor.h" | |
37 | ||
38 | /* \f */ | |
39 | ||
40 | int baduser (file, user) | |
41 | char *file, | |
42 | *user; | |
43 | { | |
44 | int hit, | |
45 | tries; | |
46 | register char *bp; | |
47 | char buffer[BUFSIZ]; | |
48 | FILE *fp; | |
49 | ||
50 | hit = 0; | |
51 | for (tries = 0; tries < 2 && !hit; tries++) { | |
52 | switch (tries) { | |
53 | case 0: | |
54 | if (file) { | |
55 | bp = isodefile (file, 0); | |
56 | break; | |
57 | } | |
58 | tries++; | |
59 | /* and fall */ | |
60 | default: | |
61 | bp = "/etc/ftpusers"; | |
62 | break; | |
63 | } | |
64 | if ((fp = fopen (bp, "r")) == NULL) | |
65 | continue; | |
66 | ||
67 | while (fgets (buffer, sizeof buffer, fp)) { | |
68 | if (bp = index (buffer, '\n')) | |
69 | *bp = NULL; | |
70 | if (strcmp (buffer, user) == 0) { | |
71 | hit++; | |
72 | break; | |
73 | } | |
74 | } | |
75 | ||
76 | (void) fclose (fp); | |
77 | } | |
78 | ||
79 | ||
80 | return hit; | |
81 | } |