1
0
mirror of https://github.com/falk-werner/webfused synced 2024-10-27 20:44:08 +00:00

fix: ensure that syslog ident is valid while logger is active

This commit is contained in:
Falk Werner 2020-11-12 11:47:09 +01:00
parent ce2f70f230
commit 3c14ba1cae

View File

@ -6,6 +6,8 @@
#include <syslog.h>
#include <strings.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
static int
@ -41,6 +43,7 @@ wfd_syslog_logger_close(
void * user_data)
{
closelog();
free(user_data);
}
struct wfd_syslog_facility
@ -97,7 +100,7 @@ wfd_syslog_logger_init(
int level,
struct wfd_settings * settings)
{
char const * ident = wfd_settings_get_string_or_default(settings, "ident", "webfused");
char * ident = strdup(wfd_settings_get_string_or_default(settings, "ident", "webfused"));
char const * facility_str = wfd_settings_get_string_or_default(settings, "facility", "daemon");
bool log_pid = wfd_settings_get_bool(settings, "log_pid");
@ -109,7 +112,7 @@ wfd_syslog_logger_init(
wfd_logger_init(level,
&wfd_syslog_logger_log,
&wfd_syslog_logger_close,
NULL);
ident);
openlog(ident, options, facility);
}