Re: iwm/iwx: try to make roaming more reliable

2021-11-27 Thread Aaron Poffenberger
On 2021-11-27 12:44 +0100, Stefan Sperling wrote:
> This patch reworks the steps involved in roaming to a new access
> point on iwm(4) and iwx(4) interfaces.
> 
> The current implementation suffers from race conditions which can
> leave the interface in a state where it gets "stuck". I have seen
> this happen on iwm(4) 9560 in particular, while testing the driver
> with new firmware images recently published by Intel. This may well
> be related to other hangs people have reported in multi-AP environments
> on both iwm(4) and iwx(4).

During testing I didn't see the race condition without the patch, but
in the past there have been occassions where I had to run `...
netstart.sh iwm0`. So far, I see no regressions with it.

The card is an 8265 in a Lenovo T450s.

iwm0 at pci2 dev 0 function 0 "Intel Dual Band Wireless-AC 8265" rev 0x78, msi

The wireless access points are both TP-Link EAP 245s, one a hardware
V1, and the other V3.


Before Patch:
iwm0: sending delba to 50:c7:bf:94:08:44 on channel 11 mode 11n
iwm0: sending deauth to 50:c7:bf:94:08:44 on channel 11 mode 11n
iwm0: firmware has detected regulatory domain 'US' (0x5553)
iwm0: roaming from 50:c7:bf:94:08:44 chan 11 to b0:95:75:6d:f0:97 chan 44
iwm0: RUN -> AUTH
iwm0: sending auth to b0:95:75:6d:f0:97 on channel 44 mode 11a
iwm0: AUTH -> ASSOC
iwm0: sending assoc_req to b0:95:75:6d:f0:97 on channel 44 mode 11a
iwm0: ASSOC -> RUN


After Patch:
iwm0: sending deauth to 50:c7:bf:94:08:44 on channel 11 mode 11n
iwm0: roaming from 50:c7:bf:94:08:44 chan 11 to b0:95:75:6d:f0:97 chan 44
iwm0: RUN -> AUTH
iwm0: sending auth to b0:95:75:6d:f0:97 on channel 44 mode 11a
iwm0: AUTH -> ASSOC
iwm0: sending assoc_req to b0:95:75:6d:f0:97 on channel 44 mode 11a
iwm0: ASSOC -> RUN


I see two differences. Before the patch, before "deauth" I see "sending
delba" but not after patching, and before "firmware has detected
regulatory domain 'US'", but not after.

Perhaps they're unimportant, or don't show up in all roaming
conditions.

Cheers,

--Aaron



Re: new site.8: document site*.tgz and /{upgrade,install}.site

2021-10-27 Thread Aaron Poffenberger
Looks good. Nice to see this moving forward. Thanks.

