Possible logic error in 'ioapic0: misconfigured as apic' fix?

2017-08-28 Thread Andrew Daugherity
I was looking at post-6.0 commits to sys/arch/i386/i386 to see if there was
anything obvious that would explain why 6.1 won't boot on a 486 while 6.0
does.
Nothing jumped out, but I did a double-take at this unrelated commit:


Stop printing the "ioapic0: misconfigured as apic..." messages.  Basically
all modern machines are "misconfigured".  We simply have to configure them
and it is pointless to complain.
[sys/arch/i386/i386/ioapic.c   r1.38 and
 sys/arch/amd64/amd64/ioapic.c r1.24]


The code doesn't seem to do what the commit log says -- the change was:
@@ -353,7 +353,7 @@
  * In case the APIC is not initialized to the correct ID
  * do it now.
  */
- if (apic_id != sc->sc_apicid) {
+ if (mp_verbose && apic_id != sc->sc_apicid) {
  printf("%s: misconfigured as apic %d",
 sc->sc_pic.pic_name, apic_id);
  ioapic_set_id(sc);


This means that without mp_verbose, ioapic_set_id(sc) doesn't get called.
If
we "simply have to configure them" and don't want to complain normally, I
think
this would be more appropriate:

if (apic_id != sc->sc_apicid) {
if (mp_verbose)
printf("%s: misconfigured as apic %d",
sc->sc_pic.pic_name, apic_id);
ioapic_set_id(sc);
}

Perhaps I'm missing something and io_apic_set_id() doesn't always need to be
called?  Also, the comments before this block are different on amd64 and
i386,
but I don't know which one is preferred.

Anyway, here's a diff:

diff --git a/sys/arch/amd64/amd64/ioapic.c b/sys/arch/amd64/amd64/ioapic.c
index e8f5e6aa7..427d0b5aa 100644
--- a/sys/arch/amd64/amd64/ioapic.c
+++ b/sys/arch/amd64/amd64/ioapic.c
@@ -356,9 +356,10 @@ ioapic_attach(struct device *parent, struct device
*self, void *aux)
 * Maybe we should record the original ID for interrupt
 * mapping later ...
 */
-   if (mp_verbose && apic_id != sc->sc_apicid) {
-   printf("%s: misconfigured as apic %d",
-   sc->sc_pic.pic_name, apic_id);
+   if (apic_id != sc->sc_apicid) {
+   if (mp_verbose)
+   printf("%s: misconfigured as apic %d",
+   sc->sc_pic.pic_name, apic_id);
ioapic_set_id(sc);
}
 #if 0
diff --git a/sys/arch/i386/i386/ioapic.c b/sys/arch/i386/i386/ioapic.c
index f6de0573e..7ec54f9cd 100644
--- a/sys/arch/i386/i386/ioapic.c
+++ b/sys/arch/i386/i386/ioapic.c
@@ -352,9 +352,10 @@ ioapic_attach(struct device *parent, struct device
*self, void *aux)
 * In case the APIC is not initialized to the correct ID
 * do it now.
 */
-   if (mp_verbose && apic_id != sc->sc_apicid) {
-   printf("%s: misconfigured as apic %d",
-   sc->sc_pic.pic_name, apic_id);
+   if (apic_id != sc->sc_apicid) {
+   if (mp_verbose)
+   printf("%s: misconfigured as apic %d",
+   sc->sc_pic.pic_name, apic_id);
ioapic_set_id(sc);
}
 #if 0


Fix OF_getbodebyname()

2017-08-28 Thread Mark Kettenis
The idea is that it will look for children of the passed node with a
specific name.  But it doesn't actually work because it looks for
nodes at the same level of the passed node.  This diff fixes it.

ok?


Index: dev/ofw/fdt.c
===
RCS file: /cvs/src/sys/dev/ofw/fdt.c,v
retrieving revision 1.20
diff -u -p -r1.20 fdt.c
--- dev/ofw/fdt.c   12 Mar 2017 11:44:42 -  1.20
+++ dev/ofw/fdt.c   28 Aug 2017 20:39:47 -
@@ -773,11 +773,9 @@ OF_getnodebyname(int handle, const char 
if (handle == 0)
node = fdt_find_node("/");
 
-   while (node) {
+   for (node = fdt_child_node(node); node; node = fdt_next_node(node)) {
if (strcmp(name, fdt_node_name(node)) == 0)
break;
-
-   node = fdt_next_node(node);
}
 
return node ? ((char *)node - (char *)tree.header) : 0;



Re: CVS: cvs.openbsd.org: src

2017-08-28 Thread lists
Mon, 28 Aug 2017 10:16:58 -0600 (MDT) Ted Unangst 
> CVSROOT:  /cvs
> Module name:  src
> Changes by:   t...@cvs.openbsd.org2017/08/28 10:16:58
> 
> Modified files:
>   usr.sbin/apmd  : apmd.8 apmd.c 
> 
> Log message:
> add -z and -Z options to auto suspend or hibernate when low on battery.
> from Jesper Wallin
> 

Hi tech@,

Could someone please test and confirm suspend still works on i386?  I am
getting the laptop to wake but it's stuck, black screen, high fan speed,
no response, only long press on the power button works.  It used to work
flawless, I suspect it might be from the last few snapshots, can't tell.

Ready to provide details if this works elsewhere & someone's interested.
Please let me know if it's a known/expected issue, or better sendbug(1).

Kind regards,
Anton Lazarov

OpenBSD 6.2-beta (GENERIC.MP) #91: Sun Aug 27 17:26:00 MDT 2017
dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
cpu0: Intel(R) Atom(TM) CPU N280 @ 1.66GHz ("GenuineIntel" 686-class) 1.67 GHz
cpu0: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,LAHF,PERF,SENSOR
real mem  = 1064452096 (1015MB)
avail mem = 1029943296 (982MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: date 04/18/11, BIOS32 rev. 0 @ 0xf0010, SMBIOS rev. 2.5 @ 
0xf0720 (30 entries)
bios0: vendor American Megatrends Inc. version "1601" date 04/18/2011
bios0: ASUSTeK Computer INC. 1005HA
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC MCFG OEMB HPET SSDT
acpi0: wakeup devices P0P2(S4) P0P1(S4) HDAC(S4) P0P4(S4) P0P8(S4) P0P5(S4) 
P0P7(S4) P0P9(S4) P0P6(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 166MHz
cpu0: mwait min=64, max=64, C-substates=0.2.2.0.2, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Atom(TM) CPU N280 @ 1.66GHz ("GenuineIntel" 686-class) 1.67 GHz
cpu1: 
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,NXE,SSE3,DTES64,MWAIT,DS-CPL,EST,TM2,SSSE3,xTPR,PDCM,MOVBE,LAHF,PERF,SENSOR
ioapic0 at mainbus0: apid 2 pa 0xfec0, version 20, 24 pins
acpimcfg0 at acpi0 addr 0xe000, bus 0-63
acpihpet0 at acpi0: 14318179 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 2 (P0P5)
acpiprt2 at acpi0: bus 1 (P0P7)
acpiprt3 at acpi0: bus -1 (P0P6)
acpiec0 at acpi0
acpicpu0 at acpi0: !C2(500@1 mwait.1@0x10), C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: !C2(500@1 mwait.1@0x10), C1(1000@1 mwait.1), PSS
acpitz0 at acpi0: critical temperature is 88 degC
"SYN0A13" at acpi0 not configured
acpibat0 at acpi0: BAT0 model "1005HA" serial   type LION oem "ASUS"
acpiac0 at acpi0: AC unit online
acpibtn0 at acpi0: LID_
acpibtn1 at acpi0: SLPB
acpibtn2 at acpi0: PWRB
"PNP0C14" at acpi0 not configured
acpivideo0 at acpi0: VGA_
acpivout0 at acpivideo0: LCDD
bios0: ROM list: 0xc/0xec00! 0xcf000/0x1000
cpu0: Enhanced SpeedStep 1667 MHz: speeds: 1667, 1333, 1000 MHz
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82945GME Host" rev 0x03
inteldrm0 at pci0 dev 2 function 0 "Intel 82945GME Video" rev 0x03
drm0 at inteldrm0
intagp0 at inteldrm0
agp0 at intagp0: aperture at 0xd000, size 0x1000
inteldrm0: apic 2 int 16
inteldrm0: 1024x600, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel 82945GM Video" rev 0x03 at pci0 dev 2 function 1 not configured
azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02: msi
azalia0: codecs: Realtek ALC269
audio0 at azalia0
ppb0 at pci0 dev 28 function 0 "Intel 82801GB PCIE" rev 0x02: apic 2 int 16
pci1 at ppb0 bus 4
ppb1 at pci0 dev 28 function 1 "Intel 82801GB PCIE" rev 0x02: apic 2 int 17
pci2 at ppb1 bus 2
athn0 at pci2 dev 0 function 0 "Atheros AR9285" rev 0x01: apic 2 int 17
athn0: AR9285 rev 2 (1T1R), ROM rev 13, address 00:25:d3:5f:06:4c
ppb2 at pci0 dev 28 function 3 "Intel 82801GB PCIE" rev 0x02: apic 2 int 19
pci3 at ppb2 bus 1
alc0 at pci3 dev 0 function 0 "Attansic Technology L2C" rev 0xc0: msi, address 
00:26:18:93:af:0b
atphy0 at alc0 phy 0: F1 10/100/1000 PHY, rev. 11
uhci0 at pci0 dev 29 function 0 "Intel 82801GB USB" rev 0x02: apic 2 int 23
uhci1 at pci0 dev 29 function 1 "Intel 82801GB USB" rev 0x02: apic 2 int 19
uhci2 at pci0 dev 29 function 2 "Intel 82801GB USB" rev 0x02: apic 2 int 18
uhci3 at pci0 dev 29 function 3 "Intel 82801GB USB" rev 0x02: apic 2 int 16
ehci0 at pci0 dev 29 function 7 "Intel 82801GB USB" rev 0x02: apic 2 int 23
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Intel EHCI root hub" rev 2.00/1.00 
addr 1
ppb3 at pci0 dev 30 

Re: strtok_r(3): mention standards

2017-08-28 Thread Jeremie Courreges-Anglas
On Mon, Aug 28 2017, "Todd C. Miller"  wrote:
> On Mon, 28 Aug 2017 14:29:18 +0200, Jeremie Courreges-Anglas wrote:
>
>> IIUC strtok_r appeared in IEEE Std 1003.1c-1995, the diff below
>> documents that.  That would be the first use of .St -p1003.1c-95 in the
>> tree.  (Is this one available online?  My search skillz have failed me
>> so far...)
>
> The "conforms to" bit does not need to specify the first version
> of the standard that the function appeared in.  I'd be inclined to
> use -p1003.1-2001 like we do in many of our other manuals.

ack.  strtok_r appeared in SUSv2 before POSIX 2001.  So, -susv2 (we
already use it, no idea if consistently though) or -p1003.1-2001?

I don't feel strongly about it, it just feels weird not to mention
a standard. :)

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: [PATCH] add initial set of regress tests for vmd

2017-08-28 Thread Carlos Cardenas
On Sun, Aug 27, 2017 at 11:44 PM, Mike Larkin  wrote:

> On Sun, Aug 27, 2017 at 02:24:08PM -0700, Carlos Cardenas wrote:
> > Howdy.
> >
> > Below is patch for some initial parsing tests for vmd:
> > * Memory string parsing (too small, invalid size, and rounding)
> > * Max disk path
> > * Max vm name
> > * Max kernel path
> > * Max NICs
> >
> > More tests to come.
> >
> > One item missing is the proper hook into regress/usr.sbin/Makefile
> > as it was unknown if they should be run all the time or only for
> > REGRESS_FULL.  Comments?
> >
> > Ok?
> >
>
> The diff doesn't apply. I think it got mangled. Can you send it again
> without line wrapping?


Re-sending.

+--+
Carlos

diff --git regress/usr.sbin/vmd/Makefile regress/usr.sbin/vmd/Makefile
new file mode 100644
index 000..d7b3794710a
--- /dev/null
+++ regress/usr.sbin/vmd/Makefile
@@ -0,0 +1,44 @@
+# $OpenBSD: $
+
+# TARGETS
+# vmd-pass: load vmd-pass-*.conf through vmd and check against
vmd-pass-*.ok
+# vmd-fail: load vmd-fail-*.conf through vmd and check against
vmd-fail-*.ok
+
+VMD_PASS=1 2 3
+VMD_FAIL=1 2 3 4 5 6 7
+
+MAKEOBJDIRPREFIX=
+
+SHELL=/bin/sh
+
+.MAIN: all
+
+.for n in ${VMD_PASS}
+VMD_PASS_TARGETS+=vmd_pass${n}
+
+vmd_pass${n}:
+   ${SUDO} vmd -n -f ${.CURDIR}/vmd-pass-${n}.conf 2>&1 | \
+   diff -u ${.CURDIR}/vmd-pass-${n}.ok /dev/stdin
+.endfor
+
+vmd-pass:  ${VMD_PASS_TARGETS}
+REGRESS_TARGETS+=vmd-pass
+REGRESS_ROOT_TARGETS+=vmd-pass
+
+.for n in ${VMD_FAIL}
+VMD_FAIL_TARGETS+=vmd_fail${n}
+
+vmd_fail${n}:
+   ${SUDO} vmd -n -f ${.CURDIR}/vmd-fail-${n}.conf 2>&1 | \
+   diff -u ${.CURDIR}/vmd-fail-${n}.ok /dev/stdin
+.endfor
+
+vmd-fail:  ${VMD_FAIL_TARGETS}
+REGRESS_TARGETS+=vmd-fail
+REGRESS_ROOT_TARGETS+=vmd-fail
+
+alltests: ${REGRESS_TARGETS}
+
+.PHONY: ${REGRESS_TARGETS}
+
+.include 
diff --git regress/usr.sbin/vmd/vmd-fail-1.conf
regress/usr.sbin/vmd/vmd-fail-1.conf
new file mode 100644
index 000..3e3006a057d
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-1.conf
@@ -0,0 +1,12 @@
+# $OpenBSD: $
+# Fail on kernel keyword; has been replaced by boot.
+ramdisk="/bsd.rd"
+switch "sw" {
+add vether0
+}
+vm "x" {
+kernel $ramdisk
+memory 2G
+disable
+interface { switch "sw" }
+}
diff --git regress/usr.sbin/vmd/vmd-fail-1.ok
regress/usr.sbin/vmd/vmd-fail-1.ok
new file mode 100644
index 000..02fcd909b1e
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-1.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-1.conf:8: syntax error
diff --git regress/usr.sbin/vmd/vmd-fail-2.conf
regress/usr.sbin/vmd/vmd-fail-2.conf
new file mode 100644
index 000..69cf1c4e630
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-2.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: $
+# Fail on memory (less than 1MB)
+vm "x" {
+memory 1048575
+}
diff --git regress/usr.sbin/vmd/vmd-fail-2.ok
regress/usr.sbin/vmd/vmd-fail-2.ok
new file mode 100644
index 000..4abf9f32b09
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-2.ok
@@ -0,0 +1,2 @@
+size must be at least one megabyte
+/usr/src/regress/usr.sbin/vmd/vmd-fail-2.conf:4: failed to parse size:
1048575
diff --git regress/usr.sbin/vmd/vmd-fail-3.conf
regress/usr.sbin/vmd/vmd-fail-3.conf
new file mode 100644
index 000..a8767829159
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-3.conf
@@ -0,0 +1,4 @@
+# $OpenBSD: $
+# Fail on VM name (> 32chars)
+vm "abcdefghijklmnopqrstuvwxyz0123456789" {
+}
diff --git regress/usr.sbin/vmd/vmd-fail-3.ok
regress/usr.sbin/vmd/vmd-fail-3.ok
new file mode 100644
index 000..788b7e53657
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-3.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-3.conf:3: vm name too long
diff --git regress/usr.sbin/vmd/vmd-fail-4.conf
regress/usr.sbin/vmd/vmd-fail-4.conf
new file mode 100644
index 000..83c59c2e61e
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-4.conf
@@ -0,0 +1,5 @@
+# $OpenBSD: $
+# Fail on nifs (> 4)
+vm "a" {
+nifs 5
+}
diff --git regress/usr.sbin/vmd/vmd-fail-4.ok
regress/usr.sbin/vmd/vmd-fail-4.ok
new file mode 100644
index 000..c533cba38d0
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-4.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-4.conf:4: syntax error
diff --git regress/usr.sbin/vmd/vmd-fail-5.conf
regress/usr.sbin/vmd/vmd-fail-5.conf
new file mode 100644
index 000..c53cfd32968
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-5.conf
@@ -0,0 +1,6 @@
+# $OpenBSD: $
+# Fail on boot path (> 128)
+ramdisk="/some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.rd"
+vm "x" {
+kernel $ramdisk
+}
diff --git regress/usr.sbin/vmd/vmd-fail-5.ok
regress/usr.sbin/vmd/vmd-fail-5.ok
new file mode 100644
index 000..f17303c6838
--- /dev/null
+++ regress/usr.sbin/vmd/vmd-fail-5.ok
@@ -0,0 +1 @@
+/usr/src/regress/usr.sbin/vmd/vmd-fail-5.conf:5: syntax error
diff --git 

Re: [patch] Add -z and -Z to apmd for automatic suspend/hibernate

2017-08-28 Thread Ted Unangst
Jesper Wallin wrote:
> On Tue, Aug 15, 2017 at 07:24:47PM -0400, Ted Unangst wrote:
> > this looks good. will commit soon.
> > 
> > (one nit, i'll correct, is man page options are upper case first.)
> 
> Sorry if this comes on as a bit pushy, but any news here? I don't know
> how 6.2-beta affects this, but maybe it would be nice to have this added
> before -release?

finally committed. it kept slipping my mind, sorry about that.



Re: ksh: walking valid history entries

2017-08-28 Thread Todd C. Miller
On Mon, 28 Aug 2017 11:13:03 +0200, Jeremie Courreges-Anglas wrote:

> Right now the code uses two methods to access "valid" entries in the
> history array.  One method only looks at entries in [history;histptr],
> the other method walks the array until it finds a NULL pointer.
> 
> The latter method appears fragile to me.  *IIUC* the test at the
> beginning of history_write() means that history_write() only walks the
> array when the latter is full ie when
> "histptr == [histsize -1]", so it doesn't access dangling
> pointers after "histptr"; also the "if (cmd == NULL)" test looks like
> dead code.
> 
> I find this error-prone and think that we should rely on a single method
> to walk the array.  This is what the third hunk does.  The first &
> second hunks undo part of my previous commit, leaving freed entries
> alone, so that we don't send the wrong hint & encourage code such as the
> current history_write().

I agree.  OK millert@

 - todd



Re: strtok_r(3): mention standards

2017-08-28 Thread Todd C. Miller
On Mon, 28 Aug 2017 14:29:18 +0200, Jeremie Courreges-Anglas wrote:

> IIUC strtok_r appeared in IEEE Std 1003.1c-1995, the diff below
> documents that.  That would be the first use of .St -p1003.1c-95 in the
> tree.  (Is this one available online?  My search skillz have failed me
> so far...)

The "conforms to" bit does not need to specify the first version
of the standard that the function appeared in.  I'd be inclined to
use -p1003.1-2001 like we do in many of our other manuals.

 - todd



Re: smtpd: tweak static table parser

2017-08-28 Thread Gilles Chehade
On Mon, Aug 28, 2017 at 05:27:03PM +0200, Eric Faurot wrote:
> Hi,
> 
> The current static (file) table parser is a bit clumsy.  It tries to
> determine the type (mapping or list entry) of each line independently
> by splitting on allowed separators (" \t:") without using any context,
> then fails if the type is not what's expected. It's impossible to define
> a list of ipv6 addresses for instance, since ':' is a valid separator.
> 
> This diff changes the parser logic. If the table is untyped, determine
> its type by examining the first entry: if it contains a separator, type
> is "mapping", otherwise type is "list".  All entries are then parsed
> according to the table type.  The "list" type can also be forced by using
> the "@list" directive in a comment. This allows to define list of entries
> containing a separator.
> 
> Existing table files should still be working as expected.
> As a bonus, parse errors are now logged with line number.
> 

as discussed, i think it's a neat idea

the diff is ok gilles@ too


> Index: table_static.c
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/table_static.c,v
> retrieving revision 1.16
> diff -u -p -r1.16 table_static.c
> --- table_static.c14 Aug 2017 08:01:14 -  1.16
> +++ table_static.c16 Aug 2017 15:27:22 -
> @@ -73,7 +73,8 @@ static int
>  table_static_config(struct table *t)
>  {
>   FILE*fp;
> - char*buf = NULL;
> + char*buf = NULL, *p;
> + int  lineno = 0;
>   size_t   sz = 0;
>   ssize_t  flen;
>   char*keyp;
> @@ -90,14 +91,47 @@ table_static_config(struct table *t)
>   }
>  
>   while ((flen = getline(, , fp)) != -1) {
> + lineno++;
>   if (buf[flen - 1] == '\n')
> - buf[flen - 1] = '\0';
> + buf[--flen] = '\0';
>  
>   keyp = buf;
> - while (isspace((unsigned char)*keyp))
> + while (isspace((unsigned char)*keyp)) {
>   ++keyp;
> - if (*keyp == '\0' || *keyp == '#')
> + --flen;
> + }
> + if (*keyp == '\0')
> + continue;
> + while (isspace((unsigned char)keyp[flen - 1]))
> + keyp[--flen] = '\0';
> + if (*keyp == '#') {
> + if (t->t_type == T_NONE) {
> + keyp++;
> + while (isspace((unsigned char)*keyp))
> + ++keyp;
> + if (!strcmp(keyp, "@list"))
> + t->t_type = T_LIST;
> + }
>   continue;
> + }
> +
> + if (t->t_type == T_NONE) {
> + for (p = keyp; *p; p++) {
> + if (*p == ' ' || *p == '\t' || *p == ':') {
> + t->t_type = T_HASH;
> + break;
> + }
> + }
> + if (t->t_type == T_NONE)
> + t->t_type = T_LIST;
> + }
> +
> + if (t->t_type == T_LIST) {
> + table_add(t, keyp, NULL);
> + continue;
> + }
> +
> + /* T_HASH */
>   valp = keyp;
>   strsep(, " \t:");
>   if (valp) {
> @@ -111,18 +145,20 @@ table_static_config(struct table *t)
>   if (*valp == '\0')
>   valp = NULL;
>   }
> + if (valp == NULL) {
> + log_warnx("%s: invalid map entry line %d", t->t_config,
> + lineno);
> + goto end;
> + }
>  
> - if (t->t_type == 0)
> - t->t_type = (valp == keyp || valp == NULL) ? T_LIST :
> - T_HASH;
> + table_add(t, keyp, valp);
> + }
>  
> - if ((valp == keyp || valp == NULL) && t->t_type == T_LIST)
> - table_add(t, keyp, NULL);
> - else if ((valp != keyp && valp != NULL) && t->t_type == T_HASH)
> - table_add(t, keyp, valp);
> - else
> - goto end;
> + if (ferror(fp)) {
> + log_warn("%s: getline", t->t_config);
> + goto end;
>   }
> +
>   /* Accept empty alias files; treat them as hashes */
>   if (t->t_type == T_NONE && t->t_backend->services & K_ALIAS)
>   t->t_type = T_HASH;
> 

-- 
Gilles Chehade

https://www.poolp.org  @poolpOrg



Re: [PATCH] diff exit status

2017-08-28 Thread Todd C. Miller
On Sun, 27 Aug 2017 00:47:26 +0200, Ibrahim Khalifa wrote:

> Bumping this to tech@ since I think it would be nice to get this into the
> stock diff.

Committed, thanks.

 - todd



smtpd: tweak static table parser

2017-08-28 Thread Eric Faurot
Hi,

The current static (file) table parser is a bit clumsy.  It tries to
determine the type (mapping or list entry) of each line independently
by splitting on allowed separators (" \t:") without using any context,
then fails if the type is not what's expected. It's impossible to define
a list of ipv6 addresses for instance, since ':' is a valid separator.

This diff changes the parser logic. If the table is untyped, determine
its type by examining the first entry: if it contains a separator, type
is "mapping", otherwise type is "list".  All entries are then parsed
according to the table type.  The "list" type can also be forced by using
the "@list" directive in a comment. This allows to define list of entries
containing a separator.

Existing table files should still be working as expected.
As a bonus, parse errors are now logged with line number.

Eric.


Index: table_static.c
===
RCS file: /cvs/src/usr.sbin/smtpd/table_static.c,v
retrieving revision 1.16
diff -u -p -r1.16 table_static.c
--- table_static.c  14 Aug 2017 08:01:14 -  1.16
+++ table_static.c  16 Aug 2017 15:27:22 -
@@ -73,7 +73,8 @@ static int
 table_static_config(struct table *t)
 {
FILE*fp;
-   char*buf = NULL;
+   char*buf = NULL, *p;
+   int  lineno = 0;
size_t   sz = 0;
ssize_t  flen;
char*keyp;
@@ -90,14 +91,47 @@ table_static_config(struct table *t)
}
 
while ((flen = getline(, , fp)) != -1) {
+   lineno++;
if (buf[flen - 1] == '\n')
-   buf[flen - 1] = '\0';
+   buf[--flen] = '\0';
 
keyp = buf;
-   while (isspace((unsigned char)*keyp))
+   while (isspace((unsigned char)*keyp)) {
++keyp;
-   if (*keyp == '\0' || *keyp == '#')
+   --flen;
+   }
+   if (*keyp == '\0')
+   continue;
+   while (isspace((unsigned char)keyp[flen - 1]))
+   keyp[--flen] = '\0';
+   if (*keyp == '#') {
+   if (t->t_type == T_NONE) {
+   keyp++;
+   while (isspace((unsigned char)*keyp))
+   ++keyp;
+   if (!strcmp(keyp, "@list"))
+   t->t_type = T_LIST;
+   }
continue;
+   }
+
+   if (t->t_type == T_NONE) {
+   for (p = keyp; *p; p++) {
+   if (*p == ' ' || *p == '\t' || *p == ':') {
+   t->t_type = T_HASH;
+   break;
+   }
+   }
+   if (t->t_type == T_NONE)
+   t->t_type = T_LIST;
+   }
+
+   if (t->t_type == T_LIST) {
+   table_add(t, keyp, NULL);
+   continue;
+   }
+
+   /* T_HASH */
valp = keyp;
strsep(, " \t:");
if (valp) {
@@ -111,18 +145,20 @@ table_static_config(struct table *t)
if (*valp == '\0')
valp = NULL;
}
+   if (valp == NULL) {
+   log_warnx("%s: invalid map entry line %d", t->t_config,
+   lineno);
+   goto end;
+   }
 
-   if (t->t_type == 0)
-   t->t_type = (valp == keyp || valp == NULL) ? T_LIST :
-   T_HASH;
+   table_add(t, keyp, valp);
+   }
 
-   if ((valp == keyp || valp == NULL) && t->t_type == T_LIST)
-   table_add(t, keyp, NULL);
-   else if ((valp != keyp && valp != NULL) && t->t_type == T_HASH)
-   table_add(t, keyp, valp);
-   else
-   goto end;
+   if (ferror(fp)) {
+   log_warn("%s: getline", t->t_config);
+   goto end;
}
+
/* Accept empty alias files; treat them as hashes */
if (t->t_type == T_NONE && t->t_backend->services & K_ALIAS)
t->t_type = T_HASH;



strtok_r(3): mention standards

2017-08-28 Thread Jeremie Courreges-Anglas

IIUC strtok_r appeared in IEEE Std 1003.1c-1995, the diff below
documents that.  That would be the first use of .St -p1003.1c-95 in the
tree.  (Is this one available online?  My search skillz have failed me
so far...)

Other systems:
- linux, "POSIX.1-2001, POSIX.1-2008", FreeBSD
- freebsd, "IEEE Std 1003.1-2001 (``POSIX.1'')"
- netbsd, "IEEE Std 1003.1c-1995 (``POSIX.1'')"

Thoughts?  ok?

Also, mandoc -Tlint warns:
  mandoc: strtok.3:90:2: STYLE: useless macro: Tn
s/Tn/Li/ ?  Other manpages are affected.


Index: strtok.3
===
RCS file: /d/cvs/src/lib/libc/string/strtok.3,v
retrieving revision 1.21
diff -u -p -p -u -r1.21 strtok.3
--- strtok.35 Jun 2013 03:39:23 -   1.21
+++ strtok.328 Aug 2017 12:26:54 -
@@ -140,6 +140,10 @@ The
 .Fn strtok
 function conforms to
 .St -ansiC .
+The
+.Fn strtok_r
+function conforms to
+.St -p1003.1c-95 .
 .Sh HISTORY
 The
 .Fn strtok



-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: [patch] Add -z and -Z to apmd for automatic suspend/hibernate

2017-08-28 Thread Jesper Wallin
On Tue, Aug 15, 2017 at 07:24:47PM -0400, Ted Unangst wrote:
> this looks good. will commit soon.
> 
> (one nit, i'll correct, is man page options are upper case first.)

Sorry if this comes on as a bit pushy, but any news here? I don't know
how 6.2-beta affects this, but maybe it would be nice to have this added
before -release?



Re: include pinebook firmware in the install media

2017-08-28 Thread Jonathan Gray
On Mon, Aug 28, 2017 at 11:54:48AM +1000, Jonathan Gray wrote:
> On Sun, Aug 27, 2017 at 09:54:07PM +0200, Peter Hessler wrote:
> > (this depends on the patch to u-boot I just sent to ports@)
> > 
> > If we should manage to boot on a Pinebook machine, we should install the
> > correct firmware for it.
> > 
> > OK?
> 
> This does not include distrib/arm64/ramdisk/list changes to actually
> include it.
> 
> The install.md changes will also break the installer for all arm64
> platforms.
> 
> The second case statement should be
> 
> pine64|pinebook)

It is unfortunate that while it is possible to put u-boot in spi
flash on this and some other systems as described in:
http://git.denx.de/?p=u-boot.git;a=blob_plain;f=board/sunxi/README.sunxi64;hb=HEAD
The boot rom in the soc will see the header from the pine64 u-boot on
the miniroot and boot that as spi flash is tried after micro sd and emmc.

Though if u-boot recent enough to have efi were on spi flash these
ramdisk parts wouldn't be required as long as the dtb didn't use pine64
for a model.  Booting off usb as well as sd card/emmc should be possible
in that configuration as well.

> 
> > 
> > Index: distrib/arm64/ramdisk/Makefile
> > ===
> > RCS file: /cvs/openbsd/src/distrib/arm64/ramdisk/Makefile,v
> > retrieving revision 1.3
> > diff -u -p -u -p -r1.3 Makefile
> > --- distrib/arm64/ramdisk/Makefile  22 Aug 2017 23:20:00 -  1.3
> > +++ distrib/arm64/ramdisk/Makefile  27 Aug 2017 19:48:36 -
> > @@ -19,6 +19,7 @@ MAKEFSARGS_RD=-o disklabel=${DISKTYPE},
> >  
> >  DIRS=\
> > pine64 \
> > +   pinebook \
> > rpi
> >  
> >  .ifndef DESTDIR
> > Index: distrib/arm64/ramdisk/install.md
> > ===
> > RCS file: /cvs/openbsd/src/distrib/arm64/ramdisk/install.md,v
> > retrieving revision 1.7
> > diff -u -p -u -p -r1.7 install.md
> > --- distrib/arm64/ramdisk/install.md22 Aug 2017 23:20:00 -  
> > 1.7
> > +++ distrib/arm64/ramdisk/install.md27 Aug 2017 19:44:28 -
> > @@ -40,6 +40,7 @@ md_installboot() {
> >  
> > case $(sysctl -n hw.product) in
> > *Pine64*)   _plat=pine64;;
> > +   *Pinebook*) _plat=pinebook;;
> > *'Raspberry Pi'*)   _plat=rpi;;
> > esac
> >  
> > @@ -53,6 +54,7 @@ md_installboot() {
> >  
> > case $_plat in
> > pine64)
> > +   pinebook)
> > dd if=$_mdec/u-boot-sunxi-with-spl.bin of=${_disk}c \
> > bs=1024 seek=8 >/dev/null 2>&1
> > ;;
> > 
> > 
> > -- 
> > The reader this message encounters not failing to understand is
> > cursed.
> > 
> 



ksh: walking valid history entries

2017-08-28 Thread Jeremie Courreges-Anglas

Right now the code uses two methods to access "valid" entries in the
history array.  One method only looks at entries in [history;histptr],
the other method walks the array until it finds a NULL pointer.

The latter method appears fragile to me.  *IIUC* the test at the
beginning of history_write() means that history_write() only walks the
array when the latter is full ie when
"histptr == [histsize -1]", so it doesn't access dangling
pointers after "histptr"; also the "if (cmd == NULL)" test looks like
dead code.

I find this error-prone and think that we should rely on a single method
to walk the array.  This is what the third hunk does.  The first &
second hunks undo part of my previous commit, leaving freed entries
alone, so that we don't send the wrong hint & encourage code such as the
current history_write().

Thoughts?  ok?


Index: history.c
===
RCS file: /d/cvs/src/bin/ksh/history.c,v
retrieving revision 1.66
diff -u -p -p -u -r1.66 history.c
--- history.c   27 Aug 2017 17:10:32 -  1.66
+++ history.c   28 Aug 2017 09:06:36 -
@@ -439,10 +439,8 @@ histreset(void)
 {
char **hp;
 
-   for (hp = history; hp <= histptr; hp++) {
+   for (hp = history; hp <= histptr; hp++)
afree(*hp, APERM);
-   *hp = NULL;
-   }
 
histptr = history - 1;
hist_source->line = 0;
@@ -530,10 +528,8 @@ sethistsize(int n)
char **hp;
 
offset = n - 1;
-   for (hp = history; hp < histptr - offset; hp++) {
+   for (hp = history; hp < histptr - offset; hp++)
afree(*hp, APERM);
-   *hp = NULL;
-   }
memmove(history, histptr - offset, n * sizeof(char *));
}
 
@@ -771,8 +767,7 @@ hist_init(Source *s)
 static void
 history_write(void)
 {
-   char*cmd, *encoded;
-   int i;
+   char**hp, *encoded;
 
/* see if file has grown over 25% */
if (line_co < histsize + (histsize / 4))
@@ -784,12 +779,8 @@ history_write(void)
bi_errorf("failed to rewrite history file - %s",
strerror(errno));
}
-   for (i = 0; i < histsize; i++) {
-   cmd = history[i];
-   if (cmd == NULL)
-   break;
-
-   if (stravis(, cmd, VIS_SAFE | VIS_NL) != -1) {
+   for (hp = history; hp <= histptr; hp++) {
+   if (stravis(, *hp, VIS_SAFE | VIS_NL) != -1) {
if (fprintf(histfh, "%s\n", encoded) == -1) {
free(encoded);
return;

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



iked const ** warning

2017-08-28 Thread Otto Moerbeek
Hi,

this one is a bit tricky (cee http://c-faq.com/ansi/constmismatch.html), 
it fixes the warning:

/usr/src/sbin/iked/crypto.c:854:44: warning: cast from 'uint8_t **'
  (aka 'unsigned char **') to 'const uint8_t **' (aka
  'const unsigned char **') must have all intermediate pointers const
  qualified to be safe [-Wcast-qual]
if (d2i_ECDSA_SIG(, (const uint8_t **), tmplen) == NULL)
  ^
Note that tmp is not used after the call.

ALso note that I'm not runing iked, so I would like confirmation from
somebody this works on a setup that triggers this function.

-Otto


Index: crypto.c
===
RCS file: /cvs/src/sbin/iked/crypto.c,v
retrieving revision 1.21
diff -u -p -r1.21 crypto.c
--- crypto.c27 Mar 2017 10:29:02 -  1.21
+++ crypto.c28 Aug 2017 07:11:50 -
@@ -833,6 +833,7 @@ _dsa_sign_ecdsa(struct iked_dsa *dsa, ui
 {
ECDSA_SIG   *obj = NULL;
uint8_t *otmp = NULL, *tmp;
+   const uint8_t   *p;
unsigned int tmplen;
int  ret = -1;
int  bnlen, off;
@@ -851,7 +852,8 @@ _dsa_sign_ecdsa(struct iked_dsa *dsa, ui
goto done;
if (!EVP_SignFinal(dsa->dsa_ctx, tmp, , dsa->dsa_key))
goto done;
-   if (d2i_ECDSA_SIG(, (const uint8_t **), tmplen) == NULL)
+   p = tmp;
+   if (d2i_ECDSA_SIG(, , tmplen) == NULL)
goto done;
if (BN_num_bytes(obj->r) > bnlen || BN_num_bytes(obj->s) > bnlen)
goto done;



csh(1): paste long lines

2017-08-28 Thread Anton Lindqvist
Hi,
deraadt@ discovered that pasting long lines in csh with filec enabled is
currently broken. NUL-terminating the input buffer from tenex()
instructs csh that the buffer contains a complete command. This is wrong
and should only happen when buffer is not full, otherwise more data has
to be read in order form a complete command.

While here, I did also discover that the prompt is printed again when
the input exceeds the input buffer. This is also true when inputting a
line continuation (i.e. backslash). In order to prevent printing the
prompt again, only print the prompt in tenex() when `needprompt == 1`.

Comments? OK?

Index: csh.c
===
RCS file: /cvs/src/bin/csh/csh.c,v
retrieving revision 1.40
diff -u -p -r1.40 csh.c
--- csh.c   26 Jul 2017 19:15:09 -  1.40
+++ csh.c   28 Aug 2017 07:10:31 -
@@ -1008,7 +1008,8 @@ process(bool catch)
 * read fresh stuff. Otherwise, we are rereading input and don't
 * need or want to prompt.
 */
-   if (!filec && aret == F_SEEK && fseekp == feobp)
+   needprompt = aret == F_SEEK && fseekp == feobp;
+   if (!filec && needprompt)
printprompt();
(void) fflush(cshout);
}
Index: csh.h
===
RCS file: /cvs/src/bin/csh/csh.h,v
retrieving revision 1.29
diff -u -p -r1.29 csh.h
--- csh.h   22 Jul 2017 09:37:21 -  1.29
+++ csh.h   28 Aug 2017 07:10:31 -
@@ -108,6 +108,7 @@ booltimflg; /* Time the next waite
 boolhavhash;   /* path hashing is available */
 
 boolfilec; /* doing filename expansion */
+boolneedprompt;/* print prompt, used by filec */
 
 /*
  * Global i/o info
Index: file.c
===
RCS file: /cvs/src/bin/csh/file.c,v
retrieving revision 1.33
diff -u -p -r1.33 file.c
--- file.c  26 Jul 2017 19:20:51 -  1.33
+++ file.c  28 Aug 2017 07:10:31 -
@@ -779,8 +779,11 @@ tenex(Char *inputline, int inputline_siz
cl.size = sizeof(buf);
if (tio->c_lflag & ALTWERASE)
cl.flags |= CL_ALTWERASE;
-   cl.flags |= CL_PROMPT;
-   cl_flush();  /* print prompt */
+   if (needprompt) {
+   needprompt = 0;
+   cl.flags |= CL_PROMPT;
+   cl_flush();
+   }
 
for (;;) {
if ((c = cl_getc()) == 0)
@@ -799,7 +802,14 @@ tenex(Char *inputline, int inputline_siz
 
for (i = 0; i < cl.len; i++)
inputline[i] = cl.buf[i];
-   inputline[i] = '\0';
+   /*
+* NUL-terminating the buffer implies that it contains a complete
+* command ready to be executed. Therefore, don't terminate if the
+* buffer is full since more characters must be read in order to form a
+* complete command.
+*/
+   if (i < sizeof(buf))
+   inputline[i] = '\0';
 
return cl.len;
 }
Index: func.c
===
RCS file: /cvs/src/bin/csh/func.c,v
retrieving revision 1.34
diff -u -p -r1.34 func.c
--- func.c  26 Jul 2017 19:15:09 -  1.34
+++ func.c  28 Aug 2017 07:10:32 -
@@ -589,7 +589,8 @@ search(int type, int level, Char *goal)
bseek();
 }
 do {
-   if (intty && !filec && fseekp == feobp && aret == F_SEEK)
+   needprompt = intty && fseekp == feobp && aret == F_SEEK;
+   if (!filec && needprompt)
(void) fprintf(cshout, "? "), (void) fflush(cshout);
aword[0] = 0;
(void) getword(aword);



Re: pf.4: sync structs with net/pfvar.h

2017-08-28 Thread Alexandr Nedvedicky
Hello,


On Sun, Aug 27, 2017 at 10:11:49PM -0400, Lawrence Teo wrote:
> This syncs the struct declarations in pf.4 with the latest net/pfvar.h
> (r1.465 at the time of writing).
> 
> ok?
looks good to me.

OK sashan



Re: [PATCH] add initial set of regress tests for vmd

2017-08-28 Thread Mike Larkin
On Sun, Aug 27, 2017 at 02:24:08PM -0700, Carlos Cardenas wrote:
> Howdy.
> 
> Below is patch for some initial parsing tests for vmd:
> * Memory string parsing (too small, invalid size, and rounding)
> * Max disk path
> * Max vm name
> * Max kernel path
> * Max NICs
> 
> More tests to come.
> 
> One item missing is the proper hook into regress/usr.sbin/Makefile
> as it was unknown if they should be run all the time or only for
> REGRESS_FULL.  Comments?
> 
> Ok?
> 

The diff doesn't apply. I think it got mangled. Can you send it again
without line wrapping?

> +--+
> Carlos
> 
> diff --git regress/usr.sbin/vmd/Makefile regress/usr.sbin/vmd/Makefile
> new file mode 100644
> index 000..d7b3794710a
> --- /dev/null
> +++ regress/usr.sbin/vmd/Makefile
> @@ -0,0 +1,44 @@
> +# $OpenBSD: $
> +
> +# TARGETS
> +# vmd-pass: load vmd-pass-*.conf through vmd and check against
> vmd-pass-*.ok
> +# vmd-fail: load vmd-fail-*.conf through vmd and check against
> vmd-fail-*.ok
> +
> +VMD_PASS=1 2 3
> +VMD_FAIL=1 2 3 4 5 6 7
> +
> +MAKEOBJDIRPREFIX=
> +
> +SHELL=/bin/sh
> +
> +.MAIN: all
> +
> +.for n in ${VMD_PASS}
> +VMD_PASS_TARGETS+=vmd_pass${n}
> +
> +vmd_pass${n}:
> +   ${SUDO} vmd -n -f ${.CURDIR}/vmd-pass-${n}.conf 2>&1 | \
> +   diff -u ${.CURDIR}/vmd-pass-${n}.ok /dev/stdin
> +.endfor
> +
> +vmd-pass:  ${VMD_PASS_TARGETS}
> +REGRESS_TARGETS+=vmd-pass
> +REGRESS_ROOT_TARGETS+=vmd-pass
> +
> +.for n in ${VMD_FAIL}
> +VMD_FAIL_TARGETS+=vmd_fail${n}
> +
> +vmd_fail${n}:
> +   ${SUDO} vmd -n -f ${.CURDIR}/vmd-fail-${n}.conf 2>&1 | \
> +   diff -u ${.CURDIR}/vmd-fail-${n}.ok /dev/stdin
> +.endfor
> +
> +vmd-fail:  ${VMD_FAIL_TARGETS}
> +REGRESS_TARGETS+=vmd-fail
> +REGRESS_ROOT_TARGETS+=vmd-fail
> +
> +alltests: ${REGRESS_TARGETS}
> +
> +.PHONY: ${REGRESS_TARGETS}
> +
> +.include 
> diff --git regress/usr.sbin/vmd/vmd-fail-1.conf
> regress/usr.sbin/vmd/vmd-fail-1.conf
> new file mode 100644
> index 000..3e3006a057d
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-1.conf
> @@ -0,0 +1,12 @@
> +# $OpenBSD: $
> +# Fail on kernel keyword; has been replaced by boot.
> +ramdisk="/bsd.rd"
> +switch "sw" {
> +add vether0
> +}
> +vm "x" {
> +kernel $ramdisk
> +memory 2G
> +disable
> +interface { switch "sw" }
> +}
> diff --git regress/usr.sbin/vmd/vmd-fail-1.ok
> regress/usr.sbin/vmd/vmd-fail-1.ok
> new file mode 100644
> index 000..02fcd909b1e
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-1.ok
> @@ -0,0 +1 @@
> +/usr/src/regress/usr.sbin/vmd/vmd-fail-1.conf:8: syntax error
> diff --git regress/usr.sbin/vmd/vmd-fail-2.conf
> regress/usr.sbin/vmd/vmd-fail-2.conf
> new file mode 100644
> index 000..69cf1c4e630
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-2.conf
> @@ -0,0 +1,5 @@
> +# $OpenBSD: $
> +# Fail on memory (less than 1MB)
> +vm "x" {
> +memory 1048575
> +}
> diff --git regress/usr.sbin/vmd/vmd-fail-2.ok
> regress/usr.sbin/vmd/vmd-fail-2.ok
> new file mode 100644
> index 000..4abf9f32b09
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-2.ok
> @@ -0,0 +1,2 @@
> +size must be at least one megabyte
> +/usr/src/regress/usr.sbin/vmd/vmd-fail-2.conf:4: failed to parse size:
> 1048575
> diff --git regress/usr.sbin/vmd/vmd-fail-3.conf
> regress/usr.sbin/vmd/vmd-fail-3.conf
> new file mode 100644
> index 000..a8767829159
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-3.conf
> @@ -0,0 +1,4 @@
> +# $OpenBSD: $
> +# Fail on VM name (> 32chars)
> +vm "abcdefghijklmnopqrstuvwxyz0123456789" {
> +}
> diff --git regress/usr.sbin/vmd/vmd-fail-3.ok
> regress/usr.sbin/vmd/vmd-fail-3.ok
> new file mode 100644
> index 000..788b7e53657
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-3.ok
> @@ -0,0 +1 @@
> +/usr/src/regress/usr.sbin/vmd/vmd-fail-3.conf:3: vm name too long
> diff --git regress/usr.sbin/vmd/vmd-fail-4.conf
> regress/usr.sbin/vmd/vmd-fail-4.conf
> new file mode 100644
> index 000..83c59c2e61e
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-4.conf
> @@ -0,0 +1,5 @@
> +# $OpenBSD: $
> +# Fail on nifs (> 4)
> +vm "a" {
> +nifs 5
> +}
> diff --git regress/usr.sbin/vmd/vmd-fail-4.ok
> regress/usr.sbin/vmd/vmd-fail-4.ok
> new file mode 100644
> index 000..c533cba38d0
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-4.ok
> @@ -0,0 +1 @@
> +/usr/src/regress/usr.sbin/vmd/vmd-fail-4.conf:4: syntax error
> diff --git regress/usr.sbin/vmd/vmd-fail-5.conf
> regress/usr.sbin/vmd/vmd-fail-5.conf
> new file mode 100644
> index 000..c53cfd32968
> --- /dev/null
> +++ regress/usr.sbin/vmd/vmd-fail-5.conf
> @@ -0,0 +1,6 @@
> +# $OpenBSD: $
> +# Fail on boot path (> 128)
> +ramdisk="/some/absolutepath/somewhere/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/abcdefghijklmnopqrstuvwxyz0123456789/bsd.rd"
> +vm "x" {
> +kernel $ramdisk
> +}
> diff --git regress/usr.sbin/vmd/vmd-fail-5.ok
> regress/usr.sbin/vmd/vmd-fail-5.ok
> new file mode 100644
> index