summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-02-10 18:13:31 -0500
committerCameron Katri <me@cameronkatri.com>2021-02-10 19:00:38 -0500
commit9768b265bd097e561103188bb97f64ef26c6cee1 (patch)
treed31efcee098e5f18f411f72c26782ebfe53523b5
parentec831d9055a20b69cb9a7300990b8e4414cbd474 (diff)
downloadpw-darwin-9768b265bd097e561103188bb97f64ef26c6cee1.tar.gz
pw-darwin-9768b265bd097e561103188bb97f64ef26c6cee1.tar.zst
pw-darwin-9768b265bd097e561103188bb97f64ef26c6cee1.zip
New Makefile, freebsd reallocarray.c, freebsd strtonum for 12/13 compat, delete tests
-rw-r--r--pw/.gitignore1
-rw-r--r--pw/Makefile30
-rw-r--r--pw/Makefile.depend20
-rw-r--r--pw/pw_conf.c8
-rw-r--r--pw/pw_utils.c6
-rw-r--r--pw/reallocarray.c51
-rw-r--r--pw/reallocarray.h4
-rw-r--r--pw/strtonum.c68
-rw-r--r--pw/tests/Makefile33
-rw-r--r--pw/tests/Makefile.depend17
-rw-r--r--pw/tests/crypt.c45
-rw-r--r--pw/tests/group3
-rwxr-xr-xpw/tests/helper_functions.shin32
-rw-r--r--pw/tests/master.passwd4
-rw-r--r--pw/tests/pw-modified.conf62
-rw-r--r--pw/tests/pw.conf62
-rwxr-xr-xpw/tests/pw_config_test.sh26
-rwxr-xr-xpw/tests/pw_etcdir_test.sh18
-rwxr-xr-xpw/tests/pw_groupadd_test.sh26
-rwxr-xr-xpw/tests/pw_groupdel_test.sh24
-rwxr-xr-xpw/tests/pw_groupmod_test.sh118
-rwxr-xr-xpw/tests/pw_groupshow_test.sh56
-rwxr-xr-xpw/tests/pw_lock_test.sh42
-rwxr-xr-xpw/tests/pw_useradd_test.sh497
-rwxr-xr-xpw/tests/pw_userdel_test.sh96
-rwxr-xr-xpw/tests/pw_usermod_test.sh302
-rwxr-xr-xpw/tests/pw_usernext_test.sh45
-rwxr-xr-xpw/tests/pw_usershow_test.sh56
28 files changed, 137 insertions, 1615 deletions
diff --git a/pw/.gitignore b/pw/.gitignore
new file mode 100644
index 0000000..2a81d98
--- /dev/null
+++ b/pw/.gitignore
@@ -0,0 +1 @@
+pw
diff --git a/pw/Makefile b/pw/Makefile
index 8db96d9..2db9f2f 100644
--- a/pw/Makefile
+++ b/pw/Makefile
@@ -1,18 +1,20 @@
-# $FreeBSD$
+CC ?= aarch64-apple-darwin-clang
+STRIP ?= aarch64-apple-darwin-strip
+LDID ?= ldid
+CFLAGS ?= -arch arm64 -isysroot /home/cameron/Documents/SDK/iPhoneOS14.3.sdk -miphoneos-version-min=13.0
+INSTALL ?= install
+FAKEROOT ?= fakeroot
+PREFIX ?= /usr
+DESTDIR ?=
-PROG= pw
-MAN= pw.conf.5 pw.8
-SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
- grupd.c pwupd.c psdate.c bitmap.c cpdir.c rm_r.c strtounum.c \
- pw_utils.c
+DEB_MAINTAINER ?= Cameron Katri <me@cameronkatri.com>
+DEB_ARCH ?= iphoneos-arm
-WARNS?= 3
+all: pw
-LIBADD= crypt util sbuf
+pw:
+ $(CC) $(CFLAGS) -o pw -I. -Isbuf -Ilibutil *.c sbuf/*.c libutil/*.c
+ $(STRIP) pw
-.include <src.opts.mk>
-
-HAS_TESTS=
-SUBDIR.${MK_TESTS}+= tests
-
-.include <bsd.prog.mk>
+clean:
+ rm -f pw
diff --git a/pw/Makefile.depend b/pw/Makefile.depend
deleted file mode 100644
index f746d7a..0000000
--- a/pw/Makefile.depend
+++ /dev/null
@@ -1,20 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- gnu/lib/csu \
- include \
- include/xlocale \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libcrypt \
- lib/libsbuf \
- lib/libutil \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/pw/pw_conf.c b/pw/pw_conf.c
index c446a66..1e35240 100644
--- a/pw/pw_conf.c
+++ b/pw/pw_conf.c
@@ -41,6 +41,10 @@ static const char rcsid[] =
#include "pw.h"
+long long
+freebsdstrtonum(const char *numstr, long long minval, long long maxval,
+ const char **errstrp);
+
#define debugging 0
enum {
@@ -380,7 +384,7 @@ read_userconfig(char const * file)
break;
case _UC_EXPIRE:
if ((q = unquote(q)) != NULL) {
- config.expire_days = strtonum(q, 0,
+ config.expire_days = freebsdstrtonum(q, 0,
INT_MAX, &errstr);
if (errstr)
warnx("Invalid expire days:"
@@ -389,7 +393,7 @@ read_userconfig(char const * file)
break;
case _UC_PASSWORD:
if ((q = unquote(q)) != NULL) {
- config.password_days = strtonum(q, 0,
+ config.password_days = freebsdstrtonum(q, 0,
INT_MAX, &errstr);
if (errstr)
warnx("Invalid password days:"
diff --git a/pw/pw_utils.c b/pw/pw_utils.c
index fbf4a3f..9e58025 100644
--- a/pw/pw_utils.c
+++ b/pw/pw_utils.c
@@ -37,6 +37,10 @@ __FBSDID("$FreeBSD$");
#include "pw.h"
+long long
+freebsdstrtonum(const char *numstr, long long minval, long long maxval,
+ const char **errstrp);
+
int
pw_checkfd(char *nptr)
{
@@ -45,7 +49,7 @@ pw_checkfd(char *nptr)
if (strcmp(nptr, "-") == 0)
return '-';
- fd = strtonum(nptr, 0, INT_MAX, &errstr);
+ fd = freebsdstrtonum(nptr, 0, INT_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad file descriptor '%s': %s",
nptr, errstr);
diff --git a/pw/reallocarray.c b/pw/reallocarray.c
index 7310133..e1e9b7c 100644
--- a/pw/reallocarray.c
+++ b/pw/reallocarray.c
@@ -1,11 +1,42 @@
-#include "reallocarray.h"
-
-#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
-void *reallocarray(void *optr, size_t nmemb, size_t size) {
- if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
- nmemb > 0 && SIZE_MAX / nmemb < size) {
- errno = ENOMEM;
- return NULL;
- }
- return realloc(optr, size * nmemb);
+/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */
+/*
+ * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
+
+void *
+reallocarray(void *optr, size_t nmemb, size_t size)
+{
+
+ if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ nmemb > 0 && SIZE_MAX / nmemb < size) {
+ errno = ENOMEM;
+ return (NULL);
+ }
+ return (realloc(optr, size * nmemb));
}
diff --git a/pw/reallocarray.h b/pw/reallocarray.h
index eacd3cc..5b01046 100644
--- a/pw/reallocarray.h
+++ b/pw/reallocarray.h
@@ -1,5 +1 @@
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-
void *reallocarray(void *optr, size_t nmemb, size_t size);
diff --git a/pw/strtonum.c b/pw/strtonum.c
new file mode 100644
index 0000000..beadfea
--- /dev/null
+++ b/pw/strtonum.c
@@ -0,0 +1,68 @@
+/*-
+ * Copyright (c) 2004 Ted Unangst and Todd Miller
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * $OpenBSD: strtonum.c,v 1.7 2013/04/17 18:40:58 tedu Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define INVALID 1
+#define TOOSMALL 2
+#define TOOLARGE 3
+
+long long
+freebsdstrtonum(const char *numstr, long long minval, long long maxval,
+ const char **errstrp)
+{
+ long long ll = 0;
+ int error = 0;
+ char *ep;
+ struct errval {
+ const char *errstr;
+ int err;
+ } ev[4] = {
+ { NULL, 0 },
+ { "invalid", EINVAL },
+ { "too small", ERANGE },
+ { "too large", ERANGE },
+ };
+
+ ev[0].err = errno;
+ errno = 0;
+ if (minval > maxval) {
+ error = INVALID;
+ } else {
+ ll = strtoll(numstr, &ep, 10);
+ if (errno == EINVAL || numstr == ep || *ep != '\0')
+ error = INVALID;
+ else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
+ error = TOOSMALL;
+ else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
+ error = TOOLARGE;
+ }
+ if (errstrp != NULL)
+ *errstrp = ev[error].errstr;
+ errno = ev[error].err;
+ if (error)
+ ll = 0;
+
+ return (ll);
+}
diff --git a/pw/tests/Makefile b/pw/tests/Makefile
deleted file mode 100644
index ecdb0fe..0000000
--- a/pw/tests/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-# $FreeBSD$
-
-PACKAGE= tests
-
-BINDIR= ${TESTSDIR}
-
-PROGS+= crypt
-LIBADD+= crypt
-
-ATF_TESTS_SH= pw_etcdir_test \
- pw_lock_test \
- pw_config_test \
- pw_groupadd_test \
- pw_groupdel_test \
- pw_groupmod_test \
- pw_groupshow_test \
- pw_useradd_test \
- pw_userdel_test \
- pw_usermod_test \
- pw_usernext_test \
- pw_usershow_test
-
-.for tp in ${ATF_TESTS_SH}
-TEST_METADATA.${tp}+= required_user="root"
-.endfor
-
-${PACKAGE}FILES+= group
-${PACKAGE}FILES+= helper_functions.shin
-${PACKAGE}FILES+= master.passwd
-${PACKAGE}FILES+= pw.conf
-${PACKAGE}FILES+= pw-modified.conf
-
-.include <bsd.test.mk>
diff --git a/pw/tests/Makefile.depend b/pw/tests/Makefile.depend
deleted file mode 100644
index 9124664..0000000
--- a/pw/tests/Makefile.depend
+++ /dev/null
@@ -1,17 +0,0 @@
-# $FreeBSD$
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
- gnu/lib/csu \
- include \
- lib/${CSU_DIR} \
- lib/libc \
- lib/libcompiler_rt \
- lib/libcrypt \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/pw/tests/crypt.c b/pw/tests/crypt.c
deleted file mode 100644
index 586fccd..0000000
--- a/pw/tests/crypt.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * Copyright (c) 2016 Spectra Logic Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include <err.h>
-#include <stdio.h>
-#include <unistd.h>
-
-int main(int argc, char** argv)
-{
- char *salt, *pass, *hash;
-
- if (argc < 3)
- errx(1, "Usage: crypt <salt> <password>");
- salt = argv[1];
- pass = argv[2];
-
- hash = crypt(pass, salt);
- printf("%s", hash);
- return (hash == NULL ? 1 : 0);
-}
diff --git a/pw/tests/group b/pw/tests/group
deleted file mode 100644
index 620c588..0000000
--- a/pw/tests/group
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD$
-#
-wheel:*:0:root
diff --git a/pw/tests/helper_functions.shin b/pw/tests/helper_functions.shin
deleted file mode 100755
index 1ee731a..0000000
--- a/pw/tests/helper_functions.shin
+++ /dev/null
@@ -1,32 +0,0 @@
-# $FreeBSD$
-
-# The pw command
-PW="pw -V ${HOME}"
-RPW="pw -R ${HOME}"
-
-# Workdir to run tests in
-TESTDIR=$(atf_get_srcdir)
-
-# Populate the files pw needs to use into $HOME
-populate_etc_skel() {
- cp ${TESTDIR}/master.passwd ${HOME} || \
- atf_fail "Populating master.passwd in ${HOME}"
- cp ${TESTDIR}/group ${HOME} || atf_fail "Populating group in ${HOME}"
-
- # Generate the passwd file
- pwd_mkdb -p -d ${HOME} ${HOME}/master.passwd || \
- atf_fail "generate passwd from master.passwd"
-}
-
-# Populate the files pw needs to use into $HOME/etc
-populate_root_etc_skel() {
- mkdir ${HOME}/etc
- cp ${TESTDIR}/master.passwd ${HOME}/etc || \
- atf_fail "Populating master.passwd in ${HOME}/etc"
- cp ${TESTDIR}/group ${HOME}/etc || \
- atf_fail "Populating group in ${HOME}/etc"
-
- # Generate the passwd file
- pwd_mkdb -p -d ${HOME}/etc ${HOME}//etc/master.passwd || \
- atf_fail "generate passwd from master.passwd"
-}
diff --git a/pw/tests/master.passwd b/pw/tests/master.passwd
deleted file mode 100644
index f7dc837..0000000
--- a/pw/tests/master.passwd
+++ /dev/null
@@ -1,4 +0,0 @@
-# $FreeBSD$
-#
-root:*:0:0::0:0:Charlie &:/root:/bin/csh
-toor:*:0:0::0:0:Bourne-again Superuser:/root:
diff --git a/pw/tests/pw-modified.conf b/pw/tests/pw-modified.conf
deleted file mode 100644
index 84f44e7..0000000
--- a/pw/tests/pw-modified.conf
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# 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 = 2000
-maxuid = 5000
-
-# Range of valid default group ids
-mingid = 2100
-maxgid = 6000
-
-# Days after which account expires (0=disabled)
-expire_days = 0
-
-# Days after which password expires (0=disabled)
-password_days = 0
diff --git a/pw/tests/pw.conf b/pw/tests/pw.conf
deleted file mode 100644
index 4e493f6..0000000
--- a/pw/tests/pw.conf
+++ /dev/null
@@ -1,62 +0,0 @@
-#
-# 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
diff --git a/pw/tests/pw_config_test.sh b/pw/tests/pw_config_test.sh
deleted file mode 100755
index fb6489a..0000000
--- a/pw/tests/pw_config_test.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-# $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_test_case modify_config_uid_gid_boundaries
-modify_config_uid_gid_boundaries_body() {
- atf_check -s exit:0 \
- ${PW} useradd -D -C ${HOME}/foo.conf \
- -u 2000,5000 -i 2100,6000
- atf_check -o file:$(atf_get_srcdir)/pw-modified.conf \
- cat ${HOME}/foo.conf
-}
-
-atf_init_test_cases() {
- atf_add_test_case generate_config
- atf_add_test_case modify_config_uid_gid_boundaries
-}
diff --git a/pw/tests/pw_etcdir_test.sh b/pw/tests/pw_etcdir_test.sh
deleted file mode 100755
index b237789..0000000
--- a/pw/tests/pw_etcdir_test.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-# $FreeBSD$
-
-# When the '-V directory' option is provided, the directory must exist
-atf_test_case etcdir_must_exist
-etcdir_must_exist_head() {
- atf_set "descr" "When the '-V directory' option is provided, the directory must exist"
-}
-
-etcdir_must_exist_body() {
- local fakedir="/this_directory_does_not_exist"
- atf_check -e inline:"pw: no such directory \`$fakedir'\n" \
- -s exit:72 -x pw -V ${fakedir} usershow root
-}
-
-atf_init_test_cases() {
- atf_add_test_case etcdir_must_exist
-}
-
diff --git a/pw/tests/pw_groupadd_test.sh b/pw/tests/pw_groupadd_test.sh
deleted file mode 100755
index 5fa7bef..0000000
--- a/pw/tests/pw_groupadd_test.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-atf_test_case group_add_gid_too_large
-group_add_gid_too_large_body() {
- populate_etc_skel
- atf_check -s exit:64 -e inline:"pw: Bad id '9999999999999': too large\n" \
- ${PW} groupadd -n test1 -g 9999999999999
-}
-
-atf_test_case group_add_already_exists
-group_add_already_exists_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} groupadd foo
- atf_check -s exit:65 \
- -e inline:"pw: group name \`foo' already exists\n" \
- ${PW} groupadd foo
-}
-
-atf_init_test_cases() {
- atf_add_test_case group_add_gid_too_large
- atf_add_test_case group_add_already_exists
-}
diff --git a/pw/tests/pw_groupdel_test.sh b/pw/tests/pw_groupdel_test.sh
deleted file mode 100755
index 88cc0e0..0000000
--- a/pw/tests/pw_groupdel_test.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-
-# Test to make sure we do not accidentially delete wheel when trying to delete
-# an unknown group
-atf_test_case group_do_not_delete_wheel_if_group_unknown
-group_do_not_delete_wheel_if_group_unknown_head() {
- atf_set "descr" "Make sure we do not consider gid 0 an unknown group"
-}
-group_do_not_delete_wheel_if_group_unknown_body() {
- populate_etc_skel
- atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
- atf_check -e inline:"pw: Bad id 'I_do_not_exist': invalid\n" -s exit:64 -x \
- ${PW} groupdel -g I_do_not_exist
- atf_check -s exit:0 -o inline:"wheel:*:0:root\n" -x ${PW} groupshow wheel
-}
-
-
-atf_init_test_cases() {
- atf_add_test_case group_do_not_delete_wheel_if_group_unknown
-}
diff --git a/pw/tests/pw_groupmod_test.sh b/pw/tests/pw_groupmod_test.sh
deleted file mode 100755
index 5806925..0000000
--- a/pw/tests/pw_groupmod_test.sh
+++ /dev/null
@@ -1,118 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-
-# Test adding & removing a user from a group
-atf_test_case groupmod_user
-groupmod_user_body() {
- populate_etc_skel
- atf_check -s exit:0 ${PW} addgroup test
- atf_check -s exit:0 ${PW} groupmod test -m root
- atf_check -s exit:0 -o match:"^test:\*:1001:root$" \
- grep "^test:\*:.*:root$" $HOME/group
- atf_check -s exit:0 ${PW} groupmod test -d root
- atf_check -s exit:0 -o match:"^test:\*:1001:$" \
- grep "^test:\*:.*:$" $HOME/group
-}
-
-
-# Test adding and removing a user that does not exist
-atf_test_case groupmod_invalid_user
-groupmod_invalid_user_body() {
- populate_etc_skel
- atf_check -s exit:0 ${PW} addgroup test
- atf_check -s exit:67 -e match:"does not exist" ${PW} groupmod test -m foo
- atf_check -s exit:0 ${PW} groupmod test -d foo
-}
-
-atf_test_case groupmod_bug_193704
-groupmod_bug_193704_head() {
- atf_set "descr" "Regression test for the #193704 bug"
-}
-groupmod_bug_193704_body() {
- populate_etc_skel
- atf_check -s exit:0 -x ${PW} groupadd test
- atf_check -s exit:0 -x ${PW} groupmod test -l newgroupname
- atf_check -s exit:65 -e match:"^pw: unknown group" -x ${PW} groupshow test
-}
-
-atf_test_case usermod_bug_185666
-usermod_bug_185666_head() {
- atf_set "descr" "Regression test for the #185666 bug"
-}
-
-usermod_bug_185666_body() {
- populate_etc_skel
- atf_check -s exit:0 -x ${PW} useradd testuser
- atf_check -s exit:0 -x ${PW} groupadd testgroup
- atf_check -s exit:0 -x ${PW} groupadd testgroup2
- atf_check -s exit:0 -x ${PW} usermod testuser -G testgroup
- atf_check -o inline:"testuser:*:1001:\n" -x ${PW} groupshow testuser
- atf_check -o inline:"testgroup:*:1002:testuser\n" -x ${PW} groupshow testgroup
- atf_check -o inline:"testgroup2:*:1003:\n" -x ${PW} groupshow testgroup2
- atf_check -s exit:0 -x ${PW} usermod testuser -G testgroup2
- atf_check -o inline:"testuser:*:1001:\n" -x ${PW} groupshow testuser
- atf_check -o inline:"testgroup:*:1002:\n" -x ${PW} groupshow testgroup
- atf_check -o inline:"testgroup2:*:1003:testuser\n" -x ${PW} groupshow testgroup2
-}
-
-atf_test_case do_not_duplicate_group_on_gid_change
-do_not_duplicate_group_on_gid_change_head() {
- atf_set "descr" "Do not duplicate group on gid change"
-}
-
-do_not_duplicate_group_on_gid_change_body() {
- populate_etc_skel
- atf_check -s exit:0 -x ${PW} groupadd testgroup
- atf_check -s exit:0 -x ${PW} groupmod testgroup -g 12345
- # use grep to see if the entry has not be duplicated
- atf_check -o inline:"testgroup:*:12345:\n" -s exit:0 -x grep "^testgroup" ${HOME}/group
-}
-
-atf_test_case groupmod_rename
-groupmod_rename_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} groupadd foo
- atf_check -s exit:0 ${PW} groupmod foo -l bar
- atf_check -s exit:0 -o match:"^bar:.*" \
- grep "^bar:.*" ${HOME}/group
-}
-
-atf_test_case groupmod_members
-groupmod_members_body() {
- populate_etc_skel
-
- for i in user1 user2 user3 user4; do
- atf_check -s exit:0 ${PW} useradd $i
- done
-
- atf_check -s exit:0 ${PW} groupadd foo -M "user1, user2"
- atf_check -o inline:"foo:*:1005:user1,user2\n" -s exit:0 \
- ${PW} groupshow foo
- atf_check -s exit:0 ${PW} groupmod foo -m "user3, user4"
- atf_check -o inline:"foo:*:1005:user1,user2,user3,user4\n" -s exit:0 \
- ${PW} groupshow foo
- atf_check -s exit:0 ${PW} groupmod foo -M "user1, user4"
- atf_check -o inline:"foo:*:1005:user1,user4\n" -s exit:0 \
- ${PW} groupshow foo
- # what about duplicates
- atf_check -s exit:0 ${PW} groupmod foo -m "user1, user2, user3, user4"
- atf_check -o inline:"foo:*:1005:user1,user4,user2,user3\n" -s exit:0 \
- ${PW} groupshow foo
- atf_check -s exit:0 ${PW} groupmod foo -d "user1, user3"
- atf_check -o inline:"foo:*:1005:user4,user2\n" -s exit:0 \
- ${PW} groupshow foo
-}
-
-atf_init_test_cases() {
- atf_add_test_case groupmod_user
- atf_add_test_case groupmod_invalid_user
- atf_add_test_case groupmod_bug_193704
- atf_add_test_case usermod_bug_185666
- atf_add_test_case do_not_duplicate_group_on_gid_change
- atf_add_test_case groupmod_rename
- atf_add_test_case groupmod_members
-}
diff --git a/pw/tests/pw_groupshow_test.sh b/pw/tests/pw_groupshow_test.sh
deleted file mode 100755
index f348d0a..0000000
--- a/pw/tests/pw_groupshow_test.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-atf_test_case group_show_all
-group_show_all_body() {
- populate_etc_skel
- atf_check -o not-empty ${PW} groupshow -a
-}
-
-atf_test_case group_show_gid
-group_show_gid_body() {
- populate_etc_skel
- atf_check -o not-empty ${PW} groupshow -g 0
-}
-
-atf_test_case group_show_name
-group_show_name_body() {
- populate_etc_skel
- atf_check -o not-empty ${PW} groupshow wheel
-}
-
-atf_test_case group_show_nonexistent_gid
-group_show_nonexistent_gid_body() {
- populate_etc_skel
-
- nonexistent_gid=4242
- no_such_name_msg="pw: unknown gid \`$nonexistent_gid'\n"
-
- atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
- $nonexistent_gid
- atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
- -g $nonexistent_gid
-}
-
-atf_test_case group_show_nonexistent_name
-group_show_nonexistent_name_body() {
- populate_etc_skel
-
- nonexistent_name=bogus
- no_such_name_msg="pw: unknown group \`$nonexistent_name'\n"
-
- atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
- $nonexistent_name
- atf_check -e "inline:$no_such_name_msg" -s exit:65 ${PW} groupshow \
- -n $nonexistent_name
-}
-
-atf_init_test_cases() {
- atf_add_test_case group_show_all
- atf_add_test_case group_show_gid
- atf_add_test_case group_show_name
- atf_add_test_case group_show_nonexistent_gid
- atf_add_test_case group_show_nonexistent_name
-}
diff --git a/pw/tests/pw_lock_test.sh b/pw/tests/pw_lock_test.sh
deleted file mode 100755
index 5ec1b09..0000000
--- a/pw/tests/pw_lock_test.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-# Test locking and unlocking a user account
-atf_test_case user_locking cleanup
-user_locking_body() {
- populate_etc_skel
- ${PW} useradd test || atf_fail "Creating test user"
- ${PW} lock test || atf_fail "Locking the user"
- atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \
- grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd
- ${PW} unlock test || atf_fail "Locking the user"
- atf_check -s exit:0 -o match:"^test:\*:1001:" \
- grep "^test:\*:1001:" $HOME/master.passwd
-}
-
-atf_test_case numeric_locking cleanup
-numeric_locking_body() {
- populate_etc_skel
- ${PW} useradd test || atf_fail "Creating test user"
- ${PW} lock 1001 || atf_fail "Locking the user"
- atf_check -s exit:0 -o match:"^test:\*LOCKED\*\*:1001:" \
- grep "^test:\*LOCKED\*\*:1001:" $HOME/master.passwd
- ${PW} unlock 1001 || atf_fail "Unlocking the user"
- atf_check -s exit:0 -o match:"^test:\*:1001:" \
- grep "^test:\*:1001:" $HOME/master.passwd
- # Now numeric names
- ${PW} useradd -n 1001 || atf_fail "Creating test user"
- ${PW} lock 1001 || atf_fail "Locking the user"
- atf_check -s exit:0 -o match:"^1001:\*LOCKED\*\*:1002:" \
- grep "^1001:\*LOCKED\*\*:1002:" $HOME/master.passwd
- ${PW} unlock 1001 || atf_fail "Unlocking the user"
- atf_check -s exit:0 -o match:"^1001:\*:1002:" \
- grep "^1001:\*:1002:" $HOME/master.passwd
-}
-
-atf_init_test_cases() {
- atf_add_test_case user_locking
- atf_add_test_case numeric_locking
-}
diff --git a/pw/tests/pw_useradd_test.sh b/pw/tests/pw_useradd_test.sh
deleted file mode 100755
index a50f018..0000000
--- a/pw/tests/pw_useradd_test.sh
+++ /dev/null
@@ -1,497 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-# Test add user
-atf_test_case user_add
-user_add_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd test
- atf_check -s exit:0 -o match:"^test:.*" \
- grep "^test:.*" $HOME/master.passwd
-}
-
-# Test add user with option -N
-atf_test_case user_add_noupdate
-user_add_noupdate_body() {
- populate_etc_skel
-
- atf_check -s exit:0 -o match:"^test:.*" ${PW} useradd test -N
- atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
-}
-
-# Test add user with comments
-atf_test_case user_add_comments
-user_add_comments_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd test -c 'Test User,work!,123,user@example.com'
- atf_check -s exit:0 -o match:'^test:.*:Test User,work!,123,user@example.com:' \
- grep '^test:.*:Test User,work!,123,user@example.com:' $HOME/master.passwd
-}
-
-# Test add user with comments and option -N
-atf_test_case user_add_comments_noupdate
-user_add_comments_noupdate_body() {
- populate_etc_skel
-
- atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
- ${PW} useradd test -c "Test User,work,123,456" -N
- atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
-}
-
-# Test add user with invalid comments
-atf_test_case user_add_comments_invalid
-user_add_comments_invalid_body() {
- populate_etc_skel
-
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd test -c "Test User,work,123:456,456"
- atf_check -s exit:1 -o empty \
- grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
-}
-
-# Test add user with invalid comments and option -N
-atf_test_case user_add_comments_invalid_noupdate
-user_add_comments_invalid_noupdate_body() {
- populate_etc_skel
-
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd test -c "Test User,work,123:456,456" -N
- atf_check -s exit:1 -o empty grep "^test:.*" $HOME/master.passwd
-}
-
-# Test add user with alternate homedir
-atf_test_case user_add_homedir
-user_add_homedir_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd test -d /foo/bar
- atf_check -s exit:0 -o match:"^test:\*:.*::0:0:User &:/foo/bar:.*" \
- ${PW} usershow test
-}
-
-# Test add user with account expiration as an epoch date
-atf_test_case user_add_account_expiration_epoch
-user_add_account_expiration_epoch_body() {
- populate_etc_skel
-
- DATE=`date -j -v+1d "+%s"`
- atf_check -s exit:0 ${PW} useradd test -e ${DATE}
- atf_check -s exit:0 -o match:"^test:\*:.*::0:${DATE}:.*" \
- ${PW} usershow test
-}
-
-# Test add user with account expiration as a DD-MM-YYYY date
-atf_test_case user_add_account_expiration_date_numeric
-user_add_account_expiration_date_numeric_body() {
- populate_etc_skel
-
- DATE=`date -j -v+1d "+%d-%m-%Y"`
- EPOCH=`date -j -f "%d-%m-%Y %H:%M:%S" "${DATE} 00:00:00" "+%s"`
- atf_check -s exit:0 ${PW} useradd test -e ${DATE}
- atf_check -s exit:0 -o match:"^test:\*:.*::0:${EPOCH}:User &:.*" \
- ${PW} usershow test
-}
-
-# Test add user with account expiration as a DD-MM-YYYY date
-atf_test_case user_add_account_expiration_date_month
-user_add_account_expiration_date_month_body() {
- populate_etc_skel
-
- DATE=`date -j -v+1d "+%d-%b-%Y"`
- EPOCH=`date -j -f "%d-%b-%Y %H:%M:%S" "${DATE} 00:00:00" "+%s"`
- atf_check -s exit:0 ${PW} useradd test -e ${DATE}
- atf_check -s exit:0 -o match:"^test:\*:.*::0:${EPOCH}:User &:.*" \
- ${PW} usershow test
-}
-
-# Test add user with account expiration as a relative date
-atf_test_case user_add_account_expiration_date_relative
-user_add_account_expiration_date_relative_body() {
- populate_etc_skel
-
- EPOCH=`date -j -v+13m "+%s"`
- BUF=`expr $EPOCH + 5`
- atf_check -s exit:0 ${PW} useradd test -e +13o
- TIME=`${PW} usershow test | awk -F ':' '{print $7}'`
- [ ! -z $TIME -a $TIME -ge $EPOCH -a $TIME -lt $BUF ] || \
- atf_fail "Expiration time($TIME) was not within $EPOCH - $BUF seconds."
-}
-
-# Test add user with password expiration as an epoch date
-atf_test_case user_add_password_expiration_epoch
-user_add_password_expiration_epoch_body() {
- populate_etc_skel
-
- DATE=`date -j -v+1d "+%s"`
- atf_check -s exit:0 ${PW} useradd test -p ${DATE}
- atf_check -s exit:0 -o match:"^test:\*:.*::${DATE}:0:.*" \
- ${PW} usershow test
-}
-
-# Test add user with password expiration as a DD-MM-YYYY date
-atf_test_case user_add_password_expiration_date_numeric
-user_add_password_expiration_date_numeric_body() {
- populate_etc_skel
-
- DATE=`date -j -v+1d "+%d-%m-%Y"`
- EPOCH=`date -j -f "%d-%m-%Y %H:%M:%S" "${DATE} 00:00:00" "+%s"`
- atf_check -s exit:0 ${PW} useradd test -p ${DATE}
- atf_check -s exit:0 -o match:"^test:\*:.*::${EPOCH}:0:User &:.*" \
- ${PW} usershow test
-}
-
-# Test add user with password expiration as a DD-MMM-YYYY date
-atf_test_case user_add_password_expiration_date_month
-user_add_password_expiration_date_month_body() {
- populate_etc_skel
-
- DATE=`date -j -v+1d "+%d-%b-%Y"`
- EPOCH=`date -j -f "%d-%b-%Y %H:%M:%S" "${DATE} 00:00:00" "+%s"`
- atf_check -s exit:0 ${PW} useradd test -p ${DATE}
- atf_check -s exit:0 -o match:"^test:\*:.*::${EPOCH}:0:User &:.*" \
- ${PW} usershow test
-}
-
-# Test add user with password expiration as a relative date
-atf_test_case user_add_password_expiration_date_relative
-user_add_password_expiration_date_relative_body() {
- populate_etc_skel
-
- EPOCH=`date -j -v+13m "+%s"`
- BUF=`expr $EPOCH + 5`
- atf_check -s exit:0 ${PW} useradd test -p +13o
- TIME=`${PW} usershow test | awk -F ':' '{print $6}'`
- [ ! -z $TIME -a $TIME -ge $EPOCH -a $TIME -lt $BUF ] || \
- atf_fail "Expiration time($TIME) was not within $EPOCH - $BUF seconds."
-}
-
-atf_test_case user_add_name_too_long
-user_add_name_too_long_body() {
- populate_etc_skel
- atf_check -e match:"too long" -s exit:64 \
- ${PW} useradd name_very_vert_very_very_very_long
-}
-
-atf_test_case user_add_name_with_spaces
-user_add_name_with_spaces_body() {
- populate_etc_skel
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd 'test user'
- atf_check -s exit:1 -o empty grep "^test user:.*" $HOME/master.passwd
- # Try again with -n which uses a slightly different code path.
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd -n 'test user'
- atf_check -s exit:1 -o empty grep "^test user:.*" $HOME/master.passwd
-}
-
-atf_test_case user_add_name_with_spaces_and_gid_specified
-user_add_name_with_spaces_and_gid_specified_body() {
- populate_etc_skel
- gid=12345
- user_name="test user"
- # pw useradd should fail because of the space in the user
- # name, not because the group doesn't exist.
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd "${user_name}" -g ${gid}
- atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
- # Try again with -n which uses a slightly different code path.
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd -n "${user_name}" -g ${gid}
- atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
- # Make sure the user isn't added even if the group exists
- atf_check -s exit:0 ${PW} groupadd blafasel -g ${gid}
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd "${user_name}" -g ${gid}
- atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
- # Try again with the -n option.
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} useradd -n "${user_name}" -g ${gid}
- atf_check -s exit:1 -o empty grep "^${user_name}:.*" $HOME/master.passwd
-}
-
-atf_test_case user_add_expiration
-user_add_expiration_body() {
- populate_etc_skel
-
- atf_check -s exit:0 \
- ${PW} useradd foo -e 20-03-2037
- atf_check -o inline:"foo:*:1001:1001::0:2121120000:User &:/home/foo:/bin/sh\n" \
- -s exit:0 grep "^foo" ${HOME}/master.passwd
- atf_check -s exit:0 ${PW} userdel foo
- atf_check -s exit:0 \
- ${PW} useradd foo -e 20-03-37
- atf_check -o inline:"foo:*:1001:1001::0:2121120000:User &:/home/foo:/bin/sh\n" \
- -s exit:0 grep "^foo" ${HOME}/master.passwd
- atf_check -s exit:0 ${PW} userdel foo
- atf_check -s exit:0 \
- ${PW} useradd foo -e 20-Mar-2037
- atf_check -o inline:"foo:*:1001:1001::0:2121120000:User &:/home/foo:/bin/sh\n" \
- -s exit:0 grep "^foo" ${HOME}/master.passwd
- atf_check -s exit:0 ${PW} userdel foo
- atf_check -e inline:"pw: Invalid date\n" -s exit:1 \
- ${PW} useradd foo -e 20-Foo-2037
- atf_check -e inline:"pw: Invalid date\n" -s exit:1 \
- ${PW} useradd foo -e 20-13-2037
- atf_check -s exit:0 ${PW} useradd foo -e "12:00 20-03-2037"
- atf_check -s exit:0 ${PW} userdel foo
- atf_check -e inline:"pw: Invalid date\n" -s exit:1 \
- ${PW} useradd foo -e "12 20-03-2037"
- atf_check -s exit:0 ${PW} useradd foo -e "20-03-2037 12:00"
- atf_check -s exit:0 ${PW} userdel foo
-}
-
-atf_test_case user_add_invalid_user_entry
-user_add_invalid_user_entry_body() {
- touch ${HOME}/master.passwd
- touch ${HOME}/group
-
- pwd_mkdb -p -d ${HOME} ${HOME}/master.passwd || \
- atf_fail "generate passwd from master.passwd"
- atf_check -s exit:0 ${PW} useradd foo
- echo "foo1:*:1002" >> ${HOME}/master.passwd
- atf_check -s exit:1 -e match:"Invalid user entry" ${PW} useradd foo2
-}
-
-atf_test_case user_add_invalid_group_entry
-user_add_invalid_group_entry_body() {
- touch ${HOME}/master.passwd
- touch ${HOME}/group
-
- pwd_mkdb -p -d ${HOME} ${HOME}/master.passwd || \
- atf_fail "generate passwd from master.passwd"
- atf_check -s exit:0 ${PW} useradd foo
- echo 'foo1:*:1002' >> group
- atf_check -s exit:1 -e match:"Invalid group entry" ${PW} useradd foo2
-}
-
-atf_test_case user_add_password_from_h
-user_add_password_from_h_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo -h 0 <<-EOF
- $(echo mypassword)
- EOF
- passhash=`awk -F ':' '/^foo:/ {print $2}' $HOME/master.passwd`
- atf_check -s exit:0 -o inline:$passhash \
- $(atf_get_srcdir)/crypt $passhash "mypassword"
-}
-
-atf_test_case user_add_R
-user_add_R_body() {
- populate_root_etc_skel
-
- atf_check -s exit:0 ${RPW} useradd foo
- atf_check -s exit:0 ${RPW} useradd bar -m
- test -d ${HOME}/home || atf_fail "Home parent directory not created"
- test -d ${HOME}/home/bar || atf_fail "Directory not created"
- atf_check -s exit:0 ${RPW} userdel bar
- test -d ${HOME}/home/bar || atf_fail "Directory removed"
- atf_check -s exit:0 ${RPW} useradd bar
- atf_check -s exit:0 ${RPW} userdel bar -r
- [ ! -d ${HOME}/home/bar ] || atf_fail "Directory not removed"
-}
-
-atf_test_case user_add_R_symlink
-user_add_R_symlink_body() {
- populate_root_etc_skel
-
- mkdir ${HOME}/usr
- atf_check -s exit:0 ${RPW} useradd foo -m
- test -d ${HOME}/usr/home || atf_fail "Home parent directory not created"
- test -h ${HOME}/home || atf_fail "/home directory is not a symlink"
- atf_check -s exit:0 -o inline:"usr/home\n" readlink ${HOME}/home
-}
-
-atf_test_case user_add_skel
-user_add_skel_body() {
- populate_root_etc_skel
-
- mkdir ${HOME}/skel
- echo "a" > ${HOME}/skel/.a
- echo "b" > ${HOME}/skel/b
- mkdir ${HOME}/skel/c
- mkdir ${HOME}/skel/c/d
- mkdir ${HOME}/skel/dot.plop
- echo "c" > ${HOME}/skel/c/d/dot.c
- mkdir ${HOME}/home
- ln -sf /nonexistent ${HOME}/skel/c/foo
- atf_check -s exit:0 ${RPW} useradd foo -k /skel -m
- test -d ${HOME}/home/foo || atf_fail "Directory not created"
- test -f ${HOME}/home/foo/.a || atf_fail "File not created"
- atf_check -o file:${HOME}/skel/.a -s exit:0 cat ${HOME}/home/foo/.a
- atf_check -o file:${HOME}/skel/b -s exit:0 cat ${HOME}/home/foo/b
- test -d ${HOME}/home/foo/c || atf_fail "Dotted directory in skel not copied"
- test -d ${HOME}/home/foo/.plop || atf_fail "Directory in skell not created"
- atf_check -o inline:"/nonexistent\n" -s ignore readlink -f ${HOME}/home/foo/c/foo
- atf_check -o file:${HOME}/skel/c/d/dot.c -s exit:0 cat ${HOME}/home/foo/c/d/.c
-}
-
-atf_test_case user_add_uid0
-user_add_uid0_body() {
- populate_etc_skel
- atf_check -e inline:"pw: WARNING: new account \`foo' has a uid of 0 (superuser access!)\n" \
- -s exit:0 ${PW} useradd foo -u 0 -g 0 -d /root -s /bin/sh -c "Bourne-again Superuser" -o
- atf_check \
- -o inline:"foo:*:0:0::0:0:Bourne-again Superuser:/root:/bin/sh\n" \
- -s exit:0 ${PW} usershow foo
-}
-
-atf_test_case user_add_uid_too_large
-user_add_uid_too_large_body() {
- populate_etc_skel
- atf_check -s exit:64 -e inline:"pw: Bad id '9999999999999': too large\n" \
- ${PW} useradd -n test1 -u 9999999999999
-}
-
-atf_test_case user_add_bad_shell
-user_add_bad_shell_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo -s sh
- atf_check -s exit:78 -e ignore ${PW} useradd bar -s badshell
-}
-
-atf_test_case user_add_already_exists
-user_add_already_exists_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:65 \
- -e inline:"pw: login name \`foo' already exists\n" \
- ${PW} useradd foo
-}
-
-atf_test_case user_add_w_error
-user_add_w_error_body() {
- populate_etc_skel
-
- atf_check -s exit:1 -e match:"pw: Invalid value for default password" \
- ${PW} useradd foo -w invalid_value
-}
-
-atf_test_case user_add_w_no
-user_add_w_no_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo -w no
- atf_check -s exit:0 -o match:"^foo:\*" grep "^foo:" $HOME/master.passwd
-}
-
-atf_test_case user_add_w_none
-user_add_w_none_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo -w none
- atf_check -s exit:0 -o match:"^foo::" grep "^foo:" $HOME/master.passwd
-}
-
-atf_test_case user_add_w_random
-user_add_w_random_body() {
- populate_etc_skel
-
- password=`${PW} useradd foo -w random | cat`
- passhash=`awk -F ':' '/^foo:/ {print $2}' $HOME/master.passwd`
- atf_check -s exit:0 -o inline:$passhash \
- $(atf_get_srcdir)/crypt $passhash "$password"
-}
-
-atf_test_case user_add_w_yes
-user_add_w_yes_body() {
- populate_etc_skel
- password=`${PW} useradd foo -w random | cat`
- passhash=`awk -F ':' '/^foo:/ {print $2}' $HOME/master.passwd`
- atf_check -s exit:0 -o inline:$passhash \
- $(atf_get_srcdir)/crypt $passhash "$password"
-}
-
-atf_test_case user_add_with_pw_conf
-user_add_with_pw_conf_body()
-{
- populate_etc_skel
- atf_check -s exit:0 \
- ${PW} useradd -D -C ${HOME}/pw.conf \
- -u 2000,32767 -i 2000,32767
- atf_check -s exit:0 \
- -o inline:"minuid = 2000\nmaxuid = 32767\nmingid = 2000\nmaxgid = 32767\n" \
- grep "^m.*id =" ${HOME}/pw.conf
- atf_check -s exit:0 \
- ${PW} useradd foo -C ${HOME}/pw.conf
-}
-
-atf_test_case user_add_defaultgroup
-user_add_defaultgroup_body()
-{
- populate_etc_skel
- echo 'defaultgroup = "plop"' > ${HOME}/pw.conf
- atf_check -s exit:0 \
- ${PW} groupadd plop -g 442
- atf_check -s exit:0 \
- ${PW} useradd foo -C ${HOME}/pw.conf
- atf_check -s exit:0 \
- -o inline:"foo:*:1001:442::0:0:User &:/home/foo:/bin/sh\n" \
- ${PW} usershow foo
-}
-
-atf_test_case user_add_conf_defaultpasswd
-user_add_conf_defaultpasswd_body()
-{
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd -D -w no
- atf_check -o inline:"defaultpasswd = \"no\"\n" \
- grep defaultpasswd ${HOME}/pw.conf
- atf_check -s exit:0 ${PW} useradd -D -w none
- atf_check -o inline:"defaultpasswd = \"none\"\n" \
- grep defaultpasswd ${HOME}/pw.conf
- atf_check -s exit:0 ${PW} useradd -D -w random
- atf_check -o inline:"defaultpasswd = \"random\"\n" \
- grep defaultpasswd ${HOME}/pw.conf
- atf_check -s exit:0 ${PW} useradd -D -w yes
- atf_check -o inline:"defaultpasswd = \"yes\"\n" \
- grep defaultpasswd ${HOME}/pw.conf
-}
-
-atf_init_test_cases() {
- atf_add_test_case user_add
- atf_add_test_case user_add_noupdate
- atf_add_test_case user_add_comments
- atf_add_test_case user_add_comments_noupdate
- atf_add_test_case user_add_comments_invalid
- atf_add_test_case user_add_comments_invalid_noupdate
- atf_add_test_case user_add_homedir
- atf_add_test_case user_add_account_expiration_epoch
- atf_add_test_case user_add_account_expiration_date_numeric
- atf_add_test_case user_add_account_expiration_date_month
- atf_add_test_case user_add_account_expiration_date_relative
- atf_add_test_case user_add_password_expiration_epoch
- atf_add_test_case user_add_password_expiration_date_numeric
- atf_add_test_case user_add_password_expiration_date_month
- atf_add_test_case user_add_password_expiration_date_relative
- atf_add_test_case user_add_name_too_long
- atf_add_test_case user_add_name_with_spaces
- atf_add_test_case user_add_name_with_spaces_and_gid_specified
- atf_add_test_case user_add_expiration
- atf_add_test_case user_add_invalid_user_entry
- atf_add_test_case user_add_invalid_group_entry
- atf_add_test_case user_add_password_from_h
- atf_add_test_case user_add_R
- atf_add_test_case user_add_R_symlink
- atf_add_test_case user_add_skel
- atf_add_test_case user_add_uid0
- atf_add_test_case user_add_uid_too_large
- atf_add_test_case user_add_bad_shell
- atf_add_test_case user_add_already_exists
- atf_add_test_case user_add_w_error
- atf_add_test_case user_add_w_no
- atf_add_test_case user_add_w_none
- atf_add_test_case user_add_w_random
- atf_add_test_case user_add_w_yes
- atf_add_test_case user_add_with_pw_conf
- atf_add_test_case user_add_defaultgroup
-
- atf_add_test_case user_add_conf_defaultpasswd
-}
diff --git a/pw/tests/pw_userdel_test.sh b/pw/tests/pw_userdel_test.sh
deleted file mode 100755
index 694d7bb..0000000
--- a/pw/tests/pw_userdel_test.sh
+++ /dev/null
@@ -1,96 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-
-# Test that a user can be deleted when another user is part of this
-# user's default group and does not go into an infinate loop.
-# PR: 191427
-atf_test_case rmuser_seperate_group cleanup
-rmuser_seperate_group_head() {
- atf_set "timeout" "30"
-}
-rmuser_seperate_group_body() {
- populate_etc_skel
- ${PW} useradd test || atf_fail "Creating test user"
- ${PW} groupmod test -M 'test,root' || \
- atf_fail "Modifying the group"
- ${PW} userdel test || atf_fail "Delete the test user"
-}
-
-
-atf_test_case user_do_not_try_to_delete_root_if_user_unknown
-user_do_not_try_to_delete_root_if_user_unknown_head() {
- atf_set "descr" \
- "Make sure not to try to remove root if deleting an unknown user"
-}
-user_do_not_try_to_delete_root_if_user_unknown_body() {
- populate_etc_skel
- atf_check -e inline:"pw: Bad id 'plop': invalid\n" -s exit:64 -x \
- ${PW} userdel -u plop
-}
-
-atf_test_case delete_files
-delete_files_body() {
- populate_root_etc_skel
-
- mkdir -p ${HOME}/skel
- touch ${HOME}/skel/a
- mkdir -p ${HOME}/home
- mkdir -p ${HOME}/var/mail
- echo "foo wedontcare" > ${HOME}/etc/opiekeys
- atf_check -s exit:0 ${RPW} useradd foo -k /skel -m
- test -d ${HOME}/home || atf_fail "Fail to create home directory"
- test -f ${HOME}/var/mail/foo || atf_fail "Mail file not created"
- atf_check -s exit:0 ${RPW} userdel foo -r
- atf_check -s exit:0 -o inline:"#oo wedontcare\n" cat ${HOME}/etc/opiekeys
- if test -f ${HOME}/var/mail/foo; then
- atf_fail "Mail file not removed"
- fi
-}
-
-atf_test_case delete_numeric_name
-delete_numeric_name_body() {
- populate_etc_skel
-
- atf_check ${PW} useradd -n foo -u 4001
- atf_check -e inline:"pw: no such user \`4001'\n" -s exit:67 \
- ${PW} userdel -n 4001
-}
-
-atf_test_case home_not_a_dir
-home_not_a_dir_body() {
- populate_root_etc_skel
- touch ${HOME}/foo
- atf_check ${RPW} useradd foo -d /foo
- atf_check ${RPW} userdel foo -r
-}
-
-atf_test_case home_shared
-home_shared_body() {
- populate_root_etc_skel
- mkdir ${HOME}/shared
- atf_check ${RPW} useradd -n testuser1 -d /shared
- atf_check ${RPW} useradd -n testuser2 -d /shared
- atf_check ${RPW} userdel -n testuser1 -r
- test -d ${HOME}/shared || atf_fail "Shared home has been removed"
-}
-
-atf_test_case home_regular_dir
-home_regular_dir_body() {
- populate_root_etc_skel
- atf_check ${RPW} useradd -n foo -d /foo
- atf_check ${RPW} userdel -n foo -r
- [ ! -d ${HOME}/foo ] || atf_fail "Home has not been removed"
-}
-
-atf_init_test_cases() {
- atf_add_test_case rmuser_seperate_group
- atf_add_test_case user_do_not_try_to_delete_root_if_user_unknown
- atf_add_test_case delete_files
- atf_add_test_case delete_numeric_name
- atf_add_test_case home_not_a_dir
- atf_add_test_case home_shared
- atf_add_test_case home_regular_dir
-}
diff --git a/pw/tests/pw_usermod_test.sh b/pw/tests/pw_usermod_test.sh
deleted file mode 100755
index cf3622f..0000000
--- a/pw/tests/pw_usermod_test.sh
+++ /dev/null
@@ -1,302 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-# Test modifying a user
-atf_test_case user_mod
-user_mod_body() {
- populate_etc_skel
-
- atf_check -s exit:67 -e match:"no such user" ${PW} usermod test
- atf_check -s exit:0 ${PW} useradd test
- atf_check -s exit:0 ${PW} usermod test
- atf_check -s exit:0 -o match:"^test:.*" \
- grep "^test:.*" $HOME/master.passwd
-}
-
-# Test modifying a user with option -N
-atf_test_case user_mod_noupdate
-user_mod_noupdate_body() {
- populate_etc_skel
-
- atf_check -s exit:67 -e match:"no such user" ${PW} usermod test -N
- atf_check -s exit:0 ${PW} useradd test
- atf_check -s exit:0 -o match:"^test:.*" ${PW} usermod test -N
- atf_check -s exit:0 -o match:"^test:.*" \
- grep "^test:.*" $HOME/master.passwd
-}
-
-# Test modifying a user with comments
-atf_test_case user_mod_comments
-user_mod_comments_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd test -c "Test User,home,123,456"
- atf_check -s exit:0 ${PW} usermod test -c "Test User,work,123,456"
- atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
- grep "^test:.*:Test User,work,123,456:" $HOME/master.passwd
-}
-
-# Test modifying a user with comments with option -N
-atf_test_case user_mod_comments_noupdate
-user_mod_comments_noupdate_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd test -c "Test User,home,123,456"
- atf_check -s exit:0 -o match:"^test:.*:Test User,work,123,456:" \
- ${PW} usermod test -c "Test User,work,123,456" -N
- atf_check -s exit:0 -o match:"^test:.*:Test User,home,123,456:" \
- grep "^test:.*:Test User,home,123,456:" $HOME/master.passwd
-}
-
-# Test modifying a user with invalid comments
-atf_test_case user_mod_comments_invalid
-user_mod_comments_invalid_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd test
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} usermod test -c "Test User,work,123:456,456"
- atf_check -s exit:1 -o empty \
- grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
- atf_check -s exit:0 -o match:"^test:\*" \
- grep "^test:\*" $HOME/master.passwd
-}
-
-# Test modifying a user with invalid comments with option -N
-atf_test_case user_mod_comments_invalid_noupdate
-user_mod_comments_invalid_noupdate_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd test
- atf_check -s exit:65 -e match:"invalid character" \
- ${PW} usermod test -c "Test User,work,123:456,456" -N
- atf_check -s exit:1 -o empty \
- grep "^test:.*:Test User,work,123:456,456:" $HOME/master.passwd
- atf_check -s exit:0 -o match:"^test:\*" \
- grep "^test:\*" $HOME/master.passwd
-}
-
-# Test modifying a user name with -l
-atf_test_case user_mod_name
-user_mod_name_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -l "bar"
- atf_check -s exit:0 -o match:"^bar:.*" \
- grep "^bar:.*" $HOME/master.passwd
-}
-
-# Test modifying a user name with -l with option -N
-atf_test_case user_mod_name_noupdate
-user_mod_name_noupdate_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 -o match:"^bar:.*" ${PW} usermod foo -l "bar" -N
- atf_check -s exit:0 -o match:"^foo:.*" \
- grep "^foo:.*" $HOME/master.passwd
-}
-
-atf_test_case user_mod_rename_multigroups
-user_mod_rename_multigroups_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} groupadd test1
- atf_check -s exit:0 ${PW} groupadd test2
- atf_check -s exit:0 ${PW} useradd foo -G test1,test2
- atf_check -o match:"foo" -s exit:0 ${PW} groupshow test1
- atf_check -o match:"foo" -s exit:0 ${PW} groupshow test2
- atf_check -s exit:0 ${PW} usermod foo -l bar
- atf_check -o match:"bar" -s exit:0 ${PW} groupshow test1
- atf_check -o match:"bar" -s exit:0 ${PW} groupshow test2
-}
-
-atf_test_case user_mod_nogroups
-user_mod_nogroups_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} groupadd test1
- atf_check -s exit:0 ${PW} groupadd test2
- atf_check -s exit:0 ${PW} groupadd test3
- atf_check -s exit:0 ${PW} groupadd test4
- atf_check -s exit:0 ${PW} useradd foo -G test1,test2
- atf_check -o match:"foo" -s exit:0 ${PW} groupshow test1
- atf_check -o match:"foo" -s exit:0 ${PW} groupshow test2
- atf_check -s exit:0 ${PW} usermod foo -G test3,test4
- atf_check -s exit:0 -o inline:"test3\ntest4\n" \
- awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group
- atf_check -s exit:0 ${PW} usermod foo -G ""
- atf_check -s exit:0 -o empty \
- awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group
-}
-
-atf_test_case user_mod_rename
-user_mod_rename_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -l bar
- atf_check -s exit:0 -o match:"^bar:.*" \
- grep "^bar:.*" ${HOME}/master.passwd
-}
-
-atf_test_case user_mod_rename_too_long
-user_mod_rename_too_long_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:64 -e match:"too long" ${PW} usermod foo \
- -l name_very_very_very_very_very_long
-}
-
-atf_test_case user_mod_h
-user_mod_h_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -h 0 <<- EOF
- $(echo a)
- EOF
- passhash=`awk -F ':' '/^foo:/ {print $2}' $HOME/master.passwd`
- atf_check -s exit:0 -o inline:$passhash \
- $(atf_get_srcdir)/crypt $passhash "a"
- atf_check -s exit:0 ${PW} usermod foo -h - <<- EOF
- $(echo b)
- EOF
- atf_check -s exit:0 -o match:"^foo:\*:.*" \
- grep "^foo" ${HOME}/master.passwd
- atf_check -e inline:"pw: Bad file descriptor 'a': invalid\n" \
- -s exit:64 ${PW} usermod foo -h a <<- EOF
- $(echo a)
- EOF
-}
-
-atf_test_case user_mod_H
-user_mod_H_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -H 0 <<- EOF
- $(echo a)
- EOF
- atf_check -s exit:0 -o match:"^foo:a:.*" \
- grep "^foo" ${HOME}/master.passwd
- atf_check -s exit:64 -e inline:"pw: -H expects a file descriptor\n" \
- ${PW} usermod foo -H -
-}
-
-atf_test_case user_mod_renamehome
-user_mod_renamehome_body() {
- populate_root_etc_skel
-
- mkdir -p ${HOME}/home
- atf_check -s exit:0 ${RPW} useradd foo -m
- test -d ${HOME}/home/foo || atf_fail "Directory not created"
- atf_check -s exit:0 ${RPW} usermod foo -l bar -d /home/bar -m
- test -d ${HOME}/home/bar || atf_fail "Directory not created"
-}
-
-atf_test_case user_mod_uid
-user_mod_uid_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -u 5000
-}
-
-atf_test_case user_mod_w_error
-user_mod_w_error_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:1 -e match:"pw: Invalid value for default password" \
- ${PW} usermod foo -w invalid_value
-}
-
-atf_test_case user_mod_w_no
-user_mod_w_no_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -w no
- atf_check -s exit:0 -o match:"^foo:\*" grep "^foo:" $HOME/master.passwd
-}
-
-atf_test_case user_mod_w_none
-user_mod_w_none_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -w none
- atf_check -s exit:0 -o match:"^foo::" grep "^foo:" $HOME/master.passwd
-}
-
-atf_test_case user_mod_w_random
-user_mod_w_random_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- password=`${PW} usermod foo -w random | cat`
- passhash=`awk -F ':' '/^foo:/ {print $2}' $HOME/master.passwd`
- atf_check -s exit:0 -o inline:$passhash \
- $(atf_get_srcdir)/crypt $passhash "$password"
-}
-
-atf_test_case user_mod_w_yes
-user_mod_w_yes_body() {
- populate_etc_skel
-
- atf_check -s exit:0 ${PW} useradd foo
- atf_check -s exit:0 ${PW} usermod foo -w yes
- passhash=`awk -F ':' '/^foo:/ {print $2}' $HOME/master.passwd`
- atf_check -s exit:0 -o inline:$passhash \
- $(atf_get_srcdir)/crypt $passhash "foo"
-}
-
-atf_test_case user_mod_m
-user_mod_m_body() {
- populate_root_etc_skel
-
- mkdir -p ${HOME}/home
- mkdir -p ${HOME}/skel
- echo "entry" > ${HOME}/skel/.file
- atf_check -s exit:0 ${RPW} useradd foo
- ! test -d ${HOME}/home/foo || atf_fail "Directory should not have been created"
- atf_check -s exit:0 ${RPW} usermod foo -m -k /skel
- test -d ${HOME}/home/foo || atf_fail "Directory should have been created"
- test -f ${HOME}/home/foo/.file || atf_fail "Skell files not added"
- echo "entry" > ${HOME}/skel/.file2
- atf_check -s exit:0 ${RPW} usermod foo -m -k /skel
- test -f ${HOME}/home/foo/.file2 || atf_fail "Skell files not added"
- echo > ${HOME}/home/foo/.file2
- atf_check -s exit:0 ${RPW} usermod foo -m -k /skel
- atf_check -s exit:0 -o inline:"\n" cat ${HOME}/home/foo/.file2
-}
-
-
-atf_init_test_cases() {
- atf_add_test_case user_mod
- atf_add_test_case user_mod_noupdate
- atf_add_test_case user_mod_comments
- atf_add_test_case user_mod_comments_noupdate
- atf_add_test_case user_mod_comments_invalid
- atf_add_test_case user_mod_comments_invalid_noupdate
- atf_add_test_case user_mod_nogroups
- atf_add_test_case user_mod_rename
- atf_add_test_case user_mod_name_noupdate
- atf_add_test_case user_mod_rename_too_long
- atf_add_test_case user_mod_rename_multigroups
- atf_add_test_case user_mod_h
- atf_add_test_case user_mod_H
- atf_add_test_case user_mod_renamehome
- atf_add_test_case user_mod_uid
- atf_add_test_case user_mod_w_error
- atf_add_test_case user_mod_w_no
- atf_add_test_case user_mod_w_none
- atf_add_test_case user_mod_w_random
- atf_add_test_case user_mod_w_yes
- atf_add_test_case user_mod_m
-}
diff --git a/pw/tests/pw_usernext_test.sh b/pw/tests/pw_usernext_test.sh
deleted file mode 100755
index 89f938e..0000000
--- a/pw/tests/pw_usernext_test.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-# Test usernext after adding a random number of new users.
-atf_test_case usernext
-usernext_body() {
- populate_etc_skel
-
- CURRENT=`${PW} usernext | sed -e 's/:.*//'`
- RANDOM=`jot -r 1 1 150`
- MAX=`expr ${CURRENT} + ${RANDOM}`
- while [ "${CURRENT}" -lt "${MAX}" ]
- do
- atf_check -s exit:0 ${PW} useradd test${CURRENT}
- CURRENT=`expr ${CURRENT} + 1`
- done
- atf_check -s exit:0 -o match:"${CURRENT}:${CURRENT}" \
- ${PW} usernext
-}
-
-# Test usernext when multiple users are added to the same group so
-# that group id doesn't increment at the same pace as new users.
-atf_test_case usernext_assigned_group
-usernext_assigned_group_body() {
- populate_etc_skel
-
- CURRENT=`${PW} usernext | sed -e 's/:.*//'`
- CURRENTGID=`${PW} groupnext`
- RANDOM=`jot -r 1 1 150`
- MAX=`expr ${CURRENT} + ${RANDOM}`
- while [ "${CURRENT}" -lt "${MAX}" ]
- do
- atf_check -s exit:0 ${PW} useradd -n test${CURRENT} -g 0
- CURRENT=`expr ${CURRENT} + 1`
- done
- atf_check -s exit:0 -o match:"${CURRENT}:${CURRENTGID}" \
- ${PW} usernext
-}
-
-atf_init_test_cases() {
- atf_add_test_case usernext
- atf_add_test_case usernext_assigned_group
-}
diff --git a/pw/tests/pw_usershow_test.sh b/pw/tests/pw_usershow_test.sh
deleted file mode 100755
index 5305979..0000000
--- a/pw/tests/pw_usershow_test.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-# $FreeBSD$
-
-# Import helper functions
-. $(atf_get_srcdir)/helper_functions.shin
-
-atf_test_case user_show_all
-user_show_all_body() {
- populate_etc_skel
- atf_check -o not-empty ${PW} usershow -a
-}
-
-atf_test_case user_show_name
-user_show_name_body() {
- populate_etc_skel
- atf_check -o not-empty ${PW} usershow root
-}
-
-atf_test_case user_show_nonexistent_name
-user_show_nonexistent_name_body() {
- populate_etc_skel
-
- nonexistent_user=bogus
- no_such_user_msg="pw: no such user \`$nonexistent_user'\n"
-
- atf_check -e "inline:$no_such_user_msg" -s exit:67 ${PW} usershow \
- $nonexistent_user
- atf_check -e "inline:$no_such_user_msg" -s exit:67 ${PW} usershow \
- -n $nonexistent_user
-}
-
-atf_test_case user_show_nonexistent_uid
-user_show_nonexistent_uid_body() {
- populate_etc_skel
-
- nonexistent_uid=4242
- no_such_uid_msg="pw: no such uid \`$nonexistent_uid'\n"
-
- atf_check -e "inline:$no_such_uid_msg" -s exit:67 ${PW} usershow \
- $nonexistent_uid
- atf_check -e "inline:$no_such_uid_msg" -s exit:67 ${PW} usershow \
- -u $nonexistent_uid
-}
-
-atf_test_case user_show_uid
-user_show_uid_body() {
- populate_etc_skel
- atf_check -o not-empty ${PW} usershow -u 0
-}
-
-atf_init_test_cases() {
- atf_add_test_case user_show_all
- atf_add_test_case user_show_name
- atf_add_test_case user_show_nonexistent_name
- atf_add_test_case user_show_nonexistent_uid
- atf_add_test_case user_show_uid
-}