static gboolean afinet_dd_init(LogPipe *s) { AFInetDestDriver *self G_GNUC_UNUSED = (AFInetDestDriver *) s; gboolean success; success = afsocket_dd_init(s); #if ENABLE_SPOOF_SOURCE if (success) { if (self->spoof_source && !self->lnet_ctx) { gchar error[LIBNET_ERRBUF_SIZE]; cap_t saved_caps; saved_caps = g_process_cap_save(); g_process_cap_modify(CAP_NET_RAW, TRUE); self->lnet_ctx = libnet_init(self->super.dest_addr->sa.sa_family == AF_INET ? LIBNET_RAW4 : LIBNET_RAW6, NULL, error); g_process_cap_restore(saved_caps); if (!self->lnet_ctx) { msg_error("Error initializing raw socket, spoof-source support disabled", evt_tag_str("error", NULL), NULL); } } } #endif return success; }
static gboolean afinet_dd_init(LogPipe *s) { AFInetDestDriver *self G_GNUC_UNUSED = (AFInetDestDriver *) s; #if ENABLE_SPOOF_SOURCE if (self->spoof_source) self->super.connections_kept_alive_accross_reloads = TRUE; #endif if (!afsocket_dd_init(s)) return FALSE; #if ENABLE_SPOOF_SOURCE if (self->super.transport_mapper->sock_type == SOCK_DGRAM) { if (self->spoof_source && !self->lnet_ctx) { gchar error[LIBNET_ERRBUF_SIZE]; cap_t saved_caps; saved_caps = g_process_cap_save(); g_process_cap_modify(CAP_NET_RAW, TRUE); self->lnet_ctx = libnet_init(self->super.bind_addr->sa.sa_family == AF_INET ? LIBNET_RAW4 : LIBNET_RAW6, NULL, error); g_process_cap_restore(saved_caps); if (!self->lnet_ctx) { msg_error("Error initializing raw socket, spoof-source support disabled", evt_tag_str("error", NULL), NULL); } } } #endif #if BUILD_WITH_SSL if (!self->tls_context && afinet_dd_is_tls_required(self)) { msg_error("transport(tls) was specified, but tls() options missing", evt_tag_str("id", self->super.super.super.id), NULL); return FALSE; } else if (self->tls_context && !afinet_dd_is_tls_allowed(self)) { msg_error("tls() options specified for a transport that doesn't allow TLS encryption", evt_tag_str("id", self->super.super.super.id), evt_tag_str("transport", self->super.transport_mapper->transport), NULL); return FALSE; } #endif return TRUE; }
static gboolean afinet_dd_init(LogPipe *s) { AFInetDestDriver *self G_GNUC_UNUSED = (AFInetDestDriver *) s; #if SYSLOG_NG_ENABLE_SPOOF_SOURCE if (self->spoof_source) self->super.connections_kept_alive_accross_reloads = TRUE; #endif if (!afsocket_dd_init(s)) return FALSE; #if SYSLOG_NG_ENABLE_SPOOF_SOURCE if (self->super.transport_mapper->sock_type == SOCK_DGRAM) { if (self->spoof_source && !self->lnet_ctx) { gchar error[LIBNET_ERRBUF_SIZE]; cap_t saved_caps; saved_caps = g_process_cap_save(); g_process_cap_modify(CAP_NET_RAW, TRUE); self->lnet_ctx = libnet_init(self->super.bind_addr->sa.sa_family == AF_INET ? LIBNET_RAW4 : LIBNET_RAW6, NULL, error); g_process_cap_restore(saved_caps); if (!self->lnet_ctx) { msg_error("Error initializing raw socket, spoof-source support disabled", evt_tag_str("error", NULL), NULL); } } } #endif return TRUE; }