Re: Why /dev/kmsg was deleted from cygwin1.dll in git?

2018-07-06 Thread Corinna Vinschen
On Jul  6 00:29, Takashi Yano wrote:
> Hi Corinna,
> 
> On Wed, 4 Jul 2018 16:52:47 +0200
> Corinna Vinschen wrote:
> > Hang on.  /dev/kmsg was implemented using a mailslot and it was never
> > accessible via the syslog(3) interface.  The code you removed has
> > nothing to do with /dev/kmsg.
> 
> First of all, /dev/kmsg was not guilty. The real culprit is the code
> I had removed by the previous patch.
> 
> However, the patch I posted was based on mis-understanding regarding
> AF_UNIX implementation. I had checked fhandler_socket_unix.cc and
> thought cygwin AF_UNIX socket is implemented not using AF_INET socket.
> On the other hand, the code, I removed, checks existence of UDP socket
> to determine whether syslogd is activated. So I thought this is no
> longer correct and should be removed.
> 
> As a matter of fact, cygwin AF_UNIX socket usually use fhandler_socket_
> local.cc, in which AF_UNIX socket is implemented using AF_INET socket.
> That is, the obove understanding was incorrect.
> 
> > What the code does is to check if we have a listener on the /dev/msg UDP
> > socket, otherwise log data may get lost or, IIRC, the syslog call may
> > even hang.  So removing this code sounds like a bad idea.
> 
> In the case of syslogd is not activated, /dev/log does not exist.
> So connect() results in an error. Therefore log data is directed to 
> windows event logging mechanism even without the removed code. In
> usual case, no problem happens. However if syslogd is killed by signal
> 9 or died accidently, /dev/log remains without listener. In this case,
> the problem you mentioned may happen.
> 
> > Can you please explain *why* removing this code helps and what happens
> > if syslogd is not running after removing the code?
> 
> OK. First, connect_syslogd() tries to connect to syslogd via /dev/log
> which is created by syslogd. However, the code which I removed can not
> perform checking existence of syslogd as expected.
> Previously, get_inet_addr() is used to get name information of the socket
> opened by syslogd. This was working correctly at that time. Currently,
> getsockname() is used instead. This does not return name infomation of
> the socket on syslogd side but returns that of client side. Since no
> listener exists for this socket, it is not listed in the table returned
> by GetUdpTable(). Therefore this check results in false.
> 
> As a result, current connect_syslogd() code gives up to connect to syslogd.
> 
> To fix this, I made a new patch attached. In this patch, get_inet_addr_local()
> is used instead of getsockname() as in the past.
> 
> I will appreciate any comments.

Thanks a lot for the detailed analysis.  Patch pushed.


Thanks
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


Re: Why /dev/kmsg was deleted from cygwin1.dll in git?

2018-07-05 Thread Takashi Yano
Hi Brian,

On Thu, 5 Jul 2018 12:38:08 -0600
Brian Inglis wrote:
> Isn't this moot as the supported package is syslog-ng, which seems to work 
> okay?

Not only inetutils syslogd but also syslog-ng does not work in cygwin
git HEAD. I confirmed syslog-ng gets back working with the patch I posted.

Moreover, syslog-ng does not remove /dev/log even after exiting normally.
This means my first patch removing the code may cause the problem below.

On Fri, 6 Jul 2018 00:29:24 +0900
Takashi Yano wrote:
> On Wed, 4 Jul 2018 16:52:47 +0200
> Corinna Vinschen wrote:
> > What the code does is to check if we have a listener on the /dev/msg UDP
> > socket, otherwise log data may get lost or, IIRC, the syslog call may
> > even hang.  So removing this code sounds like a bad idea.
...
> usual case, no problem happens. However if syslogd is killed by signal
> 9 or died accidently, /dev/log remains without listener. In this case,
> the problem you mentioned may happen.

-- 
Takashi Yano 


Re: Why /dev/kmsg was deleted from cygwin1.dll in git?

2018-07-05 Thread Brian Inglis
On 2018-07-05 09:29, Takashi Yano wrote:
> On Wed, 4 Jul 2018 16:52:47 +0200 Corinna Vinschen wrote:
>> Hang on.  /dev/kmsg was implemented using a mailslot and it was never
>> accessible via the syslog(3) interface.  The code you removed has
>> nothing to do with /dev/kmsg.
> 
> First of all, /dev/kmsg was not guilty. The real culprit is the code
> I had removed by the previous patch.
> 
> However, the patch I posted was based on mis-understanding regarding
> AF_UNIX implementation. I had checked fhandler_socket_unix.cc and
> thought cygwin AF_UNIX socket is implemented not using AF_INET socket.
> On the other hand, the code, I removed, checks existence of UDP socket
> to determine whether syslogd is activated. So I thought this is no
> longer correct and should be removed.
> 
> As a matter of fact, cygwin AF_UNIX socket usually use fhandler_socket_
> local.cc, in which AF_UNIX socket is implemented using AF_INET socket.
> That is, the obove understanding was incorrect.
> 
>> What the code does is to check if we have a listener on the /dev/msg UDP
>> socket, otherwise log data may get lost or, IIRC, the syslog call may
>> even hang.  So removing this code sounds like a bad idea.
> 
> In the case of syslogd is not activated, /dev/log does not exist.
> So connect() results in an error. Therefore log data is directed to 
> windows event logging mechanism even without the removed code. In
> usual case, no problem happens. However if syslogd is killed by signal
> 9 or died accidently, /dev/log remains without listener. In this case,
> the problem you mentioned may happen.
> 
>> Can you please explain *why* removing this code helps and what happens
>> if syslogd is not running after removing the code?
> 
> OK. First, connect_syslogd() tries to connect to syslogd via /dev/log
> which is created by syslogd. However, the code which I removed can not
> perform checking existence of syslogd as expected.
> Previously, get_inet_addr() is used to get name information of the socket
> opened by syslogd. This was working correctly at that time. Currently,
> getsockname() is used instead. This does not return name infomation of
> the socket on syslogd side but returns that of client side. Since no
> listener exists for this socket, it is not listed in the table returned
> by GetUdpTable(). Therefore this check results in false.
> 
> As a result, current connect_syslogd() code gives up to connect to syslogd.
> 
> To fix this, I made a new patch attached. In this patch, get_inet_addr_local()
> is used instead of getsockname() as in the past.
> 
> I will appreciate any comments.

