Re: [PATCH] parse ! on hostname.if for autoinstall

2018-11-09 Thread Florian Obser
I have a use for this. Do the chicken scratches allow reject routes?

I currently have bunch of lines like this in my hostname.if files:
!route -q add -net 2a01:db8::/48 ::1 -reject

On Fri, Nov 09, 2018 at 06:16:53PM -0600, Todd T. Fries wrote:
> Would there be any merit in contemplating a syntax that would permit
> adding routes in hostname.if so the installer could pick that up and
> avoid the much more corner case shell disaster scenarios?
> 
> note .. 'route add' no longer requires -inet6 so we would not need a
> special route6 syntax.
> 
> For example, one attempt at doing this could look like the below:
> 
> /usr/src/etc$ cat /etc/hostname.vether2 
> 10.2.2.2/24
> inet6 eui64
> route 1.2.3.0/24 10.2.2.1
> route 2001:db8::/96 fe80::1%\$if
> /usr/src/etc$ doas sh ./netstart -n vether2
> ifconfig vether2 10.2.2.2/24
> ifconfig vether2 inet6 eui64
> route -q add 1.2.3.0/24 10.2.2.1
> route -q add 2001:db8::/96 fe80::1%vether2
> /usr/src/etc$ ifconfig vether2
> vether2: flags=8843 mtu 1500
> lladdr fe:e1:ba:dc:67:9b
> index 20 priority 0 llprio 3
> groups: vether
> media: Ethernet autoselect
> status: active
> inet 10.2.2.2 netmask 0xff00 broadcast 10.2.2.255
> inet6 fe80::6a0e:c942:3581:6ebf%vether2 prefixlen 64 scopeid 0x14
> /usr/src/etc$ netstat -nr | grep vether2
> 1.2.3/24   10.2.2.1   UGS00 - 8 
> vether2
> 10.2.2/24  10.2.2.2   UCn10 - 4 
> vether2
> 10.2.2.1   link#20UHLch  12 - 3 
> vether2
> 10.2.2.2   fe:e1:ba:dc:67:9b  UHLl   00 - 1 
> vether2
> 10.2.2.255 10.2.2.2   UHb00 - 1 
> vether2
> 2001:db8::/96  fe80::1%vether2UGS
> 00 - 8 vether2
> fe80::%vether2/64  fe80::6a0e:c942:3581:6ebf%vether2 UCn  
>   10 - 4 vether2
> fe80::1%vether2link#20UHLch  
> 12 - 3 vether2
> fe80::6a0e:c942:3581:6ebf%vether2  fe:e1:ba:dc:67:9b  UHLl   
> 00 - 1 vether2
> ff01::%vether2/32  fe80::6a0e:c942:3581:6ebf%vether2 Um   
>   00 - 4 vether2
> ff02::%vether2/32  fe80::6a0e:c942:3581:6ebf%vether2 Um   
>   00 - 4 vether2
> /usr/src/etc$ diff -u netstart.orig netstart
> --- netstart.orig Fri Nov  9 17:58:58 2018
> +++ netstart  Fri Nov  9 18:09:39 2018
> @@ -68,6 +68,10 @@
>   _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient $_if"
>   V4_DHCPCONF=true
>   ;;
> + route)  ((${#_c[*]} == 3)) || return
> + _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
> + _cmds[${#_cmds[*]}]="route -q add${_cmd#route}"
> + ;;
>   '!'*)   _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
>   _cmds[${#_cmds[*]}]="${_cmd#!}"
>   ;;
> 
> 
> 
> If this is worth pursuing, I'll create and test an installer equivalent 
> version.
> 
> Thanks,
> 
> Penned by Theo de Raadt on 20181109 10:13.33, we have:
> | This was intentional because a user could put crazy script commands
> | in the files which don't work in the bsd.rd context.  bsd.rd is
> | quite gutted.
> | 
> | That means some circumstances could fail quite badly
> | 
> | Could be reconsidered...
> | 
> | > During auto upgrade via the auto_upgrade.conf file (no DHCP server),
> | > shell commands are skipped.
> | > This small diff is coming from parse_hn_line() in /etc/netstart, thus,
> | > it keeps the behavior similar.
> | > I think it's handy, especially if you need a static route in order to
> | > reach a mirror for example.
> | > 
> | > diff --git install.sub install.sub
> | > index bce1fa50358..31dbafdc95d 100644
> | > --- install.sub
> | > +++ install.sub
> | > @@ -2319,8 +2319,11 @@ parse_hn_line() {
> | >     _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient
> | > $_if"
> | >     V4_DHCPCONF=true
> | >     ;;
> | > -   '!'*|bridge)
> | > -   # Skip shell commands and bridge in the installer.
> | > +   '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
> | > +   _cmds[${#_cmds[*]}]="${_cmd#!}"
> | > +   ;;
> | > +   bridge)
> | > +   # Skip bridge in the installer.
> | >     return
> | >     ;;
> | >     *)  _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
> | > 
> | > 
> | > Cheers
> | > 
> 
> -- 
> Todd T. Fries . http://todd.fries.net/pgp.txt . @unix2mars . github:toddfries
> 

-- 
I'm not entirely sure you are real.



Re: [PATCH] parse ! on hostname.if for autoinstall

2018-11-09 Thread Julien Dhaille
Permit adding routes in installer was my goal :)

Le 10/11/2018 à 01:16, Todd T. Fries a écrit :
> Would there be any merit in contemplating a syntax that would permit
> adding routes in hostname.if so the installer could pick that up and
> avoid the much more corner case shell disaster scenarios?
> 
> note .. 'route add' no longer requires -inet6 so we would not need a
> special route6 syntax.
> 
> For example, one attempt at doing this could look like the below:
> 
> /usr/src/etc$ cat /etc/hostname.vether2 
> 10.2.2.2/24
> inet6 eui64
> route 1.2.3.0/24 10.2.2.1
> route 2001:db8::/96 fe80::1%\$if
> /usr/src/etc$ doas sh ./netstart -n vether2
> ifconfig vether2 10.2.2.2/24
> ifconfig vether2 inet6 eui64
> route -q add 1.2.3.0/24 10.2.2.1
> route -q add 2001:db8::/96 fe80::1%vether2
> /usr/src/etc$ ifconfig vether2
> vether2: flags=8843 mtu 1500
> lladdr fe:e1:ba:dc:67:9b
> index 20 priority 0 llprio 3
> groups: vether
> media: Ethernet autoselect
> status: active
> inet 10.2.2.2 netmask 0xff00 broadcast 10.2.2.255
> inet6 fe80::6a0e:c942:3581:6ebf%vether2 prefixlen 64 scopeid 0x14
> /usr/src/etc$ netstat -nr | grep vether2
> 1.2.3/24   10.2.2.1   UGS00 - 8 
> vether2
> 10.2.2/24  10.2.2.2   UCn10 - 4 
> vether2
> 10.2.2.1   link#20UHLch  12 - 3 
> vether2
> 10.2.2.2   fe:e1:ba:dc:67:9b  UHLl   00 - 1 
> vether2
> 10.2.2.255 10.2.2.2   UHb00 - 1 
> vether2
> 2001:db8::/96  fe80::1%vether2UGS
> 00 - 8 vether2
> fe80::%vether2/64  fe80::6a0e:c942:3581:6ebf%vether2 UCn  
>   10 - 4 vether2
> fe80::1%vether2link#20UHLch  
> 12 - 3 vether2
> fe80::6a0e:c942:3581:6ebf%vether2  fe:e1:ba:dc:67:9b  UHLl   
> 00 - 1 vether2
> ff01::%vether2/32  fe80::6a0e:c942:3581:6ebf%vether2 Um   
>   00 - 4 vether2
> ff02::%vether2/32  fe80::6a0e:c942:3581:6ebf%vether2 Um   
>   00 - 4 vether2
> /usr/src/etc$ diff -u netstart.orig netstart
> --- netstart.orig Fri Nov  9 17:58:58 2018
> +++ netstart  Fri Nov  9 18:09:39 2018
> @@ -68,6 +68,10 @@
>   _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient $_if"
>   V4_DHCPCONF=true
>   ;;
> + route)  ((${#_c[*]} == 3)) || return
> + _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
> + _cmds[${#_cmds[*]}]="route -q add${_cmd#route}"
> + ;;
>   '!'*)   _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
>   _cmds[${#_cmds[*]}]="${_cmd#!}"
>   ;;
> 
> 
> 
> If this is worth pursuing, I'll create and test an installer equivalent 
> version.
> 
> Thanks,
> 
> Penned by Theo de Raadt on 20181109 10:13.33, we have:
> | This was intentional because a user could put crazy script commands
> | in the files which don't work in the bsd.rd context.  bsd.rd is
> | quite gutted.
> | 
> | That means some circumstances could fail quite badly
> | 
> | Could be reconsidered...
> | 
> | > During auto upgrade via the auto_upgrade.conf file (no DHCP server),
> | > shell commands are skipped.
> | > This small diff is coming from parse_hn_line() in /etc/netstart, thus,
> | > it keeps the behavior similar.
> | > I think it's handy, especially if you need a static route in order to
> | > reach a mirror for example.
> | > 
> | > diff --git install.sub install.sub
> | > index bce1fa50358..31dbafdc95d 100644
> | > --- install.sub
> | > +++ install.sub
> | > @@ -2319,8 +2319,11 @@ parse_hn_line() {
> | >     _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient
> | > $_if"
> | >     V4_DHCPCONF=true
> | >     ;;
> | > -   '!'*|bridge)
> | > -   # Skip shell commands and bridge in the installer.
> | > +   '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
> | > +   _cmds[${#_cmds[*]}]="${_cmd#!}"
> | > +   ;;
> | > +   bridge)
> | > +   # Skip bridge in the installer.
> | >     return
> | >     ;;
> | >     *)  _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
> | > 
> | > 
> | > Cheers
> | > 
> 



Re: [PATCH] parse ! on hostname.if for autoinstall

2018-11-09 Thread Todd T. Fries
Would there be any merit in contemplating a syntax that would permit
adding routes in hostname.if so the installer could pick that up and
avoid the much more corner case shell disaster scenarios?

note .. 'route add' no longer requires -inet6 so we would not need a
special route6 syntax.

For example, one attempt at doing this could look like the below:

/usr/src/etc$ cat /etc/hostname.vether2 
10.2.2.2/24
inet6 eui64
route 1.2.3.0/24 10.2.2.1
route 2001:db8::/96 fe80::1%\$if
/usr/src/etc$ doas sh ./netstart -n vether2
ifconfig vether2 10.2.2.2/24
ifconfig vether2 inet6 eui64
route -q add 1.2.3.0/24 10.2.2.1
route -q add 2001:db8::/96 fe80::1%vether2
/usr/src/etc$ ifconfig vether2
vether2: flags=8843 mtu 1500
lladdr fe:e1:ba:dc:67:9b
index 20 priority 0 llprio 3
groups: vether
media: Ethernet autoselect
status: active
inet 10.2.2.2 netmask 0xff00 broadcast 10.2.2.255
inet6 fe80::6a0e:c942:3581:6ebf%vether2 prefixlen 64 scopeid 0x14
/usr/src/etc$ netstat -nr | grep vether2
1.2.3/24   10.2.2.1   UGS00 - 8 vether2
10.2.2/24  10.2.2.2   UCn10 - 4 vether2
10.2.2.1   link#20UHLch  12 - 3 vether2
10.2.2.2   fe:e1:ba:dc:67:9b  UHLl   00 - 1 vether2
10.2.2.255 10.2.2.2   UHb00 - 1 vether2
2001:db8::/96  fe80::1%vether2UGS0  
  0 - 8 vether2
fe80::%vether2/64  fe80::6a0e:c942:3581:6ebf%vether2 UCn
10 - 4 vether2
fe80::1%vether2link#20UHLch  1  
  2 - 3 vether2
fe80::6a0e:c942:3581:6ebf%vether2  fe:e1:ba:dc:67:9b  UHLl   0  
  0 - 1 vether2
ff01::%vether2/32  fe80::6a0e:c942:3581:6ebf%vether2 Um 
00 - 4 vether2
ff02::%vether2/32  fe80::6a0e:c942:3581:6ebf%vether2 Um 
00 - 4 vether2
/usr/src/etc$ diff -u netstart.orig netstart
--- netstart.orig   Fri Nov  9 17:58:58 2018
+++ netstartFri Nov  9 18:09:39 2018
@@ -68,6 +68,10 @@
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient $_if"
V4_DHCPCONF=true
;;
+   route)  ((${#_c[*]} == 3)) || return
+   _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
+   _cmds[${#_cmds[*]}]="route -q add${_cmd#route}"
+   ;;
'!'*)   _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
_cmds[${#_cmds[*]}]="${_cmd#!}"
;;



If this is worth pursuing, I'll create and test an installer equivalent version.

Thanks,

Penned by Theo de Raadt on 20181109 10:13.33, we have:
| This was intentional because a user could put crazy script commands
| in the files which don't work in the bsd.rd context.  bsd.rd is
| quite gutted.
| 
| That means some circumstances could fail quite badly
| 
| Could be reconsidered...
| 
| > During auto upgrade via the auto_upgrade.conf file (no DHCP server),
| > shell commands are skipped.
| > This small diff is coming from parse_hn_line() in /etc/netstart, thus,
| > it keeps the behavior similar.
| > I think it's handy, especially if you need a static route in order to
| > reach a mirror for example.
| > 
| > diff --git install.sub install.sub
| > index bce1fa50358..31dbafdc95d 100644
| > --- install.sub
| > +++ install.sub
| > @@ -2319,8 +2319,11 @@ parse_hn_line() {
| >     _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient
| > $_if"
| >     V4_DHCPCONF=true
| >     ;;
| > -   '!'*|bridge)
| > -   # Skip shell commands and bridge in the installer.
| > +   '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
| > +   _cmds[${#_cmds[*]}]="${_cmd#!}"
| > +   ;;
| > +   bridge)
| > +   # Skip bridge in the installer.
| >     return
| >     ;;
| >     *)  _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
| > 
| > 
| > Cheers
| > 

-- 
Todd T. Fries . http://todd.fries.net/pgp.txt . @unix2mars . github:toddfries



Re: [PATCH] parse ! on hostname.if for autoinstall

2018-11-09 Thread Julien Dhaille


diff --git distrib/miniroot/install.sub distrib/miniroot/install.sub
index bce1fa50358..31dbafdc95d 100644
--- distrib/miniroot/install.sub
+++ distrib/miniroot/install.sub
@@ -2319,8 +2319,11 @@ parse_hn_line() {
_cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient
$_if"
V4_DHCPCONF=true
;;
-   '!'*|bridge)
-   # Skip shell commands and bridge in the installer.
+   '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
+   _cmds[${#_cmds[*]}]="${_cmd#!}"
+   ;;
+   bridge)
+   # Skip bridge in the installer.
return
;;
*)  _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"

Le 09/11/2018 à 17:21, Gilles Chehade a écrit :
> On Fri, Nov 09, 2018 at 05:10:00PM +0100, Julien Dhaille wrote:
>> Hi.
>>
>> During auto upgrade via the auto_upgrade.conf file (no DHCP server),
>> shell commands are skipped.
>> This small diff is coming from parse_hn_line() in /etc/netstart, thus,
>> it keeps the behavior similar.
>> I think it's handy, especially if you need a static route in order to
>> reach a mirror for example.
>>
> 
> diff is barely readable :-p
> 
> 
>> diff --git install.sub install.sub
>> index bce1fa50358..31dbafdc95d 100644
>> --- install.sub
>> +++ install.sub
>> @@ -2319,8 +2319,11 @@ parse_hn_line() {
>> ?? _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} 
>> up;dhclient
>> $_if"
>> ?? V4_DHCPCONF=true
>> ?? ;;
>> - '!'*|bridge)
>> - # Skip shell commands and bridge in the 
>> installer.
>> + '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
>> + _cmds[${#_cmds[*]}]="${_cmd#!}"
>> + ;;
>> + bridge)
>> + # Skip bridge in the installer.
>> ?? return
>> ?? ;;
>> ?? *)?? _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
>>
>>
>> Cheers
>>
> 



Re: [PATCH] parse ! on hostname.if for autoinstall

2018-11-09 Thread Gilles Chehade
On Fri, Nov 09, 2018 at 05:10:00PM +0100, Julien Dhaille wrote:
> Hi.
> 
> During auto upgrade via the auto_upgrade.conf file (no DHCP server),
> shell commands are skipped.
> This small diff is coming from parse_hn_line() in /etc/netstart, thus,
> it keeps the behavior similar.
> I think it's handy, especially if you need a static route in order to
> reach a mirror for example.
> 

diff is barely readable :-p


> diff --git install.sub install.sub
> index bce1fa50358..31dbafdc95d 100644
> --- install.sub
> +++ install.sub
> @@ -2319,8 +2319,11 @@ parse_hn_line() {
> ?? _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} 
> up;dhclient
> $_if"
> ?? V4_DHCPCONF=true
> ?? ;;
> - '!'*|bridge)
> - # Skip shell commands and bridge in the 
> installer.
> + '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
> + _cmds[${#_cmds[*]}]="${_cmd#!}"
> + ;;
> + bridge)
> + # Skip bridge in the installer.
> ?? return
> ?? ;;
> ?? *)?? _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
> 
> 
> Cheers
> 

-- 
Gilles Chehade @poolpOrg

https://www.poolp.org tip me: https://paypal.me/poolpOrg



Re: [PATCH] parse ! on hostname.if for autoinstall

2018-11-09 Thread Theo de Raadt
This was intentional because a user could put crazy script commands
in the files which don't work in the bsd.rd context.  bsd.rd is
quite gutted.

That means some circumstances could fail quite badly

Could be reconsidered...

> During auto upgrade via the auto_upgrade.conf file (no DHCP server),
> shell commands are skipped.
> This small diff is coming from parse_hn_line() in /etc/netstart, thus,
> it keeps the behavior similar.
> I think it's handy, especially if you need a static route in order to
> reach a mirror for example.
> 
> diff --git install.sub install.sub
> index bce1fa50358..31dbafdc95d 100644
> --- install.sub
> +++ install.sub
> @@ -2319,8 +2319,11 @@ parse_hn_line() {
>     _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient
> $_if"
>     V4_DHCPCONF=true
>     ;;
> -   '!'*|bridge)
> -   # Skip shell commands and bridge in the installer.
> +   '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
> +   _cmds[${#_cmds[*]}]="${_cmd#!}"
> +   ;;
> +   bridge)
> +   # Skip bridge in the installer.
>     return
>     ;;
>     *)  _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"
> 
> 
> Cheers
> 



[PATCH] parse ! on hostname.if for autoinstall

2018-11-09 Thread Julien Dhaille
Hi.

During auto upgrade via the auto_upgrade.conf file (no DHCP server),
shell commands are skipped.
This small diff is coming from parse_hn_line() in /etc/netstart, thus,
it keeps the behavior similar.
I think it's handy, especially if you need a static route in order to
reach a mirror for example.

diff --git install.sub install.sub
index bce1fa50358..31dbafdc95d 100644
--- install.sub
+++ install.sub
@@ -2319,8 +2319,11 @@ parse_hn_line() {
    _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]} up;dhclient
$_if"
    V4_DHCPCONF=true
    ;;
-   '!'*|bridge)
-   # Skip shell commands and bridge in the installer.
+   '!'*) _cmd=$(print -- "${_c[@]}" | sed 's/\$if/'$_if'/g')
+   _cmds[${#_cmds[*]}]="${_cmd#!}"
+   ;;
+   bridge)
+   # Skip bridge in the installer.
    return
    ;;
    *)  _cmds[${#_cmds[*]}]="ifconfig $_if ${_c[@]}"


Cheers