Путь: Toys/Pending, команды версии: Ver.4 Ver.9 groupdel Комментарии в файле groupdel.c :
Исходный текст в файле groupdel.c #define FOR_groupdel #include "toys.h" void groupdel_main(void) { struct group *grp = xgetgrnam(toys.optargs[toys.optc-1]); char *entry = 0; // delete user from group if (toys.optc == 2) { int i, len = 0, found = 0; char *s; xgetpwnam(*toys.optargs); if (grp->gr_mem) for (i = 0; grp->gr_mem[i]; i++) { if (!found && !strcmp(*toys.optargs, grp->gr_mem[i])) found++; else len += strlen(grp->gr_mem[i]) + 1; } if (!found) error_exit("user '%s' not in group '%s'", *toys.optargs, toys.optargs[1]); entry = s = xmalloc(len); for (i = 0; grp->gr_mem[i]; ) { if (i) *(s++) = ','; s = stpcpy(s, grp->gr_mem[i]); } // delete group } else { struct passwd *pw; for (endpwent(); (pw = getpwent());) if (pw->pw_gid == grp->gr_gid) break; if (pw) error_exit("can't remove primary group of user '%s'", pw->pw_name); if (CFG_TOYBOX_FREE) endpwent(); } update_password("/etc/group", grp->gr_name, entry); update_password("/etc/gshadow", grp->gr_name, entry); if (CFG_TOYBOX_FREE) free(entry); } |