Re: allow KARL with config(8)'d kernels

2021-09-07 Thread Paul de Weerd
On Tue, Sep 07, 2021 at 07:57:55PM +0200, Robert Nagy wrote:
| On 07/09/21 19:31 +0200, Paul de Weerd wrote:
| > Hi all,
| > 
| > On Tue, Sep 07, 2021 at 02:30:43PM +0200, Robert Nagy wrote:
| > | /etc/reorder_kernel.conf
| > 
| > Thank you for your suggest Robert!  In the mean time, I've had a few
| > more off-list comments about this proposal - generally favorable, but
| > no better suggestions have come along.  After some more off-list
| > discussion, I'm now proposing the below diff.  It uses Theo's original
| > suggestion of /etc/bsd.re-config.
| 
| Hi
| 
| I would prefer to have -f in both tests, because install.sub is using -e
| now.

Ugh - my bad, sorry.

Fixed:


Index: libexec/reorder_kernel/reorder_kernel.sh
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/reorder_kernel.sh,v
retrieving revision 1.9
diff -u -p -r1.9 reorder_kernel.sh
--- libexec/reorder_kernel/reorder_kernel.sh28 Sep 2019 17:30:07 -  
1.9
+++ libexec/reorder_kernel/reorder_kernel.sh7 Sep 2021 16:12:07 -
@@ -63,6 +63,7 @@ fi
 
 cd $KERNEL_DIR/$KERNEL
 make newbsd
+[ -f /etc/bsd.re-config ] && config -e -c /etc/bsd.re-config -f bsd
 make newinstall
 sync
 
Index: libexec/reorder_kernel/bsd.re-config.5
===
RCS file: libexec/reorder_kernel/bsd.re-config.5
diff -N libexec/reorder_kernel/bsd.re-config.5
--- /dev/null   1 Jan 1970 00:00:00 -
+++ libexec/reorder_kernel/bsd.re-config.5  7 Sep 2021 16:16:28 -
@@ -0,0 +1,46 @@
+.\"$OpenBSD$
+.\"
+.\" Copyright (c) 2021 Paul de Weerd 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate: August 24 2021 $
+.Dt KERNEL.CONF 5
+.Os
+.Sh NAME
+.Nm bsd.re-config
+.Nd kernel configuration file
+.Sh DESCRIPTION
+The
+.Nm
+file contains configuration information for the kernel.
+If present, it is used during system startup to configure the kernel
+that will be running at the next boot.
+It can be used to enable or disable specific devices in the kernel.
+.Sh EXAMPLES
+To enable the
+.Xr ipmi 4
+driver, add the following line to
+.Nm :
+.Pp
+.Dl enable ipmi
+.Pp
+See 
+.Xr config 8
+for more details on how to configure the kernel.
+.Sh FILES
+.Bl -tag -width /etc/bsd.re-config -compact
+.It Pa /etc/bsd.re-config
+Kernel configuration file.
+.Sh SEE ALSO
+.Xr config 8
Index: libexec/reorder_kernel/Makefile
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- libexec/reorder_kernel/Makefile 21 Aug 2017 21:24:11 -  1.1
+++ libexec/reorder_kernel/Makefile 7 Sep 2021 16:11:13 -
@@ -1,6 +1,7 @@
 #  $OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
 
 SCRIPT=reorder_kernel.sh
+MAN=   bsd.re-config.5
 
 realinstall:
