- char *line;
- FILE *passwd;
- int len = strlen(login);
- int found = 0;
- llist_t *plist = NULL;
-
- passwd = fopen_or_warn(filename, "r");
- if (!passwd) return;
-
- while ((line = xmalloc_fgets(passwd))) {
- if (!strncmp(line, login, len)
- && line[len] == ':'
- ) {
- found++;
- free(line);
- } else {
- llist_add_to_end(&plist, line);
- }
- }
-
- if (!found) {
- bb_error_msg("can't find '%s' in '%s'", login, filename);
- if (!ENABLE_FEATURE_CLEAN_UP) return;
- goto clean_up;
- }
-
- if (ENABLE_FEATURE_CLEAN_UP)
- fclose(passwd);
-
- passwd = fopen_or_warn(filename, "w");
- if (passwd) {
- if (ENABLE_FEATURE_CLEAN_UP) {
- clean_up:
- while ((line = llist_pop(&plist))) {
- if (found) fputs(line, passwd);
- free(line);
- }
- fclose(passwd);
- } else {
- /* found != 0 here, no need to check */
- while ((line = llist_pop(&plist)))
- fputs(line, passwd);
- }
+ if (ENABLE_FEATURE_DEL_USER_FROM_GROUP && args[2]) {
+ return update_passwd(filename, args[2], NULL, args[1]);