Add support for logger -u /tmp/foo to log to alternate socket

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2019-10-29 10:43:14 +01:00
parent 08aa942ffb
commit ec9c92987f
3 changed files with 16 additions and 2 deletions

View File

@ -483,7 +483,7 @@ static void
connectlog_r(struct syslog_data *data)
{
/* AF_UNIX address of local logger */
static const struct sockaddr_un sun = {
static struct sockaddr_un sun = {
.sun_family = AF_LOCAL,
#ifdef HAVE_SA_LEN
.sun_len = sizeof(sun),
@ -491,6 +491,9 @@ connectlog_r(struct syslog_data *data)
.sun_path = _PATH_LOG,
};
if (data->log_sockpath && !access(data->log_sockpath, W_OK))
strlcpy(sun.sun_path, data->log_sockpath, sizeof(sun.sun_path));
if (data->log_file == -1 || fcntl(data->log_file, F_GETFL, 0) == -1) {
data->log_file = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0);
if (data->log_file == -1)