summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorEric Andersen2002-12-12 08:57:16 +0000
committerEric Andersen2002-12-12 08:57:16 +0000
commitb8dff0c2a2d2d53e6f0888568305dc17e990cddc (patch)
tree51300f163856b0aa8e1e5538d058faec603ae261 /loginutils
parentb2bfd34a7bd6ce1bd85da225a30d087586680622 (diff)
downloadbusybox-b8dff0c2a2d2d53e6f0888568305dc17e990cddc.zip
busybox-b8dff0c2a2d2d53e6f0888568305dc17e990cddc.tar.gz
Teach addgroup to add user names to groups
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/addgroup.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index f4c0245..36536bf 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 $ */