commit b43e166e7f007e7b207a075254085c219b462ec2
parent b24d282175976b1aeeebb3c2830bce044bc1dcd9
Author: ccx <root@dorje.wpr.cz>
Date: Fri, 16 Sep 2022 18:38:15 +0200
Dev manager option selects content of dev-coldplug and ok-sysinit bundle
Diffstat:
6 files changed, 179 insertions(+), 76 deletions(-)
diff --git a/config.aat b/config.aat
@@ -11,6 +11,8 @@ getty_max=4
tty_setfont=ter-v14n
+dev_manager=udev
+
X_servers=[
svc vtN
X5 5
diff --git a/postinstall.aat b/postinstall.aat
@@ -93,6 +93,7 @@
/etc +
/etc/group +
|line_append_file("sshd:x", ":22:", "", "^[^:]*:[^:]*")
+|line_append_file("dhcpcd:x", ":546:", "", "^[^:]*:[^:]*")
|line_append_file("ccx:x", ":1000:", "", "^[^:]*:[^:]*")
# Groups for /dev permissions (mdevd.conf): disk, input, uucp
|line_append_file("disk:x", ":6:", "root,adm", "^[^:]*:[^:]*")
@@ -106,6 +107,9 @@
|passwd_user("sshd:x:22:22:sshd:/dev/null:/sbin/nologin")
|shadow_user("sshd:!::0:::::")
+|passwd_user("dhcpcd:x:546:546:sshd:/dev/null:/sbin/nologin")
+|shadow_user("dhcpcd:!::0:::::")
+
|passwd_user("ccx:x:1000:1000:Jan Pobrislo:/home/ccx:/bin/zsh")
|#shadow_user("ccx:*:10000::::::")
diff --git a/postinstall.fileset b/postinstall.fileset
@@ -7,6 +7,12 @@
else
printf '%s\n' 'sshd:x:22:' >> "$fname"
fi
+? grep -qEe '^dhcpcd:x:546:$' "$fname"
+! if grep -qEe '^[^:]*:[^:]*:546:' "$fname"; then
+ sed -ire 's|^[^:]*:[^:]*:546:|dhcpcd:x:546:|' "$fname"
+ else
+ printf '%s\n' 'dhcpcd:x:546:' >> "$fname"
+ fi
? grep -qEe '^ccx:x:1000:$' "$fname"
! if grep -qEe '^[^:]*:[^:]*:1000:' "$fname"; then
sed -ire 's|^[^:]*:[^:]*:1000:|ccx:x:1000:|' "$fname"
@@ -84,6 +90,52 @@
}'
/etc/passwd f +
+!f awk 'BEGIN { FS=OFS=":"; seen=0; line="dhcpcd:x:546:546:sshd:/dev/null:/sbin/nologin"; split(line, a) }
+ { uids[$3] = $0 }
+ $1 == a[1] {
+ for(n in a) {
+ if(a[n] != $n) {
+ print "error: differing present and requested lines" >>"/dev/stderr"
+ print "requested: " line >>"/dev/stderr"
+ print "present: " $0 >>"/dev/stderr"
+ exit 1
+ }
+ }
+ seen = 1
+ }
+ { print $0 }
+ END {
+ if(seen == 0) {
+ if(a[3] in uids) {
+ print "error: user record with requested UID already present" >>"/dev/stderr"
+ print "requested: " line >>"/dev/stderr"
+ print "present: " uids[a[3]] >>"/dev/stderr"
+ exit 1
+ }
+ print line
+ }
+ }'
+/etc/shadow f +
+!f awk 'BEGIN { FS=OFS=":"; seen=0; line="dhcpcd:!::0:::::"; split(line, a) }
+ $1 == a[1] {
+ for(n in a) {
+ if(a[n] != $n) {
+ print "error: differing present and requested lines" >>"/dev/stderr"
+ print "requested: " line >>"/dev/stderr"
+ print "present: " $0 >>"/dev/stderr"
+ exit 1
+ }
+ }
+ seen = 1
+ }
+ { print $0 }
+ END {
+ if(seen == 0) {
+ print line
+ }
+ }'
+
+/etc/passwd f +
!f awk 'BEGIN { FS=OFS=":"; seen=0; line="ccx:x:1000:1000:Jan Pobrislo:/home/ccx:/bin/zsh"; split(line, a) }
{ uids[$3] = $0 }
$1 == a[1] {
diff --git a/postinstall.rsfilter b/postinstall.rsfilter
@@ -4,3 +4,5 @@
+ /etc/passwd
+ /etc/shadow
+ /etc/passwd
++ /etc/shadow
++ /etc/passwd
diff --git a/s6-rc.aat b/s6-rc.aat
@@ -16,6 +16,27 @@
|function longrun(name, deps) {
| return service(name, "longrun", deps)
|}
+|function longrun_with_logger(name, deps) {
+| longrun(name "-log", "mount-run-cgroup2\nrootfs")
+/{{name}}-log/consumer-for cN {{name}} m640
+/{{name}}-log/run
+CN #!/command/execlineb -P
+ getpid SERVICE_PID
+ foreground {
+ importas -i SERVICE_PID SERVICE_PID
+ if { test -d /run/cgroup2 }
+ if { mkdir -p /run/cgroup2/s6-rc/{{name}}-log }
+ redirfd -w 1 /run/cgroup2/s6-rc/{{name}}-log/cgroup.procs
+ printf "%s" ${SERVICE_PID}
+ }
+ unexport SERVICE_PID
+
+ if { mkdir -p /var/log/{{name}} }
+ s6-log -b -- n10 s10240000 t /var/log/{{name}}
+m750
+| longrun(name, deps)
+/{{name}}/producer-for cN {{name}}-log m640
+|}
|function list_services_with_counter(base_name, suffix, list) {
| for(suffix = 0; suffix < svc_counter[base_name]; suffix++) {
| list = list base_name (suffix ? "-" suffix : "") "\n"
@@ -47,12 +68,8 @@ m644
|add_to_bundle("ok-all-but-tty", "net-all")
-/ok-sysinit d m755
-/ok-sysinit/type cN bundle m644
-/ok-sysinit/contents
-CN mount-sysinit
- dev-coldplug
-m644
+|add_to_bundle("ok-sysinit", "mount-sysinit")
+|add_to_bundle("ok-sysinit", "dev-coldplug")
|add_to_bundle("ok-all-but-tty", "ok-mount")
/ok-mount d m755
@@ -237,16 +254,16 @@ m755
@endfor
m755
-/dev-coldplug d m755
-/dev-coldplug/dependencies
-C mount-dev
- mount-sys
- mdevd
- modules
-m644
-/dev-coldplug/down c m644
-/dev-coldplug/type c oneshot m644
-/dev-coldplug/up c mdevd-coldplug m644
+|oneshot("mdevd-coldplug", "mount-dev\nmount-sys\nmodules\nmdevd")
+/mdevd-coldplug/up c mdevd-coldplug m644
+
+|oneshot("udev-coldplug", "mount-dev\nmount-sys\nmodules\nudev")
+/udev-coldplug/up c udevadm settle m644
+
+|if(get("dev_manager")) {
+|service("dev-coldplug", "bundle", (<dev_manager>)"-coldplug")
+|add_to_bundle("ok-sysinit", (<dev_manager>))
+|}
/mdevd d m755
/mdevd/type c longrun m644
@@ -257,7 +274,6 @@ C #!/command/execlineb -P
mdevd -D 3 -f /current/conf/etc/mdevd.conf
m755
-|#add_to_bundle("ok-all-but-tty", "udev")
/udev d m755
/udev/dependencies
CN mount-sys
@@ -430,9 +446,7 @@ CN export TERM "linux"
m644
|add_to_bundle("ok-all-but-tty", "svscan-ccx")
-/svscan-ccx d m750
-/svscan-ccx/type cN longrun m640
-/svscan-ccx-log d m750
+|longrun("svscan-ccx-log", "ok-sysinit\nrootfs")
/svscan-ccx-log/consumer-for cN svscan-ccx m640
/svscan-ccx-log/run
CN #!/command/execlineb -P
@@ -452,8 +466,8 @@ CN #!/command/execlineb -P
s6-setuidgid ccx
s6-log -- t /run/user/ccx.logs
m750
-/svscan-ccx-log/type cN longrun m640
-/svscan-ccx/dependencies cN m640
+
+|longrun("svscan-ccx", "ok-sysinit\nrootfs")
/svscan-ccx/notification-fd cN 3
m640
/svscan-ccx/producer-for cN svscan-ccx-log m640
@@ -478,27 +492,7 @@ CN #!/command/execlineb -P
m750
|add_to_bundle("ok-all-but-tty", "syncthing")
-/syncthing d m750
-/syncthing-log d m750
-/syncthing-log/consumer-for cN syncthing m640
-/syncthing-log/run
-CN #!/command/execlineb -P
- getpid SERVICE_PID
- foreground {
- importas -i SERVICE_PID SERVICE_PID
- if { test -d /run/cgroup2 }
- if { mkdir -p /run/cgroup2/s6-rc/syncthing-log }
- redirfd -w 1 /run/cgroup2/s6-rc/syncthing-log/cgroup.procs
- printf "%s" ${SERVICE_PID}
- }
- unexport SERVICE_PID
-
- if { mkdir -p /var/log/syncthing }
- s6-log -b -- n10 s10240000 t /var/log/syncthing
-m750
-/syncthing-log/type cN longrun m640
-/syncthing/dependencies cN ok-mount m640
-/syncthing/producer-for cN syncthing-log m640
+|longrun_with_logger("syncthing", "ok-mount")
/syncthing/run
CN #!/command/execlineb -P
getpid SERVICE_PID
@@ -515,14 +509,9 @@ CN #!/command/execlineb -P
s6-setuidgid syncthing
syncthing -logflags 0
m750
-/syncthing/type cN longrun m640
|add_to_bundle("net-all", "wpa_supplicant")
-/wpa_supplicant d m750
-/wpa_supplicant/dependencies
-CN modules
- udev
-m640
+|longrun_with_logger("wpa_supplicant", "modules\nok-sysinit")
/wpa_supplicant/run
CN #!/command/execlineb -P
getpid SERVICE_PID
@@ -539,7 +528,6 @@ CN #!/command/execlineb -P
-iwlan0
-c/etc/wpa_supplicant/wpa_supplicant.conf
m750
-/wpa_supplicant/type cN longrun m640
@for i in X_servers
diff --git a/s6-rc.fileset b/s6-rc.fileset
@@ -238,12 +238,6 @@ m644
-/ok-sysinit d m755
-/ok-sysinit/type cN bundle m644
-/ok-sysinit/contents
-CN mount-sysinit
- dev-coldplug
-m644
/ok-mount d m755
/ok-mount/type cN bundle m644
@@ -487,16 +481,31 @@ CN foreground { modprobe af_packet }
foreground { modprobe tun }
m755
-/dev-coldplug d m755
-/dev-coldplug/dependencies
+/mdevd-coldplug d m755
+/mdevd-coldplug/type cN oneshot m644
+/mdevd-coldplug/dependencies
C mount-dev
mount-sys
+ modules
mdevd
+m644
+/mdevd-coldplug/up c mdevd-coldplug m644
+
+/udev-coldplug d m755
+/udev-coldplug/type cN oneshot m644
+/udev-coldplug/dependencies
+C mount-dev
+ mount-sys
modules
+ udev
+m644
+/udev-coldplug/up c udevadm settle m644
+
+/dev-coldplug d m755
+/dev-coldplug/type cN bundle m644
+/dev-coldplug/contents
+C udev-coldplug
m644
-/dev-coldplug/down c m644
-/dev-coldplug/type c oneshot m644
-/dev-coldplug/up c mdevd-coldplug m644
/mdevd d m755
/mdevd/type c longrun m644
@@ -668,9 +677,12 @@ CN export TERM "linux"
s6-svscanctl -a /run/service
m644
-/svscan-ccx d m750
-/svscan-ccx/type cN longrun m640
-/svscan-ccx-log d m750
+/svscan-ccx-log d m755
+/svscan-ccx-log/type cN longrun m644
+/svscan-ccx-log/dependencies
+C ok-sysinit
+ rootfs
+m644
/svscan-ccx-log/consumer-for cN svscan-ccx m640
/svscan-ccx-log/run
CN #!/command/execlineb -P
@@ -690,8 +702,13 @@ CN #!/command/execlineb -P
s6-setuidgid ccx
s6-log -- t /run/user/ccx.logs
m750
-/svscan-ccx-log/type cN longrun m640
-/svscan-ccx/dependencies cN m640
+
+/svscan-ccx d m755
+/svscan-ccx/type cN longrun m644
+/svscan-ccx/dependencies
+C ok-sysinit
+ rootfs
+m644
/svscan-ccx/notification-fd cN 3
m640
/svscan-ccx/producer-for cN svscan-ccx-log m640
@@ -715,8 +732,12 @@ CN #!/command/execlineb -P
s6-svscan -d 3 /run/user/ccx/service
m750
-/syncthing d m750
-/syncthing-log d m750
+/syncthing-log d m755
+/syncthing-log/type cN longrun m644
+/syncthing-log/dependencies
+C mount-run-cgroup2
+ rootfs
+m644
/syncthing-log/consumer-for cN syncthing m640
/syncthing-log/run
CN #!/command/execlineb -P
@@ -733,8 +754,11 @@ CN #!/command/execlineb -P
if { mkdir -p /var/log/syncthing }
s6-log -b -- n10 s10240000 t /var/log/syncthing
m750
-/syncthing-log/type cN longrun m640
-/syncthing/dependencies cN ok-mount m640
+/syncthing d m755
+/syncthing/type cN longrun m644
+/syncthing/dependencies
+C ok-mount
+m644
/syncthing/producer-for cN syncthing-log m640
/syncthing/run
CN #!/command/execlineb -P
@@ -752,13 +776,36 @@ CN #!/command/execlineb -P
s6-setuidgid syncthing
syncthing -logflags 0
m750
-/syncthing/type cN longrun m640
-/wpa_supplicant d m750
+/wpa_supplicant-log d m755
+/wpa_supplicant-log/type cN longrun m644
+/wpa_supplicant-log/dependencies
+C mount-run-cgroup2
+ rootfs
+m644
+/wpa_supplicant-log/consumer-for cN wpa_supplicant m640
+/wpa_supplicant-log/run
+CN #!/command/execlineb -P
+ getpid SERVICE_PID
+ foreground {
+ importas -i SERVICE_PID SERVICE_PID
+ if { test -d /run/cgroup2 }
+ if { mkdir -p /run/cgroup2/s6-rc/wpa_supplicant-log }
+ redirfd -w 1 /run/cgroup2/s6-rc/wpa_supplicant-log/cgroup.procs
+ printf "%s" ${SERVICE_PID}
+ }
+ unexport SERVICE_PID
+
+ if { mkdir -p /var/log/wpa_supplicant }
+ s6-log -b -- n10 s10240000 t /var/log/wpa_supplicant
+m750
+/wpa_supplicant d m755
+/wpa_supplicant/type cN longrun m644
/wpa_supplicant/dependencies
-CN modules
- udev
-m640
+C modules
+ ok-sysinit
+m644
+/wpa_supplicant/producer-for cN wpa_supplicant-log m640
/wpa_supplicant/run
CN #!/command/execlineb -P
getpid SERVICE_PID
@@ -775,7 +822,6 @@ CN #!/command/execlineb -P
-iwlan0
-c/etc/wpa_supplicant/wpa_supplicant.conf
m750
-/wpa_supplicant/type cN longrun m640
/X5 d m750
@@ -907,6 +953,15 @@ C net-all
m644
+/ok-sysinit d m755
+/ok-sysinit/type cN bundle m644
+/ok-sysinit/contents
+C mount-sysinit
+ dev-coldplug
+ udev
+
+m644
+
/net-all d m755
/net-all/type cN bundle m644
/net-all/contents