* These defaults are used if there is no defaults file.
*/
static gid_t def_group = 1000;
+static const char *def_groups = "";
static const char *def_gname = "other";
static const char *def_home = "/home";
static const char *def_shell = "/bin/bash";
#endif /* ENABLE_SUBIDS */
#define DGROUP "GROUP="
+#define DGROUPS "GROUPS="
#define DHOME "HOME="
#define DSHELL "SHELL="
#define DINACT "INACTIVE="
}
}
+ if (MATCH (buf, DGROUPS)) {
+ if (get_groups (cp) != 0) {
+ fprintf (stderr,
+ _("%s: the '%s' configuraton in %s has an invalid group, ignoring the bad group\n"),
+ Prog, DGROUPS, default_file);
+ }
+ if (user_groups[0] != NULL) {
+ do_grp_update = true;
+ def_groups = xstrdup (cp);
+ }
+ }
/*
* Default HOME filesystem
*/
static void show_defaults (void)
{
printf ("GROUP=%u\n", (unsigned int) def_group);
+ printf ("GROUPS=%s\n", def_groups);
printf ("HOME=%s\n", def_home);
printf ("INACTIVE=%ld\n", def_inactive);
printf ("EXPIRE=%s\n", def_expire);
int ofd;
int wlen;
bool out_group = false;
+ bool out_groups = false;
bool out_home = false;
bool out_inactive = false;
bool out_expire = false;
if (!out_group && MATCH (buf, DGROUP)) {
fprintf (ofp, DGROUP "%u\n", (unsigned int) def_group);
out_group = true;
+ } else if (!out_groups && MATCH (buf, DGROUPS)) {
+ fprintf (ofp, DGROUPS "%s\n", def_groups);
+ out_groups = true;
} else if (!out_home && MATCH (buf, DHOME)) {
fprintf (ofp, DHOME "%s\n", def_home);
out_home = true;
*/
if (!out_group)
fprintf (ofp, DGROUP "%u\n", (unsigned int) def_group);
+ if (!out_groups)
+ fprintf (ofp, DGROUPS "%s\n", def_groups);
if (!out_home)
fprintf (ofp, DHOME "%s\n", def_home);
if (!out_inactive)
--- /dev/null
+# Default values for useradd(8)
+#
+# The SHELL variable specifies the default login shell on your
+# system.
+# Similar to DHSELL in adduser. However, we use "sh" here because
+# useradd is a low level utility and should be as general
+# as possible
+SHELL=/bin/foobar
+#
+# The default group for users
+# 100=users on Debian systems
+# Same as USERS_GID in adduser
+# This argument is used when the -n flag is specified.
+# The default behavior (when -n and -g are not specified) is to create a
+# primary user group with the same name as the user being added to the
+# system.
+GROUP=10
+#
+# Addional supplementary groups for users
+GROUPS=bin,adm,man,cdrom
+#
+# The default home directory. Same as DHOME for adduser
+#
+HOME=/tmp
+#
+# The number of days after a password expires until the account
+# is permanently disabled
+INACTIVE=12
+#
+# The default expire date
+EXPIRE=2007-12-02
+#
+# The SKEL variable specifies the directory containing "skeletal" user
+# files; in other words, files such as a sample .profile that will be
+# copied to the new user's home directory when it is created.
+# SKEL=/etc/skel
+#
+# Defines whether the mail spool should be created while
+# creating the account
+# CREATE_MAIL_SPOOL=yes
--- /dev/null
+#!/bin/sh
+
+set -e
+
+cd "$(dirname $0)"
+
+. ../../../common/config.sh
+. ../../../common/log.sh
+
+log_start "$0" "useradd adds supplementary groups based on the GROUPS field in /etc/deault/useradd"
+
+save_config
+
+# restore the files on exit
+trap 'log_status "$0" "FAILURE"; restore_config' 0
+
+change_config
+
+printf "Create user foo, with group associations with bin,adm,man,cdrom..."
+useradd foo
+printf "OK\n"
+
+printf "Check the group file..."
+../../../common/compare_file.pl data/group /etc/group
+printf "OK\n"
+
+
+log_status "$0" "SUCCESS"
+restore_config
+trap '' 0
+