Replace logsrvd_is_early() with logsrvd_warn_stderr().
This is now defined in logsrvd_conf.c which removes a dependency on another compilation unit for the fuzzer.
This commit is contained in:
@@ -87,7 +87,6 @@ static struct connection_list connections = TAILQ_HEAD_INITIALIZER(connections);
|
||||
static struct listener_list listeners = TAILQ_HEAD_INITIALIZER(listeners);
|
||||
static const char server_id[] = "Sudo Audit Server " PACKAGE_VERSION;
|
||||
static const char *conf_file = _PATH_SUDO_LOGSRVD_CONF;
|
||||
static bool is_early = true;
|
||||
|
||||
/* Event loop callbacks. */
|
||||
static void client_msg_cb(int fd, int what, void *v);
|
||||
@@ -1818,18 +1817,13 @@ daemonize(bool nofork)
|
||||
(void) close(fd);
|
||||
}
|
||||
}
|
||||
is_early = false;
|
||||
|
||||
/* Disable logging to stderr after we become a daemon. */
|
||||
logsrvd_warn_stderr(false);
|
||||
|
||||
debug_return;
|
||||
}
|
||||
|
||||
/* The early flag is used to decide whether sudo_warn() goes to stderr too. */
|
||||
bool
|
||||
logsrvd_is_early(void)
|
||||
{
|
||||
return is_early;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(bool fatal)
|
||||
{
|
||||
|
@@ -197,7 +197,6 @@ bool fmt_log_id_message(const char *id, struct connection_closure *closure);
|
||||
bool schedule_error_message(const char *errstr, struct connection_closure *closure);
|
||||
struct connection_buffer *get_free_buf(size_t, struct connection_closure *closure);
|
||||
struct connection_closure *connection_closure_alloc(int fd, bool tls, bool relay_only, struct sudo_event_base *base);
|
||||
bool logsrvd_is_early(void);
|
||||
|
||||
/* logsrvd_conf.c */
|
||||
bool logsrvd_conf_read(const char *path);
|
||||
@@ -224,6 +223,7 @@ mode_t logsrvd_conf_iolog_mode(void);
|
||||
void address_list_addref(struct server_address_list *);
|
||||
void address_list_delref(struct server_address_list *);
|
||||
void logsrvd_conf_cleanup(void);
|
||||
void logsrvd_warn_stderr(bool enabled);
|
||||
|
||||
/* logsrvd_journal.c */
|
||||
extern struct client_message_switch cms_journal;
|
||||
|
@@ -175,6 +175,8 @@ static struct logsrvd_config {
|
||||
} logfile;
|
||||
} *logsrvd_config;
|
||||
|
||||
static bool logsrvd_warn_enable_stderr = true;
|
||||
|
||||
/* iolog getters */
|
||||
mode_t
|
||||
logsrvd_conf_iolog_mode(void)
|
||||
@@ -1254,7 +1256,7 @@ logsrvd_conv_none(int num_msgs, const struct sudo_conv_message msgs[],
|
||||
struct sudo_conv_reply replies[], struct sudo_conv_callback *callback)
|
||||
{
|
||||
/* Also write to stderr if still in the foreground. */
|
||||
if (logsrvd_is_early()) {
|
||||
if (logsrvd_warn_enable_stderr) {
|
||||
(void)logsrvd_conv_stderr(num_msgs, msgs, replies, callback);
|
||||
}
|
||||
|
||||
@@ -1280,7 +1282,7 @@ logsrvd_conv_syslog(int num_msgs, const struct sudo_conv_message msgs[],
|
||||
}
|
||||
|
||||
/* Also write to stderr if still in the foreground. */
|
||||
if (logsrvd_is_early()) {
|
||||
if (logsrvd_warn_enable_stderr) {
|
||||
(void)logsrvd_conv_stderr(num_msgs, msgs, replies, callback);
|
||||
}
|
||||
|
||||
@@ -1363,7 +1365,7 @@ logsrvd_conv_logfile(int num_msgs, const struct sudo_conv_message msgs[],
|
||||
}
|
||||
|
||||
/* Also write to stderr if still in the foreground. */
|
||||
if (logsrvd_is_early()) {
|
||||
if (logsrvd_warn_enable_stderr) {
|
||||
(void)logsrvd_conv_stderr(num_msgs, msgs, replies, callback);
|
||||
}
|
||||
|
||||
@@ -1765,3 +1767,9 @@ logsrvd_conf_cleanup(void)
|
||||
|
||||
debug_return;
|
||||
}
|
||||
|
||||
void
|
||||
logsrvd_warn_stderr(bool enabled)
|
||||
{
|
||||
logsrvd_warn_enable_stderr = enabled;
|
||||
}
|
||||
|
@@ -41,12 +41,6 @@
|
||||
#include "log_server.pb-c.h"
|
||||
#include "logsrvd.h"
|
||||
|
||||
bool
|
||||
logsrvd_is_early(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
|
Reference in New Issue
Block a user