summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-02-02 02:25:11 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-10 10:07:24 +0000
commita8423067ceac1af6176e14fbc334fe5b82431e3d (patch)
tree8dc820e73a095d0b41965c83e1f8bb3ff993359d
parentdd4038156dd7946118f58b763985cdd4c5726bea (diff)
bus: introduce --nopidfile switch to disable writing of PID files
When used with init systems such as systemd (where PID files are redundant) this allows us to disable PID files even if a path is configured for them in the normal bus configuration files. Make use of this new switch in the systemd unit file. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=45520 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--bus/bus.c10
-rw-r--r--bus/bus.h1
-rw-r--r--bus/dbus.service.in3
-rw-r--r--bus/main.c7
-rw-r--r--bus/test.c2
-rw-r--r--doc/dbus-daemon.1.in4
6 files changed, 21 insertions, 6 deletions
diff --git a/bus/bus.c b/bus/bus.c
index c7308b79..ae2a61a6 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -270,6 +270,7 @@ process_config_first_time_only (BusContext *context,
BusConfigParser *parser,
const DBusString *address,
dbus_bool_t systemd_activation,
+ dbus_bool_t write_pidfile,
DBusError *error)
{
DBusString log_prefix;
@@ -285,6 +286,7 @@ process_config_first_time_only (BusContext *context,
retval = FALSE;
auth_mechanisms = NULL;
+ pidfile = NULL;
_dbus_init_system_log ();
@@ -295,7 +297,10 @@ process_config_first_time_only (BusContext *context,
* avoid that. But we want to check for the pid file
* before overwriting any existing sockets, etc.
*/
- pidfile = bus_config_parser_get_pidfile (parser);
+
+ if (write_pidfile)
+ pidfile = bus_config_parser_get_pidfile (parser);
+
if (pidfile != NULL)
{
DBusString u;
@@ -698,6 +703,7 @@ bus_context_new (const DBusString *config_file,
DBusPipe *print_pid_pipe,
const DBusString *address,
dbus_bool_t systemd_activation,
+ dbus_bool_t write_pidfile,
DBusError *error)
{
BusContext *context;
@@ -751,7 +757,7 @@ bus_context_new (const DBusString *config_file,
goto failed;
}
- if (!process_config_first_time_only (context, parser, address, systemd_activation, error))
+ if (!process_config_first_time_only (context, parser, address, systemd_activation, write_pidfile, error))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
goto failed;
diff --git a/bus/bus.h b/bus/bus.h
index ebef17c7..c4760127 100644
--- a/bus/bus.h
+++ b/bus/bus.h
@@ -77,6 +77,7 @@ BusContext* bus_context_new (const DBusStri
DBusPipe *print_pid_pipe,
const DBusString *address,
dbus_bool_t systemd_activation,
+ dbus_bool_t write_pidfile,
DBusError *error);
dbus_bool_t bus_context_reload_config (BusContext *context,
DBusError *error);
diff --git a/bus/dbus.service.in b/bus/dbus.service.in
index 8ab067f6..160947c7 100644
--- a/bus/dbus.service.in
+++ b/bus/dbus.service.in
@@ -4,7 +4,6 @@ Requires=dbus.socket
After=syslog.target
[Service]
-ExecStartPre=-/bin/rm -f @DBUS_SYSTEM_PID_FILE@
-ExecStart=@EXPANDED_BINDIR@/dbus-daemon --system --address=systemd: --nofork --systemd-activation
+ExecStart=@EXPANDED_BINDIR@/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
ExecReload=@EXPANDED_BINDIR@/dbus-send --print-reply --system --type=method_call --dest=org.freedesktop.DBus / org.freedesktop.DBus.ReloadConfig
OOMScoreAdjust=-900
diff --git a/bus/main.c b/bus/main.c
index a0bf07c7..1e3abaeb 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -125,7 +125,7 @@ signal_handler (int sig)
static void
usage (void)
{
- fprintf (stderr, DBUS_DAEMON_NAME " [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork] [--introspect] [--address=ADDRESS] [--systemd-activation]\n");
+ fprintf (stderr, DBUS_DAEMON_NAME " [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork] [--introspect] [--address=ADDRESS] [--systemd-activation] [--nopidfile]\n");
exit (1);
}
@@ -357,6 +357,7 @@ main (int argc, char **argv)
dbus_bool_t print_pid;
int force_fork;
dbus_bool_t systemd_activation;
+ dbus_bool_t write_pidfile;
if (!_dbus_string_init (&config_file))
return 1;
@@ -374,6 +375,7 @@ main (int argc, char **argv)
print_pid = FALSE;
force_fork = FORK_FOLLOW_CONFIG_FILE;
systemd_activation = FALSE;
+ write_pidfile = TRUE;
prev_arg = NULL;
i = 1;
@@ -393,6 +395,8 @@ main (int argc, char **argv)
force_fork = FORK_NEVER;
else if (strcmp (arg, "--fork") == 0)
force_fork = FORK_ALWAYS;
+ else if (strcmp (arg, "--nopidfile") == 0)
+ write_pidfile = FALSE;
else if (strcmp (arg, "--systemd-activation") == 0)
systemd_activation = TRUE;
else if (strcmp (arg, "--system") == 0)
@@ -574,6 +578,7 @@ main (int argc, char **argv)
&print_addr_pipe, &print_pid_pipe,
_dbus_string_get_length(&address) > 0 ? &address : NULL,
systemd_activation,
+ write_pidfile,
&error);
_dbus_string_free (&config_file);
if (context == NULL)
diff --git a/bus/test.c b/bus/test.c
index 9a0c1967..19caa02d 100644
--- a/bus/test.c
+++ b/bus/test.c
@@ -292,7 +292,7 @@ bus_context_new_test (const DBusString *test_data_dir,
}
dbus_error_init (&error);
- context = bus_context_new (&config_file, FALSE, NULL, NULL, NULL, FALSE, &error);
+ context = bus_context_new (&config_file, FALSE, NULL, NULL, NULL, FALSE, FALSE, &error);
if (context == NULL)
{
_DBUS_ASSERT_ERROR_IS_SET (&error);
diff --git a/doc/dbus-daemon.1.in b/doc/dbus-daemon.1.in
index 185441c9..b063e643 100644
--- a/doc/dbus-daemon.1.in
+++ b/doc/dbus-daemon.1.in
@@ -94,6 +94,10 @@ configured in the configuration file.
.I "\-\-systemd\-activation"
Enable systemd\-style service activation. Only useful in conjunction
with the systemd system and session manager on Linux.
+.TP
+.I "\-\-nopidfile"
+Don't write a PID file even if one is configured in the configuration
+files.
.SH CONFIGURATION FILE