--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <!-- Our well-known bus type, don't change this -->
+ <type>session</type>
+
+ <!-- If we fork, keep the user's original umask to avoid affecting
+ the behavior of child processes. -->
+ <keep_umask/>
+
+ <listen>unix:path=/tmp/spotlight.ipc</listen>
+ <allow_anonymous />
+
+ <standard_session_servicedirs />
+
+ <policy context="default">
+ <!-- Allow everything to be sent -->
+ <allow send_destination="*" eavesdrop="true"/>
+ <!-- Allow everything to be received -->
+ <allow eavesdrop="true"/>
+ <!-- Allow anyone to own anything -->
+ <allow own="*"/>
+ </policy>
+
+ <!-- raise the service start timeout to 40 seconds as it can timeout
+ on the live cd on slow machines -->
+ <limit name="service_start_timeout">60000</limit>
+
+ <!-- Config files are placed here that among other things,
+ further restrict the above policy for specific services. -->
+ <includedir>/etc/dbus-1/session.d</includedir>
+
+ <!-- This is included last so local configuration can override what's
+ in this standard file -->
+ <include ignore_missing="yes">session-local.conf</include>
+
+ <include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include>
+
+ <!-- For the session bus, override the default relatively-low limits
+ with essentially infinite limits, since the bus is just running
+ as the user anyway, using up bus resources is not something we need
+ to worry about. In some cases, we do set the limits lower than
+ "all available memory" if exceeding the limit is almost certainly a bug,
+ having the bus enforce a limit is nicer than a huge memory leak. But the
+ intent is that these limits should never be hit. -->
+
+ <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max -->
+ <limit name="max_incoming_bytes">1000000000</limit>
+ <limit name="max_outgoing_bytes">1000000000</limit>
+ <limit name="max_message_size">1000000000</limit>
+ <limit name="service_start_timeout">120000</limit>
+ <limit name="auth_timeout">240000</limit>
+ <limit name="max_completed_connections">100000</limit>
+ <limit name="max_incomplete_connections">10000</limit>
+ <limit name="max_connections_per_user">100000</limit>
+ <limit name="max_pending_service_starts">10000</limit>
+ <limit name="max_names_per_connection">50000</limit>
+ <limit name="max_match_rules_per_connection">50000</limit>
+ <limit name="max_replies_per_connection">50000</limit>
+
+</busconfig>
/* static variables */
static AFPObj obj;
static sig_atomic_t got_chldsig;
-static pid_t afpd_pid = -1, cnid_metad_pid = -1;
-static uint afpd_restarts, cnid_metad_restarts;
+static pid_t afpd_pid = -1, cnid_metad_pid = -1, dbus_pid = -1;
+static uint afpd_restarts, cnid_metad_restarts, dbus_restarts;
static struct event_base *base;
struct event *sigterm_ev, *sigquit_ev, *sigchld_ev, *timer_ev;
static int in_shutdown;
+static const char *dbus_path;
/******************************************************************
* libevent helper functions
event_del(sigquit_ev);
event_del(timer_ev);
- kill_childs(SIGTERM, &afpd_pid, &cnid_metad_pid, NULL);
+ system("tracker-control -t");
+ kill_childs(SIGTERM, &afpd_pid, &cnid_metad_pid, &dbus_pid, NULL);
}
/* SIGQUIT callback */
static void sigquit_cb(evutil_socket_t fd, short what, void *arg)
{
LOG(log_note, logtype_afpd, "Exiting on SIGQUIT");
- kill_childs(SIGQUIT, &afpd_pid, &cnid_metad_pid, NULL);
+ system("tracker-control -t");
+ kill_childs(SIGQUIT, &afpd_pid, &cnid_metad_pid, &dbus_pid, NULL);
}
/* SIGCHLD callback */
int status, i;
pid_t pid;
- LOG(log_debug, logtype_afpd, "Got SIGCHLD event");
-
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
if (WIFEXITED(status)) {
if (WEXITSTATUS(status))
- LOG(log_info, logtype_afpd, "child[%d]: exited %d", pid, WEXITSTATUS(status));
+ LOG(log_info, logtype_default, "child[%d]: exited %d", pid, WEXITSTATUS(status));
else
- LOG(log_info, logtype_afpd, "child[%d]: done", pid);
+ LOG(log_info, logtype_default, "child[%d]: done", pid);
} else {
if (WIFSIGNALED(status))
- LOG(log_info, logtype_afpd, "child[%d]: killed by signal %d", pid, WTERMSIG(status));
+ LOG(log_info, logtype_default, "child[%d]: killed by signal %d", pid, WTERMSIG(status));
else
- LOG(log_info, logtype_afpd, "child[%d]: died", pid);
+ LOG(log_info, logtype_default, "child[%d]: died", pid);
}
if (pid == afpd_pid)
afpd_pid = -1;
- else if (pid = cnid_metad_pid)
+ else if (pid == cnid_metad_pid)
cnid_metad_pid = -1;
+ else if (pid == dbus_pid)
+ dbus_pid = -1;
else
LOG(log_error, logtype_afpd, "Bad pid: %d", pid);
}
- if (in_shutdown && afpd_pid == -1 && cnid_metad_pid == -1)
+ if (in_shutdown && afpd_pid == -1 && cnid_metad_pid == -1 && dbus_pid == -1)
event_base_loopbreak(base);
}
afpd_restarts++;
LOG(log_note, logtype_afpd, "Restarting 'afpd' (restarts: %u)", afpd_restarts);
if ((afpd_pid = run_process(_PATH_AFPD, "-d", "-F", obj.options.configfile, NULL)) == -1) {
- LOG(log_error, logtype_afpd, "Error starting 'afpd'");
+ LOG(log_error, logtype_default, "Error starting 'afpd'");
}
}
cnid_metad_restarts++;
LOG(log_note, logtype_afpd, "Restarting 'cnid_metad' (restarts: %u)", cnid_metad_restarts);
if ((cnid_metad_pid = run_process(_PATH_CNID_METAD, "-d", "-F", obj.options.configfile, NULL)) == -1) {
- LOG(log_error, logtype_afpd, "Error starting 'cnid_metad'");
+ LOG(log_error, logtype_default, "Error starting 'cnid_metad'");
+ }
+ }
+
+ if (dbus_pid == -1) {
+ dbus_restarts++;
+ LOG(log_note, logtype_afpd, "Restarting 'dbus' (restarts: %u)", dbus_restarts);
+ if ((dbus_pid = run_process(dbus_path, "--config-file=" _PATH_CONFDIR "dbus.session.conf", NULL)) == -1) {
+ LOG(log_error, logtype_default, "Error starting '%s'", dbus_path);
}
}
}
netatalk_exit(EXITERR_CONF);
}
+ dbus_path = iniparser_getstring(obj.iniconfig, INISEC_GLOBAL, "dbus path", "/bin/dbus-daemon");
+ LOG(log_debug, logtype_default, "DBUS: '%s'", dbus_path);
+ if ((dbus_pid = run_process(dbus_path, "--config-file=" _PATH_CONFDIR "dbus-session.conf", NULL)) == -1) {
+ LOG(log_error, logtype_default, "Error starting '%s'", dbus_path);
+ netatalk_exit(EXITERR_CONF);
+ }
+
+ setenv("DBUS_SESSION_BUS_ADDRESS", "unix:path=/tmp/spotlight.ipc", 1);
+ system("tracker-control -s");
+
if ((base = event_base_new()) == NULL) {
LOG(log_error, logtype_afpd, "Error starting event loop");
netatalk_exit(EXITERR_CONF);
LOG(log_error, logtype_afpd, "AFP service did not shutdown, killing it");
if (cnid_metad_pid != -1)
LOG(log_error, logtype_afpd, "CNID database service did not shutdown, killing it");
- kill_childs(SIGKILL, &afpd_pid, &cnid_metad_pid, NULL);
+ if (dbus_pid != -1)
+ LOG(log_error, logtype_afpd, "DBUS session daemon still running, killing it");
+ kill_childs(SIGKILL, &afpd_pid, &cnid_metad_pid, &dbus_pid, NULL);
}
LOG(log_note, logtype_afpd, "Netatalk AFP server exiting");