${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
Index: distrib/miniroot/install.sub
===
RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1175
diff -u -p -r1.1175 install.sub
--- distrib/miniroot/install.sub29 Aug 2021 13:31:52 -  1.1175
+++ distrib/miniroot/install.sub7 Sep 2021 18:00:52 -
@@ -2857,7 +2857,10 @@ finish_up() {
tar -C $_kernel_dir -xzf $_kernel_dir.tgz $_kernel
rm -f $_kernel_dir.tgz
chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
-   make newbsd; make newinstall"
+   make newbsd; \
+   [ -f /etc/bsd.re-config ] && \
+   config -e -c /etc/bsd.re-config -f bsd; \
+   make newinstall"
) >/dev/null 2>&1 && echo " done." || echo " failed."
fi
 
Index: etc/changelist
===
RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
retrieving revision 1.128
diff -u -p -r1.128 changelist
--- etc/changelist  30 Jul 2021 07:00:02 -  1.128
+++ etc/changelist  7 Sep 2021 16:10:53 -
@@ -14,6 +14,7 @@
 /etc/bgpd.conf
 /etc/boot.conf
 

Re: allow KARL with config(8)'d kernels

2021-09-07 Thread Robert Nagy
On 07/09/21 19:31 +0200, Paul de Weerd wrote:
> Hi all,
> 
> On Tue, Sep 07, 2021 at 02:30:43PM +0200, Robert Nagy wrote:
> | /etc/reorder_kernel.conf
> 
> Thank you for your suggest Robert!  In the mean time, I've had a few
> more off-list comments about this proposal - generally favorable, but
> no better suggestions have come along.  After some more off-list
> discussion, I'm now proposing the below diff.  It uses Theo's original
> suggestion of /etc/bsd.re-config.

Hi

I would prefer to have -f in both tests, because install.sub is using -e
now.
.



Re: allow KARL with config(8)'d kernels

2021-09-07 Thread Paul de Weerd
Hi all,

On Tue, Sep 07, 2021 at 02:30:43PM +0200, Robert Nagy wrote:
| /etc/reorder_kernel.conf

Thank you for your suggest Robert!  In the mean time, I've had a few
more off-list comments about this proposal - generally favorable, but
no better suggestions have come along.  After some more off-list
discussion, I'm now proposing the below diff.  It uses Theo's original
suggestion of /etc/bsd.re-config.

The diff includes:

- the change to reorder_kernel, including a manpage for the file
- the change to install.sub, so it works across installs and upgrades
- references to the new manpage from config(8) and boot_config(8)
- the changelist addition

Any further feedback?

Thanks,

Paul

Index: libexec/reorder_kernel/reorder_kernel.sh
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/reorder_kernel.sh,v
retrieving revision 1.9
diff -u -p -r1.9 reorder_kernel.sh
--- libexec/reorder_kernel/reorder_kernel.sh28 Sep 2019 17:30:07 -  
1.9
+++ libexec/reorder_kernel/reorder_kernel.sh7 Sep 2021 16:12:07 -
@@ -63,6 +63,7 @@ fi
 
 cd $KERNEL_DIR/$KERNEL
 make newbsd
+[ -f /etc/bsd.re-config ] && config -e -c /etc/bsd.re-config -f bsd
 make newinstall
 sync
 
Index: libexec/reorder_kernel/bsd.re-config.5
===
RCS file: libexec/reorder_kernel/bsd.re-config.5
diff -N libexec/reorder_kernel/bsd.re-config.5
--- /dev/null   1 Jan 1970 00:00:00 -
+++ libexec/reorder_kernel/bsd.re-config.5  7 Sep 2021 16:16:28 -
@@ -0,0 +1,46 @@
+.\"$OpenBSD$
+.\"
+.\" Copyright (c) 2021 Paul de Weerd 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate: August 24 2021 $
+.Dt KERNEL.CONF 5
+.Os
+.Sh NAME
+.Nm bsd.re-config
+.Nd kernel configuration file
+.Sh DESCRIPTION
+The
+.Nm
+file contains configuration information for the kernel.
+If present, it is used during system startup to configure the kernel
+that will be running at the next boot.
+It can be used to enable or disable specific devices in the kernel.
+.Sh EXAMPLES
+To enable the
+.Xr ipmi 4
+driver, add the following line to
+.Nm :
+.Pp
+.Dl enable ipmi
+.Pp
+See 
+.Xr config 8
+for more details on how to configure the kernel.
+.Sh FILES
+.Bl -tag -width /etc/bsd.re-config -compact
+.It Pa /etc/bsd.re-config
+Kernel configuration file.
+.Sh SEE ALSO
+.Xr config 8
Index: libexec/reorder_kernel/Makefile
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- libexec/reorder_kernel/Makefile 21 Aug 2017 21:24:11 -  1.1
+++ libexec/reorder_kernel/Makefile 7 Sep 2021 16:11:13 -
@@ -1,6 +1,7 @@
 #  $OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
 
 SCRIPT=reorder_kernel.sh
+MAN=   bsd.re-config.5
 
 realinstall:
${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
Index: distrib/miniroot/install.sub
===
RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1175
diff -u -p -r1.1175 install.sub
--- distrib/miniroot/install.sub29 Aug 2021 13:31:52 -  1.1175
+++ distrib/miniroot/install.sub7 Sep 2021 16:10:30 -
@@ -2857,7 +2857,10 @@ finish_up() {
tar -C $_kernel_dir -xzf $_kernel_dir.tgz $_kernel
rm -f $_kernel_dir.tgz
chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
-   make newbsd; make newinstall"
+   make newbsd; \
+   [ -e /etc/bsd.re-config ] && \
+   config -e -c /etc/bsd.re-config -f bsd; \
+   make newinstall"
) >/dev/null 2>&1 && echo " done." || echo " failed."
fi
 
Index: etc/changelist
===
RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
retrieving revision 1.128
diff -u -p -r1.128 changelist
--- etc/changelist  30 Jul 2021 07:00:02 -  1.128
+++ etc/changelist  7 Sep 2021 16:10:53 -
@@ -14,6 +14,7 @@
 /etc/bgpd.conf
 

Re: allow KARL with config(8)'d kernels

2021-09-07 Thread Robert Nagy
On 29/08/21 08:10 -0600, Theo de Raadt wrote:
> Ingo Schwarze  wrote:
> 
> > One - admittedly completely unUNIXy - way would be to invent a long,
> > descriptive name like /etc/kernel.config.commands or even /bsd.config.cmd
> > in the root rather than the /etc directory, which is more discoverable
> > because it is right next to the kernel itself.  The UNIXy way
> > is not necessarily better: Ken would have invented a very short,
> > pronouncable name that is not an English word but similar to one,
> > like /etc/sycoc (for SYstem COnfiguration Commands).
> 
> I have no idea why you talk about Ken, how obscure
> 
> back in those days it wasn't called /kernel, either.
> 
> the pathname "kernel.something" which is supposed to be somewhat
> related to a non-existant pathname "kernel", is what I object to.
> 
> perhaps /etc/bsd.re-config
> 
> but certainly the sub-phrase "kernel" is not discoverable.
> 

/etc/reorder_kernel.conf



Re: allow KARL with config(8)'d kernels

2021-08-31 Thread Paul de Weerd
Thank you for the suggestion Theo, I tried to update those two pages,
but a better name did not occur to me.  If anything it points at an
issue in the boot_config page which currently states: 

"Changes made can be saved for the next reboot, by using config(8)."

Although true, this breaks KARL with the user non the wiser (they may
not even be aware of the feature in the first place).  The diff below
talks a little bit about kernel relinking; I'm not sure it should (I
don't think there's mention of this elsewhere .. should it be left
out?).

Anyway, I'm a bit stuck with this project now.  Perhaps Theo's
suggestion /etc/bsd.re-config [1] is the best way to go?  The age-old
axiom of "only two hard problems in computer science" persists:
off-by-one's, cache invalidation .. and naming things :-/

Paul

[1]: https://marc.info/?l=openbsd-tech=163024631923964=2

Index: ./usr.sbin/config/config.8
===
RCS file: /home/OpenBSD/cvs/src/usr.sbin/config/config.8,v
retrieving revision 1.71
diff -u -p -r1.71 config.8
--- ./usr.sbin/config/config.8  8 Mar 2021 02:47:29 -   1.71
+++ ./usr.sbin/config/config.8  31 Aug 2021 19:17:43 -
@@ -65,6 +65,11 @@ Similarly, the same editing can be done 
 using the in-kernel editor,
 as described in
 .Xr boot_config 8 .
+Note that any such edits will be lost during upgrades and prevent a newly
+linked kernel from being installed at boot time.
+For such cases, this process can also be automated during boot using the
+.Xr kernel.conf 5
+configuration file.
 .Pp
 For kernel building, the options are as follows:
 .Bl -tag -width Ds
@@ -436,6 +441,7 @@ was given, else ignore changes).
 .Sh SEE ALSO
 .Xr options 4 ,
 .Xr files.conf 5 ,
+.Xr kernel.conf 5,
 .Xr boot.conf 8 ,
 .Xr boot_config 8
 .Pp
Index: ./share/man/man8/boot_config.8
===
RCS file: /home/OpenBSD/cvs/src/share/man/man8/boot_config.8,v
retrieving revision 1.31
diff -u -p -r1.31 boot_config.8
--- ./share/man/man8/boot_config.8  6 Sep 2019 21:30:32 -   1.31
+++ ./share/man/man8/boot_config.8  31 Aug 2021 19:17:20 -
@@ -60,6 +60,12 @@ UKC>
 .Pp
 Changes made can be saved for the next reboot, by using
 .Xr config 8 .
+However, those would not be persisted across system upgrades and would
+prevent kernel relinking.
+To ensure these changes are carried over to upgraded kernels, they can
+be save to the
+.Xr kernel.conf 5
+configuration file.
 .Sh COMMANDS
 .Bl -tag -width "disable devno | dev"
 .It Ic add Ar dev
@@ -189,6 +195,7 @@ Continuing...
 mainbus0 (root)
 .Ed
 .Sh SEE ALSO
+.Xr kernel.conf 5
 .Xr config 8
 .Sh AUTHORS
 .An Mats O Jansson Aq Mt m...@stacken.kth.se

