Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 128715 | Differences between
and this patch

Collapse All | Expand All

(-)src/useradd.c (-4 / +26 lines)
Lines 114-120 static int do_grp_update = 0; /* group f Link Here
114
static char *Prog;
114
static char *Prog;
115
115
116
static int
116
static int
117
 bflg = 0,			/* new default root of home directory */
117
    bflg = 0,			/* new default root of home directory */
118
    cflg = 0,			/* comment (GECOS) field for new account */
118
    cflg = 0,			/* comment (GECOS) field for new account */
119
    dflg = 0,			/* home directory for new account */
119
    dflg = 0,			/* home directory for new account */
120
    Dflg = 0,			/* set/show new user default values */
120
    Dflg = 0,			/* set/show new user default values */
Lines 253-258 static void get_defaults (void) Link Here
253
	const struct group *grp;
253
	const struct group *grp;
254
254
255
	/*
255
	/*
256
	 * Pull relevant settings from login.defs first.
257
	 */
258
	if (getdef_bool ("USERGROUPS_ENAB"))
259
		nflg = -1;
260
261
	/*
256
	 * Open the defaults file for reading.
262
	 * Open the defaults file for reading.
257
	 */
263
	 */
258
264
Lines 628-633 static void usage (void) Link Here
628
			   "  -K, --key KEY=VALUE		overrides /etc/login.defs defaults\n"
634
			   "  -K, --key KEY=VALUE		overrides /etc/login.defs defaults\n"
629
			   "  -m, --create-home		create home directory for the new user\n"
635
			   "  -m, --create-home		create home directory for the new user\n"
630
			   "				account\n"
636
			   "				account\n"
637
			   "  -n, --user-group		create a new group with the same name as the\n"
638
			   "				new user\n"
631
			   "  -o, --non-unique		allow create user with duplicate\n"
639
			   "  -o, --non-unique		allow create user with duplicate\n"
632
			   "				(non-unique) UID\n"
640
			   "				(non-unique) UID\n"
633
			   "  -p, --password PASSWORD	use encrypted password for the new user\n"
641
			   "  -p, --password PASSWORD	use encrypted password for the new user\n"
Lines 1009-1014 static void process_flags (int argc, cha Link Here
1009
			{"skel", required_argument, NULL, 'k'},
1017
			{"skel", required_argument, NULL, 'k'},
1010
			{"key", required_argument, NULL, 'K'},
1018
			{"key", required_argument, NULL, 'K'},
1011
			{"create-home", no_argument, NULL, 'm'},
1019
			{"create-home", no_argument, NULL, 'm'},
1020
			{"user-group", no_argument, NULL, 'n'},
1012
			{"non-unique", no_argument, NULL, 'o'},
1021
			{"non-unique", no_argument, NULL, 'o'},
1013
			{"password", required_argument, NULL, 'p'},
1022
			{"password", required_argument, NULL, 'p'},
1014
			{"shell", required_argument, NULL, 's'},
1023
			{"shell", required_argument, NULL, 's'},
Lines 1016-1022 static void process_flags (int argc, cha Link Here
1016
			{NULL, 0, NULL, '\0'}
1025
			{NULL, 0, NULL, '\0'}
1017
		};
1026
		};
1018
		while ((c =
1027
		while ((c =
1019
			getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMop:s:u:",
1028
			getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:mMnop:s:u:",
1020
				     long_options, NULL)) != -1) {
1029
				     long_options, NULL)) != -1) {
1021
			switch (c) {
1030
			switch (c) {
1022
			case 'b':
1031
			case 'b':
Lines 1156-1161 static void process_flags (int argc, cha Link Here
1156
			case 'm':
1165
			case 'm':
1157
				mflg++;
1166
				mflg++;
1158
				break;
1167
				break;
1168
			case 'n':
1169
				nflg = 1;
1170
				break;
1159
			case 'o':
1171
			case 'o':
1160
				oflg++;
1172
				oflg++;
1161
				break;
1173
				break;
Lines 1203-1208 static void process_flags (int argc, cha Link Here
1203
		usage ();
1215
		usage ();
1204
1216
1205
	/*
1217
	/*
1218
	 * Using --gid and --user-group doesn't make sense.
1219
	 */
1220
	if (nflg == -1 && gflg)
1221
		nflg = 0;
1222
	if (nflg && gflg) {
1223
		fprintf (stderr, _("%s: options -g and -n conflict\n"), Prog);
1224
		exit (E_BAD_ARG);
1225
	}
1226
1227
	/*
1206
	 * Either -D or username is required. Defaults can be set with -D
1228
	 * Either -D or username is required. Defaults can be set with -D
1207
	 * for the -b, -e, -f, -g, -s options only.
1229
	 * for the -b, -e, -f, -g, -s options only.
1208
	 */
1230
	 */
Lines 1725-1731 int main (int argc, char **argv) Link Here
1725
	 * to that group, use useradd -g username username.
1747
	 * to that group, use useradd -g username username.
1726
	 * --bero
1748
	 * --bero
1727
	 */
1749
	 */
1728
	if (!gflg) {
1750
	if (nflg) {
1729
		if (getgrnam (user_name)) {
1751
		if (getgrnam (user_name)) {
1730
			fprintf (stderr,
1752
			fprintf (stderr,
1731
				 _
1753
				 _
Lines 1759-1765 int main (int argc, char **argv) Link Here
1759
1781
1760
	/* do we have to add a group for that user? This is why we need to
1782
	/* do we have to add a group for that user? This is why we need to
1761
	 * open the group files in the open_files() function  --gafton */
1783
	 * open the group files in the open_files() function  --gafton */
1762
	if (!(nflg || gflg)) {
1784
	if (nflg) {
1763
		find_new_gid ();
1785
		find_new_gid ();
1764
		grp_add ();
1786
		grp_add ();
1765
	}
1787
	}
(-)man/useradd.8.xml (+13 lines)
Lines 204-209 Link Here
204
      </varlistentry>
204
      </varlistentry>
205
      <varlistentry>
205
      <varlistentry>
206
	<term>
206
	<term>
207
	  <option>-n</option>, <option>--user-group</option>
208
	</term>
209
	<listitem>
210
	  <para>
211
	    Create a new group with the same name as the new user.
212
	  </para>
213
	  <para>
214
	    See the <replaceable>USERGROUPS_ENAB</replaceable> login.defs option for more details.
215
	  </para>
216
	</listitem>
217
      </varlistentry>
218
      <varlistentry>
219
	<term>
207
	  <option>-o</option>, <option>--non-unique</option>
220
	  <option>-o</option>, <option>--non-unique</option>
208
	</term>
221
	</term>
209
	<listitem>
222
	<listitem>

Return to bug 128715