|
Line
Link Here
|
|
-- modules/afsocket/afsocket.c |
|
|
|
Lines 529-534
afsocket_sd_init(LogPipe *s)
Link Here
|
| 529 |
gboolean res = FALSE; |
529 |
gboolean res = FALSE; |
| 530 |
GlobalConfig *cfg = log_pipe_get_config(s); |
530 |
GlobalConfig *cfg = log_pipe_get_config(s); |
| 531 |
|
531 |
|
|
|
532 |
if (self->systemd_sock != -1) |
| 533 |
{ |
| 534 |
/* TODO: another socket types */ |
| 535 |
if ((self->bind_addr->sa.sa_family != AF_UNIX) || !(self->flags & AFSOCKET_DGRAM)) |
| 536 |
{ |
| 537 |
msg_error("Systemd activation implemented for unix datagram sockets only", NULL); |
| 538 |
return FALSE; |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 532 |
#if ENABLE_SSL |
542 |
#if ENABLE_SSL |
| 533 |
if (self->flags & AFSOCKET_REQUIRE_TLS && !self->tls_context) |
543 |
if (self->flags & AFSOCKET_REQUIRE_TLS && !self->tls_context) |
| 534 |
{ |
544 |
{ |
|
Lines 604-617
afsocket_sd_init(LogPipe *s)
Link Here
|
| 604 |
{ |
614 |
{ |
| 605 |
if (!self->connections) |
615 |
if (!self->connections) |
| 606 |
{ |
616 |
{ |
| 607 |
if (!afsocket_open_socket(self->bind_addr, !!(self->flags & AFSOCKET_STREAM), &sock)) |
617 |
if (self->systemd_sock != -1) |
|
|
618 |
{ |
| 619 |
sock = self->systemd_sock; |
| 620 |
g_fd_set_nonblock(sock, TRUE); |
| 621 |
self->bind_addr->sa_funcs->sa_bind = NULL; |
| 622 |
self->bind_addr->sa_funcs->sa_bind_prepare = NULL; |
| 623 |
} |
| 624 |
else if (!afsocket_open_socket(self->bind_addr, !!(self->flags & AFSOCKET_STREAM), &sock)) |
| 608 |
return self->super.optional; |
625 |
return self->super.optional; |
| 609 |
} |
626 |
} |
| 610 |
self->fd = -1; |
627 |
self->fd = -1; |
| 611 |
|
628 |
|
| 612 |
if (!self->setup_socket(self, sock)) |
629 |
if (!self->setup_socket(self, sock)) |
| 613 |
{ |
630 |
{ |
| 614 |
close(sock); |
631 |
if (self->systemd_sock != -1) |
|
|
632 |
close(sock); |
| 615 |
return FALSE; |
633 |
return FALSE; |
| 616 |
} |
634 |
} |
| 617 |
|
635 |
|
|
Lines 738-743
afsocket_sd_init_instance(AFSocketSource
Link Here
|
| 738 |
self->setup_socket = afsocket_sd_setup_socket; |
756 |
self->setup_socket = afsocket_sd_setup_socket; |
| 739 |
self->max_connections = 10; |
757 |
self->max_connections = 10; |
| 740 |
self->listen_backlog = 255; |
758 |
self->listen_backlog = 255; |
|
|
759 |
self->systemd_sock = -1; |
| 741 |
self->flags = flags | AFSOCKET_KEEP_ALIVE; |
760 |
self->flags = flags | AFSOCKET_KEEP_ALIVE; |
| 742 |
log_reader_options_defaults(&self->reader_options); |
761 |
log_reader_options_defaults(&self->reader_options); |
| 743 |
|
762 |
|
| 744 |
-- modules/afsocket/afsocket.h |
|
|
|
Lines 77-82
struct _AFSocketSourceDriver
Link Here
|
| 77 |
GList *connections; |
77 |
GList *connections; |
| 78 |
SocketOptions *sock_options_ptr; |
78 |
SocketOptions *sock_options_ptr; |
| 79 |
gboolean (*setup_socket)(AFSocketSourceDriver *s, gint fd); |
79 |
gboolean (*setup_socket)(AFSocketSourceDriver *s, gint fd); |
|
|
80 |
gint systemd_sock; |
| 80 |
}; |
81 |
}; |
| 81 |
|
82 |
|
| 82 |
void afsocket_sd_set_keep_alive(LogDriver *self, gint enable); |
83 |
void afsocket_sd_set_keep_alive(LogDriver *self, gint enable); |
| 83 |
-- modules/afsocket/afunix.c |
|
|
|
Lines 25-30
Link Here
|
| 25 |
#include "misc.h" |
25 |
#include "misc.h" |
| 26 |
#include "messages.h" |
26 |
#include "messages.h" |
| 27 |
#include "gprocess.h" |
27 |
#include "gprocess.h" |
|
|
28 |
#include "sd-daemon.h" |
| 28 |
|
29 |
|
| 29 |
#include <sys/types.h> |
30 |
#include <sys/types.h> |
| 30 |
#include <sys/socket.h> |
31 |
#include <sys/socket.h> |
|
Lines 67-72
afunix_sd_init(LogPipe *s)
Link Here
|
| 67 |
{ |
68 |
{ |
| 68 |
AFUnixSourceDriver *self = (AFUnixSourceDriver *) s; |
69 |
AFUnixSourceDriver *self = (AFUnixSourceDriver *) s; |
| 69 |
cap_t saved_caps; |
70 |
cap_t saved_caps; |
|
|
71 |
int fds, fd, t, r; |
| 72 |
|
| 73 |
fds = sd_listen_fds(0); |
| 74 |
if (fds < 0) |
| 75 |
{ |
| 76 |
msg_error("Failed to acquire systemd sockets", NULL); |
| 77 |
return FALSE; |
| 78 |
} |
| 79 |
else if (fds > 0) |
| 80 |
{ |
| 81 |
fd = SD_LISTEN_FDS_START; |
| 82 |
for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + fds; fd++) |
| 83 |
{ |
| 84 |
t = (self->super.flags & AFSOCKET_STREAM) ? SOCK_STREAM : SOCK_DGRAM; |
| 85 |
r = sd_is_socket_unix(fd, t, -1, self->filename, 0); |
| 86 |
if (r == 1) |
| 87 |
{ |
| 88 |
/* OK, remember this systemd socket */ |
| 89 |
self->super.systemd_sock = fd; |
| 90 |
break; |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 70 |
|
94 |
|
| 71 |
if (afsocket_sd_init(s)) |
95 |
if (afsocket_sd_init(s)) |
| 72 |
{ |
96 |
{ |
|
Lines 83-91
afunix_sd_init(LogPipe *s)
Link Here
|
| 83 |
if (self->perm >= 0) |
107 |
if (self->perm >= 0) |
| 84 |
chmod(self->filename, (mode_t) self->perm); |
108 |
chmod(self->filename, (mode_t) self->perm); |
| 85 |
g_process_cap_restore(saved_caps); |
109 |
g_process_cap_restore(saved_caps); |
|
|
110 |
|
| 111 |
if (self->super.systemd_sock != -1) |
| 112 |
{ |
| 113 |
msg_verbose("Acquired systemd socket", |
| 114 |
evt_tag_int("systemd-sock-fd", fd), |
| 115 |
evt_tag_str("systemd-sock-name", self->filename), |
| 116 |
NULL); |
| 117 |
} |
| 86 |
return TRUE; |
118 |
return TRUE; |
| 87 |
} |
119 |
} |
| 88 |
return FALSE; |
120 |
else |
|
|
121 |
{ |
| 122 |
if (self->super.systemd_sock != -1) |
| 123 |
{ |
| 124 |
msg_error("Failed to acquire systemd socket", |
| 125 |
evt_tag_int("systemd-sock-fd", fd), |
| 126 |
evt_tag_str("systemd-sock-name", self->filename), |
| 127 |
NULL); |
| 128 |
} |
| 129 |
return FALSE; |
| 130 |
} |
| 89 |
} |
131 |
} |
| 90 |
|
132 |
|
| 91 |
static void |
133 |
static void |
| 92 |
-- modules/afsocket/Makefile.am |
|
|
|
Lines 7-13
noinst_DATA = libafsocket.la
Link Here
|
| 7 |
libafsocket_notls_la_SOURCES = \ |
7 |
libafsocket_notls_la_SOURCES = \ |
| 8 |
afsocket.c afsocket.h afunix.c afunix.h afinet.c afinet.h \ |
8 |
afsocket.c afsocket.h afunix.c afunix.h afinet.c afinet.h \ |
| 9 |
tlscontext.c tlscontext.h tlstransport.c tlstransport.h \ |
9 |
tlscontext.c tlscontext.h tlstransport.c tlstransport.h \ |
| 10 |
afsocket-grammar.y afsocket-parser.c afsocket-parser.h afsocket-plugin.c |
10 |
afsocket-grammar.y afsocket-parser.c afsocket-parser.h afsocket-plugin.c \ |
|
|
11 |
sd-daemon.c sd-daemon.h |
| 11 |
libafsocket_notls_la_CPPFLAGS = $(AM_CPPFLAGS) |
12 |
libafsocket_notls_la_CPPFLAGS = $(AM_CPPFLAGS) |
| 12 |
libafsocket_notls_la_LIBADD = ../../lib/libsyslog-ng.la $(LIBNET_LIBS) $(LIBWRAP_LIBS) |
13 |
libafsocket_notls_la_LIBADD = ../../lib/libsyslog-ng.la $(LIBNET_LIBS) $(LIBWRAP_LIBS) |
| 13 |
libafsocket_notls_la_LDFLAGS = -avoid-version |
14 |
libafsocket_notls_la_LDFLAGS = -avoid-version |
|
Lines 17-23
module_LTLIBRARIES += libafsocket-tls.la
Link Here
|
| 17 |
libafsocket_tls_la_SOURCES = \ |
18 |
libafsocket_tls_la_SOURCES = \ |
| 18 |
afsocket.c afsocket.h afunix.c afunix.h afinet.c afinet.h \ |
19 |
afsocket.c afsocket.h afunix.c afunix.h afinet.c afinet.h \ |
| 19 |
tlscontext.c tlscontext.h tlstransport.c tlstransport.h \ |
20 |
tlscontext.c tlscontext.h tlstransport.c tlstransport.h \ |
| 20 |
afsocket-grammar.y afsocket-parser.c afsocket-parser.h afsocket-plugin.c |
21 |
afsocket-grammar.y afsocket-parser.c afsocket-parser.h afsocket-plugin.c \ |
|
|
22 |
sd-daemon.c sd-daemon.h |
| 21 |
libafsocket_tls_la_CPPFLAGS = $(AM_CPPFLAGS) -DENABLE_SSL=1 |
23 |
libafsocket_tls_la_CPPFLAGS = $(AM_CPPFLAGS) -DENABLE_SSL=1 |
| 22 |
libafsocket_tls_la_LIBADD = ../../lib/libsyslog-ng.la $(OPENSSL_LIBS) $(ZLIB_LIBS) $(LIBNET_LIBS) $(LIBWRAP_LIBS) |
24 |
libafsocket_tls_la_LIBADD = ../../lib/libsyslog-ng.la $(OPENSSL_LIBS) $(ZLIB_LIBS) $(LIBNET_LIBS) $(LIBWRAP_LIBS) |
| 23 |
libafsocket_tls_la_LDFLAGS = -avoid-version |
25 |
libafsocket_tls_la_LDFLAGS = -avoid-version |