On Wed, Nov 23, 2022 at 11:35:32AM +0100, Martijn van Duren wrote: > On Wed, 2022-11-23 at 10:03 +0000, Klemens Nanni wrote: > > On Wed, Nov 23, 2022 at 10:48:22AM +0100, Martijn van Duren wrote: > > > On Wed, 2022-11-23 at 09:25 +0000, Klemens Nanni wrote: > > > > On Wed, Nov 23, 2022 at 10:15:20AM +0100, Martijn van Duren wrote: > > > > > Here's an attempt to remove sed from netstart. > > > > > > > > I don't see the point in this. > > > > > > On Mon, 2022-11-21 at 20:42 -0700, Theo de Raadt wrote: > > > > Oh, except that using grep, head, or awk. That breaks NFS diskless > > > > machines, because they are in /usr, which may not be mounted yet. > > > > > > > > So this has to be done using shell features or commands in /bin and > > > > /sbin. > > > > You will see these interesting hacks in other parts of rc and netstart. > > > > > > > > > > > > > > https://marc.info/?l=openbsd-misc&m=166908823920806&w=2 > > > > Ah, NFS /usr. > > > > Instead of rolling our own shell functions, maybe this is a good reason > > to implement ${parameter/pattern/string} in ksh(1)? > > > > This should make shell scripting in base a lot easier where awk/sed is > > not available; the installer could probably use this as well. > > > > At least Bash has this (and other pattern substitution) syntax. > > > Maybe... I'm not a big fan of feature-bloat in the shell and this > function is small enough, so personally I see no reason. But if you > write it and no one else objects why not... >
If warranted, your netstart/sed case reads like a valid use case for such a ksh feature, which I wouldn't describe as bloat at this point. But looking at rc(8) again, I see this: 449 mount -s /var >/dev/null 2>&1 # cannot be on NFS 450 mount -s /var/log >/dev/null 2>&1 # cannot be on NFS 451 mount -s /usr >/dev/null 2>&1 # if NFS, fstab must use IP address 452 453 start_daemon slaacd dhcpleased resolvd >/dev/null 2>&1 454 455 echo 'starting network' 456 457 # Set carp interlock by increasing the demotion counter. 458 # Prevents carp from preempting until the system is booted. 459 ifconfig -g carp carpdemote 128 460 461 sh /etc/netstart ... 617 [[ -f /etc/rc.local ]] && sh /etc/rc.local It mounts /usr before running /etc/netstart. Can someone elaborate where/when/how/why we run netstart(8) without /usr/ mounted? Is it for setups where rc's line 451 is expected to fail silently, netstart runs and /usr gets mounted late in rc.local or so?