summaryrefslogtreecommitdiffstats
path: root/avahi-daemon
diff options
context:
space:
mode:
Diffstat (limited to 'avahi-daemon')
-rw-r--r--avahi-daemon/chroot.c6
-rw-r--r--avahi-daemon/dbus-protocol.c2
-rw-r--r--avahi-daemon/main.c6
-rw-r--r--avahi-daemon/sd-daemon.c47
-rw-r--r--avahi-daemon/sd-daemon.h20
-rw-r--r--avahi-daemon/setproctitle.c2
-rw-r--r--avahi-daemon/simple-protocol.c2
7 files changed, 21 insertions, 64 deletions
diff --git a/avahi-daemon/chroot.c b/avahi-daemon/chroot.c
index d796a39..ccd56be 100644
--- a/avahi-daemon/chroot.c
+++ b/avahi-daemon/chroot.c
@@ -394,12 +394,14 @@ int avahi_chroot_helper_unlink(const char *fname) {
return -1;
}
- if (write(helper_fd, &command, sizeof(command)) < 0) {
+ if (write(helper_fd, &command, sizeof(command)) < 0 &&
+ (errno != EPIPE && errno != ECONNRESET)) {
avahi_log_error("write() failed: %s\n", strerror(errno));
return -1;
}
- if ((r = read(helper_fd, &c, sizeof(c))) < 0) {
+ if ((r = read(helper_fd, &c, sizeof(c))) < 0 &&
+ (errno != EPIPE && errno != ECONNRESET)) {
avahi_log_error("read() failed: %s\n", r < 0 ? strerror(errno) : "EOF");
return -1;
}
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index 91ea8fa..eb8a662 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -197,7 +197,7 @@ static DBusHandlerResult msg_signal_filter_impl(AVAHI_GCC_UNUSED DBusConnection
server->reconnect_timeout = server->poll_api->timeout_new(server->poll_api, &tv, reconnect_callback, NULL);
} else {
avahi_log_warn("Disconnected from D-Bus, exiting.");
- raise(SIGQUIT);
+ raise(SIGTERM);
}
return DBUS_HANDLER_RESULT_HANDLED;
diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c
index 1e8b255..d46f40a 100644
--- a/avahi-daemon/main.c
+++ b/avahi-daemon/main.c
@@ -1046,12 +1046,10 @@ static void signal_callback(AvahiWatch *watch, AVAHI_GCC_UNUSED int fd, AVAHI_GC
switch (sig) {
case SIGINT:
- case SIGQUIT:
case SIGTERM:
avahi_log_info(
"Got %s, quitting.",
- sig == SIGINT ? "SIGINT" :
- (sig == SIGQUIT ? "SIGQUIT" : "SIGTERM"));
+ sig == SIGINT ? "SIGINT" : "SIGTERM");
avahi_simple_poll_quit(simple_poll_api);
break;
@@ -1113,7 +1111,7 @@ static int run_server(DaemonConfig *c) {
poll_api = avahi_simple_poll_get(simple_poll_api);
- if (daemon_signal_init(SIGINT, SIGQUIT, SIGHUP, SIGTERM, SIGUSR1, 0) < 0) {
+ if (daemon_signal_init(SIGINT, SIGHUP, SIGTERM, SIGUSR1, 0) < 0) {
avahi_log_error("Could not register signal handlers (%s).", strerror(errno));
goto finish;
}
diff --git a/avahi-daemon/sd-daemon.c b/avahi-daemon/sd-daemon.c
index 316fccc..6d1eebf 100644
--- a/avahi-daemon/sd-daemon.c
+++ b/avahi-daemon/sd-daemon.c
@@ -40,6 +40,7 @@
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stddef.h>
#include "sd-daemon.h"
@@ -307,17 +308,17 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t
if (length <= 0)
/* Unnamed socket */
- return l == sizeof(sa_family_t);
+ return l == offsetof(struct sockaddr_un, sun_path);
if (path[0])
/* Normal path socket */
return
- (l >= sizeof(sa_family_t) + length + 1) &&
+ (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) &&
memcmp(path, sockaddr.un.sun_path, length+1) == 0;
else
/* Abstract namespace socket */
return
- (l == sizeof(sa_family_t) + length) &&
+ (l == offsetof(struct sockaddr_un, sun_path) + length) &&
memcmp(path, sockaddr.un.sun_path, length) == 0;
}
@@ -366,7 +367,7 @@ int sd_notify(int unset_environment, const char *state) {
memset(&msghdr, 0, sizeof(msghdr));
msghdr.msg_name = &sockaddr;
- msghdr.msg_namelen = sizeof(sa_family_t) + strlen(e);
+ msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e);
if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
msghdr.msg_namelen = sizeof(struct sockaddr_un);
@@ -433,41 +434,3 @@ int sd_booted(void) {
return a.st_dev != b.st_dev;
#endif
}
-
-static int touch(const char *path) {
-
-#if !defined(DISABLE_SYSTEMD) && defined(__linux__)
- int fd;
-
- mkdir("/dev/.systemd", 0755);
- mkdir("/dev/.systemd/readahead", 0755);
-
- if ((fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666)) < 0)
- return -errno;
-
- for (;;) {
- if (close(fd) >= 0)
- break;
-
- if (errno != -EINTR)
- return -errno;
- }
-
-#endif
- return 0;
-}
-
-int sd_readahead(const char *action) {
-
- if (!action)
- return -EINVAL;
-
- if (strcmp(action, "cancel") == 0)
- return touch("/dev/.systemd/readahead/cancel");
- else if (strcmp(action, "done") == 0)
- return touch("/dev/.systemd/readahead/done");
- else if (strcmp(action, "noreplay") == 0)
- return touch("/dev/.systemd/readahead/noreplay");
-
- return -EINVAL;
-}
diff --git a/avahi-daemon/sd-daemon.h b/avahi-daemon/sd-daemon.h
index 2fbfe95..4b853a1 100644
--- a/avahi-daemon/sd-daemon.h
+++ b/avahi-daemon/sd-daemon.h
@@ -67,17 +67,21 @@ extern "C" {
See sd-daemon(7) for more information.
*/
+#ifndef _sd_printf_attr_
#if __GNUC__ >= 4
#define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
#else
#define _sd_printf_attr_(a,b)
#endif
+#endif
+#ifndef _sd_hidden_
#if (__GNUC__ >= 4) && !defined(SD_EXPORT_SYMBOLS)
#define _sd_hidden_ __attribute__ ((visibility("hidden")))
#else
#define _sd_hidden_
#endif
+#endif
/*
Log levels for usage on stderr:
@@ -181,7 +185,7 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t
READY=1 Tells systemd that daemon startup is finished (only
relevant for services of Type=notify). The passed
argument is a boolean "1" or "0". Since there is
- little value in signalling non-readiness the only
+ little value in signaling non-readiness the only
value daemons should send is "READY=1".
STATUS=... Passes a single-line status string back to systemd
@@ -202,7 +206,7 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t
fork off the process itself. Example: "MAINPID=4711"
Daemons can choose to send additional variables. However, it is
- recommened to prefix variable names not listed above with X_.
+ recommended to prefix variable names not listed above with X_.
Returns a negative errno-style error code on failure. Returns > 0
if systemd could be notified, 0 if it couldn't possibly because
@@ -248,22 +252,12 @@ int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(
fine. You should NOT protect them with a call to this function. Also
note that this function checks whether the system, not the user
session is controlled by systemd. However the functions above work
- for both session and system services.
+ for both user and system services.
See sd_booted(3) for more information.
*/
int sd_booted(void) _sd_hidden_;
-/*
- Controls ongoing disk read-ahead operations during boot-up. The argument
- must be a string, and either "cancel", "done" or "noreplay".
-
- cancel = terminate read-ahead data collection, drop collected information
- done = terminate read-ahead data collection, keep collected information
- noreplay = terminate read-ahead replay
-*/
-int sd_readahead(const char *action);
-
#ifdef __cplusplus
}
#endif
diff --git a/avahi-daemon/setproctitle.c b/avahi-daemon/setproctitle.c
index aef3555..e6f0941 100644
--- a/avahi-daemon/setproctitle.c
+++ b/avahi-daemon/setproctitle.c
@@ -85,7 +85,7 @@ void avahi_set_proc_title(const char *name, const char *fmt,...) {
va_end(ap);
setproctitle("-%s", t);
-#elif __linux__
+#elif defined(__linux__)
size_t l;
va_list ap;
diff --git a/avahi-daemon/simple-protocol.c b/avahi-daemon/simple-protocol.c
index 7f75562..3e0ebb1 100644
--- a/avahi-daemon/simple-protocol.c
+++ b/avahi-daemon/simple-protocol.c
@@ -475,7 +475,7 @@ int simple_protocol_setup(const AvahiPoll *poll_api) {
if (n == 1) {
int r;
- if ((r = sd_is_socket(AF_LOCAL, SOCK_STREAM, 1, 0)) < 0) {
+ if ((r = sd_is_socket(SD_LISTEN_FDS_START, AF_LOCAL, SOCK_STREAM, 1)) < 0) {
avahi_log_warn("Passed systemd file descriptor is of wrong type: %s", strerror(-r));
goto fail;
}