On 2021-10-27 21:13 +, Klemens Nanni  wrote:
> On Mon, Sep 06, 2021 at 02:29:50PM -0500, Aaron Poffenberger wrote:
> > Ping.
> > 
> > Will someone commit this? Seems like no one knows about /upgrade.site and it
> > fits well with sysupgrade(8).
> 
> sysupgrade(8) is one potential /upgrade.site user but I disagree about
> documenting the latter through the former.
> 
> Here is a new manual roughly merging the FAQ bits with what you, Aaron,
> provided.
> 
> site(8) is a lame but fitting name;  autoinstall(8) and sysypgrade(8)
> reference it and both sets and scripts are documented.
> 
> Examples are intentionally brief to be shorter and more concise than the
> FAQ while showing enough to get going.
> 
> 
> I am quite certain that wording, examples and the references from other
> manuals can be tweaked, but this diff looks like a good enough start
> and --if this is the way to go-- I'd prefer to commit and keep polishing
> in-tree.
> 
> Feedback? Objections? OK?
> 
> 
> Index: distrib/sets/lists/man/mi
> ===
> RCS file: /cvs/src/distrib/sets/lists/man/mi,v
> retrieving revision 1.1643
> diff -u -p -r1.1643 mi
> --- distrib/sets/lists/man/mi 21 Oct 2021 18:36:41 -  1.1643
> +++ distrib/sets/lists/man/mi 27 Oct 2021 20:39:11 -
> @@ -2558,6 +2558,7 @@
>  ./usr/share/man/man8/security.8
>  ./usr/share/man/man8/sendmail.8
>  ./usr/share/man/man8/sensorsd.8
> +./usr/share/man/man8/site.8
>  ./usr/share/man/man8/sftp-server.8
>  ./usr/share/man/man8/showmount.8
>  ./usr/share/man/man8/shutdown.8
> Index: usr.sbin/sysupgrade/sysupgrade.8
> ===
> RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
> retrieving revision 1.10
> diff -u -p -r1.10 sysupgrade.8
> --- usr.sbin/sysupgrade/sysupgrade.8  3 Oct 2019 12:43:58 -   1.10
> +++ usr.sbin/sysupgrade/sysupgrade.8  27 Oct 2021 20:42:26 -
> @@ -67,6 +67,10 @@ This is the default if the system is cur
>  Upgrade to a snapshot.
>  This is the default if the system is currently running a snapshot.
>  .El
> +.Pp
> +See
> +.Xr site 8
> +for how to customize the upgrade process.
>  .Sh FILES
>  .Bl -tag -width "/auto_upgrade.conf" -compact
>  .It Pa /auto_upgrade.conf
> @@ -83,7 +87,8 @@ Directory the upgrade is downloaded to.
>  .Xr signify 1 ,
>  .Xr installurl 5 ,
>  .Xr autoinstall 8 ,
> -.Xr release 8
> +.Xr release 8 ,
> +.Xr site 8
>  .Sh HISTORY
>  .Nm
>  first appeared in
> Index: share/man/man8/Makefile
> ===
> RCS file: /cvs/src/share/man/man8/Makefile,v
> retrieving revision 1.102
> diff -u -p -r1.102 Makefile
> --- share/man/man8/Makefile   1 May 2021 16:11:10 -   1.102
> +++ share/man/man8/Makefile   27 Oct 2021 20:38:11 -
> @@ -6,7 +6,7 @@ MAN=  afterboot.8 autoinstall.8 boot_conf
>   crash.8 daily.8 \
>   diskless.8 genassym.sh.8 intro.8 netstart.8 rc.8 \
>   rc.conf.8 rc.d.8 rc.shutdown.8 rc.subr.8 release.8 \
> - security.8 ssl.8 starttls.8 sticky.8 yp.8
> + security.8 site.8 ssl.8 starttls.8 sticky.8 yp.8
>  
>  SUBDIR=  man8.alpha man8.amd64 man8.arm64 man8.armv7 \
>   man8.hppa man8.i386 man8.landisk \
> Index: share/man/man8/autoinstall.8
> ===
> RCS file: /cvs/src/share/man/man8/autoinstall.8,v
> retrieving revision 1.23
> diff -u -p -r1.23 autoinstall.8
> --- share/man/man8/autoinstall.8  18 Jul 2021 11:08:34 -  1.23
> +++ share/man/man8/autoinstall.8  27 Oct 2021 20:42:24 -
> @@ -32,6 +32,10 @@ file and HTTP to fetch the file.
>  If that fails, the installer asks for the location which can either be
>  a URL or a local path.
>  .Pp
> +See
> +.Xr site 8
> +for how to provide custom configuration.
> +.Pp
>  To start unattended installation or upgrade choose '(A)utoinstall' at the
>  install prompt.
>  If there is only one network interface, the installer fetches the response
> @@ -235,7 +239,8 @@ host foo {
>  .Sh SEE ALSO
>  .Xr dhcp-options 5 ,
>  .Xr dhcpd.conf 5 ,
> -.Xr diskless 8
> +.Xr diskless 8 ,
> +.Xr site 8
>  .Sh HISTORY
>  The
>  .Nm
> Index: share/man/man8/site.8
> ===
> RCS file: share/man/man8/site.8
> diff -N share/man/man8/site.8
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ share/man/man8/site.8 27 Oct 2021 21:11:48 -
> @@ -0,0 +1,87 @@
> +.\" $OpenBSD: $
> +.\"
> +.

Re: [Patch] Document /upgrade.site in sysupgrade(8) man page

2021-09-06 Thread Aaron Poffenberger
Ping.

Will someone commit this? Seems like no one knows about /upgrade.site and it
fits well with sysupgrade(8).

--Aaron

On 2021-09-02 10:18 -0500, Aaron Poffenberger  wrote:
> Any further thoughts on this patch to the man page?
> 
> Cheers,
> 
> --Aaron
> 
> On 2021-08-28 12:53 -0500, Aaron Poffenberger  wrote:
> > On 2021-08-28 19:45 +0200, Sebastien Marie  wrote:
> > > On Sat, Aug 28, 2021 at 05:05:18PM +, Klemens Nanni wrote:
> > > > On Sat, Aug 28, 2021 at 10:44:48AM -0500, Aaron Poffenberger wrote:
> > > > > Based on conversations in another thread, here's a patch documenting
> > > > > use of /upgrade.site in the sysupgrade(8) man page.
> > > > > 
> > > > > The revised doc references /upgrade.site and includes examples for
> > > > > updating packages from Sebastien Marie.
> > > > 
> > > > Documenting is the right approach, imho (I didn't even know about
> > > > $MODE.site) but this should probably be done in autoinstall(8).
> > > > 
> > > > This feature has nothing to do with sysupgrade per se and next to
> > > > upgrade.site there's also install.site.
> > > 
> > > $MODE.site isn't specially related to autoinstall(8) too :)
> > > 
> > > > I'd amend autoinstall(8) and briefly mention it in sysupgrade(8), just
> > > > via EXAMPLES or so to avoid duplication but showing a neat usecase.
> > > 
> > > Currently, these scripts seems to be only documented in the FAQ
> > > (https://www.openbsd.org/faq/faq4.html#site). so having some
> > > additionnal references at them in few man pages would be good.
> > > 
> > > Having examples in sysupgrade(8) and in autoinstall(8) makes sense to
> > > me.
> > > 
> > > FAQ could be expanded a bit too.
> > > 
> > > Thanks.
> > > -- 
> > > Sebastien Marie
> > > 
> > 
> > I agree that /install.site needs explaining, but I don't think it fits
> > well in autoinstall(8). siteXX.tgz isn't touched on there and would have
> > to be addressed as well.
> > 
> > I wouldn't mine working on that, but I'd prefer to put it where it belongs,
> > or in a separate man page.
> > 
> > New diff attached. I see I put the wrong file name in the FILES section. 
> > Also,
> > I simplified the example back to Sebastien Marie's original.
> > 
> > --Aaron
> > 
> > 
> > Index: sysupgrade.8
> > ===
> > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
> > retrieving revision 1.10
> > diff -u -p -r1.10 sysupgrade.8
> > --- sysupgrade.83 Oct 2019 12:43:58 -   1.10
> > +++ sysupgrade.828 Aug 2021 17:48:18 -
> > @@ -46,6 +46,11 @@ The bootloader will automatically choose
> >  triggering a one-shot upgrade using the files in
> >  .Pa /home/_sysupgrade .
> >  .Pp
> > +If
> > +.Pa /upgrade.site
> > +exists and is executable, it is executed at the end of the upgrade
> > +process, prior to rebooting.
> > +.Pp
> >  The options are as follows:
> >  .Bl -tag -width Ds
> >  .It Fl f
> > @@ -73,16 +78,39 @@ This is the default if the system is cur
> >  Response file for the ramdisk kernel.
> >  .It Pa /bsd.upgrade
> >  The ramdisk kernel to trigger an unattended upgrade.
> > +.It Pa /upgrade.site
> > +Executable file of actions to run after upgrade.
> >  .It Pa /etc/installurl
> >  .Ox
> >  mirror top-level URL for fetching an upgrade.
> >  .It Pa /home/_sysupgrade
> >  Directory the upgrade is downloaded to.
> >  .El
> > +.Sh EXAMPLES
> > +.Pa /upgrade.site
> > +script to upgrade packages and check sysclean when
> > +.Pa /etc/rc.firsttime
> > +runs:
> > +.Bd -literal
> > +   #!/bin/sh
> > +   PATH=/sbin:/bin:/usr/sbin:/usr/bin
> > +
> > +   # upgrade packages
> > +   echo 'pkg_add -Iu' >>/etc/rc.firsttime
> > +
> > +   # run sysclean (if installed)
> > +   echo '[ -x /usr/local/sbin/sysclean ] && \\
> > +   /usr/local/sbin/sysclean | mail -Es sysclean \\
> > +   root &' >>/etc/rc.firsttime
> > +
> > +   exit 0
> > +   #
> > +.Ed
> >  .Sh SEE ALSO
> >  .Xr signify 1 ,
> >  .Xr installurl 5 ,
> >  .Xr autoinstall 8 ,
> > +.Xr rc 8 ,
> >  .Xr release 8
> >  .Sh HISTORY
> >  .Nm



Re: [Patch] Document /upgrade.site in sysupgrade(8) man page

2021-09-02 Thread Aaron Poffenberger
Any further thoughts on this patch to the man page?

Cheers,

--Aaron

On 2021-08-28 12:53 -0500, Aaron Poffenberger  wrote:
> On 2021-08-28 19:45 +0200, Sebastien Marie  wrote:
> > On Sat, Aug 28, 2021 at 05:05:18PM +, Klemens Nanni wrote:
> > > On Sat, Aug 28, 2021 at 10:44:48AM -0500, Aaron Poffenberger wrote:
> > > > Based on conversations in another thread, here's a patch documenting
> > > > use of /upgrade.site in the sysupgrade(8) man page.
> > > > 
> > > > The revised doc references /upgrade.site and includes examples for
> > > > updating packages from Sebastien Marie.
> > > 
> > > Documenting is the right approach, imho (I didn't even know about
> > > $MODE.site) but this should probably be done in autoinstall(8).
> > > 
> > > This feature has nothing to do with sysupgrade per se and next to
> > > upgrade.site there's also install.site.
> > 
> > $MODE.site isn't specially related to autoinstall(8) too :)
> > 
> > > I'd amend autoinstall(8) and briefly mention it in sysupgrade(8), just
> > > via EXAMPLES or so to avoid duplication but showing a neat usecase.
> > 
> > Currently, these scripts seems to be only documented in the FAQ
> > (https://www.openbsd.org/faq/faq4.html#site). so having some
> > additionnal references at them in few man pages would be good.
> > 
> > Having examples in sysupgrade(8) and in autoinstall(8) makes sense to
> > me.
> > 
> > FAQ could be expanded a bit too.
> > 
> > Thanks.
> > -- 
> > Sebastien Marie
> > 
> 
> I agree that /install.site needs explaining, but I don't think it fits
> well in autoinstall(8). siteXX.tgz isn't touched on there and would have
> to be addressed as well.
> 
> I wouldn't mine working on that, but I'd prefer to put it where it belongs,
> or in a separate man page.
> 
> New diff attached. I see I put the wrong file name in the FILES section. Also,
> I simplified the example back to Sebastien Marie's original.
> 
> --Aaron
> 
> 
> Index: sysupgrade.8
> ===
> RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
> retrieving revision 1.10
> diff -u -p -r1.10 sysupgrade.8
> --- sysupgrade.8  3 Oct 2019 12:43:58 -   1.10
> +++ sysupgrade.8  28 Aug 2021 17:48:18 -
> @@ -46,6 +46,11 @@ The bootloader will automatically choose
>  triggering a one-shot upgrade using the files in
>  .Pa /home/_sysupgrade .
>  .Pp
> +If
> +.Pa /upgrade.site
> +exists and is executable, it is executed at the end of the upgrade
> +process, prior to rebooting.
> +.Pp
>  The options are as follows:
>  .Bl -tag -width Ds
>  .It Fl f
> @@ -73,16 +78,39 @@ This is the default if the system is cur
>  Response file for the ramdisk kernel.
>  .It Pa /bsd.upgrade
>  The ramdisk kernel to trigger an unattended upgrade.
> +.It Pa /upgrade.site
> +Executable file of actions to run after upgrade.
>  .It Pa /etc/installurl
>  .Ox
>  mirror top-level URL for fetching an upgrade.
>  .It Pa /home/_sysupgrade
>  Directory the upgrade is downloaded to.
>  .El
> +.Sh EXAMPLES
> +.Pa /upgrade.site
> +script to upgrade packages and check sysclean when
> +.Pa /etc/rc.firsttime
> +runs:
> +.Bd -literal
> + #!/bin/sh
> + PATH=/sbin:/bin:/usr/sbin:/usr/bin
> +
> + # upgrade packages
> + echo 'pkg_add -Iu' >>/etc/rc.firsttime
> +
> + # run sysclean (if installed)
> + echo '[ -x /usr/local/sbin/sysclean ] && \\
> + /usr/local/sbin/sysclean | mail -Es sysclean \\
> + root &' >>/etc/rc.firsttime
> +
> + exit 0
> + #
> +.Ed
>  .Sh SEE ALSO
>  .Xr signify 1 ,
>  .Xr installurl 5 ,
>  .Xr autoinstall 8 ,
> +.Xr rc 8 ,
>  .Xr release 8
>  .Sh HISTORY
>  .Nm



Re: [Patch] - Add -u (update packages) to sysupgrade(8)

2021-08-30 Thread Aaron Poffenberger
On 2021-08-30 22:16 +0100, Stuart Henderson  wrote:
> On 2021/08/28 09:26, Sebastien Marie wrote:
> > On Fri, Aug 27, 2021 at 08:17:51PM -0500, Aaron Poffenberger wrote:
> > > Following is patch to add a flag to upgrade packages during
> > > rc.firsttime after a sysupgrade.
> > > 
> > 
> > if you need this flag, is it a ponctual usage (running sysupgrade with
> > the flag or not, depending the moment) ? or you will use it everytime
> > you use sysupgrade ?
> 
> For my normal use, I decide at the time I run sysupgrade whether I want
> to update packages or not (if it's just a small bump in base, or I'm
> updating to test something quickly and it won't matter about packages,
> then I'll often skip it to save time - also I'll skip it if I know
> there's a major pgsql update in the way). I'd say my "more common" case
> would be to _not_ update.
> 
> > for permanent usage, I would recommand using existing facility: the
> > /upgrade.site script.
> 
> That's handy and I didn't know about it (though it does break /u
> for /usr tab-completion though :p). I don't think I'll use it for this
> usage but it's nice to have.
> 
I tried /upgrade.site. It works, but I have to agree there are times I'd rather
upgrade and move on without packages. A flag provides that flexibility.

Regardless, documenting /upgrade.site is useful I didn't know about it until
Sebastien Marie brought it up. On some machines I find it helpful.



Re: [Patch] Document /upgrade.site in sysupgrade(8) man page

2021-08-28 Thread Aaron Poffenberger
On 2021-08-28 19:45 +0200, Sebastien Marie  wrote:
> On Sat, Aug 28, 2021 at 05:05:18PM +, Klemens Nanni wrote:
> > On Sat, Aug 28, 2021 at 10:44:48AM -0500, Aaron Poffenberger wrote:
> > > Based on conversations in another thread, here's a patch documenting
> > > use of /upgrade.site in the sysupgrade(8) man page.
> > > 
> > > The revised doc references /upgrade.site and includes examples for
> > > updating packages from Sebastien Marie.
> > 
> > Documenting is the right approach, imho (I didn't even know about
> > $MODE.site) but this should probably be done in autoinstall(8).
> > 
> > This feature has nothing to do with sysupgrade per se and next to
> > upgrade.site there's also install.site.
> 
> $MODE.site isn't specially related to autoinstall(8) too :)
> 
> > I'd amend autoinstall(8) and briefly mention it in sysupgrade(8), just
> > via EXAMPLES or so to avoid duplication but showing a neat usecase.
> 
> Currently, these scripts seems to be only documented in the FAQ
> (https://www.openbsd.org/faq/faq4.html#site). so having some
> additionnal references at them in few man pages would be good.
> 
> Having examples in sysupgrade(8) and in autoinstall(8) makes sense to
> me.
> 
> FAQ could be expanded a bit too.
> 
> Thanks.
> -- 
> Sebastien Marie
> 

I agree that /install.site needs explaining, but I don't think it fits
well in autoinstall(8). siteXX.tgz isn't touched on there and would have
to be addressed as well.

I wouldn't mine working on that, but I'd prefer to put it where it belongs,
or in a separate man page.

New diff attached. I see I put the wrong file name in the FILES section. Also,
I simplified the example back to Sebastien Marie's original.

--Aaron


Index: sysupgrade.8
===
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
retrieving revision 1.10
diff -u -p -r1.10 sysupgrade.8
--- sysupgrade.83 Oct 2019 12:43:58 -   1.10
+++ sysupgrade.828 Aug 2021 17:48:18 -
@@ -46,6 +46,11 @@ The bootloader will automatically choose
 triggering a one-shot upgrade using the files in
 .Pa /home/_sysupgrade .
 .Pp
+If
+.Pa /upgrade.site
+exists and is executable, it is executed at the end of the upgrade
+process, prior to rebooting.
+.Pp
 The options are as follows:
 .Bl -tag -width Ds
 .It Fl f
@@ -73,16 +78,39 @@ This is the default if the system is cur
 Response file for the ramdisk kernel.
 .It Pa /bsd.upgrade
 The ramdisk kernel to trigger an unattended upgrade.
+.It Pa /upgrade.site
+Executable file of actions to run after upgrade.
 .It Pa /etc/installurl
 .Ox
 mirror top-level URL for fetching an upgrade.
 .It Pa /home/_sysupgrade
 Directory the upgrade is downloaded to.
 .El
+.Sh EXAMPLES
+.Pa /upgrade.site
+script to upgrade packages and check sysclean when
+.Pa /etc/rc.firsttime
+runs:
+.Bd -literal
+   #!/bin/sh
+   PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+   # upgrade packages
+   echo 'pkg_add -Iu' >>/etc/rc.firsttime
+
+   # run sysclean (if installed)
+   echo '[ -x /usr/local/sbin/sysclean ] && \\
+   /usr/local/sbin/sysclean | mail -Es sysclean \\
+   root &' >>/etc/rc.firsttime
+
+   exit 0
+   #
+.Ed
 .Sh SEE ALSO
 .Xr signify 1 ,
 .Xr installurl 5 ,
 .Xr autoinstall 8 ,
+.Xr rc 8 ,
 .Xr release 8
 .Sh HISTORY
 .Nm



[Patch] Document /upgrade.site in sysupgrade(8) man page

2021-08-28 Thread Aaron Poffenberger
Based on conversations in another thread, here's a patch documenting
use of /upgrade.site in the sysupgrade(8) man page.

The revised doc references /upgrade.site and includes examples for
updating packages from Sebastien Marie.

--Aaron

Index: sysupgrade.8
===
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
retrieving revision 1.10
diff -u -p -r1.10 sysupgrade.8
--- sysupgrade.83 Oct 2019 12:43:58 -   1.10
+++ sysupgrade.828 Aug 2021 15:22:42 -
@@ -46,6 +46,11 @@ The bootloader will automatically choose
 triggering a one-shot upgrade using the files in
 .Pa /home/_sysupgrade .
 .Pp
+If
+.Pa /upgrade.site
+exists and is executable, it is executed at the end of the upgrade
+process, prior to rebooting.
+.Pp
 The options are as follows:
 .Bl -tag -width Ds
 .It Fl f
@@ -73,16 +78,48 @@ This is the default if the system is cur
 Response file for the ramdisk kernel.
 .It Pa /bsd.upgrade
 The ramdisk kernel to trigger an unattended upgrade.
+.It Pa /update.site
+Executable file of actions to run after upgrade.
 .It Pa /etc/installurl
 .Ox
 mirror top-level URL for fetching an upgrade.
 .It Pa /home/_sysupgrade
 Directory the upgrade is downloaded to.
 .El
+.Sh EXAMPLES
+.Pa /upgrade.site
+script to upgrade packages when
+.Pa /etc/rc.firsttime
+runs:
+.Bd -literal
+   #!/bin/sh
+   PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+   # upgrade packages
+   echo 'pkg_add -Iu' >>/etc/rc.firsttime
+
+   # other commands
+
+   exit 0
+   #
+.Ed
+.Pp
+.Pa /upgrade.site
+addition to also run
+.Xr sysclean 8
+if installed:
+.Bd -literal
+   # other commands
+   # run sysclean (if installed)
+   echo '[ -x /usr/local/sbin/sysclean ] && \\
+   /usr/local/sbin/sysclean | mail -Es sysclean \\
+   root &' >>/etc/rc.firsttime
+.Ed
 .Sh SEE ALSO
 .Xr signify 1 ,
 .Xr installurl 5 ,
 .Xr autoinstall 8 ,
+.Xr rc 8 ,
 .Xr release 8
 .Sh HISTORY
 .Nm



Re: [Patch] - Add -u (update packages) to sysupgrade(8)

2021-08-27 Thread Aaron Poffenberger
On 2021-08-27 23:00 -0400, Daniel Jakots  wrote:
> On Fri, 27 Aug 2021 20:17:51 -0500, Aaron Poffenberger
>  wrote:
> 
> > +   ${PKGS} && echo "pkg_add -Iu" >> /etc/rc.firsttime
> 
> I don't think this addition is worth it, but anyway this won't work for
> people running -current when it's release time and the release isn't
> available yet (-Dsnap).
> 
> Cheers,
> Daniel
> 

Initially I considered a PKG_ADD environment variable to let the
override the command concatenated to /etc/rc.firsttime, but held
off until needed. Something like the following would resolve that
concern.

PKG_ADD='pkg_add -Iu -Dsnap' sysupgrade -u

--Aaron



[Patch] - Add -u (update packages) to sysupgrade(8)

2021-08-27 Thread Aaron Poffenberger
Following is patch to add a flag to upgrade packages during
rc.firsttime after a sysupgrade.

--Aaron


Index: sysupgrade.8
===
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.8,v
retrieving revision 1.10
diff -u -p -u -r1.10 sysupgrade.8
--- sysupgrade.83 Oct 2019 12:43:58 -   1.10
+++ sysupgrade.827 Aug 2021 19:33:11 -
@@ -66,6 +66,11 @@ This is the default if the system is cur
 .It Fl s
 Upgrade to a snapshot.
 This is the default if the system is currently running a snapshot.
+.It Fl u
+Upgrade packages.
+Upgrade installed packages when
+.Xr rc.firsttime 8
+is run.
 .El
 .Sh FILES
 .Bl -tag -width "/auto_upgrade.conf" -compact
@@ -84,6 +89,7 @@ Directory the upgrade is downloaded to.
 .Xr installurl 5 ,
 .Xr autoinstall 8 ,
 .Xr release 8
+.Xr rc.firsttime 8
 .Sh HISTORY
 .Nm
 first appeared in
Index: sysupgrade.sh
===
RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
retrieving revision 1.44
diff -u -p -u -r1.44 sysupgrade.sh
--- sysupgrade.sh   22 Oct 2020 07:19:42 -  1.44
+++ sysupgrade.sh   27 Aug 2021 19:29:01 -
@@ -77,14 +77,16 @@ SNAP=false
 FORCE=false
 KEEP=false
 REBOOT=true
+PKGS=false
 
-while getopts fknrs arg; do
+while getopts fknrsu arg; do
case ${arg} in
f)  FORCE=true;;
k)  KEEP=true;;
n)  REBOOT=false;;
r)  RELEASE=true;;
s)  SNAP=true;;
+   u)  PKGS=true;;
*)  usage;;
esac
 done
