Skip to content

Commit 9c2358e

Browse files
CameronNemocnemo-cenic
authored andcommitted
fix(sysctl): behave more like sysctl --system
Loading of sysctl.d directories should follow the same ordering and overriding rules as xbps, modules-load, and most importantly, `sysctl --system`. This change ensures proper ordering of files loaded by building the selected files then operating on them, and it allows for masking system level configuration from /etc and even /run.
1 parent abd5e95 commit 9c2358e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

core-services/08-sysctl.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22

33
if [ -x /sbin/sysctl -o -x /bin/sysctl ]; then
44
msg "Loading sysctl(8) settings..."
5+
mkdir -p /run/vsysctl.d
56
for i in /run/sysctl.d/*.conf \
67
/etc/sysctl.d/*.conf \
78
/usr/local/lib/sysctl.d/*.conf \
8-
/usr/lib/sysctl.d/*.conf \
9-
/etc/sysctl.conf; do
9+
/usr/lib/sysctl.d/*.conf; do
1010

11-
if [ -e "$i" ]; then
12-
printf '* Applying %s ...\n' "$i"
13-
sysctl -p "$i"
11+
if [ -e "$i" ] && [ ! -e "/run/vsysctl.d/${i##*/}" ]; then
12+
ln -s "$i" "/run/vsysctl.d/${i##*/}"
1413
fi
1514
done
15+
for i in /run/vsysctl.d/*.conf; do
16+
sysctl -p "$i"
17+
done
18+
rm -rf -- /run/vsysctl.d
19+
sysctl -p /etc/sysctl.conf
1620
fi

0 commit comments

Comments
 (0)