Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 12 Apr 2018 15:04:31 +0200
From: Hrvoje Varga <hrvoje.varga@...tura.hr>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] add SOCK_STREAM support for syslog

> To be consistent with glibc and uClibc since both glibc and uClibc
> have a support for connecting to SOCK_STREAM socket in case
> when connection to a SOCK_DGRAM is unsuccessful. This patch mimics the
> same behavior.
> 
> There was a discussion whether the musl should support the SOCK_STREAM
> on musl mailing list http://www.openwall.com/lists/musl/2015/08/10/1.
> 
> Signed-off-by: Hrvoje Varga <hrvoje.varga@...tura.hr>
> ---
>  src/misc/syslog.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/src/misc/syslog.c b/src/misc/syslog.c
> index 9dd1ddb5..101847a4 100644
> --- a/src/misc/syslog.c
> +++ b/src/misc/syslog.c
> @@ -48,8 +48,22 @@ void closelog(void)
>  
>  static void __openlog()
>  {
> -	log_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
> -	if (log_fd >= 0) connect(log_fd, (void *)&log_addr, sizeof log_addr);
> +	int retry = 0;
> +	int sock_type = SOCK_DGRAM;
> +	while (retry < 2) {
> +		retry++;
> +		log_fd = socket(AF_UNIX, sock_type|SOCK_CLOEXEC, 0);
> +		if (log_fd >= 0) {
> +			if (connect(log_fd, (void *)&log_addr, sizeof log_addr) != -1) {
> +				return;
> +			}
> +			if (errno == EPROTOTYPE) {
> +				sock_type = SOCK_STREAM;
> +			}
> +			close(log_fd);
> +			log_fd = -1;
> +		}
> +	}
>  }
>  
>  void openlog(const char *ident, int opt, int facility)
> -- 
> 2.14.1
> 

Hi,

any news regarding this patch?

-- 
br,
Hrvoje

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.