On Sun, Aug 29, 2021 at 07:30:02AM -0600, Theo de Raadt wrote:
| man -k kernel, and man -k ukc, both suggest these are poor names
| for different reasons.
| 
| maybe if you write some diffs to hint at the existance of this mechanism
| in the config(8) and boot_config(8) manual pages, a better name will
| sneak up on us.
| 
| Paul de Weerd  wrote:
| 
| > Hi Theo,
| > 
| > That's a good point, but I have no better alternative.  kernel.conf
| > was the best I could come up with, as it is a configuration file for
| > the (installed) kernel.  I briefly considered:
| > 
| > - config.conf (after config(8), but seems hilariously worse to me)
| > - ukc.conf (has similar (perhaps even stronger) issues as kernel.conf)
| > 
| > Do others have a good suggestion for the color of this particular bike
| > shed?  Open to suggestions!
| > 
| > Paul
| > 
| > On Sun, Aug 29, 2021 at 07:15:34AM -0600, Theo de Raadt wrote:
| > | I am not thrilled with the name "kernel.conf".
| > | 
| > | It does not seem intuitively discoverable.
| > | 
| > | Paul de Weerd  wrote:
| > | 
| > | > Got some more positive feedback off-list, which reminded me that
| > | > there's a small piece missing:
| > | > 
| > | > Index: changelist
| > | > ===
| > | > RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
| > | > retrieving revision 1.128
| > | > diff -u -p -r1.128 changelist
| > | > --- changelist  30 Jul 2021 07:00:02 -  1.128
| > | > +++ changelist  29 Aug 2021 12:12:04 -
| > | > @@ -56,6 +56,7 @@
| > | >  +/etc/isakmpd/isakmpd.policy
| > | >  /etc/isakmpd/local.pub
| > | >  +/etc/isakmpd/private/local.key
| > | > +/etc/kernel.conf
| > | >  /etc/ksh.kshrc
| > | >  /etc/ldapd.conf
| > | >  /etc/ldpd.conf
| > | > 
| > | > Full diff (including the original diff, the diff to install.sub and
| > | > the above changelist diff) below.  Anything else I overlooked?
| > | > 
| > | > Paul
| > | > 
| > | > Index: distrib/miniroot/install.sub
| > | > ===
| > | > RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
| > | > retrieving revision 1.1172
| > | > diff -u -p -r1.1172 install.sub
| > | > --- 

Re: allow KARL with config(8)'d kernels

2021-08-29 Thread Theo de Raadt
Ingo Schwarze  wrote:

> One - admittedly completely unUNIXy - way would be to invent a long,
> descriptive name like /etc/kernel.config.commands or even /bsd.config.cmd
> in the root rather than the /etc directory, which is more discoverable
> because it is right next to the kernel itself.  The UNIXy way
> is not necessarily better: Ken would have invented a very short,
> pronouncable name that is not an English word but similar to one,
> like /etc/sycoc (for SYstem COnfiguration Commands).

I have no idea why you talk about Ken, how obscure

back in those days it wasn't called /kernel, either.

the pathname "kernel.something" which is supposed to be somewhat
related to a non-existant pathname "kernel", is what I object to.

perhaps /etc/bsd.re-config

but certainly the sub-phrase "kernel" is not discoverable.



Re: allow KARL with config(8)'d kernels

2021-08-29 Thread Ingo Schwarze
Hi,

Theo de Raadt wrote on Sun, Aug 29, 2021 at 07:15:34AM -0600:

> I am not thrilled with the name "kernel.conf".
> It does not seem intuitively discoverable.

What would be a canonical name?

It is a command file for config(8).

Note that the "config-file" for config is something else, and that
other thing is also called a "kernel configuration file", and it
is located in places like /sys/arch/luna88k/conf/GENERIC iiuc.

For command files, we normally use the name of the programming
language as a suffix (*.sh, *.pl, *.py, *.awk, *.sed, ...).  But
here, the domain specific language is really config(8), and *.config
does not work as a suffix because it is next to indistinguishable
from *.conf, and we just saw this is *not* a configuration but a
command file.

The root cause of the terminologic mess here is that the choice of
the name config(8) for the kernel configuration program was too
generic in the first place, but we are almost exactly 40 years late
for fixing that.

One - admittedly completely unUNIXy - way would be to invent a long,
descriptive name like /etc/kernel.config.commands or even /bsd.config.cmd
in the root rather than the /etc directory, which is more discoverable
because it is right next to the kernel itself.  The UNIXy way
is not necessarily better: Ken would have invented a very short,
pronouncable name that is not an English word but similar to one,
like /etc/sycoc (for SYstem COnfiguration Commands).

Is /bsd.config.cmd good enough?

Yours,
  Ingo

> Paul de Weerd  wrote:

>> Index: distrib/miniroot/install.sub
[...]
>>  chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
>> -make newbsd; make newinstall"
>> +make newbsd; \
>> +[ -e /etc/kernel.conf ] && \
>> +config -e -c /etc/kernel.conf -f bsd; \
>> +make newinstall"
>>  ) >/dev/null 2>&1 && echo " done." || echo " failed."



Re: allow KARL with config(8)'d kernels

2021-08-29 Thread Theo de Raadt
man -k kernel, and man -k ukc, both suggest these are poor names
for different reasons.

maybe if you write some diffs to hint at the existance of this mechanism
in the config(8) and boot_config(8) manual pages, a better name will
sneak up on us.

Paul de Weerd  wrote:

