Deleted Added
full compact
pw_user.c (285433) pw_user.c (285434)
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#ifndef lint
29static const char rcsid[] =
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#ifndef lint
29static const char rcsid[] =
30 "$FreeBSD: head/usr.sbin/pw/pw_user.c 285433 2015-07-12 21:43:57Z bapt $";
30 "$FreeBSD: head/usr.sbin/pw/pw_user.c 285434 2015-07-12 22:08:58Z bapt $";
31#endif /* not lint */
32
33#include <ctype.h>
34#include <err.h>
35#include <fcntl.h>
36#include <sys/param.h>
37#include <dirent.h>
38#include <paths.h>

--- 30 unchanged lines hidden (view full) ---

69{
70 struct userconf *cnf = conf.userconf;
71 const char *skeldir;
72 int skelfd = -1;
73
74 skeldir = cnf->dotdir;
75
76 if (skeldir != NULL && *skeldir != '\0') {
31#endif /* not lint */
32
33#include <ctype.h>
34#include <err.h>
35#include <fcntl.h>
36#include <sys/param.h>
37#include <dirent.h>
38#include <paths.h>

--- 30 unchanged lines hidden (view full) ---

69{
70 struct userconf *cnf = conf.userconf;
71 const char *skeldir;
72 int skelfd = -1;
73
74 skeldir = cnf->dotdir;
75
76 if (skeldir != NULL && *skeldir != '\0') {
77 skelfd = openat(conf.rootfd, cnf->dotdir,
78 O_DIRECTORY|O_CLOEXEC);
77 if (*skeldir == '/')
78 skeldir++;
79 skelfd = openat(conf.rootfd, skeldir, O_DIRECTORY|O_CLOEXEC);
79 }
80
81 copymkdir(conf.rootfd, pwd->pw_dir, skelfd, cnf->homemode, pwd->pw_uid,
82 pwd->pw_gid, 0);
83 pw_log(cnf, M_ADD, W_USER, "%s(%u) home %s made", pwd->pw_name,
84 pwd->pw_uid, pwd->pw_dir);
85}
86

--- 357 unchanged lines hidden (view full) ---

444 if (!isdigit((unsigned char)*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL)
445 errx(EX_NOUSER, "group `%s' does not exist", p);
446 }
447 sl_add(cnf->groups, newstr(grp->gr_name));
448 }
449 }
450
451 if ((arg = getarg(args, 'k')) != NULL) {
80 }
81
82 copymkdir(conf.rootfd, pwd->pw_dir, skelfd, cnf->homemode, pwd->pw_uid,
83 pwd->pw_gid, 0);
84 pw_log(cnf, M_ADD, W_USER, "%s(%u) home %s made", pwd->pw_name,
85 pwd->pw_uid, pwd->pw_dir);
86}
87

--- 357 unchanged lines hidden (view full) ---

445 if (!isdigit((unsigned char)*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL)
446 errx(EX_NOUSER, "group `%s' does not exist", p);
447 }
448 sl_add(cnf->groups, newstr(grp->gr_name));
449 }
450 }
451
452 if ((arg = getarg(args, 'k')) != NULL) {
452 if (stat(cnf->dotdir = arg->val, &st) == -1 || !S_ISDIR(st.st_mode))
453 errx(EX_OSFILE, "skeleton `%s' is not a directory or does not exist", cnf->dotdir);
453 char *tmp = cnf->dotdir = arg->val;
454 if (*tmp == '/')
455 tmp++;
456 if ((fstatat(conf.rootfd, tmp, &st, 0) == -1) ||
457 !S_ISDIR(st.st_mode))
458 errx(EX_OSFILE, "skeleton `%s' is not a directory or "
459 "does not exist", cnf->dotdir);
454 }
455
456 if ((arg = getarg(args, 's')) != NULL)
457 cnf->shell_default = arg->val;
458
459 if ((arg = getarg(args, 'w')) != NULL)
460 cnf->default_password = boolean_val(arg->val, cnf->default_password);
461 if (mode == M_ADD && getarg(args, 'D')) {

--- 912 unchanged lines hidden ---
460 }
461
462 if ((arg = getarg(args, 's')) != NULL)
463 cnf->shell_default = arg->val;
464
465 if ((arg = getarg(args, 'w')) != NULL)
466 cnf->default_password = boolean_val(arg->val, cnf->default_password);
467 if (mode == M_ADD && getarg(args, 'D')) {

--- 912 unchanged lines hidden ---