From owner-svn-src-head@freebsd.org Wed Nov 18 20:00:57 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3F6CE471390; Wed, 18 Nov 2020 20:00:57 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CbtwT1MYZz4bSY; Wed, 18 Nov 2020 20:00:57 +0000 (UTC) (envelope-from se@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 21B7217B03; Wed, 18 Nov 2020 20:00:57 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AIK0vfW010208; Wed, 18 Nov 2020 20:00:57 GMT (envelope-from se@FreeBSD.org) Received: (from se@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AIK0tDZ010202; Wed, 18 Nov 2020 20:00:55 GMT (envelope-from se@FreeBSD.org) Message-Id: <202011182000.0AIK0tDZ010202@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: se set sender to se@FreeBSD.org using -f From: =?UTF-8?Q?Stefan_E=c3=9fer?= Date: Wed, 18 Nov 2020 20:00:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r367816 - in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Group: head X-SVN-Commit-Author: se X-SVN-Commit-Paths: in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg X-SVN-Commit-Revision: 367816 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.34 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: Wed, 18 Nov 2020 20:00:57 -0000 Author: se Date: Wed Nov 18 20:00:55 2020 New Revision: 367816 URL: https://svnweb.freebsd.org/changeset/base/367816 Log: Make use of the getlocalbase() function for run-time adjustment of the local software base directory, as committed in SVN rev. 367813. The pkg and mailwrapper programs used the LOCALBASE environment variable for this purpose and this functionality is preserved by getlocalbase(). After this change, the value of the user.localbase sysctl variable is used if present (and not overridden in the environment). The nvmecontrol program gains support of a dynamic path to its plugin directory with this update. Differential Revision: https://reviews.freebsd.org/D27237 Modified: head/sbin/nvmecontrol/comnd.c head/sbin/nvmecontrol/nvmecontrol.c head/usr.sbin/mailwrapper/mailwrapper.c head/usr.sbin/pkg/Makefile head/usr.sbin/pkg/config.c head/usr.sbin/pkg/pkg.c Modified: head/sbin/nvmecontrol/comnd.c ============================================================================== --- head/sbin/nvmecontrol/comnd.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/sbin/nvmecontrol/comnd.c Wed Nov 18 20:00:55 2020 (r367816) @@ -287,7 +287,7 @@ bad_arg: * Loads all the .so's from the specified directory. */ void -cmd_load_dir(const char *dir __unused, cmd_load_cb_t cb __unused, void *argp __unused) +cmd_load_dir(const char *dir, cmd_load_cb_t cb, void *argp) { DIR *d; struct dirent *dent; Modified: head/sbin/nvmecontrol/nvmecontrol.c ============================================================================== --- head/sbin/nvmecontrol/nvmecontrol.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/sbin/nvmecontrol/nvmecontrol.c Wed Nov 18 20:00:55 2020 (r367816) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -178,11 +179,13 @@ get_nsid(int fd, char **ctrlr_str, uint32_t *nsid) int main(int argc, char *argv[]) { + static char dir[MAXPATHLEN]; cmd_init(); cmd_load_dir("/lib/nvmecontrol", NULL, NULL); - cmd_load_dir(_PATH_LOCALBASE "/lib/nvmecontrol", NULL, NULL); + snprintf(dir, MAXPATHLEN, "%s/lib/nvmecontrol", getlocalbase()); + cmd_load_dir(dir, NULL, NULL); cmd_dispatch(argc, argv, NULL); Modified: head/usr.sbin/mailwrapper/mailwrapper.c ============================================================================== --- head/usr.sbin/mailwrapper/mailwrapper.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/mailwrapper/mailwrapper.c Wed Nov 18 20:00:55 2020 (r367816) @@ -106,7 +106,7 @@ main(int argc, char *argv[], char *envp[]) addarg(&al, argv[0]); snprintf(localmailerconf, MAXPATHLEN, "%s/etc/mail/mailer.conf", - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); + getlocalbase()); mailerconf = localmailerconf; if ((config = fopen(localmailerconf, "r")) == NULL) Modified: head/usr.sbin/pkg/Makefile ============================================================================== --- head/usr.sbin/pkg/Makefile Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/pkg/Makefile Wed Nov 18 20:00:55 2020 (r367816) @@ -25,6 +25,6 @@ MAN= pkg.7 CFLAGS+=-I${SRCTOP}/contrib/libucl/include .PATH: ${SRCTOP}/contrib/libucl/include -LIBADD= archive fetch ucl sbuf crypto ssl +LIBADD= archive fetch ucl sbuf crypto ssl util .include Modified: head/usr.sbin/pkg/config.c ============================================================================== --- head/usr.sbin/pkg/config.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/pkg/config.c Wed Nov 18 20:00:55 2020 (r367816) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -455,9 +456,8 @@ config_init(void) } /* Read LOCALBASE/etc/pkg.conf first. */ - localbase = getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE; - snprintf(confpath, sizeof(confpath), "%s/etc/pkg.conf", - localbase); + localbase = getlocalbase(); + snprintf(confpath, sizeof(confpath), "%s/etc/pkg.conf", localbase); if (access(confpath, F_OK) == 0 && read_conf_file(confpath, CONFFILE_PKG)) Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Wed Nov 18 19:55:24 2020 (r367815) +++ head/usr.sbin/pkg/pkg.c Wed Nov 18 20:00:55 2020 (r367816) @@ -43,12 +43,12 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include #include -#include #include #include @@ -1045,8 +1045,7 @@ main(int argc, char *argv[]) pkgarg = NULL; yes = false; - snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); + snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", getlocalbase()); if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { bootstrap_only = true;