> Hi Theo,
> 
> That's a good point, but I have no better alternative.  kernel.conf
> was the best I could come up with, as it is a configuration file for
> the (installed) kernel.  I briefly considered:
> 
> - config.conf (after config(8), but seems hilariously worse to me)
> - ukc.conf (has similar (perhaps even stronger) issues as kernel.conf)
> 
> Do others have a good suggestion for the color of this particular bike
> shed?  Open to suggestions!
> 
> Paul
> 
> On Sun, Aug 29, 2021 at 07:15:34AM -0600, Theo de Raadt wrote:
> | I am not thrilled with the name "kernel.conf".
> | 
> | It does not seem intuitively discoverable.
> | 
> | Paul de Weerd  wrote:
> | 
> | > Got some more positive feedback off-list, which reminded me that
> | > there's a small piece missing:
> | > 
> | > Index: changelist
> | > ===
> | > RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
> | > retrieving revision 1.128
> | > diff -u -p -r1.128 changelist
> | > --- changelist30 Jul 2021 07:00:02 -  1.128
> | > +++ changelist29 Aug 2021 12:12:04 -
> | > @@ -56,6 +56,7 @@
> | >  +/etc/isakmpd/isakmpd.policy
> | >  /etc/isakmpd/local.pub
> | >  +/etc/isakmpd/private/local.key
> | > +/etc/kernel.conf
> | >  /etc/ksh.kshrc
> | >  /etc/ldapd.conf
> | >  /etc/ldpd.conf
> | > 
> | > Full diff (including the original diff, the diff to install.sub and
> | > the above changelist diff) below.  Anything else I overlooked?
> | > 
> | > Paul
> | > 
> | > Index: distrib/miniroot/install.sub
> | > ===
> | > RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
> | > retrieving revision 1.1172
> | > diff -u -p -r1.1172 install.sub
> | > --- distrib/miniroot/install.sub  9 Aug 2021 13:56:17 -   1.1172
> | > +++ distrib/miniroot/install.sub  25 Aug 2021 19:42:49 -
> | > @@ -2857,7 +2857,10 @@ finish_up() {
> | >   tar -C $_kernel_dir -xzf $_kernel_dir.tgz $_kernel
> | >   rm -f $_kernel_dir.tgz
> | >   chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
> | > - make newbsd; make newinstall"
> | > + make newbsd; \
> | > + [ -e /etc/kernel.conf ] && \
> | > + config -e -c /etc/kernel.conf -f bsd; \
> | > + make newinstall"
> | >   ) >/dev/null 2>&1 && echo " done." || echo " failed."
> | >   fi
> | >  
> | > Index: etc/changelist
> | > ===
> | > RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
> | > retrieving revision 1.128
> | > diff -u -p -r1.128 changelist
> | > --- etc/changelist30 Jul 2021 07:00:02 -  1.128
> | > +++ etc/changelist29 Aug 2021 12:12:04 -
> | > @@ -56,6 +56,7 @@
> | >  +/etc/isakmpd/isakmpd.policy
> | >  /etc/isakmpd/local.pub
> | >  +/etc/isakmpd/private/local.key
> | > +/etc/kernel.conf
> | >  /etc/ksh.kshrc
> | >  /etc/ldapd.conf
> | >  /etc/ldpd.conf
> | > Index: libexec/reorder_kernel/Makefile
> | > ===
> | > RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
> | > retrieving revision 1.1
> | > diff -u -p -r1.1 Makefile
> | > --- libexec/reorder_kernel/Makefile   21 Aug 2017 21:24:11 -  
> 1.1
> | > +++ libexec/reorder_kernel/Makefile   24 Aug 2021 07:23:38 -
> | > @@ -1,6 +1,7 @@
> | >  #$OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
> | >  
> | >  SCRIPT=  reorder_kernel.sh
> | > +MAN= kernel.conf.5
> | >  
> | >  realinstall:
> | >   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
> | > Index: libexec/reorder_kernel/kernel.conf.5
> | > ===
> | > RCS file: libexec/reorder_kernel/kernel.conf.5
> | > diff -N libexec/reorder_kernel/kernel.conf.5
> | > --- /dev/null 1 Jan 1970 00:00:00 -
> | > +++ libexec/reorder_kernel/kernel.conf.5  24 Aug 2021 07:23:07 -
> | > @@ -0,0 +1,46 @@
> | > +.\"  $OpenBSD$
> | > +.\"
> | > +.\" Copyright (c) 2021 Paul de Weerd 
> | > +.\"
> | > +.\" Permission to use, copy, modify, and distribute this software for any
> | > +.\" purpose with or without fee is hereby granted, provided that the 
> above
> | > +.\" copyright notice and this permission notice appear in all copies.
> | > +.\"
> | > +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 
> WARRANTIES
> | > +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> | > +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE 
> FOR
> | > 

Re: allow KARL with config(8)'d kernels

2021-08-29 Thread Paul de Weerd
Hi Theo,

That's a good point, but I have no better alternative.  kernel.conf
was the best I could come up with, as it is a configuration file for
the (installed) kernel.  I briefly considered:

- config.conf (after config(8), but seems hilariously worse to me)
- ukc.conf (has similar (perhaps even stronger) issues as kernel.conf)

Do others have a good suggestion for the color of this particular bike
shed?  Open to suggestions!

Paul

On Sun, Aug 29, 2021 at 07:15:34AM -0600, Theo de Raadt wrote:
| I am not thrilled with the name "kernel.conf".
| 
| It does not seem intuitively discoverable.
| 
| Paul de Weerd  wrote:
| 
| > Got some more positive feedback off-list, which reminded me that
| > there's a small piece missing:
| > 
| > Index: changelist
| > ===
| > RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
| > retrieving revision 1.128
| > diff -u -p -r1.128 changelist
| > --- changelist  30 Jul 2021 07:00:02 -  1.128
| > +++ changelist  29 Aug 2021 12:12:04 -
| > @@ -56,6 +56,7 @@
| >  +/etc/isakmpd/isakmpd.policy
| >  /etc/isakmpd/local.pub
| >  +/etc/isakmpd/private/local.key
| > +/etc/kernel.conf
| >  /etc/ksh.kshrc
| >  /etc/ldapd.conf
| >  /etc/ldpd.conf
| > 
| > Full diff (including the original diff, the diff to install.sub and
| > the above changelist diff) below.  Anything else I overlooked?
| > 
| > Paul
| > 
| > Index: distrib/miniroot/install.sub
| > ===
| > RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
| > retrieving revision 1.1172
| > diff -u -p -r1.1172 install.sub
| > --- distrib/miniroot/install.sub9 Aug 2021 13:56:17 -   1.1172
| > +++ distrib/miniroot/install.sub25 Aug 2021 19:42:49 -
| > @@ -2857,7 +2857,10 @@ finish_up() {
| > tar -C $_kernel_dir -xzf $_kernel_dir.tgz $_kernel
| > rm -f $_kernel_dir.tgz
| > chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
| > -   make newbsd; make newinstall"
| > +   make newbsd; \
| > +   [ -e /etc/kernel.conf ] && \
| > +   config -e -c /etc/kernel.conf -f bsd; \
| > +   make newinstall"
| > ) >/dev/null 2>&1 && echo " done." || echo " failed."
| > fi
| >  
| > Index: etc/changelist
| > ===
| > RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
| > retrieving revision 1.128
| > diff -u -p -r1.128 changelist
| > --- etc/changelist  30 Jul 2021 07:00:02 -  1.128
| > +++ etc/changelist  29 Aug 2021 12:12:04 -
| > @@ -56,6 +56,7 @@
| >  +/etc/isakmpd/isakmpd.policy
| >  /etc/isakmpd/local.pub
| >  +/etc/isakmpd/private/local.key
| > +/etc/kernel.conf
| >  /etc/ksh.kshrc
| >  /etc/ldapd.conf
| >  /etc/ldpd.conf
| > Index: libexec/reorder_kernel/Makefile
| > ===
| > RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
| > retrieving revision 1.1
| > diff -u -p -r1.1 Makefile
| > --- libexec/reorder_kernel/Makefile 21 Aug 2017 21:24:11 -  1.1
| > +++ libexec/reorder_kernel/Makefile 24 Aug 2021 07:23:38 -
| > @@ -1,6 +1,7 @@
| >  #  $OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
| >  
| >  SCRIPT=reorder_kernel.sh
| > +MAN=   kernel.conf.5
| >  
| >  realinstall:
| > ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
| > Index: libexec/reorder_kernel/kernel.conf.5
| > ===
| > RCS file: libexec/reorder_kernel/kernel.conf.5
| > diff -N libexec/reorder_kernel/kernel.conf.5
| > --- /dev/null   1 Jan 1970 00:00:00 -
| > +++ libexec/reorder_kernel/kernel.conf.524 Aug 2021 07:23:07 -
| > @@ -0,0 +1,46 @@
| > +.\"$OpenBSD$
| > +.\"
| > +.\" Copyright (c) 2021 Paul de Weerd 
| > +.\"
| > +.\" Permission to use, copy, modify, and distribute this software for any
| > +.\" purpose with or without fee is hereby granted, provided that the above
| > +.\" copyright notice and this permission notice appear in all copies.
| > +.\"
| > +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 
WARRANTIES
| > +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
| > +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
| > +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
| > +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
| > +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
| > +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
| > +.\"
| > +.Dd $Mdocdate: August 24 2021 $
| > +.Dt KERNEL.CONF 5
| > +.Os
| > +.Sh NAME
| > +.Nm kernel.conf
| > +.Nd kernel configuration file
| > +.Sh DESCRIPTION
| > +The
| > +.Nm
| > 

