X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=loginutils%2Faddgroup.c;h=0172e6041dde858aeb3ee980434785b79ae473ee;hb=4fbb584a0e6ee086d6b30936c7124c687b3e977f;hp=f4962ffb97e33a5e8df404f498d4a5d555c1b822;hpb=9a2dd51237c065982b918f7e15d9248aa10d89d4;p=oweals%2Fbusybox.git diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c index f4962ffb9..0172e6041 100644 --- a/loginutils/addgroup.c +++ b/loginutils/addgroup.c @@ -9,11 +9,6 @@ * */ -#include -#include -#include -#include - #include "busybox.h" /* make sure gr_name isn't taken, make sure gid is kosher @@ -26,7 +21,7 @@ static int group_study(struct group *g) struct group *grp; const int max = 65000; - etc_group = bb_xfopen(bb_path_group_file, "r"); + etc_group = xfopen(bb_path_group_file, "r"); /* make sure gr_name isn't taken, make sure gid is kosher */ desired = g->gr_gid; @@ -67,13 +62,13 @@ static int addgroup(char *group, gid_t gid, const char *user) return 1; /* add entry to group */ - file = bb_xfopen(bb_path_group_file, "a"); + file = xfopen(bb_path_group_file, "a"); /* group:passwd:gid:userlist */ fprintf(file, "%s:%s:%d:%s\n", group, "x", gr.gr_gid, user); fclose(file); #if ENABLE_FEATURE_SHADOWPASSWDS - file = bb_xfopen(bb_path_gshadow_file, "a"); + file = xfopen(bb_path_gshadow_file, "a"); fprintf(file, "%s:!::\n", group); fclose(file); #endif @@ -93,18 +88,17 @@ int addgroup_main(int argc, char **argv) { char *group; gid_t gid = 0; - - /* check for min, max and missing args and exit on error */ - bb_opt_complementally = "-1:?2:?"; - if (bb_getopt_ulflags(argc, argv, "g:", &group)) { - gid = bb_xgetlarg(group, 10, 0, LONG_MAX); + /* check for min, max and missing args and exit on error */ + opt_complementary = "-1:?2:?"; + if (getopt32(argc, argv, "g:", &group)) { + gid = xatoul_range(group, 0, (gid_t)ULONG_MAX); } /* move past the commandline options */ argv += optind; /* need to be root */ - if(geteuid()) { + if (geteuid()) { bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); }