Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/pw/pw_conf.c
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | enum { | ||||
_UC_NONE, | _UC_NONE, | ||||
_UC_DEFAULTPWD, | _UC_DEFAULTPWD, | ||||
_UC_REUSEUID, | _UC_REUSEUID, | ||||
_UC_REUSEGID, | _UC_REUSEGID, | ||||
_UC_NISPASSWD, | _UC_NISPASSWD, | ||||
_UC_DOTDIR, | _UC_DOTDIR, | ||||
_UC_NEWMAIL, | _UC_NEWMAIL, | ||||
_UC_LOGFILE, | _UC_LOGFILE, | ||||
_UC_LOGMODE, | |||||
_UC_HOMEROOT, | _UC_HOMEROOT, | ||||
_UC_HOMEMODE, | _UC_HOMEMODE, | ||||
_UC_SHELLPATH, | _UC_SHELLPATH, | ||||
_UC_SHELLS, | _UC_SHELLS, | ||||
_UC_DEFAULTSHELL, | _UC_DEFAULTSHELL, | ||||
_UC_DEFAULTGROUP, | _UC_DEFAULTGROUP, | ||||
_UC_EXTRAGROUPS, | _UC_EXTRAGROUPS, | ||||
_UC_DEFAULTCLASS, | _UC_DEFAULTCLASS, | ||||
Show All 21 Lines | |||||
}; | }; | ||||
static char const *boolfalse[] = | static char const *boolfalse[] = | ||||
{ | { | ||||
"no", "false", "0", "off", NULL | "no", "false", "0", "off", NULL | ||||
}; | }; | ||||
static struct userconf config = | static struct userconf config = | ||||
{ | { | ||||
0, /* Default password for new users? (nologin) */ | 0, /* Default password for new users? (nologin) */ | ||||
ngie: It would be really nice if this used C99 initializers (I suggest doing this in another commit). | |||||
0, /* Reuse uids? */ | 0, /* Reuse uids? */ | ||||
0, /* Reuse gids? */ | 0, /* Reuse gids? */ | ||||
NULL, /* NIS version of the passwd file */ | NULL, /* NIS version of the passwd file */ | ||||
"/usr/share/skel", /* Where to obtain skeleton files */ | "/usr/share/skel", /* Where to obtain skeleton files */ | ||||
NULL, /* Mail to send to new accounts */ | NULL, /* Mail to send to new accounts */ | ||||
"/var/log/userlog", /* Where to log changes */ | "/var/log/userlog", /* Where to log changes */ | ||||
_DEF_LOGMODE, /* Log file perms */ | |||||
"/home", /* Where to create home directory */ | "/home", /* Where to create home directory */ | ||||
_DEF_DIRMODE, /* Home directory perms, modified by umask */ | _DEF_DIRMODE, /* Home directory perms, modified by umask */ | ||||
"/bin", /* Where shells are located */ | "/bin", /* Where shells are located */ | ||||
system_shells, /* List of shells (first is default) */ | system_shells, /* List of shells (first is default) */ | ||||
bourne_shell, /* Default shell */ | bourne_shell, /* Default shell */ | ||||
NULL, /* Default group name */ | NULL, /* Default group name */ | ||||
NULL, /* Default (additional) groups */ | NULL, /* Default (additional) groups */ | ||||
NULL, /* Default login class */ | NULL, /* Default login class */ | ||||
1000, 32000, /* Allowed range of uids */ | 1000, 32000, /* Allowed range of uids */ | ||||
1000, 32000, /* Allowed range of gids */ | 1000, 32000, /* Allowed range of gids */ | ||||
0, /* Days until account expires */ | 0, /* Days until account expires */ | ||||
0 /* Days until password expires */ | 0 /* Days until password expires */ | ||||
}; | }; | ||||
static char const *comments[_UC_FIELDS] = | static char const *comments[_UC_FIELDS] = | ||||
{ | { | ||||
"#\n# pw.conf - user/group configuration defaults\n#\n", | "#\n# pw.conf - user/group configuration defaults\n#\n", | ||||
"\n# Password for new users? no=nologin yes=loginid none=blank random=random\n", | "\n# Password for new users? no=nologin yes=loginid none=blank random=random\n", | ||||
"\n# Reuse gaps in uid sequence? (yes or no)\n", | "\n# Reuse gaps in uid sequence? (yes or no)\n", | ||||
"\n# Reuse gaps in gid sequence? (yes or no)\n", | "\n# Reuse gaps in gid sequence? (yes or no)\n", | ||||
"\n# Path to the NIS passwd file (blank or 'no' for none)\n", | "\n# Path to the NIS passwd file (blank or 'no' for none)\n", | ||||
"\n# Obtain default dotfiles from this directory\n", | "\n# Obtain default dotfiles from this directory\n", | ||||
"\n# Mail this file to new user (/etc/newuser.msg or no)\n", | "\n# Mail this file to new user (/etc/newuser.msg or no)\n", | ||||
"\n# Log add/change/remove information in this file\n", | "\n# Log add/change/remove information in this file\n", | ||||
"\n# Mode for the log file, will be modified by umask\n", | |||||
"\n# Root directory in which $HOME directory is created\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# Mode for the new $HOME directory, will be modified by umask\n", | ||||
"\n# Colon separated list of directories containing valid shells\n", | "\n# Colon separated list of directories containing valid shells\n", | ||||
"\n# Comma separated list of available shells (without paths)\n", | "\n# Comma separated list of available shells (without paths)\n", | ||||
"\n# Default shell (without path)\n", | "\n# Default shell (without path)\n", | ||||
"\n# Default group (leave blank for new group per user)\n", | "\n# Default group (leave blank for new group per user)\n", | ||||
"\n# Extra groups for new users\n", | "\n# Extra groups for new users\n", | ||||
"\n# Default login class for new users\n", | "\n# Default login class for new users\n", | ||||
Show All 10 Lines | static char const *kwds[] = | ||||
"", | "", | ||||
"defaultpasswd", | "defaultpasswd", | ||||
"reuseuids", | "reuseuids", | ||||
"reusegids", | "reusegids", | ||||
"nispasswd", | "nispasswd", | ||||
"skeleton", | "skeleton", | ||||
"newmail", | "newmail", | ||||
"logfile", | "logfile", | ||||
"logmode", | |||||
"home", | "home", | ||||
"homemode", | "homemode", | ||||
"shellpath", | "shellpath", | ||||
"shells", | "shells", | ||||
"defaultshell", | "defaultshell", | ||||
"defaultgroup", | "defaultgroup", | ||||
"extragroups", | "extragroups", | ||||
"defaultclass", | "defaultclass", | ||||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | #endif | ||||
case _UC_NEWMAIL: | case _UC_NEWMAIL: | ||||
config.newmail = (q == NULL || !boolean_val(q, 1)) | config.newmail = (q == NULL || !boolean_val(q, 1)) | ||||
? NULL : newstr(q); | ? NULL : newstr(q); | ||||
break; | break; | ||||
case _UC_LOGFILE: | case _UC_LOGFILE: | ||||
config.logfile = (q == NULL || !boolean_val(q, 1)) | config.logfile = (q == NULL || !boolean_val(q, 1)) | ||||
? NULL : newstr(q); | ? NULL : newstr(q); | ||||
break; | break; | ||||
case _UC_LOGMODE: | |||||
modeset = setmode(q); | |||||
config.logmode = (q == NULL || !boolean_val(q, 1)) | |||||
? _DEF_LOGMODE : getmode(modeset, _DEF_LOGMODE); | |||||
baptUnsubmitted Not Done Inline ActionsI think we should test for EINVAL and report an error for the users like we do for _UC_MINUID bapt: I think we should test for EINVAL and report an error for the users like we do for _UC_MINUID | |||||
free(modeset); | |||||
break; | |||||
case _UC_HOMEROOT: | case _UC_HOMEROOT: | ||||
config.home = (q == NULL || !boolean_val(q, 1)) | config.home = (q == NULL || !boolean_val(q, 1)) | ||||
? "/home" : newstr(q); | ? "/home" : newstr(q); | ||||
break; | break; | ||||
case _UC_HOMEMODE: | case _UC_HOMEMODE: | ||||
modeset = setmode(q); | modeset = setmode(q); | ||||
config.homemode = (q == NULL || !boolean_val(q, 1)) | config.homemode = (q == NULL || !boolean_val(q, 1)) | ||||
? _DEF_DIRMODE : getmode(modeset, _DEF_DIRMODE); | ? _DEF_DIRMODE : getmode(modeset, _DEF_DIRMODE); | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | case _UC_DOTDIR: | ||||
break; | break; | ||||
case _UC_NEWMAIL: | case _UC_NEWMAIL: | ||||
sbuf_cat(buf, cnf->newmail ? cnf->newmail : | sbuf_cat(buf, cnf->newmail ? cnf->newmail : | ||||
boolean_str(0)); | boolean_str(0)); | ||||
break; | break; | ||||
case _UC_LOGFILE: | case _UC_LOGFILE: | ||||
sbuf_cat(buf, cnf->logfile ? cnf->logfile : | sbuf_cat(buf, cnf->logfile ? cnf->logfile : | ||||
boolean_str(0)); | boolean_str(0)); | ||||
break; | |||||
case _UC_LOGMODE: | |||||
sbuf_printf(buf, "%04o", cnf->logmode); | |||||
quote = 0; | |||||
break; | break; | ||||
case _UC_HOMEROOT: | case _UC_HOMEROOT: | ||||
sbuf_cat(buf, cnf->home); | sbuf_cat(buf, cnf->home); | ||||
break; | break; | ||||
case _UC_HOMEMODE: | case _UC_HOMEMODE: | ||||
sbuf_printf(buf, "%04o", cnf->homemode); | sbuf_printf(buf, "%04o", cnf->homemode); | ||||
quote = 0; | quote = 0; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
It would be really nice if this used C99 initializers (I suggest doing this in another commit).