Re: allow KARL with config(8)'d kernels

2021-08-29 Thread Theo de Raadt
I am not thrilled with the name "kernel.conf".

It does not seem intuitively discoverable.

Paul de Weerd  wrote:

> Got some more positive feedback off-list, which reminded me that
> there's a small piece missing:
> 
> Index: changelist
> ===
> RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
> retrieving revision 1.128
> diff -u -p -r1.128 changelist
> --- changelist30 Jul 2021 07:00:02 -  1.128
> +++ changelist29 Aug 2021 12:12:04 -
> @@ -56,6 +56,7 @@
>  +/etc/isakmpd/isakmpd.policy
>  /etc/isakmpd/local.pub
>  +/etc/isakmpd/private/local.key
> +/etc/kernel.conf
>  /etc/ksh.kshrc
>  /etc/ldapd.conf
>  /etc/ldpd.conf
> 
> Full diff (including the original diff, the diff to install.sub and
> the above changelist diff) below.  Anything else I overlooked?
> 
> Paul
> 
> Index: distrib/miniroot/install.sub
> ===
> RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
> retrieving revision 1.1172
> diff -u -p -r1.1172 install.sub
> --- distrib/miniroot/install.sub  9 Aug 2021 13:56:17 -   1.1172
> +++ distrib/miniroot/install.sub  25 Aug 2021 19:42:49 -
> @@ -2857,7 +2857,10 @@ finish_up() {
>   tar -C $_kernel_dir -xzf $_kernel_dir.tgz $_kernel
>   rm -f $_kernel_dir.tgz
>   chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
> - make newbsd; make newinstall"
> + make newbsd; \
> + [ -e /etc/kernel.conf ] && \
> + config -e -c /etc/kernel.conf -f bsd; \
> + make newinstall"
>   ) >/dev/null 2>&1 && echo " done." || echo " failed."
>   fi
>  
> Index: etc/changelist
> ===
> RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
> retrieving revision 1.128
> diff -u -p -r1.128 changelist
> --- etc/changelist30 Jul 2021 07:00:02 -  1.128
> +++ etc/changelist29 Aug 2021 12:12:04 -
> @@ -56,6 +56,7 @@
>  +/etc/isakmpd/isakmpd.policy
>  /etc/isakmpd/local.pub
>  +/etc/isakmpd/private/local.key
> +/etc/kernel.conf
>  /etc/ksh.kshrc
>  /etc/ldapd.conf
>  /etc/ldpd.conf
> Index: libexec/reorder_kernel/Makefile
> ===
> RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
> retrieving revision 1.1
> diff -u -p -r1.1 Makefile
> --- libexec/reorder_kernel/Makefile   21 Aug 2017 21:24:11 -  1.1
> +++ libexec/reorder_kernel/Makefile   24 Aug 2021 07:23:38 -
> @@ -1,6 +1,7 @@
>  #$OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
>  
>  SCRIPT=  reorder_kernel.sh
> +MAN= kernel.conf.5
>  
>  realinstall:
>   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
> Index: libexec/reorder_kernel/kernel.conf.5
> ===
> RCS file: libexec/reorder_kernel/kernel.conf.5
> diff -N libexec/reorder_kernel/kernel.conf.5
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ libexec/reorder_kernel/kernel.conf.5  24 Aug 2021 07:23:07 -
> @@ -0,0 +1,46 @@
> +.\"  $OpenBSD$
> +.\"
> +.\" Copyright (c) 2021 Paul de Weerd 
> +.\"
> +.\" Permission to use, copy, modify, and distribute this software for any
> +.\" purpose with or without fee is hereby granted, provided that the above
> +.\" copyright notice and this permission notice appear in all copies.
> +.\"
> +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +.\"
> +.Dd $Mdocdate: August 24 2021 $
> +.Dt KERNEL.CONF 5
> +.Os
> +.Sh NAME
> +.Nm kernel.conf
> +.Nd kernel configuration file
> +.Sh DESCRIPTION
> +The
> +.Nm
> +file contains configuration information for the kernel.
> +If present, it is used during system startup to configure the kernel
> +that will be running at the next boot.
> +It can be used to enable or disable specific devices in the kernel.
> +.Sh EXAMPLES
> +To enable the
> +.Xr ipmi 4
> +driver, add the following line to
> +.Nm :
> +.Pp
> +.Dl enable ipmi
> +.Pp
> +See 
> +.Xr config 8
> +for more details on how to configure the kernel.
> +.Sh FILES
> +.Bl -tag -width /etc/kernel.conf -compact
> +.It Pa /etc/kernel.conf
> +Kernel configuration file.
> +.Sh SEE ALSO
> +.Xr config 8
> Index: libexec/reorder_kernel/reorder_kernel.sh
> 

Re: allow KARL with config(8)'d kernels

2021-08-29 Thread Paul de Weerd
Got some more positive feedback off-list, which reminded me that
there's a small piece missing:

Index: changelist
===
RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
retrieving revision 1.128
diff -u -p -r1.128 changelist
--- changelist  30 Jul 2021 07:00:02 -  1.128
+++ changelist  29 Aug 2021 12:12:04 -
@@ -56,6 +56,7 @@
 +/etc/isakmpd/isakmpd.policy
 /etc/isakmpd/local.pub
 +/etc/isakmpd/private/local.key
+/etc/kernel.conf
 /etc/ksh.kshrc
 /etc/ldapd.conf
 /etc/ldpd.conf

Full diff (including the original diff, the diff to install.sub and
the above changelist diff) below.  Anything else I overlooked?

Paul

Index: distrib/miniroot/install.sub
===
RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1172
diff -u -p -r1.1172 install.sub
--- distrib/miniroot/install.sub9 Aug 2021 13:56:17 -   1.1172
+++ distrib/miniroot/install.sub25 Aug 2021 19:42:49 -
@@ -2857,7 +2857,10 @@ finish_up() {
tar -C $_kernel_dir -xzf $_kernel_dir.tgz $_kernel
rm -f $_kernel_dir.tgz
chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
-   make newbsd; make newinstall"
+   make newbsd; \
+   [ -e /etc/kernel.conf ] && \
+   config -e -c /etc/kernel.conf -f bsd; \
+   make newinstall"
) >/dev/null 2>&1 && echo " done." || echo " failed."
fi
 
