Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/update_passwd.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/libbb/update_passwd.c
r2725 r3621 63 63 or if CONFIG_CHPASSWD=y and applet_name[0] == 'c' like in chpasswd 64 64 65 8) delete a user from all groups: update_passwd(FILE, NULL, NULL, MEMBER) 66 65 67 This function does not validate the arguments fed to it 66 68 so the calling program should take care of that. … … 83 85 char *sfx_char; 84 86 char *name_colon; 85 unsigned user_len;86 87 int old_fd; 87 88 int new_fd; … … 100 101 return ret; 101 102 102 check_selinux_update_passwd(name); 103 if (name) 104 check_selinux_update_passwd(name); 103 105 104 106 /* New passwd file, "/etc/passwd+" for now */ 105 107 fnamesfx = xasprintf("%s+", filename); 106 108 sfx_char = &fnamesfx[strlen(fnamesfx)-1]; 107 name_colon = xasprintf("%s:", name); 108 user_len = strlen(name_colon); 109 name_colon = xasprintf("%s:", name ? name : ""); 109 110 110 111 if (shadow) … … 168 169 if (!line) /* EOF/error */ 169 170 break; 170 if (strncmp(name_colon, line, user_len) != 0) { 171 172 if (!name && member) { 173 /* Delete member from all groups */ 174 /* line is "GROUP:PASSWD:[member1[,member2]...]" */ 175 unsigned member_len = strlen(member); 176 char *list = strrchr(line, ':'); 177 while (list) { 178 list++; 179 next_list_element: 180 if (is_prefixed_with(list, member)) { 181 char c; 182 changed_lines++; 183 c = list[member_len]; 184 if (c == '\0') { 185 if (list[-1] == ',') 186 list--; 187 *list = '\0'; 188 break; 189 } 190 if (c == ',') { 191 overlapping_strcpy(list, list + member_len + 1); 192 goto next_list_element; 193 } 194 changed_lines--; 195 } 196 list = strchr(list, ','); 197 } 171 198 fprintf(new_fp, "%s\n", line); 172 199 goto next; 173 200 } 174 201 202 cp = is_prefixed_with(line, name_colon); 203 if (!cp) { 204 fprintf(new_fp, "%s\n", line); 205 goto next; 206 } 207 175 208 /* We have a match with "name:"... */ 176 cp = line + user_len; /* move past name:*/209 /* cp points past "name:" */ 177 210 178 211 #if ENABLE_FEATURE_ADDUSER_TO_GROUP || ENABLE_FEATURE_DEL_USER_FROM_GROUP
Note:
See TracChangeset
for help on using the changeset viewer.