pw_user.c (8a2ace2a78354f2c3ed9b8228e340a3f2beeef3a) | pw_user.c (65730d9349cc2fac547af1613bd5a019ff5663c8) |
---|---|
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 --- 53 unchanged lines hidden (view full) --- 62static char *pw_password(struct userconf * cnf, char const * user); 63static char *shell_path(char const * path, char *shells[], char *sh); 64static void rmat(uid_t uid); 65static void rmopie(char const * name); 66 67static void 68create_and_populate_homedir(struct passwd *pwd) 69{ | 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 --- 53 unchanged lines hidden (view full) --- 62static char *pw_password(struct userconf * cnf, char const * user); 63static char *shell_path(char const * path, char *shells[], char *sh); 64static void rmat(uid_t uid); 65static void rmopie(char const * name); 66 67static void 68create_and_populate_homedir(struct passwd *pwd) 69{ |
70 char *homedir, *dotdir; | |
71 struct userconf *cnf = conf.userconf; | 70 struct userconf *cnf = conf.userconf; |
71 const char *skeldir; 72 int skelfd = -1; |
|
72 | 73 |
73 homedir = dotdir = NULL; | 74 skeldir = cnf->dotdir; |
74 | 75 |
75 if (conf.rootdir[0] != '\0') { 76 asprintf(&homedir, "%s/%s", conf.rootdir, pwd->pw_dir); 77 if (homedir == NULL) 78 errx(EX_OSERR, "out of memory"); 79 asprintf(&dotdir, "%s/%s", conf.rootdir, cnf->dotdir); | 76 if (skeldir != NULL && *skeldir != '\0') { 77 skelfd = openat(conf.rootfd, cnf->dotdir, 78 O_DIRECTORY|O_CLOEXEC); |
80 } 81 | 79 } 80 |
82 copymkdir(homedir ? homedir : pwd->pw_dir, dotdir ? dotdir: cnf->dotdir, 83 cnf->homemode, pwd->pw_uid, pwd->pw_gid); | 81 copymkdir(conf.rootfd, pwd->pw_dir, skelfd, cnf->homemode, pwd->pw_uid, 82 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 88static int 89set_passwd(struct passwd *pwd, bool update) 90{ 91 int b, istty; --- 1289 unchanged lines hidden --- | 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 87static int 88set_passwd(struct passwd *pwd, bool update) 89{ 90 int b, istty; --- 1289 unchanged lines hidden --- |