@@ -193,6 +195,7 @@ if ! ${KEEP}; then
cat <<__EOT > /etc/rc.firsttime
 rm -f ${SETSDIR}/{${CLEAN}}
 __EOT
+   ${PKGS} && echo "pkg_add -Iu" >> /etc/rc.firsttime
 fi
 
 echo Fetching updated firmware.



Re: New: netctl(8) - cli network-location manager

2017-09-27 Thread Aaron Poffenberger
* Aaron Poffenberger <a...@hypernote.com> [2017-09-26 21:53:24 -0500]:

> I should add, I thought about adding commands like rcctl's
> `get|getdef|set` commands to do full interface configuration (`set
> nwid wapname` or `set bssid `) but wanted to get feedback on
> the current approach before going to far down the rabbit hole.
> 
> --Aaron
> 
> * Aaron Poffenberger <a...@hypernote.com> [2017-09-26 20:39:29 -0500]:
> 
> > Attached is a cli utility to manage network locations. It's modeled
> > after rcctl(8).
> > 
> > It doesn't attempt to replace netstart(8) or ifconfig(8). It works
> > with them by storing location information in a directory and
> > symlinking the hostname.if files to the hostname.if for the selected
> > location.
> > 
> > At the moment if doesn't handle auto discovery of WAPs, but I have
> > code I wrote earlier I'm rewriting and integrating.
> > 
> > netctl is written in pure shell so in theory it could be called at
> > boot time. To do that, I'd probably split netctl into two pieces
> > similar to the way rcctl(8) and rc.subr(8) work. One file for
> > inclusion in /etc and the main ctl for /usr.
> > 
> > The code could be integrated into netstart at some later date.
> > 
> > In addition to the netctl utility I've included a man page.
> > 
> > Comments or feedback would be appreciated.
> > 
> > --Aaron

