From owner-svn-src-head@freebsd.org Thu Jul 9 14:14:47 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4EFFB996A6E; Thu, 9 Jul 2015 14:14:47 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.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 237B11C65; Thu, 9 Jul 2015 14:14:47 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t69EElYm073283; Thu, 9 Jul 2015 14:14:47 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t69EEj4k073268; Thu, 9 Jul 2015 14:14:45 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201507091414.t69EEj4k073268@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Thu, 9 Jul 2015 14:14:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285318 - 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-head@freebsd.org X-Mailman-Version: 2.1.20 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: Thu, 09 Jul 2015 14:14:47 -0000 Author: bapt Date: Thu Jul 9 14:14:44 2015 New Revision: 285318 URL: https://svnweb.freebsd.org/changeset/base/285318 Log: Do not try to set password on group if the group is added as a consequence of of creating a user (regression from r285136) Reported by: Fabian Keil Modified: head/usr.sbin/pw/pw.c head/usr.sbin/pw/pw_group.c head/usr.sbin/pw/pwupd.h head/usr.sbin/pw/tests/pw_useradd.sh Modified: head/usr.sbin/pw/pw.c ============================================================================== --- head/usr.sbin/pw/pw.c Thu Jul 9 13:30:37 2015 (r285317) +++ head/usr.sbin/pw/pw.c Thu Jul 9 14:14:44 2015 (r285318) @@ -215,6 +215,7 @@ main(int argc, char *argv[]) if (mode == -1 || which == -1) cmdhelp(mode, which); + conf.which = which; /* * We know which mode we're in and what we're about to do, so now * let's dispatch the remaining command line args in a genric way. Modified: head/usr.sbin/pw/pw_group.c ============================================================================== --- head/usr.sbin/pw/pw_group.c Thu Jul 9 13:30:37 2015 (r285317) +++ head/usr.sbin/pw/pw_group.c Thu Jul 9 14:14:44 2015 (r285318) @@ -200,7 +200,7 @@ pw_group(int mode, char *name, long id, * software. */ - if (conf.fd != -1) + if (conf.which == W_GROUP && conf.fd != -1) set_passwd(grp, mode == M_UPDATE); if (((arg = getarg(args, 'M')) != NULL || Modified: head/usr.sbin/pw/pwupd.h ============================================================================== --- head/usr.sbin/pw/pwupd.h Thu Jul 9 13:30:37 2015 (r285317) +++ head/usr.sbin/pw/pwupd.h Thu Jul 9 14:14:44 2015 (r285318) @@ -86,6 +86,7 @@ struct pwconf { char *newname; char *config; int fd; + int which; bool dryrun; bool pretty; bool v7; Modified: head/usr.sbin/pw/tests/pw_useradd.sh ============================================================================== --- head/usr.sbin/pw/tests/pw_useradd.sh Thu Jul 9 13:30:37 2015 (r285317) +++ head/usr.sbin/pw/tests/pw_useradd.sh Thu Jul 9 14:14:44 2015 (r285318) @@ -231,6 +231,15 @@ user_add_invalid_group_entry_body() { 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 test -h 0 <<-EOF + $(echo test) + EOF +} + atf_init_test_cases() { atf_add_test_case user_add atf_add_test_case user_add_noupdate @@ -251,4 +260,5 @@ atf_init_test_cases() { 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 }