]> granicus.if.org Git - shadow/commitdiff
* NEWS, etc/login.defs: New CREATE_HOME variable to tell useradd
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 13 Sep 2008 11:55:41 +0000 (11:55 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 13 Sep 2008 11:55:41 +0000 (11:55 +0000)
to create a home directory for new users.
* src/useradd.c, man/useradd.8.xml: New -M/--no-create-home option
and CREATE_HOME usage. System accounts are not impacted by
CREATE_HOME.
* man/useradd.8.xml: Indicate that a new group is created by
default.
* src/useradd.c: Removed TODO item (moved to the TODO file).

ChangeLog
NEWS
etc/login.defs
man/useradd.8.xml
src/useradd.c

index 9be429a08b2cf2674472a25991eebfc4be4bdbc7..4447851e3a9228e6494a56761729290fc33bb33e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-09-11  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * NEWS, etc/login.defs: New CREATE_HOME variable to tell useradd
+       to create a home directory for new users.
+       * src/useradd.c, man/useradd.8.xml: New -M/--no-create-home option
+       and CREATE_HOME usage. System accounts are not impacted by
+       CREATE_HOME.
+       * man/useradd.8.xml: Indicate that a new group is created by
+       default.
+       * src/useradd.c: Removed TODO item (moved to the TODO file).
+
 2008-09-11  Miroslav Kuře  <kurem@debian.cz>
 
        * po/cs.po: Updated Czech translation.
diff --git a/NEWS b/NEWS
index 31ef88c711474e88b685c4da8d05acdcfffa767f..39ef48987438decdb48fcad8c374ab30672ec181 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,9 @@ shadow-4.1.2.1 -> shadow-4.1.3                                                UNRELEASED
   * Speed improvement in case UID_MAX/SYS_UID_MAX/GID_MAX/SYS_GID_MAX is
     used for an user/group. This should be noticeable in case of LDAP
     configured systems. This should impact useradd, groupadd, and newusers
+- /etc/login.defs
+  * New CREATE_HOME variable to tell useradd to create a home directory by
+    default.
 
 - gpasswd
   * Added support for long options --add (-a), --delete (-d),
@@ -48,6 +51,8 @@ shadow-4.1.2.1 -> shadow-4.1.3                                                UNRELEASED
 - useradd
   * audit logging improvements.
   * Speedup (see "addition of users or groups" above).
+  * See CREATE_HOME above.
+  * New -M/--no-create-home option to disable CREATE_HOME.
 - userdel
   * audit logging improvements.
 - usermod
index 12e09c0df8799dbdd1837b4018b0506c86b390a9..dbb9648690072b7533c241cd1cd0e6921b6525f0 100644 (file)
@@ -367,3 +367,12 @@ USERGROUPS_ENAB yes
 # 0 is the default value and disables this feature.
 #
 #MAX_MEMBERS_PER_GROUP 0
+
+#
+# If useradd should create home directories for users by default (non
+# system users only)
+# This option is overridden with the -M or -m flags on the useradd command
+# line.
+#
+#CREATE_HOME     yes
+
index 7d502efbfdfc51acd9f7fd75a6bd1e7863cfd176..898e034068a2455afbc8b19c3e67c495e1688367 100644 (file)
        will update system files and may also create the new user's home
        directory and copy initial files.
       </para>
+      <para>
+       By default, a group will also be created for the new user (see
+       <option>-g</option>, <option>-N</option>, <option>-U</option>, and
+       <option>USERGROUPS_ENAB</option>).
+      </para>
   </refsect1>
 
   <refsect1 id='options'>
          </para>
        </listitem>
       </varlistentry>
+      <varlistentry>
+       <term>
+         <option>-M</option>
+       </term>
+       <listitem>
+         <para>
+           Do no create the user's home directory, even if the system
+           wide setting from <filename>/etc/login.defs</filename>
+           (<option>CREATE_HOME</option>) is set to
+           <replaceable>yes</replaceable>.
+         </para>
+       </listitem>
+      </varlistentry>
       <varlistentry>
        <term>
          <option>-N</option>, <option>--no-user-group</option>
            <option>UID_MIN</option>-<option>UID_MAX</option> (and their
            <option>GID</option> counterparts for the creation of groups).
          </para>
+         <para>
+           Note that <command>useradd</command> will not create a home
+           directory for such an user, regardless of the default setting
+           in <filename>/etc/login.defs</filename>
+           (<option>CREATE_HOME</option>). You have to specify the
+           <option>-m</option> options if you want a home directory for a
+           system account to be created.
+         </para>
        </listitem>
       </varlistentry>
       <varlistentry>
index af234d87fc2e830f8322d0e5f3eb72b26a408602..5f9a01b787770592729728b3b24a815b5beaa947 100644 (file)
@@ -724,6 +724,8 @@ static void usage (void)
                 "                                faillog databases\n"
                 "  -m, --create-home             create home directory for the new user\n"
                 "                                account\n"
+                "  -M, --no-create-home          do not create user's home directory\n"
+                "                                (overrides /etc/login.defs)\n"
                 "  -N, --no-user-group           do not create a group with the same name as\n"
                 "                                the user\n"
                 "  -o, --non-unique              allow create user with duplicate\n"
@@ -983,6 +985,7 @@ static void process_flags (int argc, char **argv)
                        {"skel", required_argument, NULL, 'k'},
                        {"key", required_argument, NULL, 'K'},
                        {"create-home", no_argument, NULL, 'm'},
+                       {"no-create-home", no_argument, NULL, 'M'},
                        {"no-user-group", no_argument, NULL, 'N'},
                        {"non-unique", no_argument, NULL, 'o'},
                        {"password", required_argument, NULL, 'p'},
@@ -1133,6 +1136,9 @@ static void process_flags (int argc, char **argv)
                        case 'm':
                                mflg = true;
                                break;
+                       case 'M':
+                               Mflg = true;
+                               break;
                        case 'N':
                                Nflg = true;
                                break;
@@ -1212,6 +1218,12 @@ static void process_flags (int argc, char **argv)
                         Prog, "-U", "-N");
                usage ();
        }
