summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2020-10-27 11:29:11 +0000
committerStefan Eßer <se@FreeBSD.org>2020-10-27 11:29:11 +0000
commit1f474190fc280d4a4ef0c214e4d7fff0d1237e22 (patch)
tree123ca2f0a46ad9a1203a6b3c7a7a38c2a50854e6
parent7b39bef2cf93f6f0e79cc55a8ee2d339e42a6816 (diff)
downloadsrc-test-1f474190fc280d4a4ef0c214e4d7fff0d1237e22.tar.gz
src-test-1f474190fc280d4a4ef0c214e4d7fff0d1237e22.zip
Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE
Literal references to /usr/local exist in a large number of files in the FreeBSD base system. Many are in contributed software, in configuration files, or in the documentation, but 19 uses have been identified in C source files or headers outside the contrib and sys/contrib directories. This commit makes it possible to set _PATH_LOCALBASE in paths.h to use a different prefix for locally installed software. In order to avoid changes to openssh source files, LOCALBASE is passed to the build via Makefiles under src/secure. While _PATH_LOCALBASE could have been used here, there is precedent in the construction of the path used to a xauth program which depends on the LOCALBASE value passed on the compiler command line to select a non-default directory. This could be changed in a later commit to make the openssh build consistently use _PATH_LOCALBASE. It is considered out-of-scope for this commit. Reviewed by: imp MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D26942
Notes
Notes: svn path=/head/; revision=367075
-rw-r--r--crypto/openssh/regress/unittests/sshkey/test_sshkey.c3
-rw-r--r--lib/libc/nls/msgcat.c5
-rw-r--r--lib/libfetch/common.c3
-rw-r--r--sbin/nvmecontrol/nvmecontrol.c2
-rw-r--r--secure/lib/libssh/Makefile4
-rw-r--r--secure/usr.bin/ssh-agent/Makefile4
-rw-r--r--tools/tools/ath/athprom/athprom.c3
-rw-r--r--tools/tools/net80211/wesside/wesside/wesside.c3
-rw-r--r--usr.bin/fortune/fortune/pathnames.h4
-rw-r--r--usr.bin/mail/pathnames.h4
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c3
-rw-r--r--usr.sbin/cpucontrol/cpucontrol.c3
-rw-r--r--usr.sbin/cron/cron/pathnames.h2
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.c3
-rw-r--r--usr.sbin/pciconf/pathnames.h4
-rw-r--r--usr.sbin/pkg/config.c3
-rw-r--r--usr.sbin/pkg/config.h3
-rw-r--r--usr.sbin/pkg/pkg.c2
18 files changed, 42 insertions, 16 deletions
diff --git a/crypto/openssh/regress/unittests/sshkey/test_sshkey.c b/crypto/openssh/regress/unittests/sshkey/test_sshkey.c
index 47a03fad4fd27..3415ed68196ac 100644
--- a/crypto/openssh/regress/unittests/sshkey/test_sshkey.c
+++ b/crypto/openssh/regress/unittests/sshkey/test_sshkey.c
@@ -9,6 +9,7 @@
#include <sys/types.h>
#include <sys/param.h>
+#include <paths.h>
#include <stdio.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
@@ -79,7 +80,7 @@ build_cert(struct sshbuf *b, const struct sshkey *k, const char *type,
critopts = sshbuf_new();
ASSERT_PTR_NE(critopts, NULL);
- put_opt(critopts, "force-command", "/usr/local/bin/nethack");
+ put_opt(critopts, "force-command", _PATH_LOCALBASE "/bin/nethack");
put_opt(critopts, "source-address", "192.168.0.0/24,127.0.0.1,::1");
exts = sshbuf_new();
diff --git a/lib/libc/nls/msgcat.c b/lib/libc/nls/msgcat.c
index 5eb3273f7269f..090b4cc40ab6b 100644
--- a/lib/libc/nls/msgcat.c
+++ b/lib/libc/nls/msgcat.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <limits.h>
#include <nl_types.h>
+#include <paths.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
@@ -58,7 +59,9 @@ __FBSDID("$FreeBSD$");
#include "../locale/xlocale_private.h"
-#define _DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"
+#define _DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:" \
+ _PATH_LOCALBASE "/share/nls/%L/%N.cat:" \
+ _PATH_LOCALBASE "/share/nls/%N/%L"
#define RLOCK(fail) { int ret; \
if (__isthreaded && \
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index ae119de327367..7b08391b47999 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <inttypes.h>
#include <netdb.h>
+#include <paths.h>
#include <poll.h>
#include <pwd.h>
#include <stdarg.h>
@@ -1071,7 +1072,7 @@ fetch_ssl_setup_transport_layer(SSL_CTX *ctx, int verbose)
/*
* Configure peer verification based on environment.
*/
-#define LOCAL_CERT_FILE "/usr/local/etc/ssl/cert.pem"
+#define LOCAL_CERT_FILE _PATH_LOCALBASE "/etc/ssl/cert.pem"
#define BASE_CERT_FILE "/etc/ssl/cert.pem"
static int
fetch_ssl_setup_peer_verification(SSL_CTX *ctx, int verbose)
diff --git a/sbin/nvmecontrol/nvmecontrol.c b/sbin/nvmecontrol/nvmecontrol.c
index 03c026858ba1d..c88ea1ac29aab 100644
--- a/sbin/nvmecontrol/nvmecontrol.c
+++ b/sbin/nvmecontrol/nvmecontrol.c
@@ -179,7 +179,7 @@ main(int argc, char *argv[])
cmd_init();
cmd_load_dir("/lib/nvmecontrol", NULL, NULL);
- cmd_load_dir("/usr/local/lib/nvmecontrol", NULL, NULL);
+ cmd_load_dir(_PATH_LOCALBASE "/lib/nvmecontrol", NULL, NULL);
cmd_dispatch(argc, argv, NULL);
diff --git a/secure/lib/libssh/Makefile b/secure/lib/libssh/Makefile
index b325fe9d32d4f..aa3dc27fb5261 100644
--- a/secure/lib/libssh/Makefile
+++ b/secure/lib/libssh/Makefile
@@ -53,6 +53,10 @@ CFLAGS+= -include krb5_config.h
SRCS+= krb5_config.h
.endif
+.if defined(LOCALBASE)
+CFLAGS+= -D_PATH_SSH_ASKPASS_DEFAULT='"${LOCALBASE}/bin/ssh-askpass"'
+.endif
+
NO_LINT=
LIBADD+= crypto crypt z
diff --git a/secure/usr.bin/ssh-agent/Makefile b/secure/usr.bin/ssh-agent/Makefile
index 50eafa6ba6216..95ccd05811fe5 100644
--- a/secure/usr.bin/ssh-agent/Makefile
+++ b/secure/usr.bin/ssh-agent/Makefile
@@ -16,6 +16,10 @@ CFLAGS+= -DHAVE_LDNS=1
#LDADD+= -lldns
.endif
+.if defined(LOCALBASE)
+CFLAGS+= -DDEFAULT_PKCS11_WHITELIST='"/usr/lib*/*,${LOCALBASE}/lib*/*"'
+.endif
+
LIBADD+= crypto
.include <bsd.prog.mk>
diff --git a/tools/tools/ath/athprom/athprom.c b/tools/tools/ath/athprom/athprom.c
index e295fd1d70a17..1010c0bf5315a 100644
--- a/tools/tools/ath/athprom/athprom.c
+++ b/tools/tools/ath/athprom/athprom.c
@@ -41,12 +41,13 @@
#include <getopt.h>
#include <errno.h>
#include <err.h>
+#include <paths.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifndef DIR_TEMPLATE
-#define DIR_TEMPLATE "/usr/local/libdata/athprom"
+#define DIR_TEMPLATE _PATH_LOCALBASE "/libdata/athprom"
#endif
struct ath_diag atd;
diff --git a/tools/tools/net80211/wesside/wesside/wesside.c b/tools/tools/net80211/wesside/wesside/wesside.c
index 5d63dc421990b..d1e6fd8fe6d79 100644
--- a/tools/tools/net80211/wesside/wesside/wesside.c
+++ b/tools/tools/net80211/wesside/wesside/wesside.c
@@ -32,6 +32,7 @@
#include <netinet/ip.h>
#include <netinet/udp.h>
#include <arpa/inet.h>
+#include <paths.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -154,7 +155,7 @@ unsigned int min_prga = 128;
* XXX builtin pathnames
*/
#define CRACK_LOCAL_CMD "../aircrack/aircrack"
-#define CRACK_INSTALL_CMD "/usr/local/bin/aircrack"
+#define CRACK_INSTALL_CMD _PATH_LOCALBASE "/bin/aircrack"
#define INCR 10000
int thresh_incr = INCR;
diff --git a/usr.bin/fortune/fortune/pathnames.h b/usr.bin/fortune/fortune/pathnames.h
index 149b3e8d56b45..b6c9985ea8858 100644
--- a/usr.bin/fortune/fortune/pathnames.h
+++ b/usr.bin/fortune/fortune/pathnames.h
@@ -30,5 +30,7 @@
* $FreeBSD$
*/
+#include <paths.h>
+
#define FORTDIR "/usr/share/games/fortune:" \
- "/usr/local/share/games/fortune"
+ _PATH_LOCALBASE "/share/games/fortune"
diff --git a/usr.bin/mail/pathnames.h b/usr.bin/mail/pathnames.h
index ccccb497e91e5..e89c5288a11d0 100644
--- a/usr.bin/mail/pathnames.h
+++ b/usr.bin/mail/pathnames.h
@@ -33,8 +33,10 @@
* $FreeBSD$
*/
+#include <paths.h>
+
#define _PATH_EX "/usr/bin/ex"
#define _PATH_HELP "/usr/share/misc/mail.help"
#define _PATH_TILDE "/usr/share/misc/mail.tildehelp"
-#define _PATH_MASTER_RC "/usr/share/misc/mail.rc:/usr/local/etc/mail.rc:/etc/mail.rc"
+#define _PATH_MASTER_RC "/usr/share/misc/mail.rc:" _PATH_LOCALBASE "/etc/mail.rc:/etc/mail.rc"
#define _PATH_LESS "/usr/bin/less"
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
index d4f305fc2ff6e..77785313ff92b 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpimport.c
@@ -81,6 +81,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -148,7 +149,7 @@ static int32_t pbchar = -1;
static const char *paths[MAX_PATHS + 1] = {
"/usr/share/snmp/defs",
- "/usr/local/share/snmp/defs",
+ _PATH_LOCALBASE "/share/snmp/defs",
NULL
};
diff --git a/usr.sbin/cpucontrol/cpucontrol.c b/usr.sbin/cpucontrol/cpucontrol.c
index 31b1d165af308..09948cc95d6cb 100644
--- a/usr.sbin/cpucontrol/cpucontrol.c
+++ b/usr.sbin/cpucontrol/cpucontrol.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
+#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -59,7 +60,7 @@ __FBSDID("$FreeBSD$");
int verbosity_level = 0;
-#define DEFAULT_DATADIR "/usr/local/share/cpucontrol"
+#define DEFAULT_DATADIR _PATH_LOCALBASE "/share/cpucontrol"
#define FLAG_I 0x01
#define FLAG_M 0x02
diff --git a/usr.sbin/cron/cron/pathnames.h b/usr.sbin/cron/cron/pathnames.h
index e25519fa89eb8..b0edbd897a28c 100644
--- a/usr.sbin/cron/cron/pathnames.h
+++ b/usr.sbin/cron/cron/pathnames.h
@@ -59,7 +59,7 @@
/* 4.3BSD-style crontab */
#define SYSCRONTAB "/etc/crontab"
#define SYSCRONTABS "/etc/cron.d"
-#define LOCALSYSCRONTABS "/usr/local/etc/cron.d"
+#define LOCALSYSCRONTABS _PATH_LOCALBASE "/etc/cron.d"
/* what editor to use if no EDITOR or VISUAL
* environment variable specified.
diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c
index 1ad4053a843e5..8a9ec220a26b6 100644
--- a/usr.sbin/mailwrapper/mailwrapper.c
+++ b/usr.sbin/mailwrapper/mailwrapper.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <err.h>
+#include <paths.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -105,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") : "/usr/local");
+ getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE);
mailerconf = localmailerconf;
if ((config = fopen(localmailerconf, "r")) == NULL)
diff --git a/usr.sbin/pciconf/pathnames.h b/usr.sbin/pciconf/pathnames.h
index 61c0993bbb7c4..c35c721aa8384 100644
--- a/usr.sbin/pciconf/pathnames.h
+++ b/usr.sbin/pciconf/pathnames.h
@@ -1,4 +1,6 @@
/* $FreeBSD$ */
+#include <paths.h>
+
#define _PATH_DEVPCI "/dev/pci"
#define _PATH_PCIVDB "/usr/share/misc/pci_vendors"
-#define _PATH_LPCIVDB "/usr/local/share/pciids/pci.ids"
+#define _PATH_LPCIVDB _PATH_LOCALBASE "/share/pciids/pci.ids"
diff --git a/usr.sbin/pkg/config.c b/usr.sbin/pkg/config.c
index fc7df8d31dae9..a1dba3f2670ac 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 <paths.h>
#include <stdbool.h>
#include <unistd.h>
@@ -454,7 +455,7 @@ config_init(void)
}
/* Read LOCALBASE/etc/pkg.conf first. */
- localbase = getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE;
+ localbase = getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE;
snprintf(confpath, sizeof(confpath), "%s/etc/pkg.conf",
localbase);
diff --git a/usr.sbin/pkg/config.h b/usr.sbin/pkg/config.h
index a63997a7a60d3..f1a2aa227f16f 100644
--- a/usr.sbin/pkg/config.h
+++ b/usr.sbin/pkg/config.h
@@ -31,7 +31,8 @@
#ifndef _PKG_CONFIG_H
#define _PKG_CONFIG_H
-#define _LOCALBASE "/usr/local"
+#include <paths.h>
+
#define URL_SCHEME_PREFIX "pkg+"
typedef enum {
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index 50b196fd9b30a..3de789328c37c 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -1046,7 +1046,7 @@ main(int argc, char *argv[])
yes = false;
snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg",
- getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE);
+ getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE);
if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) {
bootstrap_only = true;