From owner-svn-src-head@freebsd.org Mon Oct 15 20:11:54 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 B026C10C7DD7; Mon, 15 Oct 2018 20:11:54 +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 63007832AC; Mon, 15 Oct 2018 20:11:54 +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 5DF4C11FD1; Mon, 15 Oct 2018 20:11:54 +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 w9FKBswY068490; Mon, 15 Oct 2018 20:11:54 GMT (envelope-from yuripv@FreeBSD.org) Received: (from yuripv@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9FKBrgQ068303; Mon, 15 Oct 2018 20:11:53 GMT (envelope-from yuripv@FreeBSD.org) Message-Id: <201810152011.w9FKBrgQ068303@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: yuripv set sender to yuripv@FreeBSD.org using -f From: Yuri Pankov Date: Mon, 15 Oct 2018 20:11:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339369 - head/usr.sbin/pw X-SVN-Group: head X-SVN-Commit-Author: yuripv X-SVN-Commit-Paths: head/usr.sbin/pw X-SVN-Commit-Revision: 339369 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.27 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: Mon, 15 Oct 2018 20:11:54 -0000 Author: yuripv Date: Mon Oct 15 20:11:53 2018 New Revision: 339369 URL: https://svnweb.freebsd.org/changeset/base/339369 Log: pw: respect path specified using -V when writing pw.conf, and -C is not explicitly specified. -V path is already used to determine which file to read default values from, so it's only logical to write them to the same file. PR: 231653 Reviewed by: eugen, bapt Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17566 Modified: head/usr.sbin/pw/pw.h head/usr.sbin/pw/pw_conf.c head/usr.sbin/pw/pw_utils.c Modified: head/usr.sbin/pw/pw.h ============================================================================== --- head/usr.sbin/pw/pw.h Mon Oct 15 19:48:36 2018 (r339368) +++ head/usr.sbin/pw/pw.h Mon Oct 15 20:11:53 2018 (r339369) @@ -64,6 +64,7 @@ enum _which }; #define _DEF_DIRMODE (S_IRWXU | S_IRWXG | S_IRWXO) +#define _PW_CONF "pw.conf" #define _PATH_PW_CONF "/etc/pw.conf" #define _UC_MAXLINE 1024 #define _UC_MAXSHELLS 32 Modified: head/usr.sbin/pw/pw_conf.c ============================================================================== --- head/usr.sbin/pw/pw_conf.c Mon Oct 15 19:48:36 2018 (r339368) +++ head/usr.sbin/pw/pw_conf.c Mon Oct 15 20:11:53 2018 (r339369) @@ -417,9 +417,13 @@ write_userconfig(struct userconf *cnf, const char *fil int i, j; struct sbuf *buf; FILE *fp; + char cfgfile[MAXPATHLEN]; - if (file == NULL) - file = _PATH_PW_CONF; + if (file == NULL) { + snprintf(cfgfile, sizeof(cfgfile), "%s/" _PW_CONF, + conf.etcpath); + file = cfgfile; + } if ((fd = open(file, O_CREAT|O_RDWR|O_TRUNC|O_EXLOCK, 0644)) == -1) return (0); Modified: head/usr.sbin/pw/pw_utils.c ============================================================================== --- head/usr.sbin/pw/pw_utils.c Mon Oct 15 19:48:36 2018 (r339368) +++ head/usr.sbin/pw/pw_utils.c Mon Oct 15 20:11:53 2018 (r339369) @@ -71,7 +71,7 @@ get_userconfig(const char *config) if (config != NULL) return (read_userconfig(config)); - snprintf(defaultcfg, sizeof(defaultcfg), "%s/pw.conf", conf.etcpath); + snprintf(defaultcfg, sizeof(defaultcfg), "%s/" _PW_CONF, conf.etcpath); return (read_userconfig(defaultcfg)); }