X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-daemon%2Fchroot.c;h=5ca605df64d2823629cebf54a8087e9a87af10d7;hb=05a83734133524435127937198fcf99bb81d3607;hp=5504cbd70fe00b9a695d67be7eb6b44a4b1716cd;hpb=aedd4e87362371d83dd64d0bfb03ea3e5526607f;p=catta diff --git a/avahi-daemon/chroot.c b/avahi-daemon/chroot.c index 5504cbd..5ca605d 100644 --- a/avahi-daemon/chroot.c +++ b/avahi-daemon/chroot.c @@ -39,6 +39,7 @@ #include "chroot.h" #include "caps.h" +#include "setproctitle.h" enum { AVAHI_CHROOT_SUCCESS = 0, @@ -53,6 +54,7 @@ enum { AVAHI_CHROOT_GET_SERVICE_BROWSER_INTROSPECT, AVAHI_CHROOT_GET_SERVICE_RESOLVER_INTROSPECT, AVAHI_CHROOT_GET_SERVICE_TYPE_BROWSER_INTROSPECT, + AVAHI_CHROOT_GET_RECORD_BROWSER_INTROSPECT, #endif AVAHI_CHROOT_UNLINK_PID, AVAHI_CHROOT_UNLINK_SOCKET, @@ -72,6 +74,7 @@ static const char* const get_file_name_table[AVAHI_CHROOT_MAX] = { AVAHI_DBUS_INTROSPECTION_DIR"/ServiceBrowser.introspect", AVAHI_DBUS_INTROSPECTION_DIR"/ServiceResolver.introspect", AVAHI_DBUS_INTROSPECTION_DIR"/ServiceTypeBrowser.introspect", + AVAHI_DBUS_INTROSPECTION_DIR"/RecordBrowser.introspect", #endif NULL, NULL @@ -90,6 +93,7 @@ static const char *const unlink_file_name_table[AVAHI_CHROOT_MAX] = { NULL, NULL, NULL, + NULL, #endif AVAHI_DAEMON_RUNTIME_DIR"/pid", AVAHI_SOCKET @@ -232,6 +236,7 @@ static int helper_main(int fd) { case AVAHI_CHROOT_GET_SERVICE_BROWSER_INTROSPECT: case AVAHI_CHROOT_GET_SERVICE_RESOLVER_INTROSPECT: case AVAHI_CHROOT_GET_SERVICE_TYPE_BROWSER_INTROSPECT: + case AVAHI_CHROOT_GET_RECORD_BROWSER_INTROSPECT: #endif case AVAHI_CHROOT_GET_RESOLV_CONF: { int payload; @@ -286,7 +291,7 @@ fail: return ret; } -int avahi_chroot_helper_start(void) { +int avahi_chroot_helper_start(const char *argv0) { int sock[2]; pid_t pid; @@ -297,15 +302,19 @@ int avahi_chroot_helper_start(void) { return -1; } - if ((pid = daemon_fork()) < 0) { + if ((pid = fork()) < 0) { close(sock[0]); close(sock[1]); - avahi_log_error(__FILE__": Failed to fork()"); + avahi_log_error(__FILE__": fork() failed: %s", strerror(errno)); return -1; } else if (pid == 0) { + + setsid(); /* Drop all remaining capabilities */ avahi_caps_drop_all(); + + avahi_set_proc_title("%s: chroot helper process", argv0); close(sock[0]); helper_main(sock[1]);