summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2020-11-18 20:00:55 +0000
committerStefan Eßer <se@FreeBSD.org>2020-11-18 20:00:55 +0000
commit56d11d4a3749408b91751f2b1d7082167ae1814d (patch)
treec3ee43806a81013696621eae845c7cb803eb2d91 /usr.sbin
parent991f6e7534a9b1a99b7da711676e6714e2cf6680 (diff)
downloadsrc-test2-56d11d4a3749408b91751f2b1d7082167ae1814d.tar.gz
src-test2-56d11d4a3749408b91751f2b1d7082167ae1814d.zip
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
Notes
Notes: svn path=/head/; revision=367816
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.c2
-rw-r--r--usr.sbin/pkg/Makefile2
-rw-r--r--usr.sbin/pkg/config.c6
-rw-r--r--usr.sbin/pkg/pkg.c5
4 files changed, 7 insertions, 8 deletions
diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c
index 8a9ec220a26b..ef9c3b4d55c2 100644
--- a/usr.sbin/mailwrapper/mailwrapper.c
+++ b/usr.sbin/mailwrapper/mailwrapper.c
@@ -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)
diff --git a/usr.sbin/pkg/Makefile b/usr.sbin/pkg/Makefile
index ebfb71c1699b..980faafc6b6c 100644
--- a/usr.sbin/pkg/Makefile
+++ b/usr.sbin/pkg/Makefile
@@ -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 <bsd.prog.mk>
diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c
index a1dba3f2670a..aaa9010b295d 100644
--- a/usr.sbin/pkg/config.c
+++ b/usr.sbin/pkg/config.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <ucl.h>
#include <err.h>
#include <errno.h>
+#include <libutil.h>
#include <paths.h>
#include <stdbool.h>
#include <unistd.h>
@@ -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))
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index 3de789328c37..a35efd8f91a8 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -43,12 +43,12 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fcntl.h>
#include <fetch.h>
+#include <libutil.h>
#include <paths.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
#include <ucl.h>
#include <openssl/err.h>
@@ -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;