svn commit: r284135 - in head/usr.sbin/pw: . tests
Baptiste Daroussin
bapt at FreeBSD.org
Sun Jun 7 20:44:09 UTC 2015
Author: bapt
Date: Sun Jun 7 20:44:06 2015
New Revision: 284135
URL: https://svnweb.freebsd.org/changeset/base/284135
Log:
Fix generating configuration file
Added:
head/usr.sbin/pw/tests/pw.conf (contents, props changed)
head/usr.sbin/pw/tests/pw_config.sh (contents, props changed)
Modified:
head/usr.sbin/pw/pw.c
head/usr.sbin/pw/pw_user.c
head/usr.sbin/pw/pwupd.h
head/usr.sbin/pw/tests/Makefile
Modified: head/usr.sbin/pw/pw.c
==============================================================================
--- head/usr.sbin/pw/pw.c Sun Jun 7 20:10:11 2015 (r284134)
+++ head/usr.sbin/pw/pw.c Sun Jun 7 20:44:06 2015 (r284135)
@@ -229,7 +229,8 @@ main(int argc, char *argv[])
conf.v7 = true;
break;
case 'C':
- config = optarg;
+ conf.config = optarg;
+ config = conf.config;
break;
case 'N':
conf.dryrun = true;
Modified: head/usr.sbin/pw/pw_user.c
==============================================================================
--- head/usr.sbin/pw/pw_user.c Sun Jun 7 20:10:11 2015 (r284134)
+++ head/usr.sbin/pw/pw_user.c Sun Jun 7 20:44:06 2015 (r284135)
@@ -292,7 +292,7 @@ pw_user(int mode, char *name, long id, s
if ((arg = getarg(args, 'w')) != NULL)
cnf->default_password = boolean_val(arg->val, cnf->default_password);
if (mode == M_ADD && getarg(args, 'D')) {
- if (getarg(args, 'n') != NULL)
+ if (name != NULL)
errx(EX_DATAERR, "can't combine `-D' with `-n name'");
if ((arg = getarg(args, 'u')) != NULL && (p = strtok(arg->val, ", \t")) != NULL) {
if ((cnf->min_uid = (uid_t) atoi(p)) == 0)
@@ -307,9 +307,8 @@ pw_user(int mode, char *name, long id, s
cnf->max_gid = 32000;
}
- arg = getarg(args, 'C');
- if (write_userconfig(arg ? arg->val : NULL))
- return EXIT_SUCCESS;
+ if (write_userconfig(conf.config))
+ return (EXIT_SUCCESS);
err(EX_IOERR, "config udpate");
}
Modified: head/usr.sbin/pw/pwupd.h
==============================================================================
--- head/usr.sbin/pw/pwupd.h Sun Jun 7 20:10:11 2015 (r284134)
+++ head/usr.sbin/pw/pwupd.h Sun Jun 7 20:44:06 2015 (r284135)
@@ -84,6 +84,7 @@ struct pwconf {
char rootdir[MAXPATHLEN];
char etcpath[MAXPATHLEN];
char *newname;
+ char *config;
bool dryrun;
bool pretty;
bool v7;
Modified: head/usr.sbin/pw/tests/Makefile
==============================================================================
--- head/usr.sbin/pw/tests/Makefile Sun Jun 7 20:10:11 2015 (r284134)
+++ head/usr.sbin/pw/tests/Makefile Sun Jun 7 20:44:06 2015 (r284135)
@@ -7,6 +7,7 @@ TESTSDIR= ${TESTSBASE}/usr.sbin/pw
ATF_TESTS_SH= pw_etcdir \
pw_lock \
+ pw_config \
pw_groupdel \
pw_groupmod \
pw_useradd \
@@ -18,7 +19,7 @@ ATF_TESTS_SH= pw_etcdir \
TEST_METADATA.${tp}+= required_user="root"
.endfor
-FILES= group helper_functions.shin master.passwd
+FILES= group helper_functions.shin master.passwd pw.conf
FILESDIR= ${TESTSDIR}
ATF_TESTS_SH+= pw_test
Added: head/usr.sbin/pw/tests/pw.conf
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/usr.sbin/pw/tests/pw.conf Sun Jun 7 20:44:06 2015 (r284135)
@@ -0,0 +1,62 @@
+#
+# pw.conf - user/group configuration defaults
+#
+
+# Password for new users? no=nologin yes=loginid none=blank random=random
+defaultpasswd = "no"
+
+# Reuse gaps in uid sequence? (yes or no)
+reuseuids = "no"
+
+# Reuse gaps in gid sequence? (yes or no)
+reusegids = "no"
+
+# Path to the NIS passwd file (blank or 'no' for none)
+nispasswd =
+
+# Obtain default dotfiles from this directory
+skeleton = "/usr/share/skel"
+
+# Mail this file to new user (/etc/newuser.msg or no)
+newmail = "no"
+
+# Log add/change/remove information in this file
+logfile = "/var/log/userlog"
+
+# Root directory in which $HOME directory is created
+home = "/home"
+
+# Mode for the new $HOME directory, will be modified by umask
+homemode = 0777
+
+# Colon separated list of directories containing valid shells
+shellpath = "/bin"
+
+# Comma separated list of available shells (without paths)
+shells = "sh","csh","tcsh"
+
+# Default shell (without path)
+defaultshell = "sh"
+
+# Default group (leave blank for new group per user)
+defaultgroup = ""
+
+# Extra groups for new users
+extragroups =
+
+# Default login class for new users
+defaultclass = ""
+
+# Range of valid default user ids
+minuid = 1000
+maxuid = 32000
+
+# Range of valid default group ids
+mingid = 1000
+maxgid = 32000
+
+# Days after which account expires (0=disabled)
+expire_days = 0
+
+# Days after which password expires (0=disabled)
+password_days = 0
Added: head/usr.sbin/pw/tests/pw_config.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/usr.sbin/pw/tests/pw_config.sh Sun Jun 7 20:44:06 2015 (r284135)
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+# Import helper functions
+. $(atf_get_srcdir)/helper_functions.shin
+
+atf_test_case generate_config
+generate_config_body() {
+ atf_check -s exit:0 \
+ ${PW} useradd -D -C ${HOME}/foo.conf
+ atf_check -o file:$(atf_get_srcdir)/pw.conf \
+ cat ${HOME}/foo.conf
+}
+
+atf_init_test_cases() {
+ atf_add_test_case generate_config
+}
More information about the svn-src-all
mailing list