diff options
Diffstat (limited to 'chmod_chown_chgrp.c')
-rw-r--r-- | chmod_chown_chgrp.c | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/chmod_chown_chgrp.c b/chmod_chown_chgrp.c index faebbbe10..85ba247b8 100644 --- a/chmod_chown_chgrp.c +++ b/chmod_chown_chgrp.c | |||
@@ -48,56 +48,6 @@ static const char chmod_usage[] = "[-R] MODE[,MODE]... FILE...\n" | |||
48 | "\t-R\tchange files and directories recursively.\n"; | 48 | "\t-R\tchange files and directories recursively.\n"; |
49 | 49 | ||
50 | 50 | ||
51 | uid_t my_getid(const char *filename, const char *name) | ||
52 | { | ||
53 | FILE *stream; | ||
54 | char *rname, *start, *end, buf[128]; | ||
55 | uid_t rid; | ||
56 | |||
57 | stream=fopen(filename,"r"); | ||
58 | |||
59 | while (fgets (buf, 128, stream) != NULL) { | ||
60 | if (buf[0] == '#') | ||
61 | continue; | ||
62 | |||
63 | start = buf; | ||
64 | end = strchr (start, ':'); | ||
65 | if (end == NULL) | ||
66 | continue; | ||
67 | *end = '\0'; | ||
68 | rname = start; | ||
69 | |||
70 | start = end + 1; | ||
71 | end = strchr (start, ':'); | ||
72 | if (end == NULL) | ||
73 | continue; | ||
74 | |||
75 | start = end + 1; | ||
76 | rid = (uid_t) strtol (start, &end, 10); | ||
77 | if (end == start) | ||
78 | continue; | ||
79 | |||
80 | if (name) { | ||
81 | if (0 == strcmp(rname, name)) | ||
82 | return( rid); | ||
83 | } | ||
84 | } | ||
85 | fclose(stream); | ||
86 | return (-1); | ||
87 | } | ||
88 | |||
89 | uid_t | ||
90 | my_getpwnam(char *name) | ||
91 | { | ||
92 | return my_getid("/etc/passwd", name); | ||
93 | } | ||
94 | |||
95 | gid_t | ||
96 | my_getgrnam(char *name) | ||
97 | { | ||
98 | return my_getid("/etc/group", name); | ||
99 | } | ||
100 | |||
101 | static int fileAction(const char *fileName, struct stat* statbuf) | 51 | static int fileAction(const char *fileName, struct stat* statbuf) |
102 | { | 52 | { |
103 | switch (whichApp) { | 53 | switch (whichApp) { |