+       if (mflg && Mflg) {
+               fprintf (stderr,
+                        _("%s: options %s and %s conflict\n"),
+                        Prog, "-m", "-M");
+               usage ();
+       }
 
        /*
         * Either -D or username is required. Defaults can be set with -D
@@ -1265,10 +1277,20 @@ static void process_flags (int argc, char **argv)
                user_shell = def_shell;
        }
 
-       /* TODO: add handle change default spool mail creation by 
-          -K CREATE_MAIL_SPOOL={yes,no}. It need rewrite internal API for handle
-          shadow tools configuration */
        create_mail_spool = def_create_mail_spool;
+
+       if (!rflg) {
+                /* for system accounts defaults are ignored and we
+                 * do not create a home dir */
+               if (getdef_bool("CREATE_HOME")) {
+                       mflg = true;
+               }
+       }
+
+       if (Mflg) {
+               /* absolutely sure that we do not create home dirs */
+               mflg = false;
+       }
 }
 
 /*
@@ -1932,26 +1954,12 @@ int main (int argc, char **argv)
                                  "Not copying any file from skel directory into it.\n"),
                                 Prog);
 
-       } else if (getdef_str ("CREATE_HOME") != NULL) {
-               /*
-                * RedHat added the CREATE_HOME option in login.defs in their
-                * version of shadow-utils (which makes -m the default, with
-                * new -M option to turn it off). Unfortunately, this
-                * changes the way useradd works (it can be run by scripts
-                * expecting some standard behaviour), compared to other
-                * Unices and other Linux distributions, and also adds a lot
-                * of confusion :-(.
-                * So we now recognize CREATE_HOME and give a warning here
-                * (better than "configuration error ... notify administrator"
-                * errors in every program that reads /etc/login.defs). -MM
-                */
-               fprintf (stderr,
-                        _
-                        ("%s: warning: CREATE_HOME not supported, please use -m instead.\n"),
-                        Prog);
        }
 
-       create_mail ();
+       /* Do not create mail directory for system accounts */
+       if( !rflg ) {
+               create_mail ();
+       }
 
        close_files ();