aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2022-09-09 13:08:43 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2022-11-02 15:51:05 +0000
commit73ab1c87c208dbb0609be572eb31591353d71e07 (patch)
treec23736cd5a3d6259822e3c237e1e7a5d528003e1
parentdf5c24d590895801e3d62494e1a350f4fed6a4f6 (diff)
sh: read more profile files.
Differential Revision: https://reviews.freebsd.org/D36505 MFC after: 1 month (cherry picked from commit 497cdf9673ec53d59634bb78862cd8dea3d5c155) sh: when loading profile, skip obvious scratch files. Differential Revision: https://reviews.freebsd.org/D36856 (cherry picked from commit d3890a547d201d1f5043e51baa406ac9d5d3a60a) sh: when loading profile, read only .sh files. Reviewers: jilles, eugen_grosbein.net, cy Subscribers: imp Differential Revision: https://reviews.freebsd.org/D37034 (cherry picked from commit 8d7221ca2dd5e0b6c633761b314cffed82ddca72) (cherry picked from commit 4ea49af3afe127c424a1b843617225fd437b51d1) Approved by: re (gjb)
-rw-r--r--bin/sh/profile20
-rw-r--r--etc/mtree/BSD.root.dist2
2 files changed, 22 insertions, 0 deletions
diff --git a/bin/sh/profile b/bin/sh/profile
index b77c8787c79d..5b8a57d4b7b2 100644
--- a/bin/sh/profile
+++ b/bin/sh/profile
@@ -12,3 +12,23 @@
# msgs -q
# Allow terminal messages
# mesg y
+
+# Load each .sh file in /etc/profile.d/, then /usr/local/etc/profile,
+# then each .sh file in /usr/local/etc/profile.d/.
+_loaded=${_loaded:-/etc/profile}
+export _loaded
+for _dir in /etc /usr/local/etc ; do
+ for _file in "${_dir}"/profile "${_dir}"/profile.d/*.sh ; do
+ if [ -f "${_file}" ] ; then
+ case :${_loaded}: in
+ *:"${_file}":*)
+ ;;
+ *)
+ _loaded="${_loaded:+${_loaded}:}${_file}"
+ . "${_file}"
+ ;;
+ esac
+ fi
+ done
+done
+unset _loaded _dir _file
diff --git a/etc/mtree/BSD.root.dist b/etc/mtree/BSD.root.dist
index cba3e9e73c79..0c70b11eed4e 100644
--- a/etc/mtree/BSD.root.dist
+++ b/etc/mtree/BSD.root.dist
@@ -74,6 +74,8 @@
..
ppp
..
+ profile.d
+ ..
rc.conf.d
..
rc.d