summaryrefslogtreecommitdiffstats
path: root/pw/pw_conf.c
diff options
context:
space:
mode:
authorLukas Ertl <le@FreeBSD.org>2007-03-30 11:23:10 +0000
committerLukas Ertl <le@FreeBSD.org>2007-03-30 11:23:10 +0000
commit678412e2ca614bde0a78f68030d634364c0b5a9f (patch)
tree0e4e14e94760be768219232eccfda8753fa332c2 /pw/pw_conf.c
parent426250738b1d9878487cba75856b1cfc6430c195 (diff)
downloadpw-darwin-678412e2ca614bde0a78f68030d634364c0b5a9f.tar.gz
pw-darwin-678412e2ca614bde0a78f68030d634364c0b5a9f.tar.zst
pw-darwin-678412e2ca614bde0a78f68030d634364c0b5a9f.zip
Add home directory creation mode to pw.conf(5) and be a bit
more specific about the effect of the current umask on -M.
Diffstat (limited to 'pw/pw_conf.c')
-rw-r--r--pw/pw_conf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/pw/pw_conf.c b/pw/pw_conf.c
index 9377239..51672b9 100644
--- a/pw/pw_conf.c
+++ b/pw/pw_conf.c
@@ -47,6 +47,7 @@ enum {
_UC_NEWMAIL,
_UC_LOGFILE,
_UC_HOMEROOT,
+ _UC_HOMEMODE,
_UC_SHELLPATH,
_UC_SHELLS,
_UC_DEFAULTSHELL,
@@ -90,6 +91,7 @@ static struct userconf config =
NULL, /* Mail to send to new accounts */
"/var/log/userlog", /* Where to log changes */
"/home", /* Where to create home directory */
+ 0777, /* Home directory perms, modified by umask */
"/bin", /* Where shells are located */
system_shells, /* List of shells (first is default) */
bourne_shell, /* Default shell */
@@ -114,6 +116,7 @@ static char const *comments[_UC_FIELDS] =
"\n# Mail this file to new user (/etc/newuser.msg or no)\n",
"\n# Log add/change/remove information in this file\n",
"\n# Root directory in which $HOME directory is created\n",
+ "\n# Mode for the new $HOME directory, will be modified by umask\n",
"\n# Colon separated list of directories containing valid shells\n",
"\n# Comma separated list of available shells (without paths)\n",
"\n# Default shell (without path)\n",
@@ -139,6 +142,7 @@ static char const *kwds[] =
"newmail",
"logfile",
"home",
+ "homemode",
"shellpath",
"shells",
"defaultshell",
@@ -255,6 +259,7 @@ read_userconfig(char const * file)
static char const toks[] = " \t\r\n,=";
char *q = strtok(NULL, toks);
int i = 0;
+ mode_t *modeset;
while (i < _UC_FIELDS && strcmp(p, kwds[i]) != 0)
++i;
@@ -294,6 +299,12 @@ read_userconfig(char const * file)
config.home = (q == NULL || !boolean_val(q, 1))
? "/home" : newstr(q);
break;
+ case _UC_HOMEMODE:
+ modeset = setmode(q);
+ config.homemode = (q == NULL || !boolean_val(q, 1))
+ ? 0777 : getmode(modeset, 0777);
+ free(modeset);
+ break;
case _UC_SHELLPATH:
config.shelldir = (q == NULL || !boolean_val(q, 1))
? "/bin" : newstr(q);
@@ -413,6 +424,10 @@ write_userconfig(char const * file)
case _UC_HOMEROOT:
val = config.home;
break;
+ case _UC_HOMEMODE:
+ sprintf(buf, "%04o", config.homemode);
+ quote = 0;
+ break;
case _UC_SHELLPATH:
val = config.shelldir;
break;