Author: se
Date: Tue Nov  3 12:29:10 2020
New Revision: 367294
URL: https://svnweb.freebsd.org/changeset/base/367294

Log:
  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

Modified:
  head/libexec/rc/rc
  head/libexec/rc/rc.conf

Modified: head/libexec/rc/rc
==============================================================================
--- head/libexec/rc/rc  Tue Nov  3 12:15:08 2020        (r367293)
+++ head/libexec/rc/rc  Tue Nov  3 12:29:10 2020        (r367294)
@@ -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

Modified: head/libexec/rc/rc.conf
==============================================================================
--- head/libexec/rc/rc.conf     Tue Nov  3 12:15:08 2020        (r367293)
+++ head/libexec/rc/rc.conf     Tue Nov  3 12:29:10 2020        (r367294)
@@ -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 /v
 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 
 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 
 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))
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to