Below is a new unified diff. I added auto-detection and joining of
wireless networks.

I haven't done the work to allow boot-time auto-detect and joining of
wireless networks, yet. It's on my todo list.

I added a simple example script to the man page showing how to use it
with apmd(8) for resuming.

I also included the Makefile and README which were not in the original
posting.

--Aaron

--- /dev/null   Wed Sep 27 22:09:14 2017
+++ MakefileWed Sep 27 21:40:26 2017
@@ -0,0 +1,11 @@
+#  $OpenBSD$
+
+MAN=   netctl.8
+
+SCRIPT=netctl.sh
+
+realinstall:
+   ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
+   ${.CURDIR}/${SCRIPT} ${DESTDIR}${BINDIR}/netctl
+
+.include 
--- /dev/null   Wed Sep 27 22:09:14 2017
+++ README.md   Wed Sep 27 20:43:01 2017
@@ -0,0 +1,159 @@
+About netctl
+
+
+`netctl` is a utility to manage network locations, interface
+configuration files, and to start, stop, or restart interfaces on
+OpenBSD.
+
+`netctl` is not a replacement for `ifconfig(8)` or `netstart(8)`. It's
+utility to make managing locations easier. `netstart` and `ifconfig`
+still do the work. `netctl` makes the user's life, especially portable
+users, easier.
+
+
+Features
+
++ Create, delete and switch between **locations** (including restarting
+  **interfaces**)
++ Enable and disable **configurations**.
++ Start, stop and restart **interfaces**.
++ Detect and join known wireless networks (**waps**).
++ Scan for wireless access points.
++ List **locations**, **configurations**, **interfaces**, and **waps**.
+
+See the man page for further details.
+
+
+Install
+---
+
+There's no installer for `netctl` at the moment. `doas make install`
+will install to **/usr/local** unless you override the PREFIX
+variable.
+
+`make install` will also create **/etc/hostname.d/** and
+**/etc/hostname.d/nwids/**
+
+
+Locations
+-
+
+`netctl` works by symlinking **hostname.if** files in location
+directories to **/etc/hostname.if** so that the normal `netstart(8)`
+code can do what it already does well.
+
+`netctl` will create **location** directories for you by calling `doas
+netctl create location_name`. `netctl` will **not** at this time
+create the **hostname.if** files. They have to be created the same
+ways as documented in `hostname.if(5)`. See the `man` page for more
+details.
+
+
+Auto Detecting and Joining Networks
+---
+
+Auto detecting and joining requires some setup. `netctl` will not
+connect to wireless access points that are not known. To create a
+*known* wap, a standard wireless **hostname.if** files should be
+created in **/etc/hostname.d/nwids**. *E.g.,*
+
+```
+   $ cat /etc/hostname.d/nwids/Silly\ Wap.nwid
+   nwid "Silly Wap"
+   wpakey '$w@pau7h99'
+   dhcp
+```
+
+The filename **must** be the same as the **nwid** in the file which
+**must** match the **ESSID** of the wireless access point. Any valid
+configuration directive `ifconfig(8)` will accept may be placed in the
+file.
+
+Executing `doas netctl -a start iwm0` will cause `netctl` to scan the
+local network (with `ifconfig iwm0 scan`) and attempt to match the
+results with the names of the **nwids** found by `ls`-ing
+**/etc/hostname.d/nwids**.
+
+**N.B.** `ifconfig scan` is called dwith *each* wlan device unless one
+is specified after the **start** parameter.
+
+
+Auto Detecting and Joining Networks When Resuming
+

