Re: don't spam console with pflogd exiting messages, misc cleanup

2017-09-07 Thread Stuart Henderson
On 2017/09/07 16:40, Theo de Raadt wrote:
> > On Thu, Sep 07, 2017 at 12:05:11PM +0200, Sebastian Benoit wrote:
> > > The reason you see the message on the console on halt and reboot is, 
> > > because
> > > syslogd is gone at that point, so the message goes to the console instead.
> > 
> > pflogd(8) explicitly requests this behavior.
> > 
> > openlog("pflogd", LOG_PID | LOG_CONS, LOG_DAEMON);
> > 
> > The LOG_CONS means to write to console if syslogd(8) is dead.  If
> > you remove that flag, the message will go away.
> 
> Right.  It is silly and old school.
> 

Ah, that explains some console messages from isakmpd at shutdown too.



Re: don't spam console with pflogd exiting messages, misc cleanup

2017-09-07 Thread Theo de Raadt
> On Thu, Sep 07, 2017 at 12:05:11PM +0200, Sebastian Benoit wrote:
> > The reason you see the message on the console on halt and reboot is, because
> > syslogd is gone at that point, so the message goes to the console instead.
> 
> pflogd(8) explicitly requests this behavior.
> 
>   openlog("pflogd", LOG_PID | LOG_CONS, LOG_DAEMON);
> 
> The LOG_CONS means to write to console if syslogd(8) is dead.  If
> you remove that flag, the message will go away.

Right.  It is silly and old school.



Re: don't spam console with pflogd exiting messages, misc cleanup

2017-09-07 Thread Bryan Steele
On Thu, Sep 07, 2017 at 01:16:18PM +0200, Alexander Bluhm wrote:
> On Thu, Sep 07, 2017 at 12:05:11PM +0200, Sebastian Benoit wrote:
> > The reason you see the message on the console on halt and reboot is, because
> > syslogd is gone at that point, so the message goes to the console instead.
> 
> pflogd(8) explicitly requests this behavior.
> 
>   openlog("pflogd", LOG_PID | LOG_CONS, LOG_DAEMON);
> 
> The LOG_CONS means to write to console if syslogd(8) is dead.  If
> you remove that flag, the message will go away.
> 
> bluhm

If that works too, i'm ok with the change (..orig diff already went in).

-Bryan.



Re: don't spam console with pflogd exiting messages, misc cleanup

2017-09-07 Thread Alexander Bluhm
On Thu, Sep 07, 2017 at 12:05:11PM +0200, Sebastian Benoit wrote:
> The reason you see the message on the console on halt and reboot is, because
> syslogd is gone at that point, so the message goes to the console instead.

pflogd(8) explicitly requests this behavior.

openlog("pflogd", LOG_PID | LOG_CONS, LOG_DAEMON);

The LOG_CONS means to write to console if syslogd(8) is dead.  If
you remove that flag, the message will go away.

bluhm



Re: don't spam console with pflogd exiting messages, misc cleanup

2017-09-07 Thread Sebastian Benoit
Bryan Steele(bry...@openbsd.org) on 2017.09.05 16:17:46 -0400:
> pflogd(8) currently spams the console on shutdown if syslogd wins the
> race to die, this logging probably comes from the fact that pflogd was
> largely based on syslogd.

i looked at that some time ago: a and found that lot of our daemons log the
fact that they exit.

Its actually nice to know that a daemon exited at a certain time. In the
case of pflogd you might want to know at what point your pflog files
stopped.

The reason you see the message on the console on halt and reboot is, because
syslogd is gone at that point, so the message goes to the console instead.

So i decided not to change this. Who cares about the message at that point?

> Also, cleanup some missed SIGCHLD handling code that is no longer
> neccesary, parent will exit when child closes its side of the
> socketpair(2).

that part is ok benno@
 
> -Bryan.
> 
> Index: pflogd.c
> ===
> RCS file: /cvs/src/sbin/pflogd/pflogd.c,v
> retrieving revision 1.55
> diff -u -p -u -r1.55 pflogd.c
> --- sbin/pflogd/pflogd.c  5 Sep 2017 15:41:25 -   1.55
> +++ sbin/pflogd/pflogd.c  5 Sep 2017 20:06:57 -
> @@ -686,7 +686,6 @@ main(int argc, char **argv)
>   }
>   }
>  
> - logmsg(LOG_NOTICE, "Exiting");
>   if (dpcap) {
>   flush_buffer(dpcap);
>   fclose(dpcap);
> Index: privsep.c
> ===
> RCS file: /cvs/src/sbin/pflogd/privsep.c,v
> retrieving revision 1.28
> diff -u -p -u -r1.28 privsep.c
> --- sbin/pflogd/privsep.c 5 Sep 2017 15:41:25 -   1.28
> +++ sbin/pflogd/privsep.c 5 Sep 2017 20:06:57 -
> @@ -49,10 +49,7 @@ enum cmd_types {
>  static int priv_fd = -1;
>  static volatile pid_t child_pid = -1;
>  
> -volatile sig_atomic_t gotsig_chld = 0;
> -
>  static void sig_pass_to_chld(int);
> -static void sig_chld(int);
>  static int  may_read(int, void *, size_t);
>  static void must_read(int, void *, size_t);
>  static void must_write(int, void *, size_t);
> @@ -150,7 +147,6 @@ priv_exec(int child, int argc, char *arg
>   signal(SIGHUP,  sig_pass_to_chld);
>   signal(SIGINT,  sig_pass_to_chld);
>   signal(SIGQUIT, sig_pass_to_chld);
> - signal(SIGCHLD, sig_chld);
>  
>   setproctitle("[priv]");
>  
> @@ -160,7 +156,7 @@ BROKENif (pledge("stdio rpath wpath cpa
>   err(1, "pledge");
>  #endif
>  
> - while (!gotsig_chld) {
> + while (1) {
>   if (may_read(sock, , sizeof(int)))
>   break;
>   switch (cmd) {
> @@ -393,13 +389,6 @@ sig_pass_to_chld(int sig)
>   if (child_pid != -1)
>   kill(child_pid, sig);
>   errno = oerrno;
> -}
> -
> -/* if parent gets a SIGCHLD, it will exit */
> -static void
> -sig_chld(int sig)
> -{
> - gotsig_chld = 1;
>  }
>  
>  /* Read all data or return 1 for error.  */
>