From: Eric Andersen Date: Thu, 12 Dec 2002 08:57:16 +0000 (-0000) Subject: Teach addgroup to add user names to groups X-Git-Tag: 1_00_pre1~293 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b8dff0c2a2d2d53e6f0888568305dc17e990cddc;p=oweals%2Fbusybox.git Teach addgroup to add user names to groups --- diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index f4c024516..36536bf50 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c @@ -83,7 +83,7 @@ static int group_study(const char *filename, struct group *g) } /* append a new user to the passwd file */ -static int addgroup(const char *filename, char *group, gid_t gid) +static int addgroup(const char *filename, char *group, gid_t gid, const char *user) { FILE *etc_group; @@ -106,7 +106,7 @@ static int addgroup(const char *filename, char *group, gid_t gid) /* add entry to group */ etc_group = xfopen(filename, "a"); - fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, ""); + fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, user); fclose(etc_group); @@ -133,6 +133,7 @@ static int addgroup(const char *filename, char *group, gid_t gid) int addgroup_main(int argc, char **argv) { char *group; + char *user; gid_t gid = 0; if (argc < 2) { @@ -145,6 +146,12 @@ int addgroup_main(int argc, char **argv) } else { show_usage(); } + + if (argc == 4) { + user = argv[3]; + } else { + user = ""; + } if (geteuid() != 0) { error_msg_and_die @@ -152,7 +159,7 @@ int addgroup_main(int argc, char **argv) } /* werk */ - return addgroup(group_file, group, gid); + return addgroup(GROUP_FILE, group, gid, user); } -/* $Id: addgroup.c,v 1.6 2002/11/14 11:10:14 andersen Exp $ */ +/* $Id: addgroup.c,v 1.7 2002/12/12 08:57:16 andersen Exp $ */