Re: New: netctl(8) - cli network-location manager

2017-09-26 Thread Aaron Poffenberger
I should add, I thought about adding commands like rcctl's
`get|getdef|set` commands to do full interface configuration (`set
nwid wapname` or `set bssid `) but wanted to get feedback on
the current approach before going to far down the rabbit hole.

--Aaron

* Aaron Poffenberger <a...@hypernote.com> [2017-09-26 20:39:29 -0500]:

> Attached is a cli utility to manage network locations. It's modeled
> after rcctl(8).
> 
> It doesn't attempt to replace netstart(8) or ifconfig(8). It works
> with them by storing location information in a directory and
> symlinking the hostname.if files to the hostname.if for the selected
> location.
> 
> At the moment if doesn't handle auto discovery of WAPs, but I have
> code I wrote earlier I'm rewriting and integrating.
> 
> netctl is written in pure shell so in theory it could be called at
> boot time. To do that, I'd probably split netctl into two pieces
> similar to the way rcctl(8) and rc.subr(8) work. One file for
> inclusion in /etc and the main ctl for /usr.
> 
> The code could be integrated into netstart at some later date.
> 
> In addition to the netctl utility I've included a man page.
> 
> Comments or feedback would be appreciated.
> 
> --Aaron
> 
> --- /dev/null Tue Sep 26 20:26:45 2017
> +++ netctlTue Sep 26 20:16:28 2017
> @@ -0,0 +1,450 @@
> +#!/bin/sh
> +#
> +# $OpenBSD$
> +#
> +# Copyright (c) 2017 Aaron Poffenberger <a...@hypernote.com>
> +#
> +# 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
> +# cmd OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS cmd, ARISING OUT OF
> +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> +#
> +
> +# Turn off Strict Bourne shell mode.
> +set +o sh
> +
> +readonly __progname="netctl"
> +readonly TRUE=0
> +readonly FALSE=1
> +readonly HN_DIR=${HN_DIR:-/etc/hostname.d}
> +
> +# Log an error
> +# Usage: log_err msg [exit code]
> +# Cheerfully copied from rc.subr(8)
> +# Copyright (c) 2010, 2011, 2014-2017 Antoine Jacoutot 
> <ajacou...@openbsd.org>
> +# Copyright (c) 2010, 2011 Ingo Schwarze <schwa...@openbsd.org>
> +# Copyright (c) 2010, 2011, 2014 Robert Nagy <rob...@openbsd.org>
> +log_err() {
> + [ -n "${1}" ] && echo "${1}" 1>&2
> + [ -n "${2}" ] && exit "${2}" || exit 1
> +}
> +
> +# Log a warning
> +# Usage: log_err msg [exit code]
> +log_warning() {
> + log_msg "${1}" 1>&2
> +}
> +
> +# Log a message
> +# Usage: log_msg msg [right justify length]
> +log_msg() {
> + local -R${2:-0} _msg="${1}"
> +
> + [ -n "${_msg}" ] && echo "${_msg}"
> +}
> +
> +# Log a message to stdout or stderr
> +# Usage: usage [2]
> +usage() {
> + echo \
> + "usage:  netctl [-h]
> + netctl ls [lsarg ...]
> + netctl create|delete location ...
> + netctl [-dr] switch location [interface ...]
> + netctl enable|disable [configuration ...]
> + netctl start|stop|restart [interface ...]
> + netctl [-v] scan [interface ...]" 1>&${1:-1}
> +}
> +
> +# Get interface configuration
> +# Expects variables to be typeset/local from calling fn
> +# Usage: get_if_conf if1
> +get_if_conf() {
> + # use co-process to preserve values set in while loop
> + ifconfig $1 |&
> + while IFS=' ' read -r -p _l; do
> + _key=${_l%%*([[:blank:]])*(:) *}
> + _val=${_l##*([[:blank:]])*${_key}*(:)*([[:blank:]])}
> +
> + [[ ${_key} == 'groups' ]] && _groups=${_val}
> + [[ ${_key} == 'media' ]] && _media=${_val}
> + [[ ${_key} == 'status' ]] && _status=${_val}
> + [[ ${_key} == 'ieee80211' ]] && _ieee80211=${_val}
> + [[ ${_key} == 'inet' ]] && _inet=${_val}
> + [[ ${_key} == 'inet6' ]] && _inet6=${_val}
> + done
> +}
> +
> +# Get interfaces
> +# Expects variable _ifs to be typeset/local from calling fn
> +# Usage: get_ifs if1
> +get_ifs() {
> + 

New: netctl(8) - cli network-location manager

2017-09-26 Thread Aaron Poffenberger
Attached is a cli utility to manage network locations. It's modeled
after rcctl(8).

It doesn't attempt to replace netstart(8) or ifconfig(8). It works
with them by storing location information in a directory and
symlinking the hostname.if files to the hostname.if for the selected
location.

At the moment if doesn't handle auto discovery of WAPs, but I have
code I wrote earlier I'm rewriting and integrating.

netctl is written in pure shell so in theory it could be called at
boot time. To do that, I'd probably split netctl into two pieces
similar to the way rcctl(8) and rc.subr(8) work. One file for
inclusion in /etc and the main ctl for /usr.

The code could be integrated into netstart at some later date.

In addition to the netctl utility I've included a man page.

Comments or feedback would be appreciated.

--Aaron

--- /dev/null   Tue Sep 26 20:26:45 2017
+++ netctl  Tue Sep 26 20:16:28 2017
@@ -0,0 +1,450 @@
+#!/bin/sh
+#
+# $OpenBSD$
+#
+# Copyright (c) 2017 Aaron Poffenberger <a...@hypernote.com>
+#
+# 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
+# cmd OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS cmd, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+# Turn off Strict Bourne shell mode.
+set +o sh
+
+readonly __progname="netctl"
+readonly TRUE=0
+readonly FALSE=1
+readonly HN_DIR=${HN_DIR:-/etc/hostname.d}
+
+# Log an error
+# Usage: log_err msg [exit code]
+# Cheerfully copied from rc.subr(8)
+# Copyright (c) 2010, 2011, 2014-2017 Antoine Jacoutot <ajacou...@openbsd.org>
+# Copyright (c) 2010, 2011 Ingo Schwarze <schwa...@openbsd.org>
+# Copyright (c) 2010, 2011, 2014 Robert Nagy <rob...@openbsd.org>
+log_err() {
+   [ -n "${1}" ] && echo "${1}" 1>&2
+   [ -n "${2}" ] && exit "${2}" || exit 1
+}
+
+# Log a warning
+# Usage: log_err msg [exit code]
+log_warning() {
+   log_msg "${1}" 1>&2
+}
+
+# Log a message
+# Usage: log_msg msg [right justify length]
+log_msg() {
+   local -R${2:-0} _msg="${1}"
+
+   [ -n "${_msg}" ] && echo "${_msg}"
+}
+
+# Log a message to stdout or stderr
+# Usage: usage [2]
+usage() {
+   echo \
+   "usage:  netctl [-h]
+   netctl ls [lsarg ...]
+   netctl create|delete location ...
+   netctl [-dr] switch location [interface ...]
+   netctl enable|disable [configuration ...]
+   netctl start|stop|restart [interface ...]
+   netctl [-v] scan [interface ...]" 1>&${1:-1}
+}
+
+# Get interface configuration
+# Expects variables to be typeset/local from calling fn
+# Usage: get_if_conf if1
+get_if_conf() {
+   # use co-process to preserve values set in while loop
+   ifconfig $1 |&
+   while IFS=' ' read -r -p _l; do
+   _key=${_l%%*([[:blank:]])*(:) *}
+   _val=${_l##*([[:blank:]])*${_key}*(:)*([[:blank:]])}
+
+   [[ ${_key} == 'groups' ]] && _groups=${_val}
+   [[ ${_key} == 'media' ]] && _media=${_val}
+   [[ ${_key} == 'status' ]] && _status=${_val}
+   [[ ${_key} == 'ieee80211' ]] && _ieee80211=${_val}
+   [[ ${_key} == 'inet' ]] && _inet=${_val}
+   [[ ${_key} == 'inet6' ]] && _inet6=${_val}
+   done
+}
+
+# Get interfaces
+# Expects variable _ifs to be typeset/local from calling fn
+# Usage: get_ifs if1
+get_ifs() {
+   local _if _excl_keys
+   # exclude network pseudo-devices
+   set -A _pseudo_devices $(ifconfig -C)
+
+   # use co-process to preserve values set in while loop
+   ifconfig $1 |&
+   while IFS=' ' read -r -p _l; do
+   [[ "${_l}" == *flags* ]] || continue
+
+   _if=${_l%%*([[:blank:]])*():*}
+
+   [ -z "${_if}" ] && continue
+
+   #_if=${_l%%*([[:blank:]])*():*}
+
+   # exclude if-type (san _if num) in pseudo-devices
+   [[ " ${_pseudo_devices[*]}0 " == *" ${_if%%*([[:digit:]])} "* 
]] &&
+   continue
+
+   _ifs[${#_ifs[*]}]="${_if}"
+   done
+
+   [ -n "${_ifs}" ] || return 1
+}
+
+get_locations() {
+   local _l
+
+   ls -p "${HN_DIR}" |&
+   # use co-proc

Re: regression tests and patch for calendar(1)

2016-09-14 Thread Aaron Poffenberger
Hi Andy,

I just ran into this regression and wrote a similar patch (though I
missed the WEEKLY test).

Thanks for the fix! It solves the Easter-calculation problem I
noticed.

For anyone looking for a quick test, none of the pre- or post-Easter
dates will be displayed when executing:

calendar -t 20160101 -A 180 -f /usr/share/calendar/calendar.christian

After Andy's patch it resolves the issue.

--Aaron

* Andy Bradford  [2016-08-31 07:52:19 -0600]:

> Hello,
> 
> While writing a  set of regression tests for calendar(1)  I discovered a
> bug introduced by my last patch.  The following patch fixes that and all
> regression tests in the attachment of tests passes.
> 
> Thanks,
> 
> Andy
> 
> Index: day.c
> ===
> RCS file: /home/cvs/src/usr.bin/calendar/day.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 day.c
> --- day.c 13 Jul 2016 21:32:01 -  1.33
> +++ day.c 31 Aug 2016 13:40:01 -
> @@ -543,7 +543,9 @@ isnow(char *endp, int bodun)
>   tdiff = difftime(ttmp, f_time)/ SECSPERDAY;
>   if (tdiff <= offset + f_dayAfter ||
>   (bodun && tdiff == -1)) {
> - if ((tmtmp.tm_mon == month) &&
> + if (((tmtmp.tm_mon == month) ||
> +  (flags & F_SPECIAL) ||
> +  (interval == WEEKLY)) &&
>   (tdiff >=  0 ||
>   (bodun && tdiff == -1))) {
>   if ((tmp = malloc(sizeof(struct 
> match))) == NULL)
>