Magellan Linux

Annotation of /trunk/busybox/patches/busybox-1.20.2-syslogd-systemd.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1940 - (hide annotations) (download)
Tue Nov 6 11:56:59 2012 UTC (11 years, 7 months ago) by niro
File size: 3559 byte(s)
-socket activiation for syslogd
1 niro 1940 From 9b3b9790b32d440eb89af5edda70a66b1829e861 Mon Sep 17 00:00:00 2001
2     From: Davide Cavalca <davide@geexbox.org>
3     Date: Tue, 25 Jan 2011 01:26:03 +0000
4     Subject: add ENABLE_FEATURE_SYSTEMD and use it in syslogd
5    
6     Signed-off-by: Davide Cavalca <davide@geexbox.org>
7     Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
8     ---
9     diff --git a/include/libbb.h b/include/libbb.h
10     index 968bdcf..32e25a8 100644
11     --- a/include/libbb.h
12     +++ b/include/libbb.h
13     @@ -1217,6 +1217,12 @@ extern void selinux_preserve_fcontext(int fdesc) FAST_FUNC;
14     #endif
15     extern void selinux_or_die(void) FAST_FUNC;
16    
17     +
18     +/* systemd support */
19     +#define SD_LISTEN_FDS_START 3
20     +int sd_listen_fds(void);
21     +
22     +
23     /* setup_environment:
24     * if chdir pw->pw_dir: ok: else if to_tmp == 1: goto /tmp else: goto / or die
25     * if clear_env = 1: cd(pw->pw_dir), clear environment, then set
26     diff --git a/libbb/systemd_support.c b/libbb/systemd_support.c
27     new file mode 100644
28     index 0000000..981296d
29     --- a/dev/null
30     +++ b/libbb/systemd_support.c
31     @@ -0,0 +1,62 @@
32     +/*
33     + * Copyright (C) 2011 Davide Cavalca <davide@geexbox.org>
34     + *
35     + * Based on http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c
36     + * Copyright 2010 Lennart Poettering
37     + *
38     + * Permission is hereby granted, free of charge, to any person
39     + * obtaining a copy of this software and associated documentation files
40     + * (the "Software"), to deal in the Software without restriction,
41     + * including without limitation the rights to use, copy, modify, merge,
42     + * publish, distribute, sublicense, and/or sell copies of the Software,
43     + * and to permit persons to whom the Software is furnished to do so,
44     + * subject to the following conditions:
45     + *
46     + * The above copyright notice and this permission notice shall be
47     + * included in all copies or substantial portions of the Software.
48     + *
49     + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
50     + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51     + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
52     + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
53     + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
54     + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
55     + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
56     + * SOFTWARE.
57     + */
58     +#include "libbb.h"
59     +
60     +//config:config FEATURE_SYSTEMD
61     +//config: bool "Enable systemd support"
62     +//config: default y
63     +//config: help
64     +//config: If you plan to use busybox daemons on a system where daemons
65     +//config: are controlled by systemd, enable this option.
66     +//config: If you don't use systemd, it is still safe to enable it,
67     +//config: but yhe downside is increased code size.
68     +
69     +//kbuild:lib-$(CONFIG_FEATURE_SYSTEMD) += systemd_support.o
70     +
71     +int sd_listen_fds(void)
72     +{
73     + const char *e;
74     + int n;
75     + int fd;
76     +
77     + e = getenv("LISTEN_PID");
78     + if (!e)
79     + return 0;
80     + n = xatoi_positive(e);
81     + /* Is this for us? */
82     + if (getpid() != (pid_t) n)
83     + return 0;
84     +
85     + e = getenv("LISTEN_FDS");
86     + if (!e)
87     + return 0;
88     + n = xatoi_positive(e);
89     + for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++)
90     + close_on_exec_on(fd);
91     +
92     + return n;
93     +}
94     diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
95     index fb73095..24cab3b 100644
96     --- a/sysklogd/syslogd.c
97     +++ b/sysklogd/syslogd.c
98     @@ -512,6 +512,11 @@ static NOINLINE int create_socket(void)
99     int sock_fd;
100     char *dev_log_name;
101    
102     +#if ENABLE_FEATURE_SYSTEMD
103     + if (sd_listen_fds() == 1)
104     + return SD_LISTEN_FDS_START;
105     +#endif
106     +
107     memset(&sunx, 0, sizeof(sunx));
108     sunx.sun_family = AF_UNIX;
109    
110     --
111     cgit v0.9.0.1-2-gef13