Isn't this moot as the supported package is syslog-ng, which seems to work okay?

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada


Re: Why /dev/kmsg was deleted from cygwin1.dll in git?

2018-07-05 Thread Takashi Yano
Hi Corinna,

On Wed, 4 Jul 2018 16:52:47 +0200
Corinna Vinschen wrote:
> Hang on.  /dev/kmsg was implemented using a mailslot and it was never
> accessible via the syslog(3) interface.  The code you removed has
> nothing to do with /dev/kmsg.

First of all, /dev/kmsg was not guilty. The real culprit is the code
I had removed by the previous patch.

However, the patch I posted was based on mis-understanding regarding
AF_UNIX implementation. I had checked fhandler_socket_unix.cc and
thought cygwin AF_UNIX socket is implemented not using AF_INET socket.
On the other hand, the code, I removed, checks existence of UDP socket
to determine whether syslogd is activated. So I thought this is no
longer correct and should be removed.

As a matter of fact, cygwin AF_UNIX socket usually use fhandler_socket_
local.cc, in which AF_UNIX socket is implemented using AF_INET socket.
That is, the obove understanding was incorrect.

> What the code does is to check if we have a listener on the /dev/msg UDP
> socket, otherwise log data may get lost or, IIRC, the syslog call may
> even hang.  So removing this code sounds like a bad idea.

In the case of syslogd is not activated, /dev/log does not exist.
So connect() results in an error. Therefore log data is directed to 
windows event logging mechanism even without the removed code. In
usual case, no problem happens. However if syslogd is killed by signal
9 or died accidently, /dev/log remains without listener. In this case,
the problem you mentioned may happen.

> Can you please explain *why* removing this code helps and what happens
> if syslogd is not running after removing the code?

OK. First, connect_syslogd() tries to connect to syslogd via /dev/log
which is created by syslogd. However, the code which I removed can not
perform checking existence of syslogd as expected.
Previously, get_inet_addr() is used to get name information of the socket
opened by syslogd. This was working correctly at that time. Currently,
getsockname() is used instead. This does not return name infomation of
the socket on syslogd side but returns that of client side. Since no
listener exists for this socket, it is not listed in the table returned
by GetUdpTable(). Therefore this check results in false.

As a result, current connect_syslogd() code gives up to connect to syslogd.

To fix this, I made a new patch attached. In this patch, get_inet_addr_local()
is used instead of getsockname() as in the past.

I will appreciate any comments.

-- 
Takashi Yano 


0001-Fix-a-problem-that-connection-to-syslogd-fails.patch
Description: Binary data


Re: Why /dev/kmsg was deleted from cygwin1.dll in git?

2018-07-04 Thread Corinna Vinschen
On Jul  4 22:01, Takashi Yano wrote:
> Hi Corinna,
> 
> On Wed, 4 Jul 2018 12:54:20 +0200
> Corinna Vinschen wrote:
> > On Jul  4 04:44, Takashi Yano wrote:
> > > Why was /dev/kmsg deleted from cygwin1.dll in git?
> > > Due to this change, syslogd in inetutils package no longer works.
> > 
> > /dev/kmsg doesn't really give any useful information.  It was never used
> > for more than some exception information, but it required a complete
> > fhandler class on its own.  I wanted to get rid of the useless code.
> 
> I looked into this problem and I realized that the real cause is not the 
> absence of /dev/kmsg but old codes in the connect_syslogd() function in
> syslog.cc.
> 
> I removed these codes and confirmed that syslogd works again.

Hang on.  /dev/kmsg was implemented using a mailslot and it was never
accessible via the syslog(3) interface.  The code you removed has
nothing to do with /dev/kmsg.

What the code does is to check if we have a listener on the /dev/msg UDP
socket, otherwise log data may get lost or, IIRC, the syslog call may
even hang.  So removing this code sounds like a bad idea.

Can you please explain *why* removing this code helps and what happens
if syslogd is not running after removing the code?


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


signature.asc
Description: PGP signature


Re: Why /dev/kmsg was deleted from cygwin1.dll in git?

2018-07-04 Thread Takashi Yano
Hi Corinna,

On Wed, 4 Jul 2018 12:54:20 +0200
Corinna Vinschen wrote:
> On Jul  4 04:44, Takashi Yano wrote:
> > Why was /dev/kmsg deleted from cygwin1.dll in git?
> > Due to this change, syslogd in inetutils package no longer works.
> 
> /dev/kmsg doesn't really give any useful information.  It was never used
> for more than some exception information, but it required a complete
> fhandler class on its own.  I wanted to get rid of the useless code.

I looked into this problem and I realized that the real cause is not the 
absence of /dev/kmsg but old codes in the connect_syslogd() function in
syslog.cc.

I removed these codes and confirmed that syslogd works again.

I make a patch attached. Could you please have a look?

-- 
Takashi Yano 


0001-Fix-a-problem-that-connection-to-syslogd-fails.patch
Description: Binary data