Re: Add $daemon_nice to rc.subr

2018-09-03 Thread Alexandre Ratchov
On Tue, Sep 04, 2018 at 04:58:53AM +0200, Thomas de Grivel wrote:
> 
> And I still feel the default nice priority of 10 is rather a good
> idea.

why?



Re: Add $daemon_nice to rc.subr

2018-09-03 Thread Antoine Jacoutot
On Tue, Sep 04, 2018 at 04:58:53AM +0200, Thomas de Grivel wrote:
> Thanks, good to know.
> 
> But if I actually wanted per daemon priorities with settable
> configuration in rc.conf.local how would I get that ? And I still feel

You would do what the man page instructs you to do in login.conf:

mydaemon1:\
:priority=10:\
:tc=daemon:

mydaemon2:\
:priority=5:\
:tc=daemon:

etc.

Where mydaemon1 and mydaemon2 each matches an rc.d script name under /etc/rc.d/

> the default nice priority of 10 is rather a good idea.

I disagree.


> Le lun. 3 sept. 2018 à 23:10, Antoine Jacoutot  a 
> écrit :
> >
> > On Mon, Sep 03, 2018 at 10:34:51PM +0200, Thomas de Grivel wrote:
> > > Hello,
> >
> > Hi.
> >
> > > Following patch allows sysadmins to configure nice values for RC daemons.
> > > Default nice value is set to 10 as I wish to prioritize interactive
> > > applications over system daemons and I think most probably do too.
> > > It is based on OpenBSD 6.3 but might apply easily to later releases.
> > > Please let me know if it is of any interest to you.
> >
> > We already support that.
> >
> > Extract from rc.d(8):
> >
> >  daemon_class is a special read-only variable.  It is set to “daemon”
> >  unless there is a login class configured in login.conf(5) with the same
> >  name as the rc.d script itself, in which case it will be set to that
> >  login class.  This allows setting many initial process properties, for
> >  example environment variables, scheduling priority, and process limits
> >  such as maximum memory use and number of files.
> >
> > Extract from login.conf(5):
> >
> >  priority   number   Initial priority (nice)
> >  level.
> >
> > Cheers!
> >
> >
> > > commit 1f4121df3ae31121d435571ffdbd93a20c1e8a07
> > > Author: Thomas de Grivel 
> > > Date:   Mon Sep 3 21:52:37 2018 +0200
> > >
> > > Add a $daemon_nice parameter.
> > > If not overriden by the launched daemon the default nice value is 10.
> > > See nice(1) for more details.
> > >
> > > diff --git rc.d/rc.subr.orig rc.d/rc.subr
> > > index 6c2f694..5f4fbe5 100644
> > > --- rc.d/rc.subr.orig
> > > +++ rc.d/rc.subr
> > > @@ -49,6 +49,7 @@ _rc_write_runfile() {
> > >   cat >${_RC_RUNFILE} < > >  daemon_class=${daemon_class}
> > >  daemon_flags=${daemon_flags}
> > > +daemon_nice=${daemon_nice}
> > >  daemon_rtable=${daemon_rtable}
> > >  daemon_timeout=${daemon_timeout}
> > >  daemon_user=${daemon_user}
> > > @@ -170,7 +171,7 @@ _rc_parse_conf() {
> > >  [ -n "${FUNCS_ONLY}" ] && return
> > >
> > >  rc_start() {
> > > - ${rcexec} "${daemon} ${daemon_flags}"
> > > + ${rcexec} "nice -n ${daemon_nice} ${daemon} ${daemon_flags}"
> > >  }
> > >
> > >  rc_check() {
> > > @@ -288,6 +289,7 @@ _RC_RUNFILE=${_RC_RUNDIR}/${_name}
> > >  _rc_do _rc_parse_conf
> > >
> > >  eval _rcflags=\${${_name}_flags}
> > > +eval _rcnice=\${${_name}_nice}
> > >  eval _rcrtable=\${${_name}_rtable}
> > >  eval _rcuser=\${${_name}_user}
> > >  eval _rctimeout=\${${_name}_timeout}
> > > @@ -295,6 +297,7 @@ eval _rctimeout=\${${_name}_timeout}
> > >  # set default values; duplicated in rcctl(8)
> > >  getcap -f /etc/login.conf ${_name} 1>/dev/null 2>&1 && 
> > > daemon_class=${_name} ||
> > >   daemon_class=daemon
> > > +[ -z "${daemon_nice}" ] && daemon_nice=10
> > >  [ -z "${daemon_rtable}" ] && daemon_rtable=0
> > >  [ -z "${daemon_user}" ] && daemon_user=root
> > >  [ -z "${daemon_timeout}" ] && daemon_timeout=30
> > > @@ -304,6 +307,7 @@ getcap -f /etc/login.conf ${_name} 1>/dev/null
> > > 2>&1 && daemon_class=${_name} ||
> > >   unset _rcflags
> > >
> > >  [ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
> > > +[ -n "${_rcnice}" ] && daemon_nice=${_rcnice}
> > >  [ -n "${_rcrtable}" ] && daemon_rtable=${_rcrtable}
> > >  [ -n "${_rcuser}" ] && daemon_user=${_rcuser}
> > >  [ -n "${_rctimeout}" ] && daemon_timeout=${_rctimeout}
> > > @@ -315,7 +319,7 @@ if [ -n "${_RC_DEBUG}" ]; then
> > >  fi
> > >
> > >  readonly daemon_class
> > > -unset _rcflags _rcrtable _rcuser _rctimeout
> > > +unset _rcflags _rcnice _rcrtable _rcuser _rctimeout
> > >  pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
> > >  rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
> > >  [ "${daemon_rtable}" -eq 0 ] ||
> > >
> > >
> > > --
> > >  Thomas de Grivel
> > >
> >
> > --
> > Antoine
> 
> 
> 
> -- 
>  Thomas de Grivel
>  http://b.lowh.net/billitch/
> 

-- 
Antoine



[patch] Fix closing socket twice bug in netcat program

2018-09-03 Thread Nan Xiao
Hi tech@,

Before netcat program exits, it will check whether s is -1, and close
socket if s is not -1:

if (s != -1)
close(s);

The following patch fixes the issue that netcat will close socket twice
if it works as a server:

Index: netcat.c
===
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.192
diff -u -p -r1.192 netcat.c
--- netcat.c10 Aug 2018 17:15:22 -  1.192
+++ netcat.c4 Sep 2018 04:51:55 -
@@ -622,9 +622,10 @@ main(int argc, char *argv[])
}
close(connfd);
}
-   if (family != AF_UNIX)
+   if (family != AF_UNIX) {
close(s);
-   else if (uflag) {
+   s = -1;
+   } else if (uflag) {
if (connect(s, NULL, 0) < 0)
err(1, "connect");
}

Thanks!
-- 
Best Regards
Nan Xiao



Re: Linux DRM

2018-09-03 Thread Joseph Mayer
Thomas,

On September 4, 2018 10:55 AM, Thomas de Grivel  wrote:

> Le lun. 3 sept. 2018 à 23:33, Philip Guenther guent...@gmail.com a écrit :
>
> > On Mon, Sep 3, 2018 at 11:46 AM Thomas de Grivel billi...@gmail.com wrote:
> >
> > > I was browsing the DRM code ported from Linux and it's a terrible
> > > mess, is there any ongoing project to clean up that codebase or
> > > rewrite it entirely ?

For the one who has not reviewed the code, can you quantify and
illustrate approximately how bad it is?

> > No. OpenBSD doesn't have the resources to reimplement the DRM subsystem or 
> > maintain a non-trivial fork of the Linux version. We don't want to get 
> > stuck with a code base that doesn't support close-to-current hardware, so 
> > the porting work has concentrated on minimizing the changes necessary to 
> > make the upstream code base work in OpenBSD.
> > It's clear that the hardware support in the upstream has large 
> > contributions from developers with inside access at the hardware vendors; 
> > without such access it's doubtful that all the hardware bugs^Wlimitations 
> > can be worked around with non-infinite resource.
> > Improvements in the DRM code itself should be done in the upstream, not 
> > just to minimize OpenBSD costs in this area, but so that all OSes that draw 
> > from that base can benefit.
>
> You probably do not care and actually neither do I but that current
> state of graphic hardware support code is crazy in my opinion.
> Computer graphic cards have to be the single most successful hardware
> in the history of computer hardware or even hardware in general and
> yet their drivers are a complete mess.

I agree this is unacceptable.

> It makes no sense to me. It all
> appears like a hideous obscurity-based false sense of security where
> you really cannot ensure the minimality of any driver and their
> features.

Common.

I guess any OS would benefit of a clean, open source, audited DRM
stack. This makes sense as a separate code project?

What's the quality of the exported interfaces? Satisfactory for
a higher-quality implementation to use it?



Re: Add $daemon_nice to rc.subr

2018-09-03 Thread Thomas de Grivel
Thanks, good to know.

But if I actually wanted per daemon priorities with settable
configuration in rc.conf.local how would I get that ? And I still feel
the default nice priority of 10 is rather a good idea.
Le lun. 3 sept. 2018 à 23:10, Antoine Jacoutot  a écrit :
>
> On Mon, Sep 03, 2018 at 10:34:51PM +0200, Thomas de Grivel wrote:
> > Hello,
>
> Hi.
>
> > Following patch allows sysadmins to configure nice values for RC daemons.
> > Default nice value is set to 10 as I wish to prioritize interactive
> > applications over system daemons and I think most probably do too.
> > It is based on OpenBSD 6.3 but might apply easily to later releases.
> > Please let me know if it is of any interest to you.
>
> We already support that.
>
> Extract from rc.d(8):
>
>  daemon_class is a special read-only variable.  It is set to “daemon”
>  unless there is a login class configured in login.conf(5) with the same
>  name as the rc.d script itself, in which case it will be set to that
>  login class.  This allows setting many initial process properties, for
>  example environment variables, scheduling priority, and process limits
>  such as maximum memory use and number of files.
>
> Extract from login.conf(5):
>
>  priority   number   Initial priority (nice)
>  level.
>
> Cheers!
>
>
> > commit 1f4121df3ae31121d435571ffdbd93a20c1e8a07
> > Author: Thomas de Grivel 
> > Date:   Mon Sep 3 21:52:37 2018 +0200
> >
> > Add a $daemon_nice parameter.
> > If not overriden by the launched daemon the default nice value is 10.
> > See nice(1) for more details.
> >
> > diff --git rc.d/rc.subr.orig rc.d/rc.subr
> > index 6c2f694..5f4fbe5 100644
> > --- rc.d/rc.subr.orig
> > +++ rc.d/rc.subr
> > @@ -49,6 +49,7 @@ _rc_write_runfile() {
> >   cat >${_RC_RUNFILE} < >  daemon_class=${daemon_class}
> >  daemon_flags=${daemon_flags}
> > +daemon_nice=${daemon_nice}
> >  daemon_rtable=${daemon_rtable}
> >  daemon_timeout=${daemon_timeout}
> >  daemon_user=${daemon_user}
> > @@ -170,7 +171,7 @@ _rc_parse_conf() {
> >  [ -n "${FUNCS_ONLY}" ] && return
> >
> >  rc_start() {
> > - ${rcexec} "${daemon} ${daemon_flags}"
> > + ${rcexec} "nice -n ${daemon_nice} ${daemon} ${daemon_flags}"
> >  }
> >
> >  rc_check() {
> > @@ -288,6 +289,7 @@ _RC_RUNFILE=${_RC_RUNDIR}/${_name}
> >  _rc_do _rc_parse_conf
> >
> >  eval _rcflags=\${${_name}_flags}
> > +eval _rcnice=\${${_name}_nice}
> >  eval _rcrtable=\${${_name}_rtable}
> >  eval _rcuser=\${${_name}_user}
> >  eval _rctimeout=\${${_name}_timeout}
> > @@ -295,6 +297,7 @@ eval _rctimeout=\${${_name}_timeout}
> >  # set default values; duplicated in rcctl(8)
> >  getcap -f /etc/login.conf ${_name} 1>/dev/null 2>&1 && 
> > daemon_class=${_name} ||
> >   daemon_class=daemon
> > +[ -z "${daemon_nice}" ] && daemon_nice=10
> >  [ -z "${daemon_rtable}" ] && daemon_rtable=0
> >  [ -z "${daemon_user}" ] && daemon_user=root
> >  [ -z "${daemon_timeout}" ] && daemon_timeout=30
> > @@ -304,6 +307,7 @@ getcap -f /etc/login.conf ${_name} 1>/dev/null
> > 2>&1 && daemon_class=${_name} ||
> >   unset _rcflags
> >
> >  [ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
> > +[ -n "${_rcnice}" ] && daemon_nice=${_rcnice}
> >  [ -n "${_rcrtable}" ] && daemon_rtable=${_rcrtable}
> >  [ -n "${_rcuser}" ] && daemon_user=${_rcuser}
> >  [ -n "${_rctimeout}" ] && daemon_timeout=${_rctimeout}
> > @@ -315,7 +319,7 @@ if [ -n "${_RC_DEBUG}" ]; then
> >  fi
> >
> >  readonly daemon_class
> > -unset _rcflags _rcrtable _rcuser _rctimeout
> > +unset _rcflags _rcnice _rcrtable _rcuser _rctimeout
> >  pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
> >  rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
> >  [ "${daemon_rtable}" -eq 0 ] ||
> >
> >
> > --
> >  Thomas de Grivel
> >
>
> --
> Antoine



-- 
 Thomas de Grivel
 http://b.lowh.net/billitch/



Re: Linux DRM

2018-09-03 Thread Thomas de Grivel
Le lun. 3 sept. 2018 à 23:33, Philip Guenther  a écrit :
>
> On Mon, Sep 3, 2018 at 11:46 AM Thomas de Grivel  wrote:
>>
>> I was browsing the DRM code ported from Linux and it's a terrible
>> mess, is there any ongoing project to clean up that codebase or
>> rewrite it entirely ?
>
>
> No.  OpenBSD doesn't have the resources to reimplement the DRM subsystem or 
> maintain a non-trivial fork of the Linux version.  We don't want to get stuck 
> with a code base that doesn't support close-to-current hardware, so the 
> porting work has concentrated on minimizing the changes necessary to make the 
> upstream code base work in OpenBSD.
>
> It's clear that the hardware support in the upstream has large contributions 
> from developers with inside access at the hardware vendors; without such 
> access it's doubtful that all the hardware bugs^Wlimitations can be worked 
> around with non-infinite resource.
>
> Improvements in the DRM code itself should be done in the upstream, not just 
> to minimize OpenBSD costs in this area, but so that all OSes that draw from 
> that base can benefit.

You probably do not care and actually neither do I but that current
state of graphic hardware support code is crazy in my opinion.
Computer graphic cards have to be the single most successful hardware
in the history of computer hardware or even hardware in general and
yet their drivers are a complete mess. It makes no sense to me. It all
appears like a hideous obscurity-based false sense of security where
you really cannot ensure the minimality of any driver and their
features.

I would not be least surprised to see a few backdoors in that code,
preventing OpenBSD for use for private intellectual property work,
however different the advertisement can be. I sure hope I'm wrong.

--
 Thomas de Grivel
 http://kmx.io/



Re: Linux DRM

2018-09-03 Thread Philip Guenther
On Mon, Sep 3, 2018 at 11:46 AM Thomas de Grivel  wrote:

> I was browsing the DRM code ported from Linux and it's a terrible
> mess, is there any ongoing project to clean up that codebase or
> rewrite it entirely ?
>

No.  OpenBSD doesn't have the resources to reimplement the DRM subsystem or
maintain a non-trivial fork of the Linux version.  We don't want to get
stuck with a code base that doesn't support close-to-current hardware, so
the porting work has concentrated on minimizing the changes necessary to
make the upstream code base work in OpenBSD.

It's clear that the hardware support in the upstream has large
contributions from developers with inside access at the hardware vendors;
without such access it's doubtful that all the hardware bugs^Wlimitations
can be worked around with non-infinite resource.

Improvements in the DRM code itself should be done in the upstream, not
just to minimize OpenBSD costs in this area, but so that all OSes that draw
from that base can benefit.


Philip Guenther


Re: Add $daemon_nice to rc.subr

2018-09-03 Thread Antoine Jacoutot
On Mon, Sep 03, 2018 at 10:34:51PM +0200, Thomas de Grivel wrote:
> Hello,
 
Hi.

> Following patch allows sysadmins to configure nice values for RC daemons.
> Default nice value is set to 10 as I wish to prioritize interactive
> applications over system daemons and I think most probably do too.
> It is based on OpenBSD 6.3 but might apply easily to later releases.
> Please let me know if it is of any interest to you.

We already support that.

Extract from rc.d(8):

 daemon_class is a special read-only variable.  It is set to “daemon”
 unless there is a login class configured in login.conf(5) with the same
 name as the rc.d script itself, in which case it will be set to that
 login class.  This allows setting many initial process properties, for
 example environment variables, scheduling priority, and process limits
 such as maximum memory use and number of files.

Extract from login.conf(5):

 priority   number   Initial priority (nice)
 level.

Cheers!


> commit 1f4121df3ae31121d435571ffdbd93a20c1e8a07
> Author: Thomas de Grivel 
> Date:   Mon Sep 3 21:52:37 2018 +0200
> 
> Add a $daemon_nice parameter.
> If not overriden by the launched daemon the default nice value is 10.
> See nice(1) for more details.
> 
> diff --git rc.d/rc.subr.orig rc.d/rc.subr
> index 6c2f694..5f4fbe5 100644
> --- rc.d/rc.subr.orig
> +++ rc.d/rc.subr
> @@ -49,6 +49,7 @@ _rc_write_runfile() {
>   cat >${_RC_RUNFILE} <  daemon_class=${daemon_class}
>  daemon_flags=${daemon_flags}
> +daemon_nice=${daemon_nice}
>  daemon_rtable=${daemon_rtable}
>  daemon_timeout=${daemon_timeout}
>  daemon_user=${daemon_user}
> @@ -170,7 +171,7 @@ _rc_parse_conf() {
>  [ -n "${FUNCS_ONLY}" ] && return
> 
>  rc_start() {
> - ${rcexec} "${daemon} ${daemon_flags}"
> + ${rcexec} "nice -n ${daemon_nice} ${daemon} ${daemon_flags}"
>  }
> 
>  rc_check() {
> @@ -288,6 +289,7 @@ _RC_RUNFILE=${_RC_RUNDIR}/${_name}
>  _rc_do _rc_parse_conf
> 
>  eval _rcflags=\${${_name}_flags}
> +eval _rcnice=\${${_name}_nice}
>  eval _rcrtable=\${${_name}_rtable}
>  eval _rcuser=\${${_name}_user}
>  eval _rctimeout=\${${_name}_timeout}
> @@ -295,6 +297,7 @@ eval _rctimeout=\${${_name}_timeout}
>  # set default values; duplicated in rcctl(8)
>  getcap -f /etc/login.conf ${_name} 1>/dev/null 2>&1 && daemon_class=${_name} 
> ||
>   daemon_class=daemon
> +[ -z "${daemon_nice}" ] && daemon_nice=10
>  [ -z "${daemon_rtable}" ] && daemon_rtable=0
>  [ -z "${daemon_user}" ] && daemon_user=root
>  [ -z "${daemon_timeout}" ] && daemon_timeout=30
> @@ -304,6 +307,7 @@ getcap -f /etc/login.conf ${_name} 1>/dev/null
> 2>&1 && daemon_class=${_name} ||
>   unset _rcflags
> 
>  [ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
> +[ -n "${_rcnice}" ] && daemon_nice=${_rcnice}
>  [ -n "${_rcrtable}" ] && daemon_rtable=${_rcrtable}
>  [ -n "${_rcuser}" ] && daemon_user=${_rcuser}
>  [ -n "${_rctimeout}" ] && daemon_timeout=${_rctimeout}
> @@ -315,7 +319,7 @@ if [ -n "${_RC_DEBUG}" ]; then
>  fi
> 
>  readonly daemon_class
> -unset _rcflags _rcrtable _rcuser _rctimeout
> +unset _rcflags _rcnice _rcrtable _rcuser _rctimeout
>  pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
>  rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
>  [ "${daemon_rtable}" -eq 0 ] ||
> 
> 
> -- 
>  Thomas de Grivel
> 

-- 
Antoine



Linux DRM

2018-09-03 Thread Thomas de Grivel
I was browsing the DRM code ported from Linux and it's a terrible
mess, is there any ongoing project to clean up that codebase or
rewrite it entirely ?

-- 
 Thomas de Grivel



Add $daemon_nice to rc.subr

2018-09-03 Thread Thomas de Grivel
Hello,

Following patch allows sysadmins to configure nice values for RC daemons.
Default nice value is set to 10 as I wish to prioritize interactive
applications over system daemons and I think most probably do too.
It is based on OpenBSD 6.3 but might apply easily to later releases.
Please let me know if it is of any interest to you.

commit 1f4121df3ae31121d435571ffdbd93a20c1e8a07
Author: Thomas de Grivel 
Date:   Mon Sep 3 21:52:37 2018 +0200

Add a $daemon_nice parameter.
If not overriden by the launched daemon the default nice value is 10.
See nice(1) for more details.

diff --git rc.d/rc.subr.orig rc.d/rc.subr
index 6c2f694..5f4fbe5 100644
--- rc.d/rc.subr.orig
+++ rc.d/rc.subr
@@ -49,6 +49,7 @@ _rc_write_runfile() {
  cat >${_RC_RUNFILE} &1 && daemon_class=${_name} ||
  daemon_class=daemon
+[ -z "${daemon_nice}" ] && daemon_nice=10
 [ -z "${daemon_rtable}" ] && daemon_rtable=0
 [ -z "${daemon_user}" ] && daemon_user=root
 [ -z "${daemon_timeout}" ] && daemon_timeout=30
@@ -304,6 +307,7 @@ getcap -f /etc/login.conf ${_name} 1>/dev/null
2>&1 && daemon_class=${_name} ||
  unset _rcflags

 [ -n "${_rcflags}" ] && daemon_flags=${_rcflags}
+[ -n "${_rcnice}" ] && daemon_nice=${_rcnice}
 [ -n "${_rcrtable}" ] && daemon_rtable=${_rcrtable}
 [ -n "${_rcuser}" ] && daemon_user=${_rcuser}
 [ -n "${_rctimeout}" ] && daemon_timeout=${_rctimeout}
@@ -315,7 +319,7 @@ if [ -n "${_RC_DEBUG}" ]; then
 fi

 readonly daemon_class
-unset _rcflags _rcrtable _rcuser _rctimeout
+unset _rcflags _rcnice _rcrtable _rcuser _rctimeout
 pexp="${daemon}${daemon_flags:+ ${daemon_flags}}"
 rcexec="su -l -c ${daemon_class} -s /bin/sh ${daemon_user} -c"
 [ "${daemon_rtable}" -eq 0 ] ||


-- 
 Thomas de Grivel



Re: smtpd: malloc+strlcpy -> strndup

2018-09-03 Thread Michael Mikonos
On Mon, Sep 03, 2018 at 02:24:49PM +0800, Michael Mikonos wrote:
> On Sat, Sep 01, 2018 at 11:31:49PM +0200, Gilles Chehade wrote:
> > On Sat, Sep 01, 2018 at 09:20:59PM +0800, Michael Mikonos wrote:
> > > Hello,
> > > 
> > > Replace a malloc+strlcpy with strndup in cmdline_symset().
> > > Parameter s is a "keyname=value" string and sym is the
> > > "keyname" part.
> > > 
> > > If s is "=value", sym will be an empty string.
> > > The patch doesn't change this behaviour although
> > > it might be undesirable to call symset() with
> > > an empty string. Possibly it could also return -1
> > > if len is zero. Thoughts?
> > > 
> > 
> > Not opposed to the diff but at this late hour I find it easier to read
> > the malloc+strlcpy and be sure there's not an off-by-one than with the
> > strndup version, I'll read again tomorrow.
> 
> In my understanding the length argument of strndup(3) doesn't include
> the terminating NUL character. I think the linux manual for strndup(3)
> is slightly clearer on this because it has the text:
> 
>   ... only n bytes are copied, and a terminating null byte ('\0') is
>   added.
> 
> > Just wanted to remind you that this function is shared between daemons
> > so this can't be an smtpd-only change :-)

Thanks for the reminder. Here is a new version of the patch to include
other daemons. I also followed a suggestion from halex@ to remove the
strlen() calls and determine length using val-s. Did I miss anything?


Index: acme-client/parse.y
===
RCS file: /cvs/src/usr.sbin/acme-client/parse.y,v
retrieving revision 1.29
diff -u -p -u -r1.29 parse.y
--- acme-client/parse.y 3 Aug 2018 17:57:21 -   1.29
+++ acme-client/parse.y 3 Sep 2018 15:18:23 -
@@ -839,17 +839,12 @@ cmdline_symset(char *s)
 {
char*sym, *val;
int ret;
-   size_t  len;
 
if ((val = strrchr(s, '=')) == NULL)
return -1;
-
-   len = strlen(s) - strlen(val) + 1;
-   if ((sym = malloc(len)) == NULL)
-   errx(EXIT_FAILURE, "cmdline_symset: malloc");
-
-   strlcpy(sym, s, len);
-
+   sym = strndup(s, val - s);
+   if (sym == NULL)
+   errx(EXIT_FAILURE, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
 
Index: bgpd/parse.y
===
RCS file: /cvs/src/usr.sbin/bgpd/parse.y,v
retrieving revision 1.331
diff -u -p -u -r1.331 parse.y
--- bgpd/parse.y27 Aug 2018 19:32:37 -  1.331
+++ bgpd/parse.y3 Sep 2018 15:18:24 -
@@ -3145,17 +3145,12 @@ cmdline_symset(char *s)
 {
char*sym, *val;
int ret;
-   size_t  len;
 
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
-   len = strlen(s) - strlen(val) + 1;
-   if ((sym = malloc(len)) == NULL)
-   fatal("cmdline_symset: malloc");
-
-   strlcpy(sym, s, len);
-
+   sym = strndup(s, val - s);
+   if (sym == NULL)
+   fatal("%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
 
Index: dvmrpd/parse.y
===
RCS file: /cvs/src/usr.sbin/dvmrpd/parse.y,v
retrieving revision 1.36
diff -u -p -u -r1.36 parse.y
--- dvmrpd/parse.y  11 Jul 2018 07:39:22 -  1.36
+++ dvmrpd/parse.y  3 Sep 2018 15:18:24 -
@@ -834,17 +834,12 @@ cmdline_symset(char *s)
 {
char*sym, *val;
int ret;
-   size_t  len;
 
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
-   len = strlen(s) - strlen(val) + 1;
-   if ((sym = malloc(len)) == NULL)
-   errx(1, "cmdline_symset: malloc");
-
-   strlcpy(sym, s, len);
-
+   sym = strndup(s, val - s);
+   if (sym == NULL)
+   errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
 
Index: eigrpd/parse.y
===
RCS file: /cvs/src/usr.sbin/eigrpd/parse.y,v
retrieving revision 1.27
diff -u -p -u -r1.27 parse.y
--- eigrpd/parse.y  11 Jul 2018 07:39:22 -  1.27
+++ eigrpd/parse.y  3 Sep 2018 15:18:24 -
@@ -1094,17 +1094,12 @@ cmdline_symset(char *s)
 {
char*sym, *val;
int ret;
-   size_t  len;
 
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
-   len = strlen(s) - strlen(val) + 1;
-   if ((sym = malloc(len)) == NULL)
-   errx(1, "cmdline_symset: malloc");
-
-   strlcpy(sym, s, len);
-
+   sym = strndup(s, val - s);
+   if (sym == NULL)
+   errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
 
Index: httpd/parse.y
===
RCS file: /cvs/src/usr.sbin/httpd/parse.y,v
retrieving revision 1.105
diff -u 

Re: xidle: launching program on timeout without active-area

2018-09-03 Thread Sebastien Marie
ping

On Tue, Aug 14, 2018 at 06:15:08AM +0200, Sebastien Marie wrote:
> ping
> 
> On Wed, Jul 25, 2018 at 02:13:49PM +0200, Sebastien Marie wrote:
> > On Wed, Jul 25, 2018 at 12:55:48PM +0200, Claudio Jeker wrote:
> > > On Wed, Jul 25, 2018 at 12:27:29PM +0200, Sebastien Marie wrote:
> > > > On Mon, Jul 16, 2018 at 11:37:41AM +0200, Sebastien Marie wrote:
> > > > 
> > > > > xidle(1) seems great for such purpose. But I didn't found a way to 
> > > > > just
> > > > > use timeout and not also an active area (a corner where the program is
> > > > > launched if pointer stays inside few seconds).
> > > > > 
> > > > > The following diff tries to implement a way to disable the active area
> > > > > without being too intrusive.
> > > > > 
> > > > > For that, I used the `delay' parameter ("Specify the number of seconds
> > > > > the pointer has to be in the given position before running the
> > > > > program."), to allow value -1, and make it to discard the event.
> > > > > 
> > > > > Does it make sens ? Or any proposition to more straighfull approch ?
> > > > > 
> > > 
> > > I would love to be able to use xidle without active area but I have to say
> > > that your approach with -1 as delay seems a bit like a hack. Wouldn't it
> > > be better to add a -no option to disable the corners all together? Maybe
> > > even make that the default instead of -nw?
> > > 
> > 
> > the "-delay -1" approch was taken to avoid too instrusive change that
> > would clash with upstream (but are we upstream ? I didn't found xidle under
> > www.x.org). Anyway, the approch with -no option seems to not be too
> > intrusive neither and it is better for user point of vue.
> > 
> > So below a new diff with -no option.
> > 
> > When used, the -no flag that sets `position' variable to `none'. The
> > active area window is still created (its avoid to manage a new case
> > where `xi->win' could be NULL), but the window isn't mapper and no
> > event asked for EnterWindow.
> > 
> > Sending USR1 still work as intented.
> > 
> > I didn't change the default value for the position, but it could be
> > easily done (one line change in xidle.c and xidle.1).
> > 
> > -- 
> > Sebastien Marie
> > 
> > Index: xidle.1
> > ===
> > RCS file: /cvs/xenocara/app/xidle/xidle.1,v
> > retrieving revision 1.4
> > diff -u -p -r1.4 xidle.1
> > --- xidle.1 9 Nov 2017 19:13:03 -   1.4
> > +++ xidle.1 25 Jul 2018 11:54:13 -
> > @@ -35,7 +35,7 @@
> >  .Op Fl area Ar pixels
> >  .Op Fl delay Ar secs
> >  .Op Fl display Ar display
> > -.Op Fl nw | ne | sw | se
> > +.Op Fl no | nw | ne | sw | se
> >  .Op Fl program Ar path
> >  .Op Fl timeout Ar secs
> >  .Ek
> > @@ -66,8 +66,8 @@ The default is 2 seconds.
> >  .It Fl display Ar display
> >  This argument allows you to specify the server to connect to; see
> >  .Xr X 7 .
> > -.It Fl nw | ne | sw | se
> > -Set the position to one of northwest, northeast, southwest, or southeast,
> > +.It Fl no | nw | ne | sw | se
> > +Set the position to one of none, northwest, northeast, southwest, or 
> > southeast,
> >  respectively.
> >  If no position is specified,
> >  the default is northwest.
> > @@ -100,7 +100,9 @@ Specify the number of seconds to wait be
> >  .Fl delay
> >  option.
> >  .It Sy position No (class Sy Position )
> > -Set the position to one of: "nw", "ne", "sw", or "se"; see descriptions of 
> > the
> > +Set the position to one of: "no", "nw", "ne", "sw", or "se"; see 
> > descriptions
> > +of the
> > +.Fl no ,
> >  .Fl nw ,
> >  .Fl ne ,
> >  .Fl sw ,
> > Index: xidle.c
> > ===
> > RCS file: /cvs/xenocara/app/xidle/xidle.c,v
> > retrieving revision 1.5
> > diff -u -p -r1.5 xidle.c
> > --- xidle.c 20 Aug 2017 16:43:25 -  1.5
> > +++ xidle.c 25 Jul 2018 11:59:40 -
> > @@ -53,7 +53,8 @@ enum {
> > north = 0x01,
> > south = 0x02,
> > east  = 0x04,
> > -   west  = 0x08
> > +   west  = 0x08,
> > +   none  = 0x10,
> >  };
> >  
> >  enum { XIDLE_LOCK = 1, XIDLE_DIE = 2 };
> > @@ -84,6 +85,7 @@ static XrmOptionDescRec opts[] = {
> > { "-program",   ".program", XrmoptionSepArg,(caddr_t)NULL },
> > { "-timeout",   ".timeout", XrmoptionSepArg,(caddr_t)NULL },
> >  
> > +   { "-no",".position",XrmoptionNoArg, (caddr_t)"no" },
> > { "-ne",".position",XrmoptionNoArg, (caddr_t)"ne" },
> > { "-nw",".position",XrmoptionNoArg, (caddr_t)"nw" },
> > { "-se",".position",XrmoptionNoArg, (caddr_t)"se" },
> > @@ -108,7 +110,7 @@ usage()
> >  {
> > fprintf(stderr, "Usage:\n%s %s\n", __progname,
> > "[-area pixels] [-delay secs] [-display host:dpy] "
> > -   "[-ne | -nw | -se | -sw]\n  [-program path] [-timeout secs]");
> > +   "[-no | -ne | -nw | -se | -sw]\n  [-program path] [-timeout 
> > secs]");
> > exit(1);
> >  }
> >  
> > 

Re: Corrected patch for smtpd.conf(5) man page

2018-09-03 Thread Jason McIntyre
On Mon, Sep 03, 2018 at 02:20:32PM +0200, Gilles Chehade wrote:
> On Mon, Sep 03, 2018 at 12:30:22PM +0100, Jason McIntyre wrote:
> > On Sun, Sep 02, 2018 at 11:59:25AM -0400, Matt Schwartz wrote:
> > > The earlier patch I created was obviously no good. Sorry for the
> > > noise. Included is the fixed patch that just adds some text for
> > > properly using an mda wrapper in the actions:
> > > 
> > > Index: smtpd.conf.5
> > > ===
> > > RCS file: /cvs/src/usr.sbin/smtpd/smtpd.conf.5,v
> > > retrieving revision 1.199
> > > diff -u -p -u -r1.199 smtpd.conf.5
> > > --- smtpd.conf.51 Sep 2018 19:56:28 -   1.199
> > > +++ smtpd.conf.52 Sep 2018 15:53:57 -
> > > @@ -205,6 +205,9 @@ Use the mapping
> > >  for virtual expansion.
> > >  The aliasing table format is described in
> > >  .Xr table 5 .
> > > +.It Cm wrapper Ar name
> > > +Use the wrapper specified in
> > > +.Cm mda wrapper.
> > 
> > that looks correct (i think). but with one adjustment - there should be
> > a space between "wrapper" and the full stop.
> > 
> > gilles? eric?
> > 
> 
> yes this reads ok
> 
> 

thanks. fixed.
jmc

> > >  .El
> > >  .Pp
> > >  The relay delivery methods also support additional options:
> > > 
> > 
> 
> -- 
> Gilles Chehade
> 
> https://www.poolp.org  @poolpOrg
> 



Re: Corrected patch for smtpd.conf(5) man page

2018-09-03 Thread Gilles Chehade
On Mon, Sep 03, 2018 at 12:30:22PM +0100, Jason McIntyre wrote:
> On Sun, Sep 02, 2018 at 11:59:25AM -0400, Matt Schwartz wrote:
> > The earlier patch I created was obviously no good. Sorry for the
> > noise. Included is the fixed patch that just adds some text for
> > properly using an mda wrapper in the actions:
> > 
> > Index: smtpd.conf.5
> > ===
> > RCS file: /cvs/src/usr.sbin/smtpd/smtpd.conf.5,v
> > retrieving revision 1.199
> > diff -u -p -u -r1.199 smtpd.conf.5
> > --- smtpd.conf.51 Sep 2018 19:56:28 -   1.199
> > +++ smtpd.conf.52 Sep 2018 15:53:57 -
> > @@ -205,6 +205,9 @@ Use the mapping
> >  for virtual expansion.
> >  The aliasing table format is described in
> >  .Xr table 5 .
> > +.It Cm wrapper Ar name
> > +Use the wrapper specified in
> > +.Cm mda wrapper.
> 
> that looks correct (i think). but with one adjustment - there should be
> a space between "wrapper" and the full stop.
> 
> gilles? eric?
> 

yes this reads ok


> >  .El
> >  .Pp
> >  The relay delivery methods also support additional options:
> > 
> 

-- 
Gilles Chehade

https://www.poolp.org  @poolpOrg



Re: Corrected patch for smtpd.conf(5) man page

2018-09-03 Thread Jason McIntyre
On Sun, Sep 02, 2018 at 11:59:25AM -0400, Matt Schwartz wrote:
> The earlier patch I created was obviously no good. Sorry for the
> noise. Included is the fixed patch that just adds some text for
> properly using an mda wrapper in the actions:
> 
> Index: smtpd.conf.5
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/smtpd.conf.5,v
> retrieving revision 1.199
> diff -u -p -u -r1.199 smtpd.conf.5
> --- smtpd.conf.51 Sep 2018 19:56:28 -   1.199
> +++ smtpd.conf.52 Sep 2018 15:53:57 -
> @@ -205,6 +205,9 @@ Use the mapping
>  for virtual expansion.
>  The aliasing table format is described in
>  .Xr table 5 .
> +.It Cm wrapper Ar name
> +Use the wrapper specified in
> +.Cm mda wrapper.

that looks correct (i think). but with one adjustment - there should be
a space between "wrapper" and the full stop.

gilles? eric?

jmc

>  .El
>  .Pp
>  The relay delivery methods also support additional options:
> 



[patch] A small modification in /usr.bin/nc/netcat.c

2018-09-03 Thread Nan Xiao
Hi tech@,

The following patch uses hostname instead of nodename to be consistent
with getaddrinfo declaration:

 int
 getaddrinfo(const char *hostname, const char *servname,
 const struct addrinfo *hints, struct addrinfo **res);

Thanks!


Index: netcat.c
===
RCS file: /cvs/src/usr.bin/nc/netcat.c,v
retrieving revision 1.192
diff -u -p -r1.192 netcat.c
--- netcat.c10 Aug 2018 17:15:22 -  1.192
+++ netcat.c3 Sep 2018 11:12:49 -
@@ -999,7 +999,7 @@ local_listen(char *host, char *port, str
int s = -1, ret, x = 1, save_errno;
int error;

-   /* Allow nodename to be null. */
+   /* Allow hostname to be null. */
hints.ai_flags |= AI_PASSIVE;

/*


-- 
Best Regards
Nan Xiao



Re: smtpd: malloc+strlcpy -> strndup

2018-09-03 Thread Michael Mikonos
On Sat, Sep 01, 2018 at 11:31:49PM +0200, Gilles Chehade wrote:
> On Sat, Sep 01, 2018 at 09:20:59PM +0800, Michael Mikonos wrote:
> > Hello,
> > 
> > Replace a malloc+strlcpy with strndup in cmdline_symset().
> > Parameter s is a "keyname=value" string and sym is the
> > "keyname" part.
> > 
> > If s is "=value", sym will be an empty string.
> > The patch doesn't change this behaviour although
> > it might be undesirable to call symset() with
> > an empty string. Possibly it could also return -1
> > if len is zero. Thoughts?
> > 
> 
> Not opposed to the diff but at this late hour I find it easier to read
> the malloc+strlcpy and be sure there's not an off-by-one than with the
> strndup version, I'll read again tomorrow.

In my understanding the length argument of strndup(3) doesn't include
the terminating NUL character. I think the linux manual for strndup(3)
is slightly clearer on this because it has the text:

  ... only n bytes are copied, and a terminating null byte ('\0') is
  added.

> Just wanted to remind you that this function is shared between daemons
> so this can't be an smtpd-only change :-)
> 
> 
> > Index: parse.y
> > ===
> > RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v
> > retrieving revision 1.218
> > diff -u -p -u -r1.218 parse.y
> > --- parse.y 25 Aug 2018 19:05:23 -  1.218
> > +++ parse.y 1 Sep 2018 12:42:45 -
> > @@ -2129,11 +2129,10 @@ cmdline_symset(char *s)
> > if ((val = strrchr(s, '=')) == NULL)
> > return (-1);
> >  
> > -   len = strlen(s) - strlen(val) + 1;
> > -   if ((sym = malloc(len)) == NULL)
> > -   errx(1, "cmdline_symset: malloc");
> > -
> > -   (void)strlcpy(sym, s, len);
> > +   len = strlen(s) - strlen(val);
> > +   sym = strndup(s, len);
> > +   if (sym == NULL)
> > +   errx(1, "%s: strndup", __func__);
> >  
> > ret = symset(sym, val + 1, 1);
> > free(sym);
> > 
> 
> -- 
> Gilles Chehade
> 
> https://www.poolp.org  @poolpOrg