Re: mountcritlocal rcorder (Was: Restrict mtree to specific directories)

2020-06-07 Thread Martin Husemann
I implemented the split and it works nicely for me.

I can now just add things like "populate_var" into rc.d which REQUIRE:
mountcritlocal and have BEFORE: MOUNTCRITLOCAL to fill the /var tmpfs
that has just been mounted.

While there I found that random_seed play special tricks and we might
consider moving it in this new section as well, or add another stage
in between, like:

mountcritlocal -> [various] -> MOUNTCRITLOCAL1
 -> random_seed -> MOUNTCRITLOCAL

Martin
Index: distrib/sets/lists/etc/mi
===
RCS file: /cvsroot/src/distrib/sets/lists/etc/mi,v
retrieving revision 1.259
diff -u -p -r1.259 mi
--- distrib/sets/lists/etc/mi   15 Sep 2019 19:38:08 -  1.259
+++ distrib/sets/lists/etc/mi   7 Jun 2020 19:21:19 -
@@ -200,6 +200,7 @@
 ./etc/rc.d/btuartd etc-obsoleteobsolete
 ./etc/rc.d/ccd etc-sys-rc
 ./etc/rc.d/cgd etc-sys-rc
+./etc/rc.d/clearcritlocal  etc-sys-rc
 ./etc/rc.d/cleartmpetc-sys-rc
 ./etc/rc.d/cronetc-cron-rc
 ./etc/rc.d/devpubd etc-sys-rc
@@ -242,6 +243,7 @@
 ./etc/rc.d/lkm1etc-obsolete
obsolete
 ./etc/rc.d/lkm2etc-obsolete
obsolete
 ./etc/rc.d/lkm3etc-obsolete
obsolete
+./etc/rc.d/llvmlockdir etc-sys-rc
 ./etc/rc.d/local   etc-sys-rc
 ./etc/rc.d/lpd etc-lpr-rc
 ./etc/rc.d/lvm etc-sys-rc
@@ -253,6 +255,7 @@
 ./etc/rc.d/motdetc-sys-rc
 ./etc/rc.d/mountalletc-sys-rc
 ./etc/rc.d/mountcritlocal  etc-sys-rc
+./etc/rc.d/MOUNTCRITLOCAL  etc-sys-rc
 ./etc/rc.d/mountcritremote etc-sys-rc
 ./etc/rc.d/mountd  etc-nfsserver-rc
 ./etc/rc.d/moused  etc-sysutil-rc
Index: etc/rc.d/MOUNTCRITLOCAL
===
RCS file: etc/rc.d/MOUNTCRITLOCAL
diff -N etc/rc.d/MOUNTCRITLOCAL
--- /dev/null   1 Jan 1970 00:00:00 -
+++ etc/rc.d/MOUNTCRITLOCAL 7 Jun 2020 19:21:19 -
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# $NetBSD: NETWORKING,v 1.2 2002/03/22 04:33:57 thorpej Exp $
+#
+
+# REQUIRE: mountcritlocal
+# PROVIDE: MOUNTCRITLOCAL
+
+#  This is a dummy dependency, for services which require local
+#  disks to be mounted and fully setup
Index: etc/rc.d/Makefile
===
RCS file: /cvsroot/src/etc/rc.d/Makefile,v
retrieving revision 1.106
diff -u -p -r1.106 Makefile
--- etc/rc.d/Makefile   18 Sep 2019 05:16:15 -  1.106
+++ etc/rc.d/Makefile   7 Jun 2020 19:21:19 -
@@ -17,7 +17,7 @@ CONFIGFILES=\
DAEMON DISKS LOGIN NETWORKING SERVERS \
accounting altqd amd apmd automount automountd autounmountd \
bluetooth bootconf.sh bootparams \
-   ccd cgd cleartmp cron \
+   ccd cgd clearcritlocal cleartmp cron \
devpubd dhcpcd dhcpd dhcpd6 dhcrelay dmesg \
downinterfaces \
envsys \
@@ -27,9 +27,10 @@ CONFIGFILES=\
identd ifwatchd inetd ip6addrctl ipfilter ipfs ipmon ipnat \
ipsec irdaattach iscsi_target iscsid isibootd \
kdc \
-   ldconfig ldpd local lpd lvm \
+   ldconfig ldpd llvmlockdir local lpd lvm \
makemandb mdnsd mixerctl modules mopd motd mountall \
-   mountcritlocal mountcritremote mountd moused mrouted \
+   mountcritlocal MOUNTCRITLOCAL \
+   mountcritremote mountd moused mrouted \
named ndbootd network newsyslog nfsd nfslocking npf npf_boot \
npfd ntpd ntpdate \
perusertmp pf pf_boot pflogd postfix powerd ppp pwcheck \
Index: etc/rc.d/bootconf.sh
===
RCS file: /cvsroot/src/etc/rc.d/bootconf.sh,v
retrieving revision 1.15
diff -u -p -r1.15 bootconf.sh
--- etc/rc.d/bootconf.sh31 Dec 2012 23:21:27 -  1.15
+++ etc/rc.d/bootconf.sh7 Jun 2020 19:21:19 -
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: bootconf
-# REQUIRE: mountcritlocal
+# REQUIRE: MOUNTCRITLOCAL
 # KEYWORD: interactive
 
 $_rc_subr_loaded . /etc/rc.subr
Index: etc/rc.d/clearcritlocal
===
RCS file: etc/rc.d/clearcritlocal
diff -N etc/rc.d/clearcritlocal
--- /dev/null   1 Jan 1970 00:00:00 -
+++ etc/rc.d/clearcritlocal 7 Jun 2020 19:21:1

mountcritlocal rcorder (Was: Restrict mtree to specific directories)

2020-06-03 Thread Martin Husemann
On Thu, Jun 04, 2020 at 05:48:34AM +0700, Robert Elz wrote:
> And of course, I should have really read mtree(1) before replying,
> so the suggested method would just be
> 
>   grep whatever original-spec-file [ | grep otherstuff ] | mtree

I ended up not using mtree for this, as it was getting more complex than
I initialy thought. I replaced it with a simple tar extraction at the
right point. I have slight trouble defining that "right point" properly
in rcorder terms though.

I think /etc/rc.d/mountcritlocal should be split, into the "real
mountcritlocal" stuff and all the cleanup happening directly after,
including the llvm lock dir setup, being moved into separate scripts
"somehow" - so we could have additional scripts added (like my tar
extraction) that get run in between.

Something like: create an empty dummy script (doing nothing) as a sentinel
that provides "mountcritlocal" and requires "mountcritlocal_mount", move
the real part of current mountcritlocal to mountcritlocal_mount, move
the llvm and cleanup stuff to separate scripts that all require
mountcritlocal_mount and have BEFORE mountcritlocal.

Martin