-
-/*
- * adduser will take a login_name as its first parameter.
- *
- * home
- * shell
- * gecos
- *
- * can be customized via command-line parameters.
- */
-int adduser_main(int argc, char **argv);
-int adduser_main(int argc, char **argv)
-{
- struct passwd pw;
- const char *usegroup = NULL;
-
- /* got root? */
- if (geteuid()) {
- bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
- }
-
- pw.pw_gecos = (char *)"Linux User,,,";
- pw.pw_shell = (char *)DEFAULT_SHELL;
- pw.pw_dir = NULL;
-
- /* check for min, max and missing args and exit on error */
- opt_complementary = "-1:?1:?";
- getopt32(argc, argv, "h:g:s:G:DSH", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup);
-
- /* create string for $HOME if not specified already */
- if (!pw.pw_dir) {
- snprintf(bb_common_bufsiz1, BUFSIZ, "/home/%s", argv[optind]);
- pw.pw_dir = bb_common_bufsiz1;
- }
-
- /* create a passwd struct */
- pw.pw_name = argv[optind];
- pw.pw_passwd = (char *)"x";
- pw.pw_uid = 0;
- pw.pw_gid = usegroup ? xgroup2gid(usegroup) : 0; /* exits on failure */
-
- /* grand finale */
- return adduser(&pw);
-}