Index: etc/changelist
===
RCS file: /home/OpenBSD/cvs/src/etc/changelist,v
retrieving revision 1.128
diff -u -p -r1.128 changelist
--- etc/changelist  30 Jul 2021 07:00:02 -  1.128
+++ etc/changelist  29 Aug 2021 12:12:04 -
@@ -56,6 +56,7 @@
 +/etc/isakmpd/isakmpd.policy
 /etc/isakmpd/local.pub
 +/etc/isakmpd/private/local.key
+/etc/kernel.conf
 /etc/ksh.kshrc
 /etc/ldapd.conf
 /etc/ldpd.conf
Index: libexec/reorder_kernel/Makefile
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- libexec/reorder_kernel/Makefile 21 Aug 2017 21:24:11 -  1.1
+++ libexec/reorder_kernel/Makefile 24 Aug 2021 07:23:38 -
@@ -1,6 +1,7 @@
 #  $OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
 
 SCRIPT=reorder_kernel.sh
+MAN=   kernel.conf.5
 
 realinstall:
${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
Index: libexec/reorder_kernel/kernel.conf.5
===
RCS file: libexec/reorder_kernel/kernel.conf.5
diff -N libexec/reorder_kernel/kernel.conf.5
--- /dev/null   1 Jan 1970 00:00:00 -
+++ libexec/reorder_kernel/kernel.conf.524 Aug 2021 07:23:07 -
@@ -0,0 +1,46 @@
+.\"$OpenBSD$
+.\"
+.\" Copyright (c) 2021 Paul de Weerd 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate: August 24 2021 $
+.Dt KERNEL.CONF 5
+.Os
+.Sh NAME
+.Nm kernel.conf
+.Nd kernel configuration file
+.Sh DESCRIPTION
+The
+.Nm
+file contains configuration information for the kernel.
+If present, it is used during system startup to configure the kernel
+that will be running at the next boot.
+It can be used to enable or disable specific devices in the kernel.
+.Sh EXAMPLES
+To enable the
+.Xr ipmi 4
+driver, add the following line to
+.Nm :
+.Pp
+.Dl enable ipmi
+.Pp
+See 
+.Xr config 8
+for more details on how to configure the kernel.
+.Sh FILES
+.Bl -tag -width /etc/kernel.conf -compact
+.It Pa /etc/kernel.conf
+Kernel configuration file.
+.Sh SEE ALSO
+.Xr config 8
Index: libexec/reorder_kernel/reorder_kernel.sh
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/reorder_kernel.sh,v
retrieving revision 1.9
diff -u -p -r1.9 reorder_kernel.sh
--- libexec/reorder_kernel/reorder_kernel.sh28 Sep 2019 17:30:07 -  
1.9
+++ libexec/reorder_kernel/reorder_kernel.sh24 Aug 2021 07:01:10 -
@@ -63,6 +63,7 @@ fi
 
 cd 

Re: allow KARL with config(8)'d kernels

2021-08-25 Thread Paul de Weerd
Robert, Sebastien and Stuart,

Thanks for your constructive and postive feedback.  Combined with some
off-list (positive) feedback, it suggests this is at least worth
further consideration.

On Tue, Aug 24, 2021 at 08:05:37PM +0200, Robert Nagy wrote:
| I am happy to see this. All for it. Did you check all the error cases
| to make sure that reorder_kernel will report what needs to be reported?

Well, the thing I checked was that reorder_kernel sets errexit.  So if
an error does occur during the config(8) run that gets added with the
diff, it will get reported as usual.

- no /etc/kernel.conf -> works as expected
- proper /etc/kernel.conf -> works as expected
- full partition -> config still is able to change the kernel

- faulty /etc/kernel.conf -> no new kernel, logged to console

On Wed, Aug 25, 2021 at 10:35:19AM +0200, Sebastien Marie wrote:
| - does it integrate well with syspatch ?
| 
|   yes, syspatch will call /usr/libexec/reorder_kernel (and the
|   configuration will be applied)

Yes, I did consider this case and figured it would be fine as syspatch
just runs reorder_kernel (and even checks its exit status).

| - after install or upgrade, does the installed kernel (by installer)
|   has the configuration applied ?
| 
|   it seems not: install.sub has it owns logic and is directly calling
|   "make newbsd ; make install" and do not use reorder_kernel script.

Looking just now, install.sub runs in a chroot of the freshly
installed / upgraded system, and issues make newbsd and make
newinstall.  Fixing that would be as straightforward as the original
diff.  Since there seems to be general interest in my original diff,
I've included such a diff below (not sure if this should be a separate
commit or not).

|   I could see reason to avoid it, and reason to requiring it.
| 
| 
|   For install, no problem: the file is controlled (it doesn't
|   exist). It doesn't change anything.

Personally, I don't see a reason to avoid it.  For install, it could
exist.  site.tgz could install an /etc/kernel.conf, for those users
that need to configure their kernels to have them work after the
initial install (this will help automated installs where the operator
already knows in advance that their kernel will need some further
configuration).

|   For upgrade, the file could exists. Should the installer using it or
|   not ?
| 
| 
|   If using it, it makes the upgrade process dependent of the file: how
|   to deal with an invalid file ? should the file ignored (kernel
|   installed but not configured) ?

If you have a broken /etc/kernel.conf, it'll never work.  A bit like
screwing up your /etc/boot.conf - you get to keep all pieces of your
broken system.

|   how to deal with a format change in config(8) (file on disk in old
|   format, used config(8) understanding new format) ? but config(8)
|   doesn't change often, and could take care of both formats for one
|   release, and/or current.html could mention some required changes.

This is a good point, something I didn't consider.  But I agree with
your arguments here - seems like something that a) wouldn't happen
frequently and b) can be dealt with when it does.

On Wed, Aug 25, 2021 at 11:32:36AM +0100, Stuart Henderson wrote:
| Somebody had an earlier method for applying kernel config changes
| automatically that IIRC used a bootloader based mechanism passing the
| config to the kernel. I think that might actually be better overall
| as you could bypass it at the boot loader (rather than requiring a
| backup "clean" kernel) though that's more work and I expect difficult
| to do within space constraints on some archs.

I readily agree that that sounds like a better approach to me.
However, that approach is beyond my current skillset, I had an itch to
scratch, and this was my (relatively unintrusive) solution.

The diff below for install.sub has not been tested (yet).

Thanks again,

Paul

Index: install.sub
===
RCS file: /home/OpenBSD/cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1172
diff -u -p -r1.1172 install.sub
--- install.sub 9 Aug 2021 13:56:17 -   1.1172
+++ install.sub 25 Aug 2021 19:42:49 -
@@ -2857,7 +2857,10 @@ finish_up() {
tar -C $_kernel_dir -xzf $_kernel_dir.tgz $_kernel
rm -f $_kernel_dir.tgz
chroot /mnt /bin/ksh -e -c "cd ${_kernel_dir#/mnt}/$_kernel; \
-   make newbsd; make newinstall"
+   make newbsd; \
+   [ -e /etc/kernel.conf ] && \
+   config -e -c /etc/kernel.conf -f bsd; \
+   make newinstall"
) >/dev/null 2>&1 && echo " done." || echo " failed."
fi
 


