switch (state) {
case AVAHI_SERVER_RUNNING:
avahi_log_info("Server startup complete. Host name is %s. Local service cookie is %u.", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s));
-
+ sd_notifyf(0, "STATUS=Server startup complete. Host name is %s. Local service cookie is %u.", avahi_server_get_host_name_fqdn(s), avahi_server_get_local_service_cookie(s));
avahi_set_proc_title(argv0, "%s: running [%s]", argv0, avahi_server_get_host_name_fqdn(s));
static_service_add_to_server();
case AVAHI_SERVER_COLLISION: {
char *n;
- avahi_set_proc_title(argv0, "%s: collision", argv0);
-
static_service_remove_from_server();
static_hosts_remove_from_server();
remove_dns_server_entry_groups();
n = avahi_alternative_host_name(avahi_server_get_host_name(s));
- avahi_log_warn("Host name conflict, retrying with <%s>", n);
+
+ avahi_log_warn("Host name conflict, retrying with %s", n);
+ sd_notifyf(0, "STATUS=Host name conflict, retrying with %s", n);
+ avahi_set_proc_title(argv0, "%s: collision [%s]", argv0, n);
+
avahi_server_set_host_name(s, n);
avahi_free(n);
case AVAHI_SERVER_FAILURE:
avahi_log_error("Server error: %s", avahi_strerror(avahi_server_errno(s)));
+ sd_notifyf(0, "STATUS=Server error: %s", avahi_strerror(avahi_server_errno(s)));
+
avahi_simple_poll_quit(simple_poll_api);
break;
case AVAHI_SERVER_REGISTERING:
+ sd_notifyf(0, "STATUS=Registering host name %s", avahi_server_get_host_name_fqdn(s));
avahi_set_proc_title(argv0, "%s: registering [%s]", argv0, avahi_server_get_host_name_fqdn(s));
static_service_remove_from_server();
/* Imported from ../avahi-client/nss-check.c */
int avahi_nss_support(void);
+static void ignore_signal(int sig) {
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = SA_RESTART;
+
+ sigaction(sig, &sa, NULL);
+}
+
static int run_server(DaemonConfig *c) {
int r = -1;
int error;
assert(c);
+ ignore_signal(SIGPIPE);
+
if (!(nss_support = avahi_nss_support()))
avahi_log_warn("WARNING: No NSS support for mDNS detected, consider installing nss-mdns!");
break;
}
+ r = 0;
finish:
if (daemon_close_all(-1) < 0)
avahi_log_warn("Failed to close all remaining file descriptors: %s", strerror(errno));
+ daemon_reset_sigs(-1);
+ daemon_unblock_sigs(-1);
+
if (make_runtime_dir() < 0)
goto finish;
}
#endif
avahi_log_info("%s "PACKAGE_VERSION" starting up.", argv0);
-
+ sd_notifyf(0, "STATUS=%s "PACKAGE_VERSION" starting up.", argv0);
avahi_set_proc_title(argv0, "%s: starting up", argv0);
if (run_server(&config) == 0)
r = 0;
+
+ avahi_log_info("%s "PACKAGE_VERSION" exiting.", argv0);
+ sd_notifyf(0, "STATUS=%s "PACKAGE_VERSION" exiting.", argv0);
}
finish:
struct stat st_path;
memset(&st_path, 0, sizeof(st_path));
- if (fstat(fd, &st_path) < 0) {
+ if (stat(path, &st_path) < 0) {
if (errno == ENOENT || errno == ENOTDIR)
return 0;
memset(&msghdr, 0, sizeof(msghdr));
msghdr.msg_name = &sockaddr;
- msghdr.msg_namelen = sizeof(struct sockaddr_un);
+ msghdr.msg_namelen = sizeof(sa_family_t) + strlen(e);
+
+ if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
+ msghdr.msg_namelen = sizeof(struct sockaddr_un);
+
msghdr.msg_iov = &iovec;
msghdr.msg_iovlen = 1;
msghdr.msg_control = &control;