From 08867050c9339cd21d4ca1ea12ad88e37db1f60e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20E=C3=9Fer?= Date: Tue, 3 Nov 2020 12:29:10 +0000 Subject: [PATCH] Replace literal uses of /usr/local with a variable The variable defaults to "/usr/local", unless sysctl returns some other value for "user.localbase". The value of user.localbase defaults to _PATH_LOCALBASE as defined in paths.h and thus this commit has no immediate effect. The purpose of this change is to make /etc/defaults/rc.conf automatically use the value of _PATH_LOCALBASE when not set to the default value. Reviewed by: imp, scottl MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D27014 --- libexec/rc/rc | 2 ++ libexec/rc/rc.conf | 17 ++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libexec/rc/rc b/libexec/rc/rc index 69edcf4ac9f..35db4a85051 100644 --- a/libexec/rc/rc +++ b/libexec/rc/rc @@ -59,6 +59,8 @@ else _boot="quietstart" fi +_localbase=`/sbin/sysctl -n user.localbase 2> /dev/null` + dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` if [ ${dlv:=0} -ne 0 -o -f /etc/diskless ]; then sh /etc/rc.initdiskless diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 4d9406cf73c..5c58c00dd5e 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -21,6 +21,9 @@ ### Important initial Boot-time options #################### ############################################################## +# Set default value of _localbase if not previously set +: ${_localbase:="/usr/local"} + # rc_debug can't be set here without interferring with rc.subr's setting it # when the kenv variable rc.debug is set. #rc_debug="NO" # Set to YES to enable debugging output from rc.d @@ -58,7 +61,7 @@ varmfs_flags="-S" # Extra mount options for the mfs /var mfs_type="auto" # "md", "tmpfs", "auto" to prefer tmpfs with md as fallback populate_var="AUTO" # Set to YES to always (re)populate /var, NO to never cleanvar_enable="YES" # Clean the /var directory -local_startup="/usr/local/etc/rc.d" # startup script dirs. +local_startup="${_localbase}/etc/rc.d" # startup script dirs. script_name_sep=" " # Change if your startup scripts' names contain spaces rc_conf_files="/etc/rc.conf /etc/rc.conf.local" @@ -188,7 +191,7 @@ ipfw_netflow_enable="NO" # Enable netflow logging via ng_netflow ip_portrange_first="NO" # Set first dynamically allocated port ip_portrange_last="NO" # Set last dynamically allocated port ike_enable="NO" # Enable IKE daemon (usually racoon or isakmpd) -ike_program="/usr/local/sbin/isakmpd" # Path to IKE daemon +ike_program="${_localbase}/sbin/isakmpd" # Path to IKE daemon ike_flags="" # Additional flags for IKE daemon ipsec_enable="NO" # Set to YES to run setkey on ipsec_file ipsec_file="/etc/ipsec.conf" # Name of config file for setkey @@ -647,19 +650,19 @@ linux_mounts_enable="YES" # If linux_enable is set to YES, mount Linux-specific clear_tmp_enable="NO" # Clear /tmp at startup. clear_tmp_X="YES" # Clear and recreate X11-related directories in /tmp ldconfig_insecure="NO" # Set to YES to disable ldconfig security checks -ldconfig_paths="/usr/lib/compat /usr/local/lib /usr/local/lib/compat/pkg" +ldconfig_paths="/usr/lib/compat ${_localbase}/lib ${_localbase}/lib/compat/pkg" # shared library search paths ldconfig32_paths="/usr/lib32 /usr/lib32/compat" # 32-bit compatibility shared library search paths -ldconfigsoft_paths="/usr/libsoft /usr/libsoft/compat /usr/local/libsoft" +ldconfigsoft_paths="/usr/libsoft /usr/libsoft/compat ${_localbase}/libsoft" # soft float compatibility shared library search paths # Note: temporarily with extra stuff for transition -ldconfig_local_dirs="/usr/local/libdata/ldconfig" +ldconfig_local_dirs="${_localbase}/libdata/ldconfig" # Local directories with ldconfig configuration files. -ldconfig_local32_dirs="/usr/local/libdata/ldconfig32" +ldconfig_local32_dirs="${_localbase}/libdata/ldconfig32" # Local directories with 32-bit compatibility ldconfig # configuration files. -ldconfig_localsoft_dirs="/usr/local/libdata/ldconfigsoft" +ldconfig_localsoft_dirs="${_localbase}/libdata/ldconfigsoft" # Local directories with soft float compatibility ldconfig # configuration files. kern_securelevel_enable="NO" # kernel security level (see security(7)) -- 2.45.0