*
*/
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-
#include "busybox.h"
/* make sure gr_name isn't taken, make sure gid is kosher
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;
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
{
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);
}