diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 09:13:01 +0000 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /loginutils/addgroup.c | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) | |
download | busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.gz busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.tar.bz2 busybox-w32-cad5364599eb5062d59e0c397ed638ddd61a8d5d.zip |
Major coreutils update.
Diffstat (limited to 'loginutils/addgroup.c')
-rw-r--r-- | loginutils/addgroup.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index 1d754af8e..2e8188dec 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c | |||
@@ -54,16 +54,16 @@ static int group_study(const char *filename, struct group *g) | |||
54 | struct group *grp; | 54 | struct group *grp; |
55 | const int max = 65000; | 55 | const int max = 65000; |
56 | 56 | ||
57 | etc_group = xfopen(filename, "r"); | 57 | etc_group = bb_xfopen(filename, "r"); |
58 | 58 | ||
59 | /* make sure gr_name isn't taken, make sure gid is kosher */ | 59 | /* make sure gr_name isn't taken, make sure gid is kosher */ |
60 | desired = g->gr_gid; | 60 | desired = g->gr_gid; |
61 | while ((grp = fgetgrent(etc_group))) { | 61 | while ((grp = fgetgrent(etc_group))) { |
62 | if ((strcmp(grp->gr_name, g->gr_name)) == 0) { | 62 | if ((strcmp(grp->gr_name, g->gr_name)) == 0) { |
63 | error_msg_and_die("%s: group already in use\n", g->gr_name); | 63 | bb_error_msg_and_die("%s: group already in use\n", g->gr_name); |
64 | } | 64 | } |
65 | if ((desired) && grp->gr_gid == desired) { | 65 | if ((desired) && grp->gr_gid == desired) { |
66 | error_msg_and_die("%d: gid has already been allocated\n", | 66 | bb_error_msg_and_die("%d: gid has already been allocated\n", |
67 | desired); | 67 | desired); |
68 | } | 68 | } |
69 | if ((grp->gr_gid > g->gr_gid) && (grp->gr_gid < max)) { | 69 | if ((grp->gr_gid > g->gr_gid) && (grp->gr_gid < max)) { |
@@ -89,7 +89,6 @@ static int addgroup(const char *filename, char *group, gid_t gid, const char *us | |||
89 | 89 | ||
90 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS | 90 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS |
91 | FILE *etc_gshadow; | 91 | FILE *etc_gshadow; |
92 | const char *gshadow = gshadow_file; | ||
93 | #endif | 92 | #endif |
94 | 93 | ||
95 | struct group gr; | 94 | struct group gr; |
@@ -104,7 +103,7 @@ static int addgroup(const char *filename, char *group, gid_t gid, const char *us | |||
104 | return 1; | 103 | return 1; |
105 | 104 | ||
106 | /* add entry to group */ | 105 | /* add entry to group */ |
107 | etc_group = xfopen(filename, "a"); | 106 | etc_group = bb_xfopen(filename, "a"); |
108 | 107 | ||
109 | fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, user); | 108 | fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, user); |
110 | fclose(etc_group); | 109 | fclose(etc_group); |
@@ -112,8 +111,8 @@ static int addgroup(const char *filename, char *group, gid_t gid, const char *us | |||
112 | 111 | ||
113 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS | 112 | #ifdef CONFIG_FEATURE_SHADOWPASSWDS |
114 | /* add entry to gshadow if necessary */ | 113 | /* add entry to gshadow if necessary */ |
115 | if (access(gshadow, F_OK|W_OK) == 0) { | 114 | if (access(bb_path_gshadow_file, F_OK|W_OK) == 0) { |
116 | etc_gshadow = xfopen(gshadow, "a"); | 115 | etc_gshadow = bb_xfopen(bb_path_gshadow_file, "a"); |
117 | fprintf(etc_gshadow, "%s:!::\n", group); | 116 | fprintf(etc_gshadow, "%s:!::\n", group); |
118 | fclose(etc_gshadow); | 117 | fclose(etc_gshadow); |
119 | } | 118 | } |
@@ -144,7 +143,7 @@ int addgroup_main(int argc, char **argv) | |||
144 | gid = strtol(optarg, NULL, 10); | 143 | gid = strtol(optarg, NULL, 10); |
145 | break; | 144 | break; |
146 | default: | 145 | default: |
147 | show_usage(); | 146 | bb_show_usage(); |
148 | break; | 147 | break; |
149 | } | 148 | } |
150 | } | 149 | } |
@@ -153,7 +152,7 @@ int addgroup_main(int argc, char **argv) | |||
153 | group = argv[optind]; | 152 | group = argv[optind]; |
154 | optind++; | 153 | optind++; |
155 | } else { | 154 | } else { |
156 | show_usage(); | 155 | bb_show_usage(); |
157 | } | 156 | } |
158 | 157 | ||
159 | if (optind < argc) { | 158 | if (optind < argc) { |
@@ -164,12 +163,12 @@ int addgroup_main(int argc, char **argv) | |||
164 | } | 163 | } |
165 | 164 | ||
166 | if (geteuid() != 0) { | 165 | if (geteuid() != 0) { |
167 | error_msg_and_die | 166 | bb_error_msg_and_die |
168 | ("Only root may add a group to the system."); | 167 | ("Only root may add a group to the system."); |
169 | } | 168 | } |
170 | 169 | ||
171 | /* werk */ | 170 | /* werk */ |
172 | return addgroup(group_file, group, gid, user); | 171 | return addgroup(bb_path_group_file, group, gid, user); |
173 | } | 172 | } |
174 | 173 | ||
175 | /* $Id: addgroup.c,v 1.9 2003/01/09 18:53:53 andersen Exp $ */ | 174 | /* $Id: addgroup.c,v 1.10 2003/03/19 09:12:20 mjn3 Exp $ */ |