-- 
>[<++>-]<+++.>+++[<-->-]<.>+++[<+
+++>-]<.>++[<>-]<+.--.[-]
 http://www.weirdnet.nl/ 



Re: allow KARL with config(8)'d kernels

2021-08-25 Thread Stuart Henderson
On 2021/08/25 10:35, Sebastien Marie wrote:
> On Tue, Aug 24, 2021 at 01:53:41PM +0200, Paul de Weerd wrote:
> > I have a new machine where I'd like to use IPMI.  Of course, doing
> > `config -e -f /bsd` will break KARL, so I tried to find a minimal way
> > of supporting this.  Done by introducing a new config file,
> > /etc/kernel.conf, which gets applied to the kernel reorder_kernel
> > builds and installs.
> 
> I like it: it is simple.
> 
> but here are some thoughts (with questions and some answers, but it is
> open):
> 
> - does it integrate well with syspatch ?
> 
>   yes, syspatch will call /usr/libexec/reorder_kernel (and the
>   configuration will be applied)
> 
> 
> - after install or upgrade, does the installed kernel (by installer)
>   has the configuration applied ?
> 
>   it seems not: install.sub has it owns logic and is directly calling
>   "make newbsd ; make install" and do not use reorder_kernel script.
>   
> 
>   I could see reason to avoid it, and reason to requiring it.
> 
> 
>   For install, no problem: the file is controlled (it doesn't
>   exist). It doesn't change anything.
> 
>   For upgrade, the file could exists. Should the installer using it or
>   not ?
> 
> 
>   If using it, it makes the upgrade process dependent of the file: how
>   to deal with an invalid file ? should the file ignored (kernel
>   installed but not configured) ?

I don't see a reason why upgrade shouldn't use it.
Invalid file handling is no more or less of a problem for upgrades than reboots.


>   how to deal with a format change in config(8) (file on disk in old
>   format, used config(8) understanding new format) ? but config(8)
>   doesn't change often, and could take care of both formats for one
>   release, and/or current.html could mention some required changes.
> 
> 
>   If not using it, does it is a problem that the first boot will be
>   different from next boot ?
> 
>   I could imagine some changes made to be the machine bootable, so the
>   first boot could lead to unbootable machine (but it isn't different
>   from now).

> Questions are open: I have no problem which using or not using the
> configuration file on upgrade, but I think it should be documented (to
> avoid questions and/or surprises).
> 

Somebody had an earlier method for applying kernel config changes
automatically that IIRC used a bootloader based mechanism passing the
config to the kernel. I think that might actually be better overall
as you could bypass it at the boot loader (rather than requiring a
backup "clean" kernel) though that's more work and I expect difficult
to do within space constraints on some archs.

I would be quite happy to have this problem solved one way or another,
while a "one size fits all" kernel should be the goal, there are
some workarounds needed e.g. for semi-broken hardware and I think that's
always likely to be the case.



Re: allow KARL with config(8)'d kernels

2021-08-25 Thread Sebastien Marie
On Tue, Aug 24, 2021 at 01:53:41PM +0200, Paul de Weerd wrote:
> I have a new machine where I'd like to use IPMI.  Of course, doing
> `config -e -f /bsd` will break KARL, so I tried to find a minimal way
> of supporting this.  Done by introducing a new config file,
> /etc/kernel.conf, which gets applied to the kernel reorder_kernel
> builds and installs.

I like it: it is simple.

but here are some thoughts (with questions and some answers, but it is
open):

- does it integrate well with syspatch ?

  yes, syspatch will call /usr/libexec/reorder_kernel (and the
  configuration will be applied)


- after install or upgrade, does the installed kernel (by installer)
  has the configuration applied ?

  it seems not: install.sub has it owns logic and is directly calling
  "make newbsd ; make install" and do not use reorder_kernel script.
  

  I could see reason to avoid it, and reason to requiring it.


  For install, no problem: the file is controlled (it doesn't
  exist). It doesn't change anything.

  For upgrade, the file could exists. Should the installer using it or
  not ?


  If using it, it makes the upgrade process dependent of the file: how
  to deal with an invalid file ? should the file ignored (kernel
  installed but not configured) ?

  how to deal with a format change in config(8) (file on disk in old
  format, used config(8) understanding new format) ? but config(8)
  doesn't change often, and could take care of both formats for one
  release, and/or current.html could mention some required changes.


  If not using it, does it is a problem that the first boot will be
  different from next boot ?

  I could imagine some changes made to be the machine bootable, so the
  first boot could lead to unbootable machine (but it isn't different
  from now).


Questions are open: I have no problem which using or not using the
configuration file on upgrade, but I think it should be documented (to
avoid questions and/or surprises).

Thanks
-- 
Sebastien Marie



