From owner-svn-src-head@freebsd.org Sun Oct 21 14:23:57 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5718FF3ACB; Sun, 21 Oct 2018 14:23:57 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 639668F905; Sun, 21 Oct 2018 14:23:57 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 415C86B90; Sun, 21 Oct 2018 14:23:57 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9LENvwg065024; Sun, 21 Oct 2018 14:23:57 GMT (envelope-from yuripv@FreeBSD.org) Received: (from yuripv@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9LENuij065022; Sun, 21 Oct 2018 14:23:56 GMT (envelope-from yuripv@FreeBSD.org) Message-Id: <201810211423.w9LENuij065022@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: yuripv set sender to yuripv@FreeBSD.org using -f From: Yuri Pankov Date: Sun, 21 Oct 2018 14:23:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339534 - in head/usr.sbin/pw: . tests X-SVN-Group: head X-SVN-Commit-Author: yuripv X-SVN-Commit-Paths: in head/usr.sbin/pw: . tests X-SVN-Commit-Revision: 339534 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Oct 2018 14:23:58 -0000 Author: yuripv Date: Sun Oct 21 14:23:56 2018 New Revision: 339534 URL: https://svnweb.freebsd.org/changeset/base/339534 Log: pw: fix the checks in boolean_str() after r326738. Add related test cases for `pw useradd -D -w`. PR: 231649 Reviewed by: eugen Approved by: kib (mentor) Differential Revision: https://reviews.freebsd.org/D17299 Modified: head/usr.sbin/pw/pw_conf.c head/usr.sbin/pw/tests/pw_useradd_test.sh Modified: head/usr.sbin/pw/pw_conf.c ============================================================================== --- head/usr.sbin/pw/pw_conf.c Sun Oct 21 14:19:16 2018 (r339533) +++ head/usr.sbin/pw/pw_conf.c Sun Oct 21 14:23:56 2018 (r339534) @@ -221,12 +221,14 @@ passwd_val(char const * str, int dflt) char const * boolean_str(int val) { - if (val == -1) - return "random"; - else if (val == -2) - return "none"; + if (val == P_NO) + return (boolfalse[0]); + else if (val == P_RANDOM) + return ("random"); + else if (val == P_NONE) + return ("none"); else - return val ? booltrue[0] : boolfalse[0]; + return (booltrue[0]); } char * Modified: head/usr.sbin/pw/tests/pw_useradd_test.sh ============================================================================== --- head/usr.sbin/pw/tests/pw_useradd_test.sh Sun Oct 21 14:19:16 2018 (r339533) +++ head/usr.sbin/pw/tests/pw_useradd_test.sh Sun Oct 21 14:23:56 2018 (r339534) @@ -421,6 +421,7 @@ user_add_with_pw_conf_body() atf_check -s exit:0 \ ${PW} useradd foo -C ${HOME}/pw.conf } + atf_test_case user_add_defaultgroup user_add_defaultgroup_body() { @@ -435,6 +436,25 @@ user_add_defaultgroup_body() ${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 @@ -472,4 +492,6 @@ atf_init_test_cases() { 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 }