From owner-svn-src-all@FreeBSD.ORG Sun Jun 7 21:00:01 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 246EDAD4; Sun, 7 Jun 2015 21:00:01 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 12BAF1217; Sun, 7 Jun 2015 21:00:01 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57L00RP001204; Sun, 7 Jun 2015 21:00:00 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t57L007f001153; Sun, 7 Jun 2015 21:00:00 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201506072100.t57L007f001153@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 7 Jun 2015 21:00:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r284137 - in head/usr.sbin/pw: . tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jun 2015 21:00:01 -0000 Author: bapt Date: Sun Jun 7 20:59:59 2015 New Revision: 284137 URL: https://svnweb.freebsd.org/changeset/base/284137 Log: Fix setting uid/gid min/max via pw Added: head/usr.sbin/pw/tests/pw-modified.conf - copied, changed from r284135, head/usr.sbin/pw/tests/pw.conf Modified: head/usr.sbin/pw/pw.c head/usr.sbin/pw/tests/Makefile head/usr.sbin/pw/tests/pw_config.sh Modified: head/usr.sbin/pw/pw.c ============================================================================== --- head/usr.sbin/pw/pw.c Sun Jun 7 20:45:13 2015 (r284136) +++ head/usr.sbin/pw/pw.c Sun Jun 7 20:59:59 2015 (r284137) @@ -251,11 +251,20 @@ main(int argc, char *argv[]) addarg(&arglist, 'g', optarg); break; } - /* FALLTHROUGH */ - case 'u': if (strspn(optarg, "0123456789") != strlen(optarg)) - errx(EX_USAGE, "%s expects a number", - which == 1 ? "-g" : "-u" ); + errx(EX_USAGE, "-g expects a number"); + id = strtonum(optarg, 0, LONG_MAX, &errstr); + if (errstr != NULL) + errx(EX_USAGE, "Bad id '%s': %s", optarg, + errstr); + break; + case 'u': + if (strspn(optarg, "0123456789,") != strlen(optarg)) + errx(EX_USAGE, "-u expects a number"); + if (strchr(optarg, ',') != NULL) { + addarg(&arglist, 'u', optarg); + break; + } id = strtonum(optarg, 0, LONG_MAX, &errstr); if (errstr != NULL) errx(EX_USAGE, "Bad id '%s': %s", optarg, Modified: head/usr.sbin/pw/tests/Makefile ============================================================================== --- head/usr.sbin/pw/tests/Makefile Sun Jun 7 20:45:13 2015 (r284136) +++ head/usr.sbin/pw/tests/Makefile Sun Jun 7 20:59:59 2015 (r284137) @@ -19,7 +19,8 @@ ATF_TESTS_SH= pw_etcdir \ TEST_METADATA.${tp}+= required_user="root" .endfor -FILES= group helper_functions.shin master.passwd pw.conf +FILES= group helper_functions.shin master.passwd pw.conf \ + pw-modified.conf FILESDIR= ${TESTSDIR} ATF_TESTS_SH+= pw_test Copied and modified: head/usr.sbin/pw/tests/pw-modified.conf (from r284135, head/usr.sbin/pw/tests/pw.conf) ============================================================================== --- head/usr.sbin/pw/tests/pw.conf Sun Jun 7 20:44:06 2015 (r284135, copy source) +++ head/usr.sbin/pw/tests/pw-modified.conf Sun Jun 7 20:59:59 2015 (r284137) @@ -48,12 +48,12 @@ extragroups = defaultclass = "" # Range of valid default user ids -minuid = 1000 -maxuid = 32000 +minuid = 2000 +maxuid = 5000 # Range of valid default group ids -mingid = 1000 -maxgid = 32000 +mingid = 2100 +maxgid = 6000 # Days after which account expires (0=disabled) expire_days = 0 Modified: head/usr.sbin/pw/tests/pw_config.sh ============================================================================== --- head/usr.sbin/pw/tests/pw_config.sh Sun Jun 7 20:45:13 2015 (r284136) +++ head/usr.sbin/pw/tests/pw_config.sh Sun Jun 7 20:59:59 2015 (r284137) @@ -11,6 +11,16 @@ generate_config_body() { 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 }