> Index: reorder_kernel.sh
> ===
> RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/reorder_kernel.sh,v
> retrieving revision 1.9
> diff -u -p -r1.9 reorder_kernel.sh
> --- reorder_kernel.sh 28 Sep 2019 17:30:07 -  1.9
> +++ reorder_kernel.sh 24 Aug 2021 07:01:10 -
> @@ -63,6 +63,7 @@ fi
>  
>  cd $KERNEL_DIR/$KERNEL
>  make newbsd
> +[ -f /etc/kernel.conf ] && config -e -c /etc/kernel.conf -f bsd
>  make newinstall
>  sync
>  
> Index: Makefile
> ===
> RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
> retrieving revision 1.1
> diff -u -p -r1.1 Makefile
> --- Makefile  21 Aug 2017 21:24:11 -  1.1
> +++ Makefile  24 Aug 2021 07:23:38 -
> @@ -1,6 +1,7 @@
>  #$OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
>  
>  SCRIPT=  reorder_kernel.sh
> +MAN= kernel.conf.5
>  
>  realinstall:
>   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
> Index: kernel.conf.5
> ===
> RCS file: kernel.conf.5
> diff -N kernel.conf.5
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ kernel.conf.5 24 Aug 2021 07:23:07 -
> @@ -0,0 +1,46 @@
> +.\"  $OpenBSD$
> +.\"
> +.\" Copyright (c) 2021 Paul de Weerd 
> +.\"
> +.\" Permission to use, copy, modify, and distribute this software for any
> +.\" purpose with or without fee is hereby granted, provided that the above
> +.\" copyright notice and this permission notice appear in all copies.
> +.\"
> +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +.\"
> +.Dd $Mdocdate: August 24 2021 $
> +.Dt KERNEL.CONF 5
> +.Os
> +.Sh NAME
> +.Nm kernel.conf
> +.Nd kernel configuration file
> +.Sh DESCRIPTION
> +The
> +.Nm
> +file contains configuration information for the kernel.
> +If present, it is used during system startup to configure the kernel
> +that will be running at the next boot.
> +It can be used to enable or disable specific devices in the kernel.
> +.Sh EXAMPLES
> +To enable the
> +.Xr ipmi 4
> +driver, add the following line to
> +.Nm :
> +.Pp
> +.Dl enable ipmi
> +.Pp
> +See 
> +.Xr config 8
> +for more details on how to configure the kernel.
> +.Sh FILES
> +.Bl -tag -width /etc/kernel.conf -compact
> +.It Pa /etc/kernel.conf
> +Kernel configuration file.
> +.Sh SEE ALSO
> +.Xr config 8
> 
> -- 
> >[<++>-]<+++.>+++[<-->-]<.>+++[<+
> 

Re: allow KARL with config(8)'d kernels

2021-08-24 Thread Robert Nagy
I am happy to see this. All for it. Did you check all the error cases
to make sure that reorder_kernel will report what needs to be reported?

On 24/08/21 13:53 +0200, Paul de Weerd wrote:
> I have a new machine where I'd like to use IPMI.  Of course, doing
> `config -e -f /bsd` will break KARL, so I tried to find a minimal way
> of supporting this.  Done by introducing a new config file,
> /etc/kernel.conf, which gets applied to the kernel reorder_kernel
> builds and installs.
> 
> Paul 'WEiRD' de Weerd
> 
> Index: reorder_kernel.sh
> ===
> RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/reorder_kernel.sh,v
> retrieving revision 1.9
> diff -u -p -r1.9 reorder_kernel.sh
> --- reorder_kernel.sh 28 Sep 2019 17:30:07 -  1.9
> +++ reorder_kernel.sh 24 Aug 2021 07:01:10 -
> @@ -63,6 +63,7 @@ fi
>  
>  cd $KERNEL_DIR/$KERNEL
>  make newbsd
> +[ -f /etc/kernel.conf ] && config -e -c /etc/kernel.conf -f bsd
>  make newinstall
>  sync
>  
> Index: Makefile
> ===
> RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
> retrieving revision 1.1
> diff -u -p -r1.1 Makefile
> --- Makefile  21 Aug 2017 21:24:11 -  1.1
> +++ Makefile  24 Aug 2021 07:23:38 -
> @@ -1,6 +1,7 @@
>  #$OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
>  
>  SCRIPT=  reorder_kernel.sh
> +MAN= kernel.conf.5
>  
>  realinstall:
>   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
> Index: kernel.conf.5
> ===
> RCS file: kernel.conf.5
> diff -N kernel.conf.5
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ kernel.conf.5 24 Aug 2021 07:23:07 -
> @@ -0,0 +1,46 @@
> +.\"  $OpenBSD$
> +.\"
> +.\" Copyright (c) 2021 Paul de Weerd 
> +.\"
> +.\" Permission to use, copy, modify, and distribute this software for any
> +.\" purpose with or without fee is hereby granted, provided that the above
> +.\" copyright notice and this permission notice appear in all copies.
> +.\"
> +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +.\"
> +.Dd $Mdocdate: August 24 2021 $
> +.Dt KERNEL.CONF 5
> +.Os
> +.Sh NAME
> +.Nm kernel.conf
> +.Nd kernel configuration file
> +.Sh DESCRIPTION
> +The
> +.Nm
> +file contains configuration information for the kernel.
> +If present, it is used during system startup to configure the kernel
> +that will be running at the next boot.
> +It can be used to enable or disable specific devices in the kernel.
> +.Sh EXAMPLES
> +To enable the
> +.Xr ipmi 4
> +driver, add the following line to
> +.Nm :
> +.Pp
> +.Dl enable ipmi
> +.Pp
> +See 
> +.Xr config 8
> +for more details on how to configure the kernel.
> +.Sh FILES
> +.Bl -tag -width /etc/kernel.conf -compact
> +.It Pa /etc/kernel.conf
> +Kernel configuration file.
> +.Sh SEE ALSO
> +.Xr config 8
> 
> -- 
> >[<++>-]<+++.>+++[<-->-]<.>+++[<+
> +++>-]<.>++[<>-]<+.--.[-]
>  http://www.weirdnet.nl/ 
> 

-- 
Regards,
Robert Nagy



allow KARL with config(8)'d kernels

2021-08-24 Thread Paul de Weerd
I have a new machine where I'd like to use IPMI.  Of course, doing
`config -e -f /bsd` will break KARL, so I tried to find a minimal way
of supporting this.  Done by introducing a new config file,
/etc/kernel.conf, which gets applied to the kernel reorder_kernel
builds and installs.

Paul 'WEiRD' de Weerd

Index: reorder_kernel.sh
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/reorder_kernel.sh,v
retrieving revision 1.9
diff -u -p -r1.9 reorder_kernel.sh
--- reorder_kernel.sh   28 Sep 2019 17:30:07 -  1.9
+++ reorder_kernel.sh   24 Aug 2021 07:01:10 -
@@ -63,6 +63,7 @@ fi
 
 cd $KERNEL_DIR/$KERNEL
 make newbsd
+[ -f /etc/kernel.conf ] && config -e -c /etc/kernel.conf -f bsd
 make newinstall
 sync
 
Index: Makefile
===
RCS file: /home/OpenBSD/cvs/src/libexec/reorder_kernel/Makefile,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile
--- Makefile21 Aug 2017 21:24:11 -  1.1
+++ Makefile24 Aug 2021 07:23:38 -
@@ -1,6 +1,7 @@
 #  $OpenBSD: Makefile,v 1.1 2017/08/21 21:24:11 rpe Exp $
 
 SCRIPT=reorder_kernel.sh
+MAN=   kernel.conf.5
 
 realinstall:
${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
Index: kernel.conf.5
===
RCS file: kernel.conf.5
diff -N kernel.conf.5
--- /dev/null   1 Jan 1970 00:00:00 -
+++ kernel.conf.5   24 Aug 2021 07:23:07 -
@@ -0,0 +1,46 @@
+.\"$OpenBSD$
+.\"
+.\" Copyright (c) 2021 Paul de Weerd 
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd $Mdocdate: August 24 2021 $
+.Dt KERNEL.CONF 5
+.Os
+.Sh NAME
+.Nm kernel.conf
+.Nd kernel configuration file
+.Sh DESCRIPTION
+The
+.Nm
+file contains configuration information for the kernel.
+If present, it is used during system startup to configure the kernel
+that will be running at the next boot.
+It can be used to enable or disable specific devices in the kernel.
+.Sh EXAMPLES
+To enable the
+.Xr ipmi 4
+driver, add the following line to
+.Nm :
+.Pp
+.Dl enable ipmi
+.Pp
+See 
+.Xr config 8
+for more details on how to configure the kernel.
+.Sh FILES
+.Bl -tag -width /etc/kernel.conf -compact
+.It Pa /etc/kernel.conf
+Kernel configuration file.
+.Sh SEE ALSO
+.Xr config 8

-- 
>[<++>-]<+++.>+++[<-->-]<.>+++[<+
+++>-]<.>++[<>-]<+.--.[-]
 http://www.weirdnet.nl/