View | Details | Raw Unified | Return to bug 16880 | Differences between
and this patch

Collapse All | Expand All

(-)pw.8 (+3 lines)
Lines 41-46 Link Here
41
.Op Fl u Ar uid
41
.Op Fl u Ar uid
42
.Op Fl c Ar comment
42
.Op Fl c Ar comment
43
.Op Fl d Ar dir
43
.Op Fl d Ar dir
44
.Op Fl U Ar umask
44
.Op Fl e Ar date
45
.Op Fl e Ar date
45
.Op Fl p Ar date
46
.Op Fl p Ar date
46
.Op Fl g Ar group
47
.Op Fl g Ar group
Lines 346-351 Link Here
346
- normally
347
- normally
347
.Pa /home
348
.Pa /home
348
with the account name as a subdirectory.
349
with the account name as a subdirectory.
350
.It Fl U Ar umask
351
Set the umask to be used when creating the account's home directory and skeleton files.  Default is parent process umask.
349
.It Fl e Ar date
352
.It Fl e Ar date
350
Set the account's expiration date. 
353
Set the account's expiration date. 
351
Format of the date is either a UNIX time in decimal, or a date in
354
Format of the date is either a UNIX time in decimal, or a date in
(-)pw.c (-8 / +35 lines)
Lines 29-34 Link Here
29
  "$FreeBSD: src/usr.sbin/pw/pw.c,v 1.18 2000/01/15 00:20:20 davidn Exp $";
29
  "$FreeBSD: src/usr.sbin/pw/pw.c,v 1.18 2000/01/15 00:20:20 davidn Exp $";
30
#endif /* not lint */
30
#endif /* not lint */
31
31
32
#include <ctype.h>
32
#include <err.h>
33
#include <err.h>
33
#include <fcntl.h>
34
#include <fcntl.h>
34
#include <paths.h>
35
#include <paths.h>
Lines 89-94 Link Here
89
90
90
static struct cargs arglist;
91
static struct cargs arglist;
91
92
93
static int mask;
94
92
static int      getindex(const char *words[], const char *word);
95
static int      getindex(const char *words[], const char *word);
93
static void     cmdhelp(int mode, int which);
96
static void     cmdhelp(int mode, int which);
94
97
Lines 105-117 Link Here
105
	static const char *opts[W_NUM][M_NUM] =
108
	static const char *opts[W_NUM][M_NUM] =
106
	{
109
	{
107
		{ /* user */
110
		{ /* user */
108
			"V:C:qn:u:c:d:e:p:g:G:mk:s:oL:i:w:h:Db:NPy:Y",
111
			"V:C:U:qn:u:c:d:e:p:g:G:mk:s:oL:i:w:h:Db:NPy:Y",
109
			"V:C:qn:u:rY",
112
			"V:C:U:qn:u:rY",
110
			"V:C:qn:u:c:d:e:p:g:G:ml:k:s:w:L:h:FNPY",
113
			"V:C:U:qn:u:c:d:e:p:g:G:ml:k:s:w:L:h:FNPY",
111
			"V:C:qn:u:FPa7",
114
			"V:C:U:qn:u:FPa7",
112
			"V:C:q",
115
			"V:C:U:q",
113
			"V:C:q",
116
			"V:C:U:q",
114
			"V:C:q"
117
			"V:C:U:q"
115
		},
118
		},
116
		{ /* grp  */
119
		{ /* grp  */
117
			"V:C:qn:g:h:M:pNPY",
120
			"V:C:qn:g:h:M:pNPY",
Lines 128-134 Link Here
128
		pw_group
131
		pw_group
129
	};
132
	};
130
133
131
	umask(0);		/* We wish to handle this manually */
132
	LIST_INIT(&arglist);
134
	LIST_INIT(&arglist);
133
135
134
	/*
136
	/*
Lines 221-226 Link Here
221
			setgrdir(etcpath);
223
			setgrdir(etcpath);
222
		}
224
		}
223
	}
225
	}
226
227
	/*
228
	 * Set the umask if specified on the command line
229
	 */
230
231
	if (getarg(&arglist, 'U') != NULL) {
232
		char * um = getarg(&arglist, 'U')-> val;
233
		if (um != NULL) {
234
			if (isdigit(*um)) {
235
				mask = 0;
236
				do {
237
					if (*um >= '8' || *um < '0') {
238
						fprintf(stderr, "Illegal umask: %s\n", um);
239
						exit(EX_USAGE);
240
					}
241
					mask = (mask << 3) + (*um - '0');
242
				} while (*++um != '\0');
243
				umask(mask);
244
			} else {
245
				fprintf(stderr, "Illegal umask: %s\n", um);
246
				exit(EX_USAGE);
247
			}
248
		}
249
	}
224
    
250
    
225
	/*
251
	/*
226
	 * Now, let's do the common initialisation
252
	 * Now, let's do the common initialisation
Lines 301-306 Link Here
301
				"\t-u uid         user id\n"
327
				"\t-u uid         user id\n"
302
				"\t-c comment     user name/comment\n"
328
				"\t-c comment     user name/comment\n"
303
				"\t-d directory   home directory\n"
329
				"\t-d directory   home directory\n"
330
				"\t-U umask       Directory/file creation mask\n"
304
				"\t-e date        account expiry date\n"
331
				"\t-e date        account expiry date\n"
305
				"\t-p date        password expiry date\n"
332
				"\t-p date        password expiry date\n"
306
				"\t-g grp         initial group\n"
333
				"\t-g grp         initial group\n"
(-)pw_user.c (-4 / +4 lines)
Lines 179-185 Link Here
179
			if (strchr(cnf->home+1, '/') == NULL) {
179
			if (strchr(cnf->home+1, '/') == NULL) {
180
				strcpy(dbuf, "/usr");
180
				strcpy(dbuf, "/usr");
181
				strncat(dbuf, cnf->home, MAXPATHLEN-5);
181
				strncat(dbuf, cnf->home, MAXPATHLEN-5);
182
				if (mkdir(dbuf, 0755) != -1 || errno == EEXIST) {
182
				if (mkdir(dbuf, 0777) != -1 || errno == EEXIST) {
183
					chown(dbuf, 0, 0);
183
					chown(dbuf, 0, 0);
184
					symlink(dbuf, cnf->home);
184
					symlink(dbuf, cnf->home);
185
				}
185
				}
Lines 191-197 Link Here
191
				while ((p = strchr(++p, '/')) != NULL) {
191
				while ((p = strchr(++p, '/')) != NULL) {
192
					*p = '\0';
192
					*p = '\0';
193
					if (stat(dbuf, &st) == -1) {
193
					if (stat(dbuf, &st) == -1) {
194
						if (mkdir(dbuf, 0755) == -1)
194
						if (mkdir(dbuf, 0777) == -1)
195
							goto direrr;
195
							goto direrr;
196
						chown(dbuf, 0, 0);
196
						chown(dbuf, 0, 0);
197
					} else if (!S_ISDIR(st.st_mode))
197
					} else if (!S_ISDIR(st.st_mode))
Lines 200-206 Link Here
200
				}
200
				}
201
			}
201
			}
202
			if (stat(dbuf, &st) == -1) {
202
			if (stat(dbuf, &st) == -1) {
203
				if (mkdir(dbuf, 0755) == -1) {
203
				if (mkdir(dbuf, 0777) == -1) {
204
				direrr:	err(EX_OSFILE, "mkdir '%s'", dbuf);
204
				direrr:	err(EX_OSFILE, "mkdir '%s'", dbuf);
205
				}
205
				}
206
				chown(dbuf, 0, 0);
206
				chown(dbuf, 0, 0);
Lines 734-740 Link Here
734
	 * existing files will *not* be overwritten.
734
	 * existing files will *not* be overwritten.
735
	 */
735
	 */
736
	if (!PWALTDIR() && getarg(args, 'm') != NULL && pwd->pw_dir && *pwd->pw_dir == '/' && pwd->pw_dir[1]) {
736
	if (!PWALTDIR() && getarg(args, 'm') != NULL && pwd->pw_dir && *pwd->pw_dir == '/' && pwd->pw_dir[1]) {
737
		copymkdir(pwd->pw_dir, cnf->dotdir, 0755, pwd->pw_uid, pwd->pw_gid);
737
		copymkdir(pwd->pw_dir, cnf->dotdir, 0777, pwd->pw_uid, pwd->pw_gid);
738
		pw_log(cnf, mode, W_USER, "%s(%ld) home %s made",
738
		pw_log(cnf, mode, W_USER, "%s(%ld) home %s made",
739
		       pwd->pw_name, (long) pwd->pw_uid, pwd->pw_dir);
739
		       pwd->pw_name, (long) pwd->pw_uid, pwd->pw_dir);
740
	}
740
	}

Return to bug 16880