]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove custom logger and output all diagnostics via syslog(3).
authorRoy Marples <roy@marples.name>
Fri, 24 Mar 2017 09:13:02 +0000 (09:13 +0000)
committerRoy Marples <roy@marples.name>
Fri, 24 Mar 2017 09:13:02 +0000 (09:13 +0000)
Remove the --logfile option.
Support LOG_PTRIM and LOG_NLOG if available.

This reduces the binary size by almost 5k.
If you don't like how the diagnostics look on your screen, speak
with your libc vendor about implementing the above NetBSD extensions.

22 files changed:
src/arp.c
src/bpf.c
src/common.c
src/common.h
src/control.c
src/dhcp-common.c
src/dhcp.c
src/dhcp6.c
src/dhcpcd.c
src/dhcpcd.h
src/duid.c
src/if-bsd.c
src/if-linux.c
src/if-options.c
src/if-options.h
src/if.c
src/ipv4.c
src/ipv4ll.c
src/ipv6.c
src/ipv6nd.c
src/route.c
src/script.c

index 313f0d8a1de84d355fe69de21a3f322d47acd405..9db5387f03bc2d85bbcf89410a52a4f89064a26b 100644 (file)
--- a/src/arp.c
+++ b/src/arp.c
@@ -38,6 +38,7 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #define ELOOP_QUEUE 5
@@ -151,8 +152,7 @@ arp_packet(struct interface *ifp, uint8_t *data, size_t len)
        }
        if (ifn) {
 #ifdef ARP_DEBUG
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: ignoring ARP from self", ifp->name);
+               syslog(LOG_DEBUG, "%s: ignoring ARP from self", ifp->name);
 #endif
                return;
        }
@@ -202,8 +202,7 @@ arp_read(void *arg)
        while (!(flags & BPF_EOF)) {
                bytes = bpf_read(ifp, state->fd, buf, sizeof(buf), &flags);
                if (bytes == -1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: arp bpf_read: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: arp bpf_read: %m", ifp->name);
                        arp_close(ifp);
                        return;
                }
@@ -220,8 +219,7 @@ arp_open(struct interface *ifp)
        if (state->fd == -1) {
                state->fd = bpf_open(ifp, bpf_arp);
                if (state->fd == -1) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
-                           __func__, ifp->name);
+                       syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
                        return -1;
                }
                eloop_event_add(ifp->ctx->eloop, state->fd, arp_read, ifp);
@@ -255,13 +253,13 @@ arp_probe1(void *arg)
                tv.tv_nsec = 0;
                eloop_timeout_add_tv(ifp->ctx->eloop, &tv, arp_probed, astate);
        }
-       logger(ifp->ctx, LOG_DEBUG,
+       syslog(LOG_DEBUG,
            "%s: ARP probing %s (%d of %d), next in %0.1f seconds",
            ifp->name, inet_ntoa(astate->addr),
            astate->probes ? astate->probes : PROBE_NUM, PROBE_NUM,
            timespec_to_double(&tv));
        if (arp_request(ifp, 0, astate->addr.s_addr) == -1)
-               logger(ifp->ctx, LOG_ERR, "send_arp: %m");
+               syslog(LOG_ERR, "send_arp: %m");
 }
 
 void
@@ -269,8 +267,7 @@ arp_probe(struct arp_state *astate)
 {
 
        if (arp_open(astate->iface) == -1) {
-               logger(astate->iface->ctx, LOG_ERR,
-                   "%s: %s: %m", __func__, astate->iface->name);
+               syslog(LOG_ERR, "%s: %s: %m", __func__, astate->iface->name);
                return;
        } else {
                const struct iarp_state *state = ARP_CSTATE(astate->iface);
@@ -278,7 +275,7 @@ arp_probe(struct arp_state *astate)
                bpf_arp(astate->iface, state->fd);
        }
        astate->probes = 0;
-       logger(astate->iface->ctx, LOG_DEBUG, "%s: probing for %s",
+       syslog(LOG_DEBUG, "%s: probing for %s",
            astate->iface->name, inet_ntoa(astate->addr));
        arp_probe1(astate);
 }
@@ -311,18 +308,18 @@ arp_announce1(void *arg)
        astate->claims++;
 #else
        if (++astate->claims < ANNOUNCE_NUM)
-               logger(ifp->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: ARP announcing %s (%d of %d), "
                    "next in %d.0 seconds",
                    ifp->name, inet_ntoa(astate->addr),
                    astate->claims, ANNOUNCE_NUM, ANNOUNCE_WAIT);
        else
-               logger(ifp->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: ARP announcing %s (%d of %d)",
                    ifp->name, inet_ntoa(astate->addr),
                    astate->claims, ANNOUNCE_NUM);
        if (arp_request(ifp, astate->addr.s_addr, astate->addr.s_addr) == -1)
-               logger(ifp->ctx, LOG_ERR, "send_arp: %m");
+               syslog(LOG_ERR, "arp_request: %m");
 #endif
        eloop_timeout_add_sec(ifp->ctx->eloop, ANNOUNCE_WAIT,
            astate->claims < ANNOUNCE_NUM ? arp_announce1 : arp_announced,
@@ -335,8 +332,7 @@ arp_announce(struct arp_state *astate)
 
 #ifndef KERNEL_RFC5227
        if (arp_open(astate->iface) == -1) {
-               logger(astate->iface->ctx, LOG_ERR,
-                   "%s: %s: %m", __func__, astate->iface->name);
+               syslog(LOG_ERR, "%s: %s: %m", __func__, astate->iface->name);
                return;
        }
 #endif
@@ -353,15 +349,13 @@ arp_report_conflicted(const struct arp_state *astate,
        if (amsg != NULL) {
                char buf[HWADDR_LEN * 3];
 
-               logger(astate->iface->ctx, LOG_ERR,
-                   "%s: hardware address %s claims %s",
+               syslog(LOG_ERR, "%s: hardware address %s claims %s",
                    astate->iface->name,
                    hwaddr_ntoa(amsg->sha, astate->iface->hwlen,
                    buf, sizeof(buf)),
                    inet_ntoa(astate->failed));
        } else
-               logger(astate->iface->ctx, LOG_ERR,
-                   "%s: DAD detected %s",
+               syslog(LOG_ERR, "%s: DAD detected %s",
                    astate->iface->name, inet_ntoa(astate->failed));
 }
 
@@ -392,7 +386,7 @@ arp_new(struct interface *ifp, const struct in_addr *addr)
                ifp->if_data[IF_DATA_ARP] = malloc(sizeof(*state));
                state = ARP_STATE(ifp);
                if (state == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return NULL;
                }
                state->fd = -1;
@@ -403,7 +397,7 @@ arp_new(struct interface *ifp, const struct in_addr *addr)
        }
 
        if ((astate = calloc(1, sizeof(*astate))) == NULL) {
-               logger(ifp->ctx, LOG_ERR, "%s: %s: %m", ifp->name, __func__);
+               syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__);
                return NULL;
        }
        astate->iface = ifp;
index f22060739c9070cdf7910c3334423b5802e68587..b89f7d8212485ae0904a28b74d6a5018fc924e9d 100644 (file)
--- a/src/bpf.c
+++ b/src/bpf.c
@@ -48,6 +48,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 
 #include "common.h"
 #include "arp.h"
@@ -149,7 +150,7 @@ bpf_open(struct interface *ifp, int (*filter)(struct interface *, int))
                goto eexit;
        if (pv.bv_major != BPF_MAJOR_VERSION ||
            pv.bv_minor < BPF_MINOR_VERSION) {
-               logger(ifp->ctx, LOG_ERR, "BPF version mismatch - recompile");
+               syslog(LOG_ERR, "BPF version mismatch - recompile");
                goto eexit;
        }
 
@@ -464,7 +465,7 @@ bpf_arp(struct interface *ifp, int fd)
                TAILQ_FOREACH(astate, &state->arp_states, next) {
                        if (++naddrs > ARP_ADDRS_MAX) {
                                errno = ENOBUFS;
-                               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                break;
                        }
                        BPF_SET_JUMP(bp, BPF_JMP + BPF_JEQ + BPF_K,
index 4e2dd4393da43385d18426cf31b2ad3e5bbdd769..35cd9b182ec38c37598f8a95b2c7bb45078d10ae 100644 (file)
 #include "dhcpcd.h"
 #include "if-options.h"
 
-#ifndef _PATH_DEVNULL
-#  define _PATH_DEVNULL "/dev/null"
-#endif
-
 /* Most route(4) messages are less than 256 bytes. */
 #define IOVEC_BUFSIZ   256
 
-#if USE_LOGFILE
-void
-logger_open(struct dhcpcd_ctx *ctx)
-{
-
-       if (ctx->logfile) {
-               int f = O_CREAT | O_APPEND | O_TRUNC;
-
-#ifdef O_CLOEXEC
-               f |= O_CLOEXEC;
-#endif
-               ctx->log_fd = open(ctx->logfile, O_WRONLY | f, 0644);
-               if (ctx->log_fd == -1)
-                       warn("open: %s", ctx->logfile);
-#ifndef O_CLOEXEC
-               else {
-                       if ((f = fcntl(ctx->log_fd, F_GETFD)) == -1 ||
-                           fcntl(ctx->log_fd, F_SETFD, f | FD_CLOEXEC) == -1)
-                               warn("fcntl: %s", ctx->logfile);
-               }
-#endif
-       } else
-               openlog(PACKAGE, LOG_PID, LOG_DAEMON);
-}
-
-void
-logger_close(struct dhcpcd_ctx *ctx)
-{
-
-       if (ctx->log_fd != -1) {
-               close(ctx->log_fd);
-               ctx->log_fd = -1;
-       }
-       closelog();
-}
-
-/*
- * NetBSD's gcc has been modified to check for the non standard %m in printf
- * like functions and warn noisily about it that they should be marked as
- * syslog like instead.
- * This is all well and good, but our logger also goes via vfprintf and
- * when marked as a sysloglike funcion, gcc will then warn us that the
- * function should be printflike instead!
- * This creates an infinte loop of gcc warnings.
- * Until NetBSD solves this issue, we have to disable a gcc diagnostic
- * for our fully standards compliant code in the logger function.
- */
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wmissing-format-attribute"
-#endif
-void
-logger(struct dhcpcd_ctx *ctx, int pri, const char *fmt, ...)
-{
-       va_list va;
-       int serrno;
-#ifndef HAVE_PRINTF_M
-       char fmt_cpy[1024];
-#endif
-
-       /* If we're printing the pidfile, don't do anything. */
-       if (ctx != NULL && ctx->options & DHCPCD_PRINT_PIDFILE)
-               return;
-
-       serrno = errno;
-       va_start(va, fmt);
-
-#ifndef HAVE_PRINTF_M
-       /* Print strerrno(errno) in place of %m */
-       if (ctx == NULL || !(ctx->options & DHCPCD_QUIET) || ctx->log_fd != -1)
-       {
-               const char *p;
-               char *fp = fmt_cpy, *serr = NULL;
-               size_t fmt_left = sizeof(fmt_cpy) - 1, fmt_wrote;
-
-               for (p = fmt; *p != '\0'; p++) {
-                       if (p[0] == '%' && p[1] == '%') {
-                               if (fmt_left < 2)
-                                       break;
-                               *fp++ = '%';
-                               *fp++ = '%';
-                               fmt_left -= 2;
-                               p++;
-                       } else if (p[0] == '%' && p[1] == 'm') {
-                               if (serr == NULL) {
-                                       /* strerror_r isn't portable.
-                                        * strerror_l isn't widely found
-                                        * and also problematic to use.
-                                        * Also, if strerror_l exists then
-                                        * strerror could easily be made
-                                        * treadsafe in the same libc.
-                                        * dhcpcd is only threaded in RTEMS
-                                        * where strerror is threadsafe,
-                                        * so this should be fine. */
-                                       serr = strerror(serrno);
-                               }
-                               fmt_wrote = strlcpy(fp, serr, fmt_left);
-                               if (fmt_wrote > fmt_left)
-                                       break;
-                               fp += fmt_wrote;
-                               fmt_left -= fmt_wrote;
-                               p++;
-                       } else {
-                               *fp++ = *p;
-                               --fmt_left;
-                       }
-                       if (fmt_left == 0)
-                               break;
-               }
-               *fp++ = '\0';
-               fmt = fmt_cpy;
-       }
-#endif
-
-       if ((ctx == NULL || !(ctx->options & DHCPCD_QUIET)) &&
-           (pri < LOG_DEBUG || (ctx && ctx->options & DHCPCD_DEBUG)))
-       {
-               va_list vac;
-
-               va_copy(vac, va);
-#ifdef HAVE_PRINTF_M
-               errno = serrno;
-#endif
-               vfprintf(stderr, fmt, vac);
-               fputc('\n', stderr);
-               va_end(vac);
-       }
-
-       /* Don't send to syslog if dumping leases or testing */
-       if (ctx && ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST))
-               goto out;
-
-       if (ctx && ctx->log_fd != -1) {
-               if (pri < LOG_DEBUG || (ctx->options & DHCPCD_DEBUG)) {
-                       struct timeval tv;
-                       char buf[32];
-
-                       /* Write the time, syslog style. month day time - */
-                       if (gettimeofday(&tv, NULL) != -1) {
-                               time_t now;
-                               struct tm tmnow;
-
-                               tzset();
-                               now = tv.tv_sec;
-                               localtime_r(&now, &tmnow);
-                               strftime(buf, sizeof(buf), "%b %d %T ", &tmnow);
-                               dprintf(ctx->log_fd, "%s", buf);
-                       }
-
-#ifdef HAVE_PRINTF_M
-                       errno = serrno;
-#endif
-                       vdprintf(ctx->log_fd, fmt, va);
-                       dprintf(ctx->log_fd, "\n");
-               }
-       } else {
-#ifdef HAVE_PRINTF_M
-               errno = serrno;
-#endif
-               vsyslog(pri, fmt, va);
-       }
-out:
-       va_end(va);
-}
-#endif
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))
-#pragma GCC diagnostic pop
-#endif
-
 ssize_t
-setvar(struct dhcpcd_ctx *ctx,
-    char **e, const char *prefix, const char *var, const char *value)
+setvar(char **e, const char *prefix, const char *var, const char *value)
 {
        size_t len = strlen(var) + strlen(value) + 3;
 
@@ -239,7 +65,7 @@ setvar(struct dhcpcd_ctx *ctx,
                len += strlen(prefix) + 1;
        *e = malloc(len);
        if (*e == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return -1;
        }
        if (prefix)
@@ -250,36 +76,33 @@ setvar(struct dhcpcd_ctx *ctx,
 }
 
 ssize_t
-setvard(struct dhcpcd_ctx *ctx,
-    char **e, const char *prefix, const char *var, size_t value)
+setvard(char **e, const char *prefix, const char *var, size_t value)
 {
 
        char buffer[32];
 
        snprintf(buffer, sizeof(buffer), "%zu", value);
-       return setvar(ctx, e, prefix, var, buffer);
+       return setvar(e, prefix, var, buffer);
 }
 
 ssize_t
-addvar(struct dhcpcd_ctx *ctx,
-    char ***e, const char *prefix, const char *var, const char *value)
+addvar(char ***e, const char *prefix, const char *var, const char *value)
 {
        ssize_t len;
 
-       len = setvar(ctx, *e, prefix, var, value);
+       len = setvar(*e, prefix, var, value);
        if (len != -1)
                (*e)++;
        return (ssize_t)len;
 }
 
 ssize_t
-addvard(struct dhcpcd_ctx *ctx,
-    char ***e, const char *prefix, const char *var, size_t value)
+addvard(char ***e, const char *prefix, const char *var, size_t value)
 {
        char buffer[32];
 
        snprintf(buffer, sizeof(buffer), "%zu", value);
-       return addvar(ctx, e, prefix, var, buffer);
+       return addvar(e, prefix, var, buffer);
 }
 
 const char *
index 2ecede05f085acf48e0d8b77d83be29b7b7df75c..a016fe6c04f42c49cb1e505936bac20ed62b47e5 100644 (file)
@@ -31,7 +31,6 @@
 #include <sys/param.h>
 #include <sys/time.h>
 #include <stdio.h>
-#include <syslog.h>
 
 #include "config.h"
 #include "defs.h"
@@ -175,42 +174,10 @@ void get_line_free(void);
 extern int clock_monotonic;
 int get_monotonic(struct timespec *);
 
-/* We could shave a few k off the binary size by just using the
- * syslog(3) interface.
- * However, this results in a ugly output on the command line
- * and relies on syslogd(8) starting before dhcpcd which is not
- * always the case. */
-#ifdef SMALL
-# undef USE_LOGFILE
-# define USE_LOGFILE 0
-#endif
-#ifndef USE_LOGFILE
-# define USE_LOGFILE 1
-#endif
-#if USE_LOGFILE
-void logger_open(struct dhcpcd_ctx *);
-#define logger_mask(ctx, lvl) setlogmask((lvl))
-void logger(struct dhcpcd_ctx *, int, const char *, ...) __sysloglike(3, 4);
-void logger_close(struct dhcpcd_ctx *);
-#else
-#define logger_open(ctx) openlog(PACKAGE, LOG_PERROR | LOG_PID, LOG_DAEMON)
-#define logger_mask(ctx, lvl) setlogmask((lvl))
-#define logger(ctx, pri, fmt, ...)                     \
-       do {                                            \
-               UNUSED((ctx));                          \
-               syslog((pri), (fmt), ##__VA_ARGS__);    \
-       } while (0 /*CONSTCOND */)
-#define logger_close(ctx) closelog()
-#endif
-
-ssize_t setvar(struct dhcpcd_ctx *,
-    char **, const char *, const char *, const char *);
-ssize_t setvard(struct dhcpcd_ctx *,
-    char **, const char *, const char *, size_t);
-ssize_t addvar(struct dhcpcd_ctx *,
-    char ***, const char *, const char *, const char *);
-ssize_t addvard(struct dhcpcd_ctx *,
-    char ***, const char *, const char *, size_t);
+ssize_t setvar(char **, const char *, const char *, const char *);
+ssize_t setvard(char **, const char *, const char *, size_t);
+ssize_t addvar(char ***, const char *, const char *, const char *);
+ssize_t addvard(char ***, const char *, const char *, size_t);
 
 const char *hwaddr_ntoa(const void *, size_t, char *, size_t);
 size_t hwaddr_aton(uint8_t *, const char *);
index 4e0824ba182607c88a4c6fc67a0257401a45ec89..2613e7fa4acb226f49c94f944a2de801e2f52ea5 100644 (file)
@@ -35,6 +35,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -140,8 +141,7 @@ control_handle_data(void *arg)
                }
                *ap = NULL;
                if (dhcpcd_handleargs(fd->ctx, fd, argc, argvp) == -1) {
-                       logger(fd->ctx, LOG_ERR,
-                           "%s: dhcpcd_handleargs: %m", __func__);
+                       syslog(LOG_ERR, "%s: dhcpcd_handleargs: %m", __func__);
                        if (errno != EINTR && errno != EAGAIN) {
                                control_delete(fd);
                                return;
@@ -366,8 +366,7 @@ control_writeone(void *arg)
        iov[1].iov_base = data->data;
        iov[1].iov_len = data->data_len;
        if (writev(fd->fd, iov, 2) == -1) {
-               logger(fd->ctx, LOG_ERR,
-                   "%s: writev fd %d: %m", __func__, fd->fd);
+               syslog(LOG_ERR, "%s: writev fd %d: %m", __func__, fd->fd);
                if (errno != EINTR && errno != EAGAIN)
                        control_delete(fd);
                return;
index 91aed334f1dddfc853ac7bfa2038381f0c483a16..b4a1af053e055ad6738a7fb89e17845540455e27 100644 (file)
@@ -34,6 +34,7 @@
 #include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #include <arpa/nameser.h> /* after normal includes for sunos */
@@ -920,7 +921,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                            prefix, opt, 1, od, ol, ifname))
                                return 1;
                        else
-                               logger(ctx, LOG_ERR, "%s: %s %d: %m",
+                               syslog(LOG_ERR, "%s: %s %d: %m",
                                    ifname, __func__, opt->option);
                }
                return 0;
@@ -931,7 +932,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                if (opt->type & OT_INDEX) {
                        if (opt->index > 999) {
                                errno = ENOBUFS;
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return 0;
                        }
                }
@@ -939,7 +940,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                    (opt->type & OT_INDEX ? 3 : 0);
                pfx = malloc(e);
                if (pfx == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return 0;
                }
                if (opt->type & OT_INDEX)
@@ -957,7 +958,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                eo = dhcp_optlen(eopt, ol);
                if (eo == -1) {
                        if (env == NULL)
-                               logger(ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "%s: %s %d.%d/%zu: "
                                    "malformed embedded option",
                                    ifname, __func__, opt->option,
@@ -972,7 +973,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                         * option which is optional. */
                        if (env == NULL &&
                            (ol != 0 || !(eopt->type & OT_OPTIONAL)))
-                               logger(ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "%s: %s %d.%d/%zu: missing embedded option",
                                    ifname, __func__, opt->option,
                                    eopt->option, i);
@@ -987,7 +988,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                            pfx, eopt, ov, od, (size_t)eo, ifname))
                                n++;
                        else if (env == NULL)
-                               logger(ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "%s: %s %d.%d/%zu: %m",
                                    ifname, __func__,
                                    opt->option, eopt->option, i);
index f0ce8d538ece341bf8fc24c64dfc5654f4fb82d5..f6b3104e40eea6d02a97221e5c703dd4aaf412ab 100644 (file)
@@ -49,6 +49,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #define ELOOP_QUEUE 2
@@ -599,7 +600,7 @@ get_option_routes(struct rt_head *routes, struct interface *ifp,
                if (!(ifo->options & DHCPCD_CSR_WARNED) &&
                    !(state->added & STATE_FAKE))
                {
-                       logger(ifp->ctx, LOG_DEBUG,
+                       syslog(LOG_DEBUG,
                            "%s: using %sClassless Static Routes",
                            ifp->name, csr);
                        ifo->options |= DHCPCD_CSR_WARNED;
@@ -752,12 +753,10 @@ make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type)
 #endif
 
        if ((mtu = if_getmtu(ifp)) == -1)
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: if_getmtu: %m", ifp->name);
+               syslog(LOG_ERR, "%s: if_getmtu: %m", ifp->name);
        else if (mtu < MTU_MIN) {
                if (if_setmtu(ifp, MTU_MIN) == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: if_setmtu: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: if_setmtu: %m", ifp->name);
                mtu = MTU_MIN;
        }
 
@@ -1015,7 +1014,7 @@ make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type)
                        {
                                AREA_FIT(vivco->len);
                                if (vivco->len + 2 + *lp > 255) {
-                                       logger(ifp->ctx, LOG_ERR,
+                                       syslog(LOG_ERR,
                                            "%s: VIVCO option too big",
                                            ifp->name);
                                        free(bootp);
@@ -1085,8 +1084,7 @@ make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type)
                        alen = -1;
                }
                if (alen == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: dhcp_auth_encode: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: dhcp_auth_encode: %m", ifp->name);
                else if (alen != 0) {
                        auth_len = (uint8_t)alen;
                        AREA_CHECK(auth_len);
@@ -1120,7 +1118,7 @@ make_message(struct bootp **bootpm, const struct interface *ifp, uint8_t type)
        return (ssize_t)len;
 
 toobig:
-       logger(ifp->ctx, LOG_ERR, "%s: DHCP message too big", ifp->name);
+       syslog(LOG_ERR, "%s: DHCP message too big", ifp->name);
        free(bootp);
        return -1;
 }
@@ -1132,7 +1130,7 @@ write_lease(const struct interface *ifp, const struct bootp *bootp, size_t len)
        ssize_t bytes;
        const struct dhcp_state *state = D_CSTATE(ifp);
 
-       logger(ifp->ctx, LOG_DEBUG, "%s: writing lease `%s'",
+       syslog(LOG_DEBUG, "%s: writing lease `%s'",
            ifp->name, state->leasefile);
 
        fd = open(state->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
@@ -1169,14 +1167,14 @@ read_lease(struct interface *ifp, struct bootp **bootp)
        }
        if (fd == -1) {
                if (errno != ENOENT)
-                       logger(ifp->ctx, LOG_ERR, "%s: open `%s': %m",
+                       syslog(LOG_ERR, "%s: open `%s': %m",
                            ifp->name, state->leasefile);
                return 0;
        }
        if (state->leasefile[0] == '\0')
-               logger(ifp->ctx, LOG_DEBUG, "reading standard input");
+               syslog(LOG_DEBUG, "reading standard input");
        else
-               logger(ifp->ctx, LOG_DEBUG, "%s: reading lease `%s'",
+               syslog(LOG_DEBUG, "%s: reading lease `%s'",
                    ifp->name, state->leasefile);
 
        bytes = dhcp_read_lease_fd(fd, (void **)&lease);
@@ -1184,8 +1182,7 @@ read_lease(struct interface *ifp, struct bootp **bootp)
                close(fd);
        if (bytes == 0) {
                free(lease);
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp_read_lease_fd: %m", __func__);
+               syslog(LOG_ERR, "%s: dhcp_read_lease_fd: %m", __func__);
                return 0;
        }
 
@@ -1196,7 +1193,7 @@ read_lease(struct interface *ifp, struct bootp **bootp)
         * scribble whatever in the stored lease file. */
        if (bytes < offsetof(struct bootp, vend) + 4) {
                free(lease);
-               logger(ifp->ctx, LOG_ERR, "%s: truncated lease", __func__);
+               syslog(LOG_ERR, "%s: truncated lease", __func__);
                return 0;
        }
 
@@ -1216,23 +1213,21 @@ read_lease(struct interface *ifp, struct bootp **bootp)
                if (dhcp_auth_validate(&state->auth, &ifp->options->auth,
                    lease, bytes, 4, type, auth, auth_len) == NULL)
                {
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: dhcp_auth_validate: %m", ifp->name);
+                       syslog(LOG_DEBUG, "%s: dhcp_auth_validate: %m",
+                           ifp->name);
                        free(lease);
                        return 0;
                }
                if (state->auth.token)
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: validated using 0x%08" PRIu32,
+                       syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
                            ifp->name, state->auth.token->secretid);
                else
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: accepted reconfigure key", ifp->name);
+                       syslog(LOG_DEBUG, "%s: accepted reconfigure key",
+                           ifp->name);
        } else if ((ifp->options->auth.options & DHCPCD_AUTH_SENDREQUIRE) ==
            DHCPCD_AUTH_SENDREQUIRE)
        {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: authentication now required", ifp->name);
+               syslog(LOG_ERR, "%s: authentication now required", ifp->name);
                free(lease);
                return 0;
        }
@@ -1358,37 +1353,37 @@ dhcp_env(char **env, const char *prefix,
                /* Set some useful variables that we derive from the DHCP
                 * message but are not necessarily in the options */
                addr.s_addr = bootp->yiaddr ? bootp->yiaddr : bootp->ciaddr;
-               addvar(ifp->ctx, &ep, prefix, "ip_address", inet_ntoa(addr));
+               addvar(&ep, prefix, "ip_address", inet_ntoa(addr));
                if (get_option_addr(ifp->ctx, &net,
                    bootp, bootp_len, DHO_SUBNETMASK) == -1)
                {
                        net.s_addr = ipv4_getnetmask(addr.s_addr);
-                       addvar(ifp->ctx, &ep, prefix,
+                       addvar(&ep, prefix,
                            "subnet_mask", inet_ntoa(net));
                }
                snprintf(cidr, sizeof(cidr), "%d", inet_ntocidr(net));
-               addvar(ifp->ctx, &ep, prefix, "subnet_cidr", cidr);
+               addvar(&ep, prefix, "subnet_cidr", cidr);
                if (get_option_addr(ifp->ctx, &brd,
                    bootp, bootp_len, DHO_BROADCAST) == -1)
                {
                        brd.s_addr = addr.s_addr | ~net.s_addr;
-                       addvar(ifp->ctx, &ep, prefix,
+                       addvar(&ep, prefix,
                            "broadcast_address", inet_ntoa(brd));
                }
                addr.s_addr = bootp->yiaddr & net.s_addr;
-               addvar(ifp->ctx, &ep, prefix,
+               addvar(&ep, prefix,
                    "network_number", inet_ntoa(addr));
        }
 
        if (*bootp->file && !(overl & 1)) {
                print_string(safe, sizeof(safe), OT_STRING,
                    bootp->file, sizeof(bootp->file));
-               addvar(ifp->ctx, &ep, prefix, "filename", safe);
+               addvar(&ep, prefix, "filename", safe);
        }
        if (*bootp->sname && !(overl & 2)) {
                print_string(safe, sizeof(safe), OT_STRING | OT_DOMAIN,
                    bootp->sname, sizeof(bootp->sname));
-               addvar(ifp->ctx, &ep, prefix, "server_name", safe);
+               addvar(&ep, prefix, "server_name", safe);
        }
 
        /* Zero our indexes */
@@ -1695,7 +1690,7 @@ send_message(struct interface *ifp, uint8_t type,
                /* No carrier? Don't bother sending the packet. */
                if (ifp->carrier == LINK_DOWN)
                        return;
-               logger(ifp->ctx, LOG_DEBUG, "%s: sending %s with xid 0x%x",
+               syslog(LOG_DEBUG, "%s: sending %s with xid 0x%x",
                    ifp->name,
                    ifo->options & DHCPCD_BOOTP ? "BOOTP" : get_dhcp_op(type),
                    state->xid);
@@ -1715,7 +1710,7 @@ send_message(struct interface *ifp, uint8_t type,
                 * However, we do need to advance the timeout. */
                if (ifp->carrier == LINK_DOWN)
                        goto fail;
-               logger(ifp->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: sending %s (xid 0x%x), next in %0.1f seconds",
                    ifp->name,
                    ifo->options & DHCPCD_BOOTP ? "BOOTP" : get_dhcp_op(type),
@@ -1740,8 +1735,8 @@ send_message(struct interface *ifp, uint8_t type,
                s = dhcp_openudp(ifp);
                if (s == -1) {
                        if (errno != EADDRINUSE)
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: dhcp_openudp: %m", ifp->name);
+                               syslog(LOG_ERR, "%s: dhcp_openudp: %m",
+                                   ifp->name);
                        /* We cannot renew */
                        state->addr = NULL;
                }
@@ -1767,14 +1762,13 @@ send_message(struct interface *ifp, uint8_t type,
                r = sendto(s, (uint8_t *)bootp, len, 0,
                    (struct sockaddr *)&sin, sizeof(sin));
                if (r == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: dhcp_sendpacket: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: dhcp_sendpacket: %m", ifp->name);
        } else {
                size_t ulen;
 
                udp = dhcp_makeudppacket(&ulen, (uint8_t *)bootp, len, from,to);
                if (udp == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "dhcp_makeudppacket: %m");
+                       syslog(LOG_ERR, "dhcp_makeudppacket: %m");
                        r = 0;
                } else {
                        r = bpf_send(ifp, state->bpf_fd,
@@ -1787,8 +1781,7 @@ send_message(struct interface *ifp, uint8_t type,
                 * As such we remove it from consideration without actually
                 * stopping the interface. */
                if (r == -1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: if_sendraw: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: if_sendraw: %m", ifp->name);
                        switch(errno) {
                        case ENETDOWN:
                        case ENETRESET:
@@ -1871,12 +1864,10 @@ dhcp_discover(void *arg)
                    ifo->reboot, ipv4ll_start, ifp);
 #endif
        if (ifo->options & DHCPCD_REQUEST)
-               logger(ifp->ctx, LOG_INFO,
-                   "%s: soliciting a DHCP lease (requesting %s)",
+               syslog(LOG_INFO, "%s: soliciting a DHCP lease (requesting %s)",
                    ifp->name, inet_ntoa(ifo->req_addr));
        else
-               logger(ifp->ctx, LOG_INFO,
-                   "%s: soliciting a %s lease",
+               syslog(LOG_INFO, "%s: soliciting a %s lease",
                    ifp->name, ifo->options & DHCPCD_BOOTP ? "BOOTP" : "DHCP");
        send_discover(ifp);
 }
@@ -1910,13 +1901,13 @@ dhcp_leaseextend(struct interface *ifp)
                        return -1;
 #endif
 
-               logger(ifp->ctx, LOG_WARNING,
+               syslog(LOG_WARNING,
                    "%s: extending lease until DaD failure or DHCP", ifp->name);
                return 0;
        }
 #endif
 
-       logger(ifp->ctx, LOG_WARNING, "%s: extending lease", ifp->name);
+       syslog(LOG_WARNING, "%s: extending lease", ifp->name);
        return 0;
 }
 
@@ -1937,12 +1928,11 @@ dhcp_expire(void *arg)
 {
        struct interface *ifp = arg;
 
-       logger(ifp->ctx, LOG_ERR, "%s: DHCP lease expired", ifp->name);
+       syslog(LOG_ERR, "%s: DHCP lease expired", ifp->name);
        if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) {
                if (dhcp_leaseextend(ifp) == 0)
                        return;
-               logger(ifp->ctx, LOG_ERR, "%s: dhcp_leaseextend: %m",
-                   ifp->name);
+               syslog(LOG_ERR, "%s: dhcp_leaseextend: %m", ifp->name);
        }
        dhcp_expire1(ifp);
 }
@@ -1975,8 +1965,8 @@ dhcp_startrenew(void *arg)
        eloop_timeout_delete(ifp->ctx->eloop, dhcp_startrenew, ifp);
 
        lease = &state->lease;
-       logger(ifp->ctx, LOG_DEBUG, "%s: renewing lease of %s",
-           ifp->name, inet_ntoa(lease->addr));
+       syslog(LOG_DEBUG, "%s: renewing lease of %s", ifp->name,
+           inet_ntoa(lease->addr));
        state->state = DHS_RENEW;
        dhcp_new_xid(ifp);
        state->interval = 0;
@@ -1997,9 +1987,8 @@ dhcp_rebind(void *arg)
        struct dhcp_state *state = D_STATE(ifp);
        struct dhcp_lease *lease = &state->lease;
 
-       logger(ifp->ctx, LOG_WARNING,
-           "%s: failed to renew DHCP, rebinding", ifp->name);
-       logger(ifp->ctx, LOG_DEBUG, "%s: expire in %"PRIu32" seconds",
+       syslog(LOG_WARNING, "%s: failed to renew DHCP, rebinding", ifp->name);
+       syslog(LOG_DEBUG, "%s: expire in %"PRIu32" seconds",
            ifp->name, lease->leasetime - lease->rebindtime);
        state->state = DHS_REBIND;
        eloop_timeout_delete(ifp->ctx->eloop, send_renew, ifp);
@@ -2047,7 +2036,7 @@ dhcp_arp_probed(struct arp_state *astate)
        if (state->state == DHS_BOUND)
                return;
 
-       logger(ifp->ctx, LOG_DEBUG, "%s: DAD completed for %s",
+       syslog(LOG_DEBUG, "%s: DAD completed for %s",
            ifp->name, inet_ntoa(astate->addr));
        if (state->state != DHS_INFORM)
                dhcp_bind(ifp);
@@ -2194,13 +2183,13 @@ dhcp_bind(struct interface *ifp)
        }
        get_lease(ifp, lease, state->new, state->new_len);
        if (ifo->options & DHCPCD_STATIC) {
-               logger(ifp->ctx, LOG_INFO, "%s: using static address %s/%d",
+               syslog(LOG_INFO, "%s: using static address %s/%d",
                    ifp->name, inet_ntoa(lease->addr),
                    inet_ntocidr(lease->mask));
                lease->leasetime = ~0U;
                state->reason = "STATIC";
        } else if (ifo->options & DHCPCD_INFORM) {
-               logger(ifp->ctx, LOG_INFO, "%s: received approval for %s",
+               syslog(LOG_INFO, "%s: received approval for %s",
                    ifp->name, inet_ntoa(lease->addr));
                lease->leasetime = ~0U;
                state->reason = "INFORM";
@@ -2211,11 +2200,11 @@ dhcp_bind(struct interface *ifp)
                        lease->renewaltime =
                            lease->rebindtime =
                            lease->leasetime;
-                       logger(ifp->ctx, LOG_INFO, "%s: leased %s for infinity",
+                       syslog(LOG_INFO, "%s: leased %s for infinity",
                            ifp->name, inet_ntoa(lease->addr));
                } else {
                        if (lease->leasetime < DHCP_MIN_LEASE) {
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: minimum lease is %d seconds",
                                    ifp->name, DHCP_MIN_LEASE);
                                lease->leasetime = DHCP_MIN_LEASE;
@@ -2226,7 +2215,7 @@ dhcp_bind(struct interface *ifp)
                        else if (lease->rebindtime >= lease->leasetime) {
                                lease->rebindtime =
                                    (uint32_t)(lease->leasetime * T2);
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: rebind time greater than lease "
                                    "time, forcing to %"PRIu32" seconds",
                                    ifp->name, lease->rebindtime);
@@ -2237,13 +2226,12 @@ dhcp_bind(struct interface *ifp)
                        else if (lease->renewaltime > lease->rebindtime) {
                                lease->renewaltime =
                                    (uint32_t)(lease->leasetime * T1);
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: renewal time greater than rebind "
                                    "time, forcing to %"PRIu32" seconds",
                                    ifp->name, lease->renewaltime);
                        }
-                       logger(ifp->ctx,
-                           state->addr &&
+                       syslog(state->addr &&
                            lease->addr.s_addr == state->addr->addr.s_addr &&
                            !(state->added & STATE_FAKE) ?
                            LOG_DEBUG : LOG_INFO,
@@ -2279,7 +2267,7 @@ dhcp_bind(struct interface *ifp)
                    (time_t)lease->rebindtime, dhcp_rebind, ifp);
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    (time_t)lease->leasetime, dhcp_expire, ifp);
-               logger(ifp->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: renew in %"PRIu32" seconds, rebind in %"PRIu32
                    " seconds",
                    ifp->name, lease->renewaltime, lease->rebindtime);
@@ -2290,8 +2278,7 @@ dhcp_bind(struct interface *ifp)
        if (!state->lease.frominfo &&
            !(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)))
                if (write_lease(ifp, state->new, state->new_len) == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: write_lease: %m", __func__);
+                       syslog(LOG_ERR, "%s: write_lease: %m", __func__);
 
        ipv4_applyaddr(ifp);
 }
@@ -2302,7 +2289,7 @@ dhcp_lastlease(void *arg)
        struct interface *ifp = arg;
        struct dhcp_state *state = D_STATE(ifp);
 
-       logger(ifp->ctx, LOG_INFO,
+       syslog(LOG_INFO,
            "%s: timed out contacting a DHCP server, using last lease",
            ifp->name);
        dhcp_bind(ifp);
@@ -2313,8 +2300,7 @@ dhcp_lastlease(void *arg)
        if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND &&
            dhcp_leaseextend(ifp) == -1)
        {
-               logger(ifp->ctx, LOG_ERR, "%s: dhcp_leaseextend: %m",
-                   ifp->name);
+               syslog(LOG_ERR, "%s: dhcp_leaseextend: %m", ifp->name);
                dhcp_expire(ifp);
        }
        dhcp_discover(ifp);
@@ -2380,7 +2366,7 @@ dhcp_arp_address(struct interface *ifp)
                        /* Add the address now, let the kernel handle DAD. */
                        ipv4_addaddr(ifp, &l.addr, &l.mask, &l.brd);
                } else
-                       logger(ifp->ctx, LOG_INFO, "%s: waiting for DAD on %s",
+                       syslog(LOG_INFO, "%s: waiting for DAD on %s",
                            ifp->name, inet_ntoa(addr));
                return 0;
        }
@@ -2389,7 +2375,7 @@ dhcp_arp_address(struct interface *ifp)
                struct dhcp_lease l;
 
                get_lease(ifp, &l, state->offer, state->offer_len);
-               logger(ifp->ctx, LOG_INFO, "%s: probing address %s/%d",
+               syslog(LOG_INFO, "%s: probing address %s/%d",
                    ifp->name, inet_ntoa(l.addr), inet_ntocidr(l.mask));
                /* We need to handle DAD. */
                arp_probe(astate);
@@ -2423,10 +2409,8 @@ dhcp_static(struct interface *ifp)
        if (ifo->req_addr.s_addr == INADDR_ANY &&
            (ia = ipv4_iffindaddr(ifp, NULL, NULL)) == NULL)
        {
-               logger(ifp->ctx, LOG_INFO,
-                   "%s: waiting for 3rd party to "
-                   "configure IP address",
-                   ifp->name);
+               syslog(LOG_INFO, "%s: waiting for 3rd party to "
+                   "configure IP address", ifp->name);
                state->reason = "3RDPARTY";
                script_runreason(ifp, state->reason);
                return;
@@ -2461,7 +2445,7 @@ dhcp_inform(struct interface *ifp)
        if (ifo->req_addr.s_addr == INADDR_ANY) {
                ia = ipv4_iffindaddr(ifp, NULL, NULL);
                if (ia == NULL) {
-                       logger(ifp->ctx, LOG_INFO,
+                       syslog(LOG_INFO,
                            "%s: waiting for 3rd party to configure IP address",
                            ifp->name);
                        if (!(ifp->ctx->options & DHCPCD_TEST)) {
@@ -2474,7 +2458,7 @@ dhcp_inform(struct interface *ifp)
                ia = ipv4_iffindaddr(ifp, &ifo->req_addr, &ifo->req_mask);
                if (ia == NULL) {
                        if (ifp->ctx->options & DHCPCD_TEST) {
-                               logger(ifp->ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "%s: cannot add IP address in test mode",
                                    ifp->name);
                                return;
@@ -2537,8 +2521,7 @@ dhcp_reboot(struct interface *ifp)
        state->interval = 0;
 
        if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) {
-               logger(ifp->ctx, LOG_INFO,
-                   "%s: waiting for carrier", ifp->name);
+               syslog(LOG_INFO, "%s: waiting for carrier", ifp->name);
                return;
        }
        if (ifo->options & DHCPCD_STATIC) {
@@ -2546,7 +2529,7 @@ dhcp_reboot(struct interface *ifp)
                return;
        }
        if (ifo->options & DHCPCD_INFORM) {
-               logger(ifp->ctx, LOG_INFO, "%s: informing address of %s",
+               syslog(LOG_INFO, "%s: informing address of %s",
                    ifp->name, inet_ntoa(state->lease.addr));
                dhcp_inform(ifp);
                return;
@@ -2558,7 +2541,7 @@ dhcp_reboot(struct interface *ifp)
        if (!IS_DHCP(state->offer))
                return;
 
-       logger(ifp->ctx, LOG_INFO, "%s: rebinding lease of %s",
+       syslog(LOG_INFO, "%s: rebinding lease of %s",
            ifp->name, inet_ntoa(state->lease.addr));
        dhcp_new_xid(ifp);
        state->lease.server.s_addr = 0;
@@ -2616,7 +2599,7 @@ dhcp_drop(struct interface *ifp, const char *reason)
                    state->new != NULL &&
                    state->lease.server.s_addr != INADDR_ANY)
                {
-                       logger(ifp->ctx, LOG_INFO, "%s: releasing lease of %s",
+                       syslog(LOG_INFO, "%s: releasing lease of %s",
                            ifp->name, inet_ntoa(state->lease.addr));
                        dhcp_new_xid(ifp);
                        send_message(ifp, DHCP_RELEASE, NULL);
@@ -2699,7 +2682,7 @@ log_dhcp(int lvl, const char *msg,
                        tmpl = (al * 4) + 1;
                        tmp = malloc(tmpl);
                        if (tmp == NULL) {
-                               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                free(a);
                                return;
                        }
@@ -2711,7 +2694,7 @@ log_dhcp(int lvl, const char *msg,
                addr.s_addr = bootp->yiaddr;
                a = strdup(inet_ntoa(addr));
                if (a == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return;
                }
        } else
@@ -2726,10 +2709,10 @@ log_dhcp(int lvl, const char *msg,
                print_string(sname, sizeof(sname), OT_STRING | OT_DOMAIN,
                    bootp->sname, sizeof(bootp->sname));
                if (a == NULL)
-                       logger(ifp->ctx, lvl, "%s: %s %s %s `%s'",
+                       syslog(lvl, "%s: %s %s %s `%s'",
                            ifp->name, msg, tfrom, inet_ntoa(addr), sname);
                else
-                       logger(ifp->ctx, lvl, "%s: %s %s %s %s `%s'",
+                       syslog(lvl, "%s: %s %s %s %s `%s'",
                            ifp->name, msg, a, tfrom, inet_ntoa(addr), sname);
        } else {
                if (r != 0) {
@@ -2737,10 +2720,10 @@ log_dhcp(int lvl, const char *msg,
                        addr = *from;
                }
                if (a == NULL)
-                       logger(ifp->ctx, lvl, "%s: %s %s %s",
+                       syslog(lvl, "%s: %s %s %s",
                            ifp->name, msg, tfrom, inet_ntoa(addr));
                else
-                       logger(ifp->ctx, lvl, "%s: %s %s %s %s",
+                       syslog(lvl, "%s: %s %s %s %s",
                            ifp->name, msg, a, tfrom, inet_ntoa(addr));
        }
        free(a);
@@ -2774,7 +2757,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
        /* Handled in our BPF filter. */
 #if 0
        if (bootp->op != BOOTREPLY) {
-               logger(ifp->ctx, LOG_DEBUG, "%s: op (%d) is not BOOTREPLY",
+               syslog(LOG_DEBUG, "%s: op (%d) is not BOOTREPLY",
                    ifp->name, bootp->op);
                return;
        }
@@ -2784,7 +2767,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
        {
                char buf[sizeof(bootp->chaddr) * 3];
 
-               logger(ifp->ctx, LOG_DEBUG, "%s: xid 0x%x is for hwaddr %s",
+               syslog(LOG_DEBUG, "%s: xid 0x%x is for hwaddr %s",
                    ifp->name, ntohl(bootp->xid),
                    hwaddr_ntoa(bootp->chaddr, sizeof(bootp->chaddr),
                    buf, sizeof(buf)));
@@ -2797,8 +2780,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
            bootp, bootp_len, DHO_MESSAGETYPE) == -1)
                type = 0;
        else if (ifo->options & DHCPCD_BOOTP) {
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: ignoring DHCP reply (expecting BOOTP)",
+               syslog(LOG_DEBUG, "%s: ignoring DHCP reply (expecting BOOTP)",
                    ifp->name);
                return;
        }
@@ -2812,18 +2794,17 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                    (uint8_t *)bootp, bootp_len, 4, type,
                    auth, auth_len) == NULL)
                {
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: dhcp_auth_validate: %m", ifp->name);
+                       syslog(LOG_DEBUG, "%s: dhcp_auth_validate: %m",
+                           ifp->name);
                        LOGDHCP0(LOG_ERR, "authentication failed");
                        return;
                }
                if (state->auth.token)
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: validated using 0x%08" PRIu32,
+                       syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
                            ifp->name, state->auth.token->secretid);
                else
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: accepted reconfigure key", ifp->name);
+                       syslog(LOG_INFO, "%s: accepted reconfigure key",
+                           ifp->name);
        } else if (ifo->auth.options & DHCPCD_AUTH_SEND) {
                if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
                        LOGDHCP0(LOG_ERR, "no authentication");
@@ -2877,7 +2858,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
 #if 0
        /* Ensure it's the right transaction */
        if (state->xid != ntohl(bootp->xid)) {
-               logger(ifp->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: wrong xid 0x%x (expecting 0x%x) from %s",
                    ifp->name, ntohl(bootp->xid), state->xid,
                    inet_ntoa(*from));
@@ -2920,8 +2901,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                if ((msg = get_option_string(ifp->ctx,
                    bootp, bootp_len, DHO_MESSAGE)))
                {
-                       logger(ifp->ctx, LOG_WARNING, "%s: message: %s",
-                           ifp->name, msg);
+                       syslog(LOG_WARNING, "%s: message: %s", ifp->name, msg);
                        free(msg);
                }
                if (state->state == DHS_INFORM) /* INFORM should not be NAKed */
@@ -2968,8 +2948,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                if ((msg = get_option_string(ifp->ctx,
                    bootp, bootp_len, DHO_MESSAGE)))
                {
-                       logger(ifp->ctx, LOG_WARNING,
-                           "%s: message: %s", ifp->name, msg);
+                       syslog(LOG_WARNING, "%s: message: %s", ifp->name, msg);
                        free(msg);
                }
 #ifdef IPV4LL
@@ -2988,7 +2967,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                                ipv4ll_start(ifp);
                                break;
                        default:
-                               logger(ifp->ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "%s: unknown auto configuration option %d",
                                    ifp->name, tmp);
                                break;
@@ -3049,8 +3028,7 @@ dhcp_handledhcp(struct interface *ifp, struct bootp *bootp, size_t bootp_len,
                if (state->offer_len < bootp_len) {
                        free(state->offer);
                        if ((state->offer = malloc(bootp_len)) == NULL) {
-                               logger(ifp->ctx, LOG_ERR, "%s: malloc: %m",
-                                   __func__);
+                               syslog(LOG_ERR, "%s: malloc: %m", __func__);
                                state->offer_len = 0;
                                return;
                        }
@@ -3127,8 +3105,7 @@ rapidcommit:
                if (state->offer_len < bootp_len) {
                        free(state->offer);
                        if ((state->offer = malloc(bootp_len)) == NULL) {
-                               logger(ifp->ctx, LOG_ERR, "%s: malloc: %m",
-                                   __func__);
+                               syslog(LOG_ERR, "%s: malloc: %m", __func__);
                                state->offer_len = 0;
                                return;
                        }
@@ -3221,27 +3198,24 @@ dhcp_handlepacket(struct interface *ifp, uint8_t *data, size_t len, int flags)
 
        if (valid_udp_packet(data, len, &from, flags & RAW_PARTIALCSUM) == -1)
        {
-               logger(ifp->ctx, LOG_ERR, "%s: invalid UDP packet from %s",
+               syslog(LOG_ERR, "%s: invalid UDP packet from %s",
                    ifp->name, inet_ntoa(from));
                return;
        }
        i = whitelisted_ip(ifp->options, from.s_addr);
        if (i == 0) {
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: non whitelisted DHCP packet from %s",
+               syslog(LOG_WARNING, "%s: non whitelisted DHCP packet from %s",
                    ifp->name, inet_ntoa(from));
                return;
        } else if (i != 1 && blacklisted_ip(ifp->options, from.s_addr) == 1) {
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: blacklisted DHCP packet from %s",
+               syslog(LOG_WARNING, "%s: blacklisted DHCP packet from %s",
                    ifp->name, inet_ntoa(from));
                return;
        }
        if (ifp->flags & IFF_POINTOPOINT &&
            (state->addr == NULL || state->addr->brd.s_addr != from.s_addr))
        {
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: server %s is not destination",
+               syslog(LOG_WARNING, "%s: server %s is not destination",
                    ifp->name, inet_ntoa(from));
        }
 
@@ -3256,8 +3230,7 @@ dhcp_handlepacket(struct interface *ifp, uint8_t *data, size_t len, int flags)
        /* udp_len must be correct because the values are checked in
         * valid_udp_packet(). */
        if (udp_len < offsetof(struct bootp, vend)) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: truncated packet (%zu) from %s",
+               syslog(LOG_ERR, "%s: truncated packet (%zu) from %s",
                    ifp->name, udp_len, inet_ntoa(from));
                return;
        }
@@ -3288,8 +3261,8 @@ dhcp_readpacket(void *arg)
        while (!(flags & BPF_EOF)) {
                bytes = bpf_read(ifp, state->bpf_fd, buf,sizeof(buf), &flags);
                if (bytes == -1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: dhcp if_readrawpacket: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: dhcp if_readrawpacket: %m",
+                           ifp->name);
                        dhcp_close(ifp);
                        return;
                }
@@ -3308,7 +3281,7 @@ dhcp_handleudp(void *arg)
        /* Just read what's in the UDP fd and discard it as we always read
         * from the raw fd */
        if (read(ctx->udp_fd, buffer, sizeof(buffer)) == -1) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                eloop_event_delete(ctx->eloop, ctx->udp_fd);
                close(ctx->udp_fd);
                ctx->udp_fd = -1;
@@ -3326,13 +3299,12 @@ dhcp_open(struct interface *ifp)
                state->bpf_fd = bpf_open(ifp, bpf_bootp);
                if (state->bpf_fd == -1) {
                        if (errno == ENOENT) {
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s not found", bpf_name);
+                               syslog(LOG_ERR, "%s not found", bpf_name);
                                /* May as well disable IPv4 entirely at
                                 * this point as we really need it. */
                                ifp->options->options &= ~DHCPCD_IPV4;
                        } else
-                               logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
+                               syslog(LOG_ERR, "%s: %s: %m",
                                    __func__, ifp->name);
                        return -1;
                }
@@ -3355,7 +3327,7 @@ dhcp_dump(struct interface *ifp)
            AF_INET, ifp);
        state->new_len = read_lease(ifp, &state->new);
        if (state->new == NULL) {
-               logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
+               syslog(LOG_ERR, "%s: %s: %m",
                    *ifp->name ? ifp->name : state->leasefile, __func__);
                return -1;
        }
@@ -3363,7 +3335,7 @@ dhcp_dump(struct interface *ifp)
        return script_runreason(ifp, state->reason);
 
 eexit:
-       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+       syslog(LOG_ERR, "%s: %m", __func__);
        return -1;
 }
 
@@ -3478,16 +3450,16 @@ dhcp_init(struct interface *ifp)
                return 0;
 
        if (ifo->options & DHCPCD_CLIENTID)
-               logger(ifp->ctx, LOG_DEBUG, "%s: using ClientID %s", ifp->name,
+               syslog(LOG_DEBUG, "%s: using ClientID %s", ifp->name,
                    hwaddr_ntoa(state->clientid + 1, state->clientid[0],
                        buf, sizeof(buf)));
        else if (ifp->hwlen)
-               logger(ifp->ctx, LOG_DEBUG, "%s: using hwaddr %s", ifp->name,
+               syslog(LOG_DEBUG, "%s: using hwaddr %s", ifp->name,
                    hwaddr_ntoa(ifp->hwaddr, ifp->hwlen, buf, sizeof(buf)));
        return 0;
 
 eexit:
-       logger(ifp->ctx, LOG_ERR, "%s: error making ClientID: %m", __func__);
+       syslog(LOG_ERR, "%s: error making ClientID: %m", __func__);
        return -1;
 }
 
@@ -3512,15 +3484,15 @@ dhcp_start1(void *arg)
                        /* Don't log an error if some other process
                         * is handling this. */
                        if (errno != EADDRINUSE)
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: dhcp_openudp: %m", __func__);
+                               syslog(LOG_ERR, "%s: dhcp_openudp: %m",
+                                   __func__);
                } else
                        eloop_event_add(ifp->ctx->eloop,
                            ifp->ctx->udp_fd, dhcp_handleudp, ifp->ctx);
        }
 
        if (dhcp_init(ifp) == -1) {
-               logger(ifp->ctx, LOG_ERR, "%s: dhcp_init: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp_init: %m", ifp->name);
                return;
        }
 
@@ -3557,8 +3529,8 @@ dhcp_start1(void *arg)
                return;
        }
        if (ifp->hwlen == 0 && ifo->clientid[0] == '\0') {
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: needs a clientid to configure", ifp->name);
+               syslog(LOG_WARNING, "%s: needs a clientid to configure",
+                   ifp->name);
                dhcp_drop(ifp, "FAIL");
                eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
                return;
@@ -3612,7 +3584,7 @@ dhcp_start1(void *arg)
                                state->added |= STATE_ADDED | STATE_FAKE;
                                rt_build(ifp->ctx, AF_INET);
                        } else
-                               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                }
                if (!IS_DHCP(state->offer)) {
                        free(state->offer);
@@ -3629,7 +3601,7 @@ dhcp_start1(void *arg)
                        if (now == -1 ||
                            (time_t)state->lease.leasetime < now - st.st_mtime)
                        {
-                               logger(ifp->ctx, LOG_DEBUG,
+                               syslog(LOG_DEBUG,
                                    "%s: discarding expired lease", ifp->name);
                                free(state->offer);
                                state->offer = NULL;
@@ -3737,8 +3709,7 @@ dhcp_start(struct interface *ifp)
        tv.tv_nsec = (suseconds_t)arc4random_uniform(
            (DHCP_MAX_DELAY - DHCP_MIN_DELAY) * NSEC_PER_SEC);
        timespecnorm(&tv);
-       logger(ifp->ctx, LOG_DEBUG,
-           "%s: delaying IPv4 for %0.1f seconds",
+       syslog(LOG_DEBUG, "%s: delaying IPv4 for %0.1f seconds",
            ifp->name, timespec_to_double(&tv));
 
        eloop_timeout_add_tv(ifp->ctx->eloop, &tv, dhcp_start1, ifp);
@@ -3773,8 +3744,8 @@ dhcp_handleifa(int cmd, struct ipv4_addr *ia)
 
        if (cmd == RTM_DELADDR) {
                if (state->addr == ia) {
-                       logger(ifp->ctx, LOG_INFO,
-                           "%s: deleted IP address %s", ifp->name, ia->saddr);
+                       syslog(LOG_INFO, "%s: deleted IP address %s",
+                           ifp->name, ia->saddr);
                        state->addr = NULL;
                        /* Don't clear the added state as we need
                         * to drop the lease. */
index c0d18549eca1717c8e64744630da3fdd748319b7..bda1347b6bf8e118b85d7f6e88303845a1c42a84 100644 (file)
@@ -41,6 +41,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -215,8 +216,7 @@ dhcp6_makevendor(void *data, const struct interface *ifp)
        }
 
        if (len > UINT16_MAX) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: DHCPv6 Vendor Class too big", ifp->name);
+               syslog(LOG_ERR, "%s: DHCPv6 Vendor Class too big", ifp->name);
                return 0;
        }
 
@@ -437,7 +437,7 @@ dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp,
                ifp->if_data[IF_DATA_DHCP6] = calloc(1, sizeof(*state));
                state = D6_STATE(ifp);
                if (state == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
 
@@ -515,8 +515,7 @@ dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp,
        {
                sa = inet_ntop(AF_INET6, &prefix->prefix,
                    sabuf, sizeof(sabuf));
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: invalid prefix %s/%d + %d/%d: %m",
+               syslog(LOG_ERR, "%s: invalid prefix %s/%d + %d/%d: %m",
                    ifp->name, sa, prefix->prefix_len,
                    sla->sla, sla->prefix_len);
                return -1;
@@ -527,8 +526,7 @@ dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp,
        {
                sa = inet_ntop(AF_INET6, &prefix->prefix_exclude,
                    sabuf, sizeof(sabuf));
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: cannot delegate excluded prefix %s/%d",
+               syslog(LOG_ERR, "%s: cannot delegate excluded prefix %s/%d",
                    ifp->name, sa, prefix->prefix_exclude_len);
                return -1;
        }
@@ -753,8 +751,7 @@ dhcp6_makemessage(struct interface *ifp)
                        alen = -1;
                }
                if (alen == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: dhcp_auth_encode: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: dhcp_auth_encode: %m", ifp->name);
                else if (alen != 0) {
                        auth_len = (uint16_t)alen;
                        len += sizeof(o) + auth_len;
@@ -1085,8 +1082,7 @@ dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *))
        }
 
        if (!callback)
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: %s %s with xid 0x%02x%02x%02x",
+               syslog(LOG_DEBUG, "%s: %s %s with xid 0x%02x%02x%02x",
                    ifp->name,
                    broad_uni,
                    dhcp6_get_op(state->send->type),
@@ -1153,7 +1149,7 @@ dhcp6_sendmessage(struct interface *ifp, void (*callback)(void *))
 
 logsend:
                if (ifp->carrier != LINK_DOWN)
-                       logger(ifp->ctx, LOG_DEBUG,
+                       syslog(LOG_DEBUG,
                            "%s: %s %s (xid 0x%02x%02x%02x),"
                            " next in %0.1f seconds",
                            ifp->name,
@@ -1186,8 +1182,7 @@ logsend:
        if (ifp->options->auth.options & DHCPCD_AUTH_SEND &&
            dhcp6_update_auth(ifp, state->send, state->send_len) == -1)
        {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_updateauth: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_updateauth: %m", ifp->name);
                if (errno != ESRCH)
                        return -1;
        }
@@ -1211,8 +1206,7 @@ logsend:
        memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
        if (sendmsg(ctx->dhcp6_fd, &ctx->sndhdr, 0) == -1) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: %s: sendmsg: %m", ifp->name, __func__);
+               syslog(LOG_ERR, "%s: %s: sendmsg: %m", ifp->name, __func__);
                /* Allow DHCPv6 to continue .... the errors
                 * would be rate limited by the protocol.
                 * Generally the error is ENOBUFS when struggling to
@@ -1228,8 +1222,7 @@ logsend:
                        eloop_timeout_add_tv(ifp->ctx->eloop,
                            &state->RT, state->MRCcallback, ifp);
                else
-                       logger(ifp->ctx, LOG_WARNING,
-                           "%s: sent %d times with no reply",
+                       syslog(LOG_WARNING, "%s: sent %d times with no reply",
                            ifp->name, state->RTC);
        }
        return 0;
@@ -1309,8 +1302,7 @@ dhcp6_startrenew(void *arg)
        state->MRC = 0;
 
        if (dhcp6_makemessage(ifp) == -1)
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_makemessage: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_makemessage: %m", ifp->name);
        else
                dhcp6_sendrenew(ifp);
 }
@@ -1349,7 +1341,7 @@ dhcp6_dadcallback(void *arg)
        if (ap->flags & IPV6_AF_DUPLICATED)
                /* XXX FIXME
                 * We should decline the address */
-               logger(ap->iface->ctx, LOG_WARNING, "%s: DAD detected %s",
+               syslog(LOG_WARNING, "%s: DAD detected %s",
                    ap->iface->name, ap->saddr);
 
        if (!wascompleted) {
@@ -1370,8 +1362,8 @@ dhcp6_dadcallback(void *arg)
                                }
                        }
                        if (!wascompleted) {
-                               logger(ap->iface->ctx, LOG_DEBUG,
-                                   "%s: DHCPv6 DAD completed", ifp->name);
+                               syslog(LOG_DEBUG, "%s: DHCPv6 DAD completed",
+                                   ifp->name);
                                script_runreason(ifp,
                                    ap->delegating_prefix ?
                                    "DELEGATED6" : state->reason);
@@ -1401,7 +1393,7 @@ dhcp6_addrequestedaddrs(struct interface *ifp)
                        continue;
                a = calloc(1, sizeof(*a));
                if (a == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return;
                }
                a->flags = IPV6_AF_REQUEST;
@@ -1447,7 +1439,7 @@ dhcp6_startdiscover(void *arg)
 #ifndef SMALL
        dhcp6_delete_delegates(ifp);
 #endif
-       logger(ifp->ctx, LOG_INFO, "%s: soliciting a DHCPv6 lease", ifp->name);
+       syslog(LOG_INFO, "%s: soliciting a DHCPv6 lease", ifp->name);
        state = D6_STATE(ifp);
        state->state = DH6S_DISCOVER;
        state->RTC = 0;
@@ -1467,8 +1459,7 @@ dhcp6_startdiscover(void *arg)
        dhcp6_addrequestedaddrs(ifp);
 
        if (dhcp6_makemessage(ifp) == -1)
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_makemessage: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_makemessage: %m", ifp->name);
        else
                dhcp6_senddiscover(ifp);
 }
@@ -1479,8 +1470,7 @@ dhcp6_failconfirm(void *arg)
        struct interface *ifp;
 
        ifp = arg;
-       logger(ifp->ctx, LOG_ERR,
-           "%s: failed to confirm prior address", ifp->name);
+       syslog(LOG_ERR, "%s: failed to confirm prior address", ifp->name);
        /* Section 18.1.2 says that we SHOULD use the last known
         * IP address(s) and lifetimes if we didn't get a reply.
         * I disagree with this. */
@@ -1493,7 +1483,7 @@ dhcp6_failrequest(void *arg)
        struct interface *ifp;
 
        ifp = arg;
-       logger(ifp->ctx, LOG_ERR, "%s: failed to request address", ifp->name);
+       syslog(LOG_ERR, "%s: failed to request address", ifp->name);
        /* Section 18.1.1 says that client local policy dictates
         * what happens if a REQUEST fails.
         * Of the possible scenarios listed, moving back to the
@@ -1510,8 +1500,7 @@ dhcp6_failrebind(void *arg)
        struct interface *ifp;
 
        ifp = arg;
-       logger(ifp->ctx, LOG_ERR,
-           "%s: failed to rebind prior delegation", ifp->name);
+       syslog(LOG_ERR, "%s: failed to rebind prior delegation", ifp->name);
        dhcp6_delete_delegates(ifp);
        /* Section 18.1.2 says that we SHOULD use the last known
         * IP address(s) and lifetimes if we didn't get a reply.
@@ -1551,11 +1540,10 @@ dhcp6_startrebind(void *arg)
        eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendrenew, ifp);
        state = D6_STATE(ifp);
        if (state->state == DH6S_RENEW)
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: failed to renew DHCPv6, rebinding", ifp->name);
+               syslog(LOG_WARNING, "%s: failed to renew DHCPv6, rebinding",
+                   ifp->name);
        else
-               logger(ifp->ctx, LOG_INFO,
-                   "%s: rebinding prior DHCPv6 lease", ifp->name);
+               syslog(LOG_INFO, "%s: rebinding prior DHCPv6 lease", ifp->name);
        state->state = DH6S_REBIND;
        state->RTC = 0;
        state->MRC = 0;
@@ -1575,8 +1563,7 @@ dhcp6_startrebind(void *arg)
        }
 
        if (dhcp6_makemessage(ifp) == -1)
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_makemessage: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_makemessage: %m", ifp->name);
        else
                dhcp6_sendrebind(ifp);
 
@@ -1604,8 +1591,7 @@ dhcp6_startrequest(struct interface *ifp)
        state->MRCcallback = dhcp6_failrequest;
 
        if (dhcp6_makemessage(ifp) == -1) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_makemessage: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_makemessage: %m", ifp->name);
                return;
        }
 
@@ -1625,11 +1611,9 @@ dhcp6_startconfirm(struct interface *ifp)
        state->MRT = CNF_MAX_RT;
        state->MRC = 0;
 
-       logger(ifp->ctx, LOG_INFO,
-           "%s: confirming prior DHCPv6 lease", ifp->name);
+       syslog(LOG_INFO, "%s: confirming prior DHCPv6 lease", ifp->name);
        if (dhcp6_makemessage(ifp) == -1) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_makemessage: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_makemessage: %m", ifp->name);
                return;
        }
        dhcp6_sendconfirm(ifp);
@@ -1646,8 +1630,8 @@ dhcp6_startinform(void *arg)
        ifp = arg;
        state = D6_STATE(ifp);
        if (state->new == NULL || ifp->options->options & DHCPCD_DEBUG)
-               logger(ifp->ctx, LOG_INFO,
-                   "%s: requesting DHCPv6 information", ifp->name);
+               syslog(LOG_INFO, "%s: requesting DHCPv6 information",
+                   ifp->name);
        state->state = DH6S_INFORM;
        state->RTC = 0;
        state->IMD = INF_MAX_DELAY;
@@ -1656,8 +1640,7 @@ dhcp6_startinform(void *arg)
        state->MRC = 0;
 
        if (dhcp6_makemessage(ifp) == -1)
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_makemessage: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_makemessage: %m", ifp->name);
        else
                dhcp6_sendinform(ifp);
 }
@@ -1670,7 +1653,7 @@ dhcp6_startexpire(void *arg)
        ifp = arg;
        eloop_timeout_delete(ifp->ctx->eloop, dhcp6_sendrebind, ifp);
 
-       logger(ifp->ctx, LOG_ERR, "%s: DHCPv6 lease expired", ifp->name);
+       syslog(LOG_ERR, "%s: DHCPv6 lease expired", ifp->name);
        dhcp6_freedrop_addrs(ifp, 1, NULL);
 #ifndef SMALL
        dhcp6_delete_delegates(ifp);
@@ -1679,8 +1662,8 @@ dhcp6_startexpire(void *arg)
        if (ipv6nd_hasradhcp(ifp) || dhcp6_hasprefixdelegation(ifp))
                dhcp6_startdiscover(ifp);
        else
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: no advertising IPv6 router wants DHCP", ifp->name);
+               syslog(LOG_WARNING, "%s: no advertising IPv6 router wants DHCP",
+                   ifp->name);
 }
 
 static void
@@ -1719,8 +1702,7 @@ dhcp6_startrelease(struct interface *ifp)
 #endif
 
        if (dhcp6_makemessage(ifp) == -1)
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: dhcp6_makemessage: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_makemessage: %m", ifp->name);
        else {
                dhcp6_sendrelease(ifp);
                dhcp6_finishrelease(ifp);
@@ -1743,12 +1725,12 @@ dhcp6_checkstatusok(const struct interface *ifp,
        else
                farg = m;
        if ((opt = f(farg, len, D6_OPTION_STATUS_CODE, &opt_len)) == NULL) {
-               //logger(ifp->ctx, LOG_DEBUG, "%s: no status", ifp->name);
+               //syslog(LOG_DEBUG, "%s: no status", ifp->name);
                return 0;
        }
 
        if (opt_len < sizeof(code)) {
-               logger(ifp->ctx, LOG_ERR, "%s: status truncated", ifp->name);
+               syslog(LOG_ERR, "%s: status truncated", ifp->name);
                return -1;
        }
        memcpy(&code, opt, sizeof(code));
@@ -1769,7 +1751,7 @@ dhcp6_checkstatusok(const struct interface *ifp,
                }
        } else {
                if ((sbuf = malloc((size_t)opt_len + 1)) == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return false;
                }
                memcpy(sbuf, opt, opt_len);
@@ -1777,7 +1759,7 @@ dhcp6_checkstatusok(const struct interface *ifp,
                status = sbuf;
        }
 
-       logger(ifp->ctx, LOG_ERR, "%s: DHCPv6 REPLY: %s", ifp->name, status);
+       syslog(LOG_ERR, "%s: DHCPv6 REPLY: %s", ifp->name, status);
        free(sbuf);
        return -1;
 }
@@ -1839,8 +1821,8 @@ dhcp6_findna(struct interface *ifp, uint16_t ot, const uint8_t *iaid,
                d = nd;
                if (ol < 24) {
                        errno = EINVAL;
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: IA Address option truncated", ifp->name);
+                       syslog(LOG_ERR, "%s: IA Address option truncated",
+                           ifp->name);
                        continue;
                }
                memcpy(&ia, o, ol);
@@ -1849,7 +1831,7 @@ dhcp6_findna(struct interface *ifp, uint16_t ot, const uint8_t *iaid,
                /* RFC 3315 22.6 */
                if (ia.pltime > ia.vltime) {
                        errno = EINVAL;
-                       logger(ifp->ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "%s: IA Address pltime %"PRIu32" > vltime %"PRIu32,
                            ifp->name, ia.pltime, ia.vltime);
                        continue;
@@ -1861,7 +1843,7 @@ dhcp6_findna(struct interface *ifp, uint16_t ot, const uint8_t *iaid,
                if (a == NULL) {
                        a = calloc(1, sizeof(*a));
                        if (a == NULL) {
-                               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                break;
                        }
                        a->iface = ifp;
@@ -1932,8 +1914,8 @@ dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
                d = nd;
                if (ol < sizeof(pdp)) {
                        errno = EINVAL;
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: IA Prefix option truncated", ifp->name);
+                       syslog(LOG_ERR, "%s: IA Prefix option truncated",
+                           ifp->name);
                        continue;
                }
 
@@ -1943,7 +1925,7 @@ dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
                /* RFC 3315 22.6 */
                if (pdp.pltime > pdp.vltime) {
                        errno = EINVAL;
-                       logger(ifp->ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "%s: IA Prefix pltime %"PRIu32" > vltime %"PRIu32,
                            ifp->name, pdp.pltime, pdp.vltime);
                        continue;
@@ -1962,7 +1944,7 @@ dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
                if (a == NULL) {
                        a = calloc(1, sizeof(*a));
                        if (a == NULL) {
-                               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                break;
                        }
                        a->iface = ifp;
@@ -2019,8 +2001,7 @@ dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
                if (o == NULL)
                        continue;
                if (ol < 2) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: truncated PD Exclude", ifp->name);
+                       syslog(LOG_ERR, "%s: truncated PD Exclude", ifp->name);
                        continue;
                }
                a->prefix_exclude_len = *o++;
@@ -2028,8 +2009,8 @@ dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
                if (((a->prefix_exclude_len - a->prefix_len - 1) / NBBY) + 1
                    != ol)
                {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: PD Exclude length mismatch", ifp->name);
+                       syslog(LOG_ERR, "%s: PD Exclude length mismatch",
+                           ifp->name);
                        a->prefix_exclude_len = 0;
                        continue;
                }
@@ -2086,8 +2067,7 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l,
                o.len = ntohs(o.len);
                if (o.len > l || sizeof(o) + o.len > l) {
                        errno = EINVAL;
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: option overflow", ifp->name);
+                       syslog(LOG_ERR, "%s: option overflow", ifp->name);
                        break;
                }
                p = d + sizeof(o);
@@ -2108,8 +2088,7 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l,
                }
                if (o.len < nl) {
                        errno = EINVAL;
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: IA option truncated", ifp->name);
+                       syslog(LOG_ERR, "%s: IA option truncated", ifp->name);
                        continue;
                }
 
@@ -2125,16 +2104,14 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l,
                if (j == ifo->ia_len &&
                    !(ifo->ia_len == 0 && ifp->ctx->options & DHCPCD_DUMPLEASE))
                {
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: ignoring unrequested IAID %s",
+                       syslog(LOG_DEBUG, "%s: ignoring unrequested IAID %s",
                            ifp->name,
                            hwaddr_ntoa(ia.iaid, sizeof(ia.iaid),
                            buf, sizeof(buf)));
                        continue;
                }
                if ( j < ifo->ia_len && ifo->ia[j].ia_type != o.code) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: IAID %s: option type mismatch",
+                       syslog(LOG_ERR, "%s: IAID %s: option type mismatch",
                            ifp->name,
                            hwaddr_ntoa(ia.iaid, sizeof(ia.iaid),
                            buf, sizeof(buf)));
@@ -2146,10 +2123,11 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l,
                        ia.t2 = ntohl(ia.t2);
                        /* RFC 3315 22.4 */
                        if (ia.t2 > 0 && ia.t1 > ia.t2) {
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: IAID %s T1 (%d) > T2 (%d) from %s",
                                    ifp->name,
-                                   hwaddr_ntoa(iaid, sizeof(iaid), buf, sizeof(buf)),
+                                   hwaddr_ntoa(iaid, sizeof(iaid), buf,
+                                               sizeof(buf)),
                                    ia.t1, ia.t2, sfrom);
                                continue;
                        }
@@ -2164,7 +2142,7 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l,
                        if (dhcp6_findpd(ifp, ia.iaid, p, o.len,
                                         acquired) == 0)
                        {
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: %s: DHCPv6 REPLY missing Prefix",
                                    ifp->name, sfrom);
                                continue;
@@ -2174,7 +2152,7 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l,
                        if (dhcp6_findna(ifp, o.code, ia.iaid, p, o.len,
                                         acquired) == 0)
                        {
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: %s: DHCPv6 REPLY missing IA Address",
                                    ifp->name, sfrom);
                                continue;
@@ -2217,8 +2195,7 @@ dhcp6_validatelease(struct interface *ifp,
        struct timespec aq;
 
        if (len <= sizeof(*m)) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: DHCPv6 lease truncated", ifp->name);
+               syslog(LOG_ERR, "%s: DHCPv6 lease truncated", ifp->name);
                return -1;
        }
 
@@ -2235,8 +2212,8 @@ dhcp6_validatelease(struct interface *ifp,
        nia = dhcp6_findia(ifp, m, len, sfrom, acquired);
        if (nia == 0) {
                if (state->state != DH6S_CONFIRM && ok != 1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: no useable IA found in lease", ifp->name);
+                       syslog(LOG_ERR, "%s: no useable IA found in lease",
+                           ifp->name);
                        return -1;
                }
 
@@ -2259,12 +2236,12 @@ dhcp6_writelease(const struct interface *ifp)
        ssize_t bytes;
 
        state = D6_CSTATE(ifp);
-       logger(ifp->ctx, LOG_DEBUG,
-           "%s: writing lease `%s'", ifp->name, state->leasefile);
+       syslog(LOG_DEBUG, "%s: writing lease `%s'",
+           ifp->name, state->leasefile);
 
        fd = open(state->leasefile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
        if (fd == -1) {
-               logger(ifp->ctx, LOG_ERR, "%s: dhcp6_writelease: %m", ifp->name);
+               syslog(LOG_ERR, "%s: dhcp6_writelease: %m", ifp->name);
                return -1;
        }
        bytes = write(fd, state->new, state->new_len);
@@ -2290,11 +2267,11 @@ dhcp6_readlease(struct interface *ifp, int validate)
 
        state = D6_STATE(ifp);
        if (state->leasefile[0] == '\0') {
-               logger(ifp->ctx, LOG_DEBUG, "reading standard input");
+               syslog(LOG_DEBUG, "reading standard input");
                fd = fileno(stdin);
                fd_opened = false;
        } else {
-               logger(ifp->ctx, LOG_DEBUG, "%s: reading lease `%s'",
+               syslog(LOG_DEBUG, "%s: reading lease `%s'",
                    ifp->name, state->leasefile);
                fd = open(state->leasefile, O_RDONLY);
                if (fd != -1 && fstat(fd, &st) == -1) {
@@ -2340,8 +2317,7 @@ dhcp6_readlease(struct interface *ifp, int validate)
            state->leasefile[0] != '\0')
        {
                if ((time_t)state->expire < now - st.st_mtime) {
-                       logger(ifp->ctx,
-                           LOG_DEBUG,"%s: discarding expired lease",
+                       syslog(LOG_DEBUG,"%s: discarding expired lease",
                            ifp->name);
                        retval = 0;
                        goto ex;
@@ -2358,24 +2334,21 @@ auth:
                    (uint8_t *)state->new, state->new_len, 6, state->new->type,
                    o, ol) == NULL)
                {
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: dhcp_auth_validate: %m", ifp->name);
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: authentication failed", ifp->name);
+                       syslog(LOG_DEBUG, "%s: dhcp_auth_validate: %m",
+                           ifp->name);
+                       syslog(LOG_ERR, "%s: authentication failed", ifp->name);
                        goto ex;
                }
                if (state->auth.token)
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: validated using 0x%08" PRIu32,
+                       syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
                            ifp->name, state->auth.token->secretid);
                else
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: accepted reconfigure key", ifp->name);
+                       syslog(LOG_INFO, "%s: accepted reconfigure key",
+                           ifp->name);
        } else if ((ifp->options->auth.options & DHCPCD_AUTH_SENDREQUIRE) ==
            DHCPCD_AUTH_SENDREQUIRE)
        {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: authentication now required", ifp->name);
+               syslog(LOG_ERR, "%s: authentication now required", ifp->name);
                goto ex;
        }
 #endif
@@ -2425,8 +2398,7 @@ dhcp6_startinit(struct interface *ifp)
                r = dhcp6_readlease(ifp, 1);
                if (r == -1) {
                        if (errno != ENOENT)
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: dhcp6_readlease: %s: %m",
+                               syslog(LOG_ERR, "%s: dhcp6_readlease: %s: %m",
                                    ifp->name, state->leasefile);
                } else if (r != 0) {
                        /* RFC 3633 section 12.1 */
@@ -2460,7 +2432,7 @@ dhcp6_ifdelegateaddr(struct interface *ifp, struct ipv6_addr *prefix,
                if (prefix->prefix_exclude_len == 0) {
                        /* Don't spam the log automatically */
                        if (sla)
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: DHCPv6 server does not support "
                                    "OPTION_PD_EXCLUDE",
                                    ifp->name);
@@ -2473,8 +2445,7 @@ dhcp6_ifdelegateaddr(struct interface *ifp, struct ipv6_addr *prefix,
                return NULL;
 
        if (fls64(sla->suffix) > 128 - pfxlen) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: suffix %" PRIu64 " + prefix_len %d > 128",
+               syslog(LOG_ERR, "%s: suffix %" PRIu64 " + prefix_len %d > 128",
                    ifp->name, sla->suffix, pfxlen);
                return NULL;
        }
@@ -2488,7 +2459,7 @@ dhcp6_ifdelegateaddr(struct interface *ifp, struct ipv6_addr *prefix,
        } else {
                dadcounter = ipv6_makeaddr(&daddr, ifp, &addr, pfxlen);
                if (dadcounter == -1) {
-                       logger(ifp->ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "%s: error adding slaac to prefix_len %d",
                            ifp->name, pfxlen);
                        return NULL;
@@ -2504,7 +2475,7 @@ dhcp6_ifdelegateaddr(struct interface *ifp, struct ipv6_addr *prefix,
        if (ia == NULL) {
                ia = calloc(1, sizeof(*ia));
                if (ia == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return NULL;
                }
                ia->iface = ifp;
@@ -2553,7 +2524,8 @@ dhcp6_script_try_run(struct interface *ifp, int delegated)
                        continue;
                if (ap->flags & IPV6_AF_ONLINK) {
                        if (!(ap->flags & IPV6_AF_DADCOMPLETED) &&
-                           ipv6_iffindaddr(ap->iface, &ap->addr, IN6_IFF_TENTATIVE))
+                           ipv6_iffindaddr(ap->iface, &ap->addr,
+                                           IN6_IFF_TENTATIVE))
                                ap->flags |= IPV6_AF_DADCOMPLETED;
                        if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0 &&
                            ((delegated && ap->delegating_prefix) ||
@@ -2569,8 +2541,8 @@ dhcp6_script_try_run(struct interface *ifp, int delegated)
                if (!delegated)
                        dhcpcd_daemonise(ifp->ctx);
        } else
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: waiting for DHCPv6 DAD to complete", ifp->name);
+               syslog(LOG_DEBUG, "%s: waiting for DHCPv6 DAD to complete",
+                   ifp->name);
 }
 
 #ifdef SMALL
@@ -2613,8 +2585,8 @@ dhcp6_delegate_prefix(struct interface *ifp)
                                /* We only want to log this the once as we loop
                                 * through many interfaces first. */
                                ap->flags |= IPV6_AF_DELEGATEDLOG;
-                               logger(ifp->ctx,
-                                   ap->flags & IPV6_AF_NEW ?LOG_INFO:LOG_DEBUG,
+                               syslog(ap->flags & IPV6_AF_NEW ?
+                                   LOG_INFO : LOG_DEBUG,
                                    "%s: delegated prefix %s",
                                    ifp->name, ap->saddr);
                                ap->flags &= ~IPV6_AF_NEW;
@@ -2628,7 +2600,7 @@ dhcp6_delegate_prefix(struct interface *ifp)
                                        /* no SLA configured, so lets
                                         * automate it */
                                        if (ifd->carrier != LINK_UP) {
-                                               logger(ifp->ctx, LOG_DEBUG,
+                                               syslog(LOG_DEBUG,
                                                    "%s: has no carrier, cannot"
                                                    " delegate addresses",
                                                    ifd->name);
@@ -2644,7 +2616,7 @@ dhcp6_delegate_prefix(struct interface *ifp)
                                        if (strcmp(ifd->name, sla->ifname))
                                                continue;
                                        if (ifd->carrier != LINK_UP) {
-                                               logger(ifp->ctx, LOG_DEBUG,
+                                               syslog(LOG_DEBUG,
                                                    "%s: has no carrier, cannot"
                                                    " delegate addresses",
                                                    ifd->name);
@@ -2708,7 +2680,7 @@ dhcp6_find_delegates(struct interface *ifp)
                                        if (strcmp(ifp->name, sla->ifname))
                                                continue;
                                        if (ipv6_linklocal(ifp) == NULL) {
-                                               logger(ifp->ctx, LOG_DEBUG,
+                                               syslog(LOG_DEBUG,
                                                    "%s: delaying adding"
                                                    " delegated addresses for"
                                                    " LL address",
@@ -2726,8 +2698,7 @@ dhcp6_find_delegates(struct interface *ifp)
        }
 
        if (k) {
-               logger(ifp->ctx, LOG_INFO,
-                   "%s: adding delegated prefixes", ifp->name);
+               syslog(LOG_INFO, "%s: adding delegated prefixes", ifp->name);
                state = D6_STATE(ifp);
                state->state = DH6S_DELEGATED;
                ipv6_addaddrs(&state->addrs);
@@ -2768,7 +2739,7 @@ dhcp6_handledata(void *arg)
        ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
        bytes = recvmsg_realloc(ctx->dhcp6_fd, &ctx->rcvhdr, 0);
        if (bytes == -1) {
-               logger(ctx, LOG_ERR, "%s: recvmsg: %m", __func__);
+               syslog(LOG_ERR, "%s: recvmsg: %m", __func__);
                close(ctx->dhcp6_fd);
                eloop_event_delete(ctx->eloop, ctx->dhcp6_fd);
                ctx->dhcp6_fd = -1;
@@ -2778,8 +2749,7 @@ dhcp6_handledata(void *arg)
        ctx->sfrom = inet_ntop(AF_INET6, &ctx->from.sin6_addr,
            ctx->ntopbuf, sizeof(ctx->ntopbuf));
        if (len < sizeof(struct dhcp6_message)) {
-               logger(ctx, LOG_ERR,
-                   "DHCPv6 packet too short from %s", ctx->sfrom);
+               syslog(LOG_ERR, "DHCPv6 packet too short from %s", ctx->sfrom);
                return;
        }
 
@@ -2798,8 +2768,8 @@ dhcp6_handledata(void *arg)
                }
        }
        if (pkt.ipi6_ifindex == 0) {
-               logger(ctx, LOG_ERR,
-                   "DHCPv6 reply did not contain index from %s", ctx->sfrom);
+               syslog(LOG_ERR, "DHCPv6 reply did not contain index from %s",
+                   ctx->sfrom);
                return;
        }
 
@@ -2810,7 +2780,7 @@ dhcp6_handledata(void *arg)
                        break;
        }
        if (ifp == NULL) {
-               logger(ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "DHCPv6 reply for unexpected interface from %s",
                    ctx->sfrom);
                return;
@@ -2818,8 +2788,8 @@ dhcp6_handledata(void *arg)
 
        state = D6_STATE(ifp);
        if (state == NULL || state->send == NULL) {
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: DHCPv6 reply received but not running", ifp->name);
+               syslog(LOG_DEBUG, "%s: DHCPv6 reply received but not running",
+                   ifp->name);
                return;
        }
 
@@ -2827,10 +2797,10 @@ dhcp6_handledata(void *arg)
        /* We're already bound and this message is for another machine */
        /* XXX DELEGATED? */
        if (r->type != DHCP6_RECONFIGURE &&
-           (state->state == DH6S_BOUND || state->state == DH6S_INFORMED)) 
+           (state->state == DH6S_BOUND || state->state == DH6S_INFORMED))
        {
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: DHCPv6 reply received but already bound", ifp->name);
+               syslog(LOG_DEBUG, "%s: DHCPv6 reply received but already bound",
+                   ifp->name);
                return;
        }
 
@@ -2839,8 +2809,7 @@ dhcp6_handledata(void *arg)
            r->xid[1] != state->send->xid[1] ||
            r->xid[2] != state->send->xid[2]))
        {
-               logger(ctx, LOG_DEBUG,
-                   "%s: wrong xid 0x%02x%02x%02x"
+               syslog(LOG_DEBUG, "%s: wrong xid 0x%02x%02x%02x"
                    " (expecting 0x%02x%02x%02x) from %s",
                    ifp->name,
                    r->xid[0], r->xid[1], r->xid[2],
@@ -2851,7 +2820,7 @@ dhcp6_handledata(void *arg)
        }
 
        if (dhcp6_findmoption(r, len, D6_OPTION_SERVERID, NULL) == NULL) {
-               logger(ifp->ctx, LOG_DEBUG, "%s: no DHCPv6 server ID from %s",
+               syslog(LOG_DEBUG, "%s: no DHCPv6 server ID from %s",
                    ifp->name, ctx->sfrom);
                return;
        }
@@ -2860,7 +2829,7 @@ dhcp6_handledata(void *arg)
        if (o == NULL || ol != ctx->duid_len ||
            memcmp(o, ctx->duid, ol) != 0)
        {
-               logger(ifp->ctx, LOG_DEBUG, "%s: incorrect client ID from %s",
+               syslog(LOG_DEBUG, "%s: incorrect client ID from %s",
                    ifp->name, ctx->sfrom);
                return;
        }
@@ -2873,7 +2842,7 @@ dhcp6_handledata(void *arg)
                if (has_option_mask(ifo->requiremask6, opt->option) &&
                    !dhcp6_findmoption(r, len, (uint16_t)opt->option, NULL))
                {
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "%s: reject DHCPv6 (no option %s) from %s",
                            ifp->name, opt->var, ctx->sfrom);
                        return;
@@ -2881,7 +2850,7 @@ dhcp6_handledata(void *arg)
                if (has_option_mask(ifo->rejectmask6, opt->option) &&
                    dhcp6_findmoption(r, len, (uint16_t)opt->option, NULL))
                {
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "%s: reject DHCPv6 (option %s) from %s",
                            ifp->name, opt->var, ctx->sfrom);
                        return;
@@ -2895,28 +2864,26 @@ dhcp6_handledata(void *arg)
                if (dhcp_auth_validate(&state->auth, &ifo->auth,
                    (uint8_t *)r, len, 6, r->type, auth, auth_len) == NULL)
                {
-                       logger(ifp->ctx, LOG_DEBUG, "dhcp_auth_validate: %m");
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: authentication failed from %s",
+                       syslog(LOG_DEBUG, "dhcp_auth_validate: %m");
+                       syslog(LOG_ERR, "%s: authentication failed from %s",
                            ifp->name, ctx->sfrom);
                        return;
                }
                if (state->auth.token)
-                       logger(ifp->ctx, LOG_DEBUG,
+                       syslog(LOG_DEBUG,
                            "%s: validated using 0x%08" PRIu32,
                            ifp->name, state->auth.token->secretid);
                else
-                       logger(ifp->ctx, LOG_DEBUG,
+                       syslog(LOG_INFO,
                            "%s: accepted reconfigure key", ifp->name);
        } else if (ifo->auth.options & DHCPCD_AUTH_SEND) {
                if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: no authentication from %s",
+                       syslog(LOG_ERR, "%s: no authentication from %s",
                            ifp->name, ctx->sfrom);
                        return;
                }
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: no authentication from %s", ifp->name, ctx->sfrom);
+               syslog(LOG_WARNING, "%s: no authentication from %s",
+                   ifp->name, ctx->sfrom);
        }
 #else
        auth = NULL;
@@ -3000,14 +2967,13 @@ dhcp6_handledata(void *arg)
                        memcpy(&max_rt, o, sizeof(max_rt));
                        max_rt = ntohl(max_rt);
                        if (max_rt >= 60 && max_rt <= 86400) {
-                               logger(ifp->ctx, LOG_DEBUG,
-                                   "%s: SOL_MAX_RT %llu -> %u", ifp->name,
+                               syslog(LOG_DEBUG, "%s: SOL_MAX_RT %llu -> %u",
+                                   ifp->name,
                                    (unsigned long long)state->sol_max_rt,
                                    max_rt);
                                state->sol_max_rt = (time_t)max_rt;
                        } else
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: invalid SOL_MAX_RT %u",
+                               syslog(LOG_ERR, "%s: invalid SOL_MAX_RT %u",
                                    ifp->name, max_rt);
                }
                o = dhcp6_findmoption(r, len, D6_OPTION_INF_MAX_RT, &ol);
@@ -3017,15 +2983,13 @@ dhcp6_handledata(void *arg)
                        memcpy(&max_rt, o, sizeof(max_rt));
                        max_rt = ntohl(max_rt);
                        if (max_rt >= 60 && max_rt <= 86400) {
-                               logger(ifp->ctx, LOG_DEBUG,
-                                   "%s: INF_MAX_RT %llu -> %u",
+                               syslog(LOG_DEBUG, "%s: INF_MAX_RT %llu -> %u",
                                    ifp->name,
                                    (unsigned long long)state->inf_max_rt,
                                    max_rt);
                                state->inf_max_rt = (time_t)max_rt;
                        } else
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: invalid INF_MAX_RT %u",
+                               syslog(LOG_ERR, "%s: invalid INF_MAX_RT %u",
                                    ifp->name, max_rt);
                }
                if (dhcp6_validatelease(ifp, r, len, ctx->sfrom, NULL) == -1)
@@ -3033,31 +2997,29 @@ dhcp6_handledata(void *arg)
                break;
        case DHCP6_RECONFIGURE:
                if (auth == NULL) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: unauthenticated %s from %s",
+                       syslog(LOG_ERR, "%s: unauthenticated %s from %s",
                            ifp->name, op, ctx->sfrom);
                        if (ifo->auth.options & DHCPCD_AUTH_REQUIRE)
                                return;
                }
-               logger(ifp->ctx, LOG_INFO, "%s: %s from %s",
+               syslog(LOG_INFO, "%s: %s from %s",
                    ifp->name, op, ctx->sfrom);
                o = dhcp6_findmoption(r, len, D6_OPTION_RECONF_MSG, &ol);
                if (o == NULL) {
-                       logger(ifp->ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "%s: missing Reconfigure Message option",
                            ifp->name);
                        return;
                }
                if (ol != 1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: missing Reconfigure Message type", ifp->name);
+                       syslog(LOG_ERR, "%s: missing Reconfigure Message type",
+                           ifp->name);
                        return;
                }
                switch(*o) {
                case DHCP6_RENEW:
                        if (state->state != DH6S_BOUND) {
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: not bound, ignoring %s",
+                               syslog(LOG_ERR, "%s: not bound, ignoring %s",
                                    ifp->name, op);
                                return;
                        }
@@ -3065,8 +3027,7 @@ dhcp6_handledata(void *arg)
                        break;
                case DHCP6_INFORMATION_REQ:
                        if (state->state != DH6S_INFORMED) {
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: not informed, ignoring %s",
+                               syslog(LOG_ERR, "%s: not informed, ignoring %s",
                                    ifp->name, op);
                                return;
                        }
@@ -3075,20 +3036,18 @@ dhcp6_handledata(void *arg)
                        dhcp6_startinform(ifp);
                        break;
                default:
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: unsupported %s type %d",
+                       syslog(LOG_ERR, "%s: unsupported %s type %d",
                            ifp->name, op, *o);
                        break;
                }
                return;
        default:
-               logger(ifp->ctx, LOG_ERR, "%s: invalid DHCP6 type %s (%d)",
+               syslog(LOG_ERR, "%s: invalid DHCP6 type %s (%d)",
                    ifp->name, op, r->type);
                return;
        }
        if (!valid_op) {
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: invalid state for DHCP6 type %s (%d)",
+               syslog(LOG_WARNING, "%s: invalid state for DHCP6 type %s (%d)",
                    ifp->name, op, r->type);
                return;
        }
@@ -3097,8 +3056,7 @@ dhcp6_handledata(void *arg)
                free(state->recv);
                state->recv = malloc(len);
                if (state->recv == NULL) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: malloc recv: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: malloc recv: %m", ifp->name);
                        return;
                }
        }
@@ -3115,7 +3073,7 @@ dhcp6_handledata(void *arg)
                }
                if (ap == NULL)
                        ap = TAILQ_FIRST(&state->addrs);
-               logger(ifp->ctx, LOG_INFO, "%s: ADV %s from %s",
+               syslog(LOG_INFO, "%s: ADV %s from %s",
                    ifp->name, ap->saddr, ctx->sfrom);
                if (ifp->ctx->options & DHCPCD_TEST)
                        break;
@@ -3130,7 +3088,7 @@ dhcp6_handledata(void *arg)
                        break;
                }
        }
-       logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
+       syslog(has_new ? LOG_INFO : LOG_DEBUG,
            "%s: %s received from %s", ifp->name, op, ctx->sfrom);
 
        state->reason = NULL;
@@ -3164,7 +3122,7 @@ dhcp6_handledata(void *arg)
                                if (ap->flags & IPV6_AF_STALE)
                                        continue;
                                if (ap->prefix_vltime <= state->renew)
-                                       logger(ifp->ctx, LOG_WARNING,
+                                       syslog(LOG_WARNING,
                                            "%s: %s will expire before renewal",
                                            ifp->name, ap->saddr);
                                else
@@ -3183,7 +3141,7 @@ dhcp6_handledata(void *arg)
                                 * and T2 fields for the T1 and T2 parameters,
                                 * unless those values in those fields are 0.
                                 */
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: ignoring T1 %"PRIu32
                                    " to due address expiry",
                                    ifp->name, state->renew);
@@ -3232,18 +3190,18 @@ dhcp6_handledata(void *arg)
                ipv6_addaddrs(&state->addrs);
 
                if (state->state == DH6S_INFORMED)
-                       logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
+                       syslog(has_new ? LOG_INFO : LOG_DEBUG,
                            "%s: refresh in %"PRIu32" seconds",
                            ifp->name, state->renew);
                else if (state->renew || state->rebind)
-                       logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
+                       syslog(has_new ? LOG_INFO : LOG_DEBUG,
                            "%s: renew in %"PRIu32", "
                            "rebind in %"PRIu32", "
                            "expire in %"PRIu32" seconds",
                            ifp->name,
                            state->renew, state->rebind, state->expire);
                else if (state->expire == 0)
-                       logger(ifp->ctx, has_new ? LOG_INFO : LOG_DEBUG,
+                       syslog(has_new ? LOG_INFO : LOG_DEBUG,
                            "%s: will expire", ifp->name);
                if_initrt(ifp->ctx, AF_INET6);
                rt_build(ifp->ctx, AF_INET6);
@@ -3295,7 +3253,7 @@ dhcp6_open(struct dhcpcd_ctx *ctx)
        n = 1;
        if (setsockopt(ctx->dhcp6_fd, SOL_SOCKET, SO_REUSEPORT,
            &n, sizeof(n)) == -1)
-               logger(ctx, LOG_WARNING, "setsockopt: SO_REUSEPORT: %m");
+               syslog(LOG_WARNING, "setsockopt: SO_REUSEPORT: %m");
 #endif
 
        if (!(ctx->options & DHCPCD_MASTER)) {
@@ -3346,13 +3304,13 @@ dhcp6_activateinterfaces(struct interface *ifp)
                        sla = &ia->sla[j];
                        ifd = if_find(ifp->ctx->ifaces, sla->ifname);
                        if (ifd == NULL) {
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: cannot delegate to %s: %m",
                                    ifp->name, sla->ifname);
                                continue;
                        }
                        if (!ifd->active) {
-                               logger(ifp->ctx, LOG_INFO,
+                               syslog(LOG_INFO,
                                    "%s: activating for delegation",
                                    sla->ifname);
                                dhcpcd_activateinterface(ifd,
@@ -3459,7 +3417,7 @@ gogogo:
        dhcp_set_leasefile(state->leasefile, sizeof(state->leasefile),
            AF_INET6, ifp);
        if (ipv6_linklocal(ifp) == NULL) {
-               logger(ifp->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: delaying DHCPv6 soliciation for LL address",
                    ifp->name);
                ipv6_addlinklocalcallback(ifp, dhcp6_start1, ifp);
@@ -3677,7 +3635,7 @@ dhcp6_env(char **env, const char *prefix, const struct interface *ifp,
                i = strlen(prefix) + strlen("_dhcp6") + 1;
                pfx = malloc(i);
                if (pfx == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                snprintf(pfx, i, "%s_dhcp6", prefix);
@@ -3757,7 +3715,7 @@ delegated:
                i += strlen(prefix) + strlen("_delegated_dhcp6_prefix=");
                 v = val = env[n] = malloc(i);
                if (v == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                v += snprintf(val, i, "%s_delegated_dhcp6_prefix=", prefix);
@@ -3787,14 +3745,14 @@ dhcp6_dump(struct interface *ifp)
 
        ifp->if_data[IF_DATA_DHCP6] = state = calloc(1, sizeof(*state));
        if (state == NULL) {
-               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return -1;
        }
        TAILQ_INIT(&state->addrs);
        dhcp_set_leasefile(state->leasefile, sizeof(state->leasefile),
            AF_INET6, ifp);
        if (dhcp6_readlease(ifp, 0) == -1) {
-               logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
+               syslog(LOG_ERR, "%s: %s: %m",
                    *ifp->name ? ifp->name : state->leasefile, __func__);
                return -1;
        }
index 2d21e5d57c52dfd8c7e8adf9617da22cb02fdf6c..0e8720e6d1f04a7a35ae662dde8dc53b7486cea9 100644 (file)
@@ -44,6 +44,7 @@ const char dhcpcd_copyright[] = "Copyright (c) 2006-2017 Roy Marples";
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 #include <time.h>
 
@@ -172,7 +173,7 @@ handle_exit_timeout(void *arg)
        struct dhcpcd_ctx *ctx;
 
        ctx = arg;
-       logger(ctx, LOG_ERR, "timed out");
+       syslog(LOG_ERR, "timed out");
        if (!(ctx->options & DHCPCD_MASTER)) {
                eloop_exit(ctx->eloop, EXIT_FAILURE);
                return;
@@ -257,7 +258,7 @@ dhcpcd_ipwaited(struct dhcpcd_ctx *ctx)
 
        TAILQ_FOREACH(ifp, ctx->ifaces, next) {
                if ((af = dhcpcd_ifafwaiting(ifp)) != AF_MAX) {
-                       logger(ctx, LOG_DEBUG,
+                       syslog(LOG_DEBUG,
                            "%s: waiting for an %s address",
                            ifp->name, dhcpcd_af(af));
                        return 0;
@@ -265,7 +266,7 @@ dhcpcd_ipwaited(struct dhcpcd_ctx *ctx)
        }
 
        if ((af = dhcpcd_afwaiting(ctx)) != AF_MAX) {
-               logger(ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "waiting for an %s address",
                    dhcpcd_af(af));
                return 0;
@@ -295,7 +296,7 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
        }
 
        if (ctx->options & DHCPCD_ONESHOT) {
-               logger(ctx, LOG_INFO, "exiting due to oneshot");
+               syslog(LOG_INFO, "exiting due to oneshot");
                eloop_exit(ctx->eloop, EXIT_SUCCESS);
                return 0;
        }
@@ -304,11 +305,11 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
        if (ctx->options & DHCPCD_DAEMONISED ||
            !(ctx->options & DHCPCD_DAEMONISE))
                return 0;
-       logger(ctx, LOG_DEBUG, "forking to background");
+       syslog(LOG_DEBUG, "forking to background");
 
        /* Setup a signal pipe so parent knows when to exit. */
        if (pipe(sidpipe) == -1) {
-               logger(ctx, LOG_ERR, "pipe: %m");
+               syslog(LOG_ERR, "pipe: %m");
                return 0;
        }
 
@@ -321,22 +322,22 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
 
        switch (pid = fork()) {
        case -1:
-               logger(ctx, LOG_ERR, "fork: %m");
+               syslog(LOG_ERR, "fork: %m");
                return 0;
        case 0:
                if ((lpid = pidfile_lock(ctx->pidfile)) != 0)
-                       logger(ctx, LOG_ERR, "%s: pidfile_lock %d: %m",
+                       syslog(LOG_ERR, "%s: pidfile_lock %d: %m",
                            __func__, lpid);
                setsid();
                /* Notify parent it's safe to exit as we've detached. */
                close(sidpipe[0]);
                if (write(sidpipe[1], &buf, 1) == -1)
-                       logger(ctx, LOG_ERR, "failed to notify parent: %m");
+                       syslog(LOG_ERR, "failed to notify parent: %m");
                close(sidpipe[1]);
                /* Some polling methods don't survive after forking,
                 * so ensure we can requeue all our events. */
                if (eloop_requeue(ctx->eloop) == -1) {
-                       logger(ctx, LOG_ERR, "eloop_requeue: %m");
+                       syslog(LOG_ERR, "eloop_requeue: %m");
                        eloop_exit(ctx->eloop, EXIT_FAILURE);
                }
                if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
@@ -351,9 +352,9 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
                /* Wait for child to detach */
                close(sidpipe[1]);
                if (read(sidpipe[0], &buf, 1) == -1)
-                       logger(ctx, LOG_ERR, "failed to read child: %m");
+                       syslog(LOG_ERR, "failed to read child: %m");
                close(sidpipe[0]);
-               logger(ctx, LOG_INFO, "forked to background, child pid %d", pid);
+               syslog(LOG_INFO, "forked to background, child pid %d", pid);
                ctx->options |= DHCPCD_FORKED;
                eloop_exit(ctx->eloop, EXIT_SUCCESS);
                return pid;
@@ -379,7 +380,7 @@ stop_interface(struct interface *ifp)
        struct dhcpcd_ctx *ctx;
 
        ctx = ifp->ctx;
-       logger(ctx, LOG_INFO, "%s: removing interface", ifp->name);
+       syslog(LOG_INFO, "%s: removing interface", ifp->name);
        ifp->options->options |= DHCPCD_STOPPING;
 
        dhcpcd_drop(ifp, 1);
@@ -526,7 +527,7 @@ configure_interface1(struct interface *ifp)
        {
                ifo->ia = malloc(sizeof(*ifo->ia));
                if (ifo->ia == NULL)
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                else {
                        ifo->ia_len = 1;
                        ifo->ia->ia_type = D6_OPTION_IA_NA;
@@ -559,21 +560,19 @@ dhcpcd_selectprofile(struct interface *ifp, const char *profile)
                r = print_string(pssid, sizeof(pssid), OT_ESCSTRING,
                    ifp->ssid, ifp->ssid_len);
                if (r == -1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: %s: %m", ifp->name, __func__);
+                       syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__);
                        pssid[0] = '\0';
                }
        } else
                pssid[0] = '\0';
        ifo = read_config(ifp->ctx, ifp->name, pssid, profile);
        if (ifo == NULL) {
-               logger(ifp->ctx, LOG_DEBUG, "%s: no profile %s",
-                   ifp->name, profile);
+               syslog(LOG_DEBUG, "%s: no profile %s", ifp->name, profile);
                return -1;
        }
        if (profile != NULL) {
                strlcpy(ifp->profile, profile, sizeof(ifp->profile));
-               logger(ifp->ctx, LOG_INFO, "%s: selected profile %s",
+               syslog(LOG_INFO, "%s: selected profile %s",
                    ifp->name, profile);
        } else
                *ifp->profile = '\0';
@@ -607,7 +606,7 @@ configure_interface(struct interface *ifp, int argc, char **argv,
 
        /* If the mtime has changed drop any old lease */
        if (old != 0 && ifp->options->mtime != old) {
-               logger(ifp->ctx, LOG_WARNING,
+               syslog(LOG_WARNING,
                    "%s: confile file changed, expiring leases", ifp->name);
                dhcpcd_drop(ifp, 0);
        }
@@ -639,8 +638,7 @@ dhcpcd_initstate2(struct interface *ifp, unsigned long long options)
 
        if (options) {
                if ((ifo = default_config(ifp->ctx)) == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %s: %m",
-                           ifp->name, __func__);
+                       syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__);
                        return;
                }
                ifo->options |= options;
@@ -650,7 +648,7 @@ dhcpcd_initstate2(struct interface *ifp, unsigned long long options)
                ifo = ifp->options;
 
        if (ifo->options & DHCPCD_IPV6 && ipv6_init(ifp->ctx) == -1) {
-               logger(ifp->ctx, LOG_ERR, "ipv6_init: %m");
+               syslog(LOG_ERR, "ipv6_init: %m");
                ifo->options &= ~DHCPCD_IPV6;
        }
 }
@@ -709,12 +707,11 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags,
 
        if (carrier == LINK_UNKNOWN) {
                if (errno != ENOTTY) /* For example a PPP link on BSD */
-                       logger(ctx, LOG_ERR, "%s: carrier_status: %m", ifname);
+                       syslog(LOG_ERR, "%s: carrier_status: %m", ifname);
        } else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
                if (ifp->carrier != LINK_DOWN) {
                        if (ifp->carrier == LINK_UP)
-                               logger(ctx, LOG_INFO, "%s: carrier lost",
-                                   ifp->name);
+                               syslog(LOG_INFO, "%s: carrier lost", ifp->name);
                        ifp->carrier = LINK_DOWN;
                        script_runreason(ifp, "NOCARRIER");
 #ifdef NOCARRIER_PRESERVE_IP
@@ -729,8 +726,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags,
                }
        } else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
                if (ifp->carrier != LINK_UP) {
-                       logger(ctx, LOG_INFO, "%s: carrier acquired",
-                           ifp->name);
+                       syslog(LOG_INFO, "%s: carrier acquired", ifp->name);
                        ifp->carrier = LINK_UP;
 #if !defined(__linux__) && !defined(__NetBSD__)
                        /* BSD does not emit RTM_NEWADDR or RTM_CHGADDR when the
@@ -791,7 +787,7 @@ warn_iaid_conflict(struct interface *ifp, uint8_t *iaid)
 
        /* This is only a problem if the interfaces are on the same network. */
        if (ifn)
-               logger(ifp->ctx, LOG_ERR,
+               syslog(LOG_ERR,
                    "%s: IAID conflicts with one assigned to %s",
                    ifp->name, ifn->name);
 }
@@ -811,8 +807,7 @@ dhcpcd_startinterface(void *arg)
                case LINK_UP:
                        break;
                case LINK_DOWN:
-                       logger(ifp->ctx, LOG_INFO, "%s: waiting for carrier",
-                           ifp->name);
+                       syslog(LOG_INFO, "%s: waiting for carrier", ifp->name);
                        return;
                case LINK_UNKNOWN:
                        /* No media state available.
@@ -834,7 +829,7 @@ dhcpcd_startinterface(void *arg)
                if (ifp->ctx->duid == NULL) {
                        if (duid_init(ifp) == 0)
                                return;
-                       logger(ifp->ctx, LOG_INFO, "DUID %s",
+                       syslog(LOG_INFO, "DUID %s",
                            hwaddr_ntoa(ifp->ctx->duid,
                            ifp->ctx->duid_len,
                            buf, sizeof(buf)));
@@ -843,7 +838,7 @@ dhcpcd_startinterface(void *arg)
 
        if (ifo->options & (DHCPCD_DUID | DHCPCD_IPV6)) {
                /* Report IAIDs */
-               logger(ifp->ctx, LOG_INFO, "%s: IAID %s", ifp->name,
+               syslog(LOG_INFO, "%s: IAID %s", ifp->name,
                    hwaddr_ntoa(ifo->iaid, sizeof(ifo->iaid),
                    buf, sizeof(buf)));
                warn_iaid_conflict(ifp, ifo->iaid);
@@ -851,7 +846,7 @@ dhcpcd_startinterface(void *arg)
                        if (memcmp(ifo->iaid, ifo->ia[i].iaid,
                            sizeof(ifo->iaid)))
                        {
-                               logger(ifp->ctx, LOG_INFO, "%s: IAID %s",
+                               syslog(LOG_INFO, "%s: IAID %s",
                                    ifp->name, hwaddr_ntoa(ifo->ia[i].iaid,
                                    sizeof(ifo->ia[i].iaid),
                                    buf, sizeof(buf)));
@@ -861,7 +856,7 @@ dhcpcd_startinterface(void *arg)
        }
 
        if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
-               logger(ifp->ctx, LOG_ERR, "%s: ipv6_start: %m", ifp->name);
+               syslog(LOG_ERR, "%s: ipv6_start: %m", ifp->name);
                ifo->options &= ~DHCPCD_IPV6;
        }
        if (ifo->options & DHCPCD_IPV6) {
@@ -899,8 +894,8 @@ dhcpcd_startinterface(void *arg)
 #endif
                        }
                        if (nolease == -1)
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: dhcp6_start: %m", ifp->name);
+                               syslog(LOG_ERR, "%s: dhcp6_start: %m",
+                                   ifp->name);
                }
        }
 
@@ -921,7 +916,7 @@ dhcpcd_prestartinterface(void *arg)
        if ((!(ifp->ctx->options & DHCPCD_MASTER) ||
            ifp->options->options & DHCPCD_IF_UP) &&
            if_up(ifp) == -1)
-               logger(ifp->ctx, LOG_ERR, "%s: if_up: %m", ifp->name);
+               syslog(LOG_ERR, "%s: if_up: %m", ifp->name);
 
        if (ifp->options->options & DHCPCD_LINK &&
            ifp->carrier == LINK_UNKNOWN)
@@ -933,7 +928,7 @@ dhcpcd_prestartinterface(void *arg)
                            ifp->flags, ifp->name);
                        return;
                }
-               logger(ifp->ctx, LOG_INFO,
+               syslog(LOG_INFO,
                    "%s: unknown carrier, waiting for interface flags",
                    ifp->name);
        }
@@ -979,7 +974,7 @@ dhcpcd_handlelink(void *arg)
 
        ctx = arg;
        if (if_handlelink(ctx) == -1) {
-               logger(ctx, LOG_ERR, "if_handlelink: %m");
+               syslog(LOG_ERR, "if_handlelink: %m");
                eloop_event_delete(ctx->eloop, ctx->link_fd);
                close(ctx->link_fd);
                ctx->link_fd = -1;
@@ -1003,7 +998,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname)
                        return -1;
                }
                if (ifp->active) {
-                       logger(ctx, LOG_DEBUG, "%s: interface departed",
+                       syslog(LOG_DEBUG, "%s: interface departed",
                            ifp->name);
                        ifp->options->options |= DHCPCD_DEPARTED;
                        stop_interface(ifp);
@@ -1016,7 +1011,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname)
        i = -1;
        ifs = if_discover(ctx, -1, UNCONST(argv));
        if (ifs == NULL) {
-               logger(ctx, LOG_ERR, "%s: if_discover: %m", __func__);
+               syslog(LOG_ERR, "%s: if_discover: %m", __func__);
                return -1;
        }
        TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
@@ -1039,7 +1034,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname)
                iff = if_find(ctx->ifaces, ifp->name);
                if (iff) {
                        if (iff->active)
-                               logger(ctx, LOG_DEBUG, "%s: interface updated",
+                               syslog(LOG_DEBUG, "%s: interface updated",
                                    iff->name);
                        /* The flags and hwaddr could have changed */
                        iff->flags = ifp->flags;
@@ -1051,8 +1046,7 @@ dhcpcd_handleinterface(void *arg, int action, const char *ifname)
                        TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
                        if (!ifp->active)
                                continue;
-                       logger(ctx, LOG_DEBUG, "%s: interface added",
-                           ifp->name);
+                       syslog(LOG_DEBUG, "%s: interface added", ifp->name);
                        dhcpcd_initstate(ifp, 0);
                        run_preinit(ifp);
                        iff = ifp;
@@ -1086,14 +1080,14 @@ dhcpcd_handlehwaddr(struct dhcpcd_ctx *ctx, const char *ifname,
 
        if (hwlen > sizeof(ifp->hwaddr)) {
                errno = ENOBUFS;
-               logger(ctx, LOG_ERR, "%s: %s: %m", ifp->name, __func__);
+               syslog(LOG_ERR, "%s: %s: %m", ifp->name, __func__);
                return;
        }
 
        if (ifp->hwlen == hwlen && memcmp(ifp->hwaddr, hwaddr, hwlen) == 0)
                return;
 
-       logger(ctx, LOG_INFO, "%s: new hardware address: %s", ifp->name,
+       syslog(LOG_INFO, "%s: new hardware address: %s", ifp->name,
            hwaddr_ntoa(hwaddr, hwlen, buf, sizeof(buf)));
        ifp->hwlen = hwlen;
        memcpy(ifp->hwaddr, hwaddr, hwlen);
@@ -1213,19 +1207,19 @@ signal_cb(int sig, void *arg)
        exit_code = EXIT_FAILURE;
        switch (sig) {
        case SIGINT:
-               logger(ctx, LOG_INFO, sigmsg, "SIGINT", "stopping");
+               syslog(LOG_INFO, sigmsg, "SIGINT", "stopping");
                break;
        case SIGTERM:
-               logger(ctx, LOG_INFO, sigmsg, "SIGTERM", "stopping");
+               syslog(LOG_INFO, sigmsg, "SIGTERM", "stopping");
                exit_code = EXIT_SUCCESS;
                break;
        case SIGALRM:
-               logger(ctx, LOG_INFO, sigmsg, "SIGALRM", "releasing");
+               syslog(LOG_INFO, sigmsg, "SIGALRM", "releasing");
                opts |= DHCPCD_RELEASE;
                exit_code = EXIT_SUCCESS;
                break;
        case SIGHUP:
-               logger(ctx, LOG_INFO, sigmsg, "SIGHUP", "rebinding");
+               syslog(LOG_INFO, sigmsg, "SIGHUP", "rebinding");
                reload_config(ctx);
                /* Preserve any options passed on the commandline
                 * when we were started. */
@@ -1233,20 +1227,19 @@ signal_cb(int sig, void *arg)
                    ctx->argc - ctx->ifc);
                return;
        case SIGUSR1:
-               logger(ctx, LOG_INFO, sigmsg, "SIGUSR1", "renewing");
+               syslog(LOG_INFO, sigmsg, "SIGUSR1", "renewing");
                dhcpcd_renew(ctx);
                return;
        case SIGUSR2:
-               logger_close(ctx);
-               logger_open(ctx);
-               logger(ctx, LOG_INFO, sigmsg, "SIGUSR2", "reopened logfile");
+               closelog();
+               openlog(NULL, ctx->log_opts, LOG_DAEMON);
+               syslog(LOG_INFO, sigmsg, "SIGUSR2", "reopened syslog");
                return;
        case SIGPIPE:
-               logger(ctx, LOG_WARNING, "received SIGPIPE");
+               syslog(LOG_WARNING, "received SIGPIPE");
                return;
        default:
-               logger(ctx, LOG_ERR,
-                   "received signal %d, "
+               syslog(LOG_ERR, "received signal %d, "
                    "but don't know what to do with it",
                    sig);
                return;
@@ -1288,8 +1281,7 @@ dhcpcd_getinterfaces(void *arg)
                if (!ifp->active)
                        continue;
                if (send_interface(fd, ifp) == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "send_interface %d: %m", fd->fd);
+                       syslog(LOG_ERR, "send_interface %d: %m", fd->fd);
        }
 }
 
@@ -1344,7 +1336,7 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx, struct fd_list *fd,
                *p++ = ' ';
        }
        *--p = '\0';
-       logger(ctx, LOG_INFO, "control command: %s", tmp);
+       syslog(LOG_INFO, "control command: %s", tmp);
        free(tmp);
 
        optind = 0;
@@ -1467,10 +1459,6 @@ main(int argc, char **argv)
 
        memset(&ctx, 0, sizeof(ctx));
 
-       ctx.log_fd = -1;
-       logger_open(&ctx);
-       logger_mask(&ctx, LOG_UPTO(LOG_INFO));
-
        ifo = NULL;
        ctx.cffile = CONFIG;
        ctx.control_fd = ctx.control_unpriv_fd = ctx.link_fd = -1;
@@ -1485,6 +1473,13 @@ main(int argc, char **argv)
 #endif
 #ifdef INET
        ctx.udp_fd = -1;
+#endif
+       ctx.log_opts = LOG_PID;
+#ifdef LOG_PERROR
+       ctx.log_opts |= LOG_PERROR;
+#endif
+#ifdef LOG_PTRIM
+       ctx.log_opts |= LOG_PTRIM;
 #endif
        i = 0;
        while ((opt = getopt_long(argc, argv,
@@ -1501,11 +1496,6 @@ main(int argc, char **argv)
                case 'f':
                        ctx.cffile = optarg;
                        break;
-               case 'j':
-                       ctx.logfile = strdup(optarg);
-                       logger_close(&ctx);
-                       logger_open(&ctx);
-                       break;
 #ifdef USE_SIGNALS
                case 'k':
                        sig = SIGALRM;
@@ -1521,6 +1511,11 @@ main(int argc, char **argv)
                         * out of user definable signals. */
                        i = 4;
                        break;
+               case 'q':
+#ifdef LOG_PERROR
+                       ctx.log_opts &= ~LOG_PERROR;
+                       break;
+#endif
                case 'x':
                        sig = SIGTERM;
                        siga = "TERM";
@@ -1535,6 +1530,9 @@ main(int argc, char **argv)
                        break;
                case 'T':
                        i = 1;
+#ifdef LOG_NLOG
+                       ctx.log_opts |= LOG_NLOG;
+#endif
                        break;
                case 'U':
                        i = 3;
@@ -1550,6 +1548,9 @@ main(int argc, char **argv)
                }
        }
 
+       openlog(NULL, ctx.log_opts, LOG_DAEMON);
+       setlogmask(LOG_UPTO(LOG_INFO));
+
        ctx.argv = argv;
        ctx.argc = argc;
        ctx.ifc = argc - optind;
@@ -1613,7 +1614,7 @@ main(int argc, char **argv)
 #endif
 
        if (ctx.options & DHCPCD_DEBUG)
-               logger_mask(&ctx, LOG_UPTO(LOG_DEBUG));
+               setlogmask(LOG_UPTO(LOG_DEBUG));
 
        if (!(ctx.options & (DHCPCD_TEST | DHCPCD_DUMPLEASE))) {
 printpidfile:
@@ -1623,7 +1624,7 @@ printpidfile:
                        const char *per;
 
                        if (strlen(argv[optind]) > IF_NAMESIZE) {
-                               logger(&ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "%s: interface name too long",
                                    argv[optind]);
                                goto exit_failure;
@@ -1653,19 +1654,19 @@ printpidfile:
        }
 
        if (chdir("/") == -1)
-               logger(&ctx, LOG_ERR, "chdir `/': %m");
+               syslog(LOG_ERR, "chdir `/': %m");
 
        /* Freeing allocated addresses from dumping leases can trigger
         * eloop removals as well, so init here. */
        if ((ctx.eloop = eloop_new()) == NULL) {
-               logger(&ctx, LOG_ERR, "%s: eloop_init: %m", __func__);
+               syslog(LOG_ERR, "%s: eloop_init: %m", __func__);
                goto exit_failure;
        }
 
        /* Open our persistent sockets.
         * This is needed early for dumping leases on valid interfaces. */
        if (if_opensockets(&ctx) == -1) {
-               logger(&ctx, LOG_ERR, "if_opensockets: %m");
+               syslog(LOG_ERR, "if_opensockets: %m");
                goto exit_failure;
        }
 
@@ -1680,14 +1681,14 @@ printpidfile:
                                TAILQ_INIT(ctx.ifaces);
                }
                if (ctx.ifaces == NULL) {
-                       logger(&ctx, LOG_ERR, "if_discover: %m");
+                       syslog(LOG_ERR, "if_discover: %m");
                        goto exit_failure;
                }
                ifp = if_find(ctx.ifaces, argv[optind]);
                if (ifp == NULL) {
                        ifp = calloc(1, sizeof(*ifp));
                        if (ifp == NULL) {
-                               logger(&ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                goto exit_failure;
                        }
                        if (optind != argc)
@@ -1731,21 +1732,20 @@ printpidfile:
                if (ctx.control_fd == -1)
                        ctx.control_fd = control_open(NULL);
                if (ctx.control_fd != -1) {
-                       logger(&ctx, LOG_INFO,
+                       syslog(LOG_INFO,
                            "sending commands to master dhcpcd process");
                        len = control_send(&ctx, argc, argv);
                        control_close(&ctx);
                        if (len > 0) {
-                               logger(&ctx, LOG_DEBUG, "send OK");
+                               syslog(LOG_DEBUG, "send OK");
                                goto exit_success;
                        } else {
-                               logger(&ctx, LOG_ERR,
-                                   "failed to send commands");
+                               syslog(LOG_ERR, "failed to send commands");
                                goto exit_failure;
                        }
                } else {
                        if (errno != ENOENT)
-                               logger(&ctx, LOG_ERR, "control_open: %m");
+                               syslog(LOG_ERR, "control_open: %m");
                }
 #ifdef USE_SIGNALS
        }
@@ -1755,13 +1755,13 @@ printpidfile:
        if (sig != 0) {
                pid = pidfile_read(ctx.pidfile);
                if (pid != 0 && pid != -1)
-                       logger(&ctx, LOG_INFO, "sending signal %s to pid %d",
+                       syslog(LOG_INFO, "sending signal %s to pid %d",
                            siga, pid);
                if (pid == 0 || pid == -1 || kill(pid, sig) != 0) {
                        if (sig != SIGHUP && sig != SIGUSR1 && errno != EPERM)
-                               logger(&ctx, LOG_ERR, ""PACKAGE" not running");
+                               syslog(LOG_ERR, ""PACKAGE" not running");
                        if (pid != 0 && pid != -1 && errno != ESRCH) {
-                               logger(&ctx, LOG_ERR, "kill: %m");
+                               syslog(LOG_ERR, "kill: %m");
                                goto exit_failure;
                        }
                        unlink(ctx.pidfile);
@@ -1773,8 +1773,7 @@ printpidfile:
                        if (sig == SIGHUP || sig == SIGUSR1)
                                goto exit_success;
                        /* Spin until it exits */
-                       logger(&ctx, LOG_INFO,
-                           "waiting for pid %d to exit", pid);
+                       syslog(LOG_INFO, "waiting for pid %d to exit", pid);
                        ts.tv_sec = 0;
                        ts.tv_nsec = 100000000; /* 10th of a second */
                        for(i = 0; i < 100; i++) {
@@ -1782,7 +1781,7 @@ printpidfile:
                                if (pidfile_read(ctx.pidfile) == -1)
                                        goto exit_success;
                        }
-                       logger(&ctx, LOG_ERR, "pid %d failed to exit", pid);
+                       syslog(LOG_ERR, "pid %d failed to exit", pid);
                        goto exit_failure;
                }
        }
@@ -1790,16 +1789,16 @@ printpidfile:
        if (!(ctx.options & DHCPCD_TEST)) {
                /* Ensure we have the needed directories */
                if (mkdir(RUNDIR, 0755) == -1 && errno != EEXIST)
-                       logger(&ctx, LOG_ERR, "mkdir `%s': %m", RUNDIR);
+                       syslog(LOG_ERR, "mkdir `%s': %m", RUNDIR);
                if (mkdir(DBDIR, 0755) == -1 && errno != EEXIST)
-                       logger(&ctx, LOG_ERR, "mkdir `%s': %m", DBDIR);
+                       syslog(LOG_ERR, "mkdir `%s': %m", DBDIR);
 
                if ((pid = pidfile_lock(ctx.pidfile)) != 0) {
                        if (pid == -1)
-                               logger(&ctx, LOG_ERR, "%s: pidfile_lock: %m",
+                               syslog(LOG_ERR, "%s: pidfile_lock: %m",
                                    __func__);
                        else
-                               logger(&ctx, LOG_ERR, ""PACKAGE
+                               syslog(LOG_ERR, ""PACKAGE
                                    " already running on pid %d (%s)",
                                    pid, ctx.pidfile);
                        goto exit_failure;
@@ -1808,30 +1807,30 @@ printpidfile:
 
        if (ctx.options & DHCPCD_MASTER) {
                if (control_start(&ctx, NULL) == -1)
-                       logger(&ctx, LOG_ERR, "control_start: %m");
+                       syslog(LOG_ERR, "control_start: %m");
        }
 #else
        if (control_start(&ctx,
            ctx.options & DHCPCD_MASTER ? NULL : argv[optind]) == -1)
        {
-               logger(&ctx, LOG_ERR, "control_start: %m");
+               syslog(LOG_ERR, "control_start: %m");
                goto exit_failure;
        }
 #endif
 
-       logger(&ctx, LOG_DEBUG, PACKAGE "-" VERSION " starting");
+       syslog(LOG_DEBUG, PACKAGE "-" VERSION " starting");
        ctx.options |= DHCPCD_STARTED;
 #ifdef USE_SIGNALS
        if (eloop_signal_set_cb(ctx.eloop,
            dhcpcd_signals, dhcpcd_signals_len,
            signal_cb, &ctx) == -1)
        {
-               logger(&ctx, LOG_ERR, "eloop_signal_set_cb: %m");
+               syslog(LOG_ERR, "eloop_signal_set_cb: %m");
                goto exit_failure;
        }
        /* Save signal mask, block and redirect signals to our handler */
        if (eloop_signal_mask(ctx.eloop, &ctx.sigset) == -1) {
-               logger(&ctx, LOG_ERR, "eloop_signal_mask: %m");
+               syslog(LOG_ERR, "eloop_signal_mask: %m");
                goto exit_failure;
        }
 #endif
@@ -1853,14 +1852,13 @@ printpidfile:
 
        ctx.ifaces = if_discover(&ctx, ctx.ifc, ctx.ifv);
        if (ctx.ifaces == NULL) {
-               logger(&ctx, LOG_ERR, "if_discover: %m");
+               syslog(LOG_ERR, "if_discover: %m");
                goto exit_failure;
        }
        for (i = 0; i < ctx.ifc; i++) {
                if ((ifp = if_find(ctx.ifaces, ctx.ifv[i])) == NULL ||
                    !ifp->active)
-                       logger(&ctx, LOG_ERR,
-                           "%s: interface not found or invalid",
+                       syslog(LOG_ERR, "%s: interface not found or invalid",
                            ctx.ifv[i]);
        }
        TAILQ_FOREACH(ifp, ctx.ifaces, next) {
@@ -1869,13 +1867,13 @@ printpidfile:
        }
        if (ifp == NULL) {
                if (ctx.ifc == 0)
-                       logger(&ctx,
-                           ctx.options & DHCPCD_INACTIVE ? LOG_DEBUG : LOG_ERR,
+                       syslog(ctx.options & DHCPCD_INACTIVE ?
+                           LOG_DEBUG : LOG_ERR,
                            "no valid interfaces found");
                else
                        goto exit_failure;
                if (!(ctx.options & DHCPCD_LINK)) {
-                       logger(&ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "aborting as link detection is disabled");
                        goto exit_failure;
                }
@@ -1917,8 +1915,7 @@ printpidfile:
                    ctx.options & DHCPCD_LINK &&
                    !(ctx.options & DHCPCD_WAITIP))
                {
-                       logger(&ctx,
-                           ctx.options & DHCPCD_INACTIVE ?
+                       syslog(ctx.options & DHCPCD_INACTIVE ?
                            LOG_DEBUG : LOG_WARNING,
                            "no interfaces have a carrier");
                        if (dhcpcd_daemonise(&ctx))
@@ -1957,7 +1954,7 @@ exit_failure:
 
 exit1:
        if (control_stop(&ctx) == -1)
-               logger(&ctx, LOG_ERR, "control_stop: %m:");
+               syslog(LOG_ERR, "control_stop: %m:");
        /* Free memory and close fd's */
        if (ctx.ifaces) {
                while ((ifp = TAILQ_FIRST(ctx.ifaces))) {
@@ -1981,9 +1978,8 @@ exit1:
        free(ctx.iov[0].iov_base);
 
        if (ctx.options & DHCPCD_STARTED && !(ctx.options & DHCPCD_FORKED))
-               logger(&ctx, LOG_INFO, PACKAGE " exited");
-       logger_close(&ctx);
-       free(ctx.logfile);
+               syslog(LOG_INFO, PACKAGE " exited");
+       closelog();
 #ifdef USE_SIGNALS
        if (ctx.options & DHCPCD_FORKED)
                _exit(i); /* so atexit won't remove our pidfile */
index 2deee8aaa1c66c42205328b5486b6198dc4ffea6..8d32fb49847511e09907b8cbb2835d6ed934ed13 100644 (file)
@@ -119,8 +119,7 @@ struct dhcpcd_ctx {
        char pidfile[sizeof(PIDFILE) + IF_NAMESIZE + 1];
        const char *cffile;
        unsigned long long options;
-       char *logfile;
-       int log_fd;
+       int log_opts;
        int argc;
        char **argv;
        int ifac;       /* allowed interfaces */
index cdfa1955e54e663d402b0c2017d2af019c0ad782..d50b8a642524ecda7012d57c4644cfa3f92e7883 100644 (file)
@@ -42,6 +42,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -100,15 +101,13 @@ duid_get(uint8_t **d, const struct interface *ifp)
                        *d = data;
                        return len;
                }
-               logger(ifp->ctx, LOG_ERR,
-                   "DUID too big (max %u): %s", DUID_LEN, DUID);
+               syslog(LOG_ERR, "DUID too big (max %u): %s", DUID_LEN, DUID);
                /* Keep the buffer, will assign below. */
        } else {
                if (errno != ENOENT)
-                       logger(ifp->ctx, LOG_ERR,
-                           "error reading DUID: %s: %m", DUID);
+                       syslog(LOG_ERR, "error reading DUID: %s: %m", DUID);
                if ((data = malloc(DUID_LEN)) == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: malloc: %m", __func__);
+                       syslog(LOG_ERR, "%s: malloc: %m", __func__);
                        return 0;
                }
        }
@@ -118,26 +117,26 @@ duid_get(uint8_t **d, const struct interface *ifp)
 
        /* No file? OK, lets make one based on our interface */
        if (ifp->family == ARPHRD_NETROM) {
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: is a NET/ROM pseudo interface", ifp->name);
+               syslog(LOG_WARNING, "%s: is a NET/ROM pseudo interface",
+                   ifp->name);
                TAILQ_FOREACH(ifp2, ifp->ctx->ifaces, next) {
                        if (ifp2->family != ARPHRD_NETROM)
                                break;
                }
                if (ifp2) {
                        ifp = ifp2;
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "picked interface %s to generate a DUID",
                            ifp->name);
                } else {
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "no interfaces have a fixed hardware address");
                        return duid_make(data, ifp, DUID_LL);
                }
        }
 
        if (!(fp = fopen(DUID, "w"))) {
-               logger(ifp->ctx, LOG_ERR, "error writing DUID: %s: %m", DUID);
+               syslog(LOG_ERR, "error writing DUID: %s: %m", DUID);
                return duid_make(data, ifp, DUID_LL);
        }
        len = duid_make(data, ifp, DUID_LLT);
@@ -146,7 +145,7 @@ duid_get(uint8_t **d, const struct interface *ifp)
                x = -1;
        /* Failed to write the duid? scrub it, we cannot use it */
        if (x < 1) {
-               logger(ifp->ctx, LOG_ERR, "error writing DUID: %s: %m", DUID);
+               syslog(LOG_ERR, "error writing DUID: %s: %m", DUID);
                unlink(DUID);
                return duid_make(data, ifp, DUID_LL);
        }
index a3946f4dc4d5b398cc0167e78086ceca45c89c6b..ed3ba2f11d6b4e2353e19d669bf77d7320e2ed23 100644 (file)
@@ -66,6 +66,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #if defined(OpenBSD) && OpenBSD >= 201411
@@ -1038,7 +1039,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                        ifr_sin->sin_family = AF_INET;
                        ifr_sin->sin_addr = addr;
                        if (ioctl(ctx->pf_inet_fd, SIOCGIFADDR, &ifr) == 0) {
-                               logger(ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: ignored false RTM_DELADDR for %s",
                                    ifp->name, inet_ntoa(addr));
                                break;
@@ -1050,8 +1051,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                if (ifam->ifam_type == RTM_DELADDR)
                        addrflags = 0 ;
                else if ((addrflags = if_addrflags(ifp, &addr, NULL)) == -1) {
-                       logger(ctx, LOG_ERR,
-                           "%s: if_addrflags: %s: %m",
+                       syslog(LOG_ERR, "%s: if_addrflags: %s: %m",
                            ifp->name, inet_ntoa(addr));
                        break;
                }
@@ -1077,8 +1077,7 @@ if_ifa(struct dhcpcd_ctx *ctx, const struct ifa_msghdr *ifam)
                if (ifam->ifam_type == RTM_DELADDR)
                    addrflags = 0;
                else if ((addrflags = if_addrflags6(ifp, &addr6, NULL)) == -1) {
-                       logger(ctx, LOG_ERR,
-                           "%s: if_addrflags6: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: if_addrflags6: %m", ifp->name);
                        break;
                }
 #endif
@@ -1320,7 +1319,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
 
 #ifdef ND6_IFF_AUTO_LINKLOCAL
                if (own && flags & ND6_IFF_AUTO_LINKLOCAL) {
-                       logger(ifp->ctx, LOG_DEBUG,
+                       syslog(LOG_DEBUG,
                            "%s: disabling Kernel IPv6 auto link-local support",
                            ifp->name);
                        flags &= ~ND6_IFF_AUTO_LINKLOCAL;
@@ -1336,7 +1335,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
 
 #ifdef ND6_IFF_ACCEPT_RTADV
                if (own && flags & ND6_IFF_ACCEPT_RTADV) {
-                       logger(ifp->ctx, LOG_DEBUG,
+                       syslog(LOG_DEBUG,
                            "%s: disabling Kernel IPv6 RA support",
                            ifp->name);
                        flags &= ~ND6_IFF_ACCEPT_RTADV;
@@ -1354,8 +1353,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
                if (nd.ndi.flags != (uint32_t)flags) {
                        nd.ndi.flags = (uint32_t)flags;
                        if (ioctl(s, SIOCSIFINFO_FLAGS, &nd) == -1) {
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: SIOCSIFINFO_FLAGS: %m",
+                               syslog(LOG_ERR, "%s: SIOCSIFINFO_FLAGS: %m",
                                    ifp->name);
                                return -1;
                        }
@@ -1366,16 +1364,14 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
                 * LLADDR auto configuration are disabled where applicable. */
 #ifdef SIOCIFAFATTACH
                if (af_attach(s, ifp, AF_INET6) == -1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: af_attach: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: af_attach: %m", ifp->name);
                        return -1;
                }
 #endif
 
 #ifdef SIOCGIFXFLAGS
                if (set_ifxflags(s, ifp, own) == -1) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: set_ifxflags: %m", ifp->name);
+                       syslog(LOG_ERR, "%s: set_ifxflags: %m", ifp->name);
                        return -1;
                }
 #endif
@@ -1403,12 +1399,12 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
        if (ra == -1)
                /* The sysctl probably doesn't exist, but this isn't an
                 * error as such so just log it and continue */
-               logger(ctx, errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
+               syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
                    "IPV6CTL_ACCEPT_RTADV: %m");
        else if (ra != 0 && own) {
-               logger(ctx, LOG_DEBUG, "disabling Kernel IPv6 RA support");
+               syslog(LOG_DEBUG, "disabling Kernel IPv6 RA support");
                if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 0) == -1) {
-                       logger(ctx, LOG_ERR, "IPV6CTL_ACCEPT_RTADV: %m");
+                       syslog(LOG_ERR, "IPV6CTL_ACCEPT_RTADV: %m");
                        return ra;
                }
                ra = 0;
@@ -1420,7 +1416,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
                 * and prefixes so the kernel does not expire prefixes
                 * and default routes we are trying to own. */
                if (if_raflush(s) == -1)
-                       logger(ctx, LOG_WARNING, "if_raflush: %m");
+                       syslog(LOG_WARNING, "if_raflush: %m");
        }
 
        ctx->ra_global = ra;
index 01ebf1d08f6c7513990619a98604c0111f3f3a04..485472532bd432ac14ed29889f5fc0326a20d3cb 100644 (file)
@@ -54,6 +54,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -1067,8 +1068,8 @@ _if_getssid_nl80211(__unused struct dhcpcd_ctx *ctx, struct interface *ifp,
            NLA_DATA(tb[NL80211_ATTR_BSS]),
            NLA_LEN(tb[NL80211_ATTR_BSS]),
            NL80211_BSS_STATUS) == -1)
-               return 0;
-               
+               return 0;
+
        if (bss[NL80211_BSS_BSSID] == NULL || bss[NL80211_BSS_STATUS] == NULL)
                return 0;
 
@@ -1643,8 +1644,8 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
                ifname = "all";
        else if (own) {
                if (if_disable_autolinklocal(ctx, ifp->index) == -1)
-                       logger(ctx, LOG_DEBUG,
-                           "%s: if_disable_autolinklocal: %m", ifp->name);
+                       syslog(LOG_DEBUG, "%s: if_disable_autolinklocal: %m",
+                           ifp->name);
        }
        if (ifp)
                ifname = ifp->name;
@@ -1653,11 +1654,11 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
        ra = check_proc_int(path);
        if (ra != 1) {
                if (!own)
-                       logger(ctx, LOG_WARNING,
-                           "%s: IPv6 kernel autoconf disabled", ifname);
+                       syslog(LOG_WARNING, "%s: IPv6 kernel autoconf disabled",
+                           ifname);
        } else if (ra != -1 && own) {
                if (write_path(path, "0") == -1) {
-                       logger(ctx, LOG_ERR, "write_path: %s: %m", path);
+                       syslog(LOG_ERR, "write_path: %s: %m", path);
                        return -1;
                }
        }
@@ -1667,13 +1668,12 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own)
        if (ra == -1)
                /* The sysctl probably doesn't exist, but this isn't an
                 * error as such so just log it and continue */
-               logger(ctx, errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
-                   "%s: %m", path);
+               syslog(errno == ENOENT ? LOG_DEBUG:LOG_WARNING, "%s: %m", path);
        else if (ra != 0 && own) {
-               logger(ctx, LOG_DEBUG, "%s: disabling kernel IPv6 RA support",
+               syslog(LOG_DEBUG, "%s: disabling kernel IPv6 RA support",
                    ifname);
                if (write_path(path, "0") == -1) {
-                       logger(ctx, LOG_ERR, "write_path: %s: %m", path);
+                       syslog(LOG_ERR, "write_path: %s: %m", path);
                        return ra;
                }
                return 0;
index eaeb7873fbb7048cd2961f49d0fd1102712d58b7..ca755f3a5d383daae618cee4f48f25ff6a00e3d9 100644 (file)
@@ -41,6 +41,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 #include <time.h>
 
@@ -114,7 +115,6 @@ const struct option cf_options[] = {
        {"reconfigure",     no_argument,       NULL, 'g'},
        {"hostname",        optional_argument, NULL, 'h'},
        {"vendorclassid",   optional_argument, NULL, 'i'},
-       {"logfile",         required_argument, NULL, 'j'},
        {"release",         no_argument,       NULL, 'k'},
        {"leasetime",       required_argument, NULL, 'l'},
        {"metric",          required_argument, NULL, 'm'},
@@ -209,8 +209,7 @@ const struct option cf_options[] = {
 };
 
 static char *
-add_environ(struct dhcpcd_ctx *ctx, struct if_options *ifo,
-    const char *value, int uniq)
+add_environ(struct if_options *ifo, const char *value, int uniq)
 {
        char **newlist;
        char **lst = ifo->environ;
@@ -219,12 +218,12 @@ add_environ(struct dhcpcd_ctx *ctx, struct if_options *ifo,
 
        match = strdup(value);
        if (match == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return NULL;
        }
        p = strchr(match, '=');
        if (p == NULL) {
-               logger(ctx, LOG_ERR, "%s: no assignment: %s", __func__, value);
+               syslog(LOG_ERR, "%s: no assignment: %s", __func__, value);
                free(match);
                return NULL;
        }
@@ -236,8 +235,7 @@ add_environ(struct dhcpcd_ctx *ctx, struct if_options *ifo,
                        if (uniq) {
                                n = strdup(value);
                                if (n == NULL) {
-                                       logger(ctx, LOG_ERR,
-                                           "%s: %m", __func__);
+                                       syslog(LOG_ERR, "%s: %m", __func__);
                                        free(match);
                                        return NULL;
                                }
@@ -249,8 +247,7 @@ add_environ(struct dhcpcd_ctx *ctx, struct if_options *ifo,
                                lv = strlen(p);
                                n = realloc(lst[i], l + lv + 2);
                                if (n == NULL) {
-                                       logger(ctx, LOG_ERR,
-                                           "%s: %m", __func__);
+                                       syslog(LOG_ERR, "%s: %m", __func__);
                                        free(match);
                                        return NULL;
                                }
@@ -268,12 +265,12 @@ add_environ(struct dhcpcd_ctx *ctx, struct if_options *ifo,
        free(match);
        n = strdup(value);
        if (n == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return NULL;
        }
        newlist = realloc(lst, sizeof(char *) * (i + 2));
        if (newlist == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                free(n);
                return NULL;
        }
@@ -440,26 +437,26 @@ parse_uint32(uint32_t *i, const char *arg)
 #endif
 
 static char **
-splitv(struct dhcpcd_ctx *ctx, int *argc, char **argv, const char *arg)
+splitv(int *argc, char **argv, const char *arg)
 {
        char **n, **v = argv;
        char *o = strdup(arg), *p, *t, *nt;
 
        if (o == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return v;
        }
        p = o;
        while ((t = strsep(&p, ", "))) {
                nt = strdup(t);
                if (nt == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        free(o);
                        return v;
                }
                n = realloc(v, sizeof(char *) * ((size_t)(*argc) + 1));
                if (n == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        free(o);
                        free(nt);
                        return v;
@@ -473,8 +470,7 @@ splitv(struct dhcpcd_ctx *ctx, int *argc, char **argv, const char *arg)
 
 #ifdef INET
 static int
-parse_addr(struct dhcpcd_ctx *ctx,
-    struct in_addr *addr, struct in_addr *net, const char *arg)
+parse_addr(struct in_addr *addr, struct in_addr *net, const char *arg)
 {
        char *p;
 
@@ -494,13 +490,13 @@ parse_addr(struct dhcpcd_ctx *ctx,
                if (e != 0 ||
                    (net != NULL && inet_cidrtoaddr((int)i, net) != 0))
                {
-                       logger(ctx, LOG_ERR, "`%s' is not a valid CIDR", p);
+                       syslog(LOG_ERR, "`%s' is not a valid CIDR", p);
                        return -1;
                }
        }
 
        if (addr != NULL && inet_aton(arg, addr) == 0) {
-               logger(ctx, LOG_ERR, "`%s' is not a valid IP address", arg);
+               syslog(LOG_ERR, "`%s' is not a valid IP address", arg);
                return -1;
        }
        if (p != NULL)
@@ -511,12 +507,11 @@ parse_addr(struct dhcpcd_ctx *ctx,
 }
 #else
 static int
-parse_addr(struct dhcpcd_ctx *ctx,
-    __unused struct in_addr *addr, __unused struct in_addr *net,
+parse_addr(__unused struct in_addr *addr, __unused struct in_addr *net,
     __unused const char *arg)
 {
 
-       logger(ctx, LOG_ERR, "No IPv4 support");
+       syslog(LOG_ERR, "No IPv4 support");
        return -1;
 }
 #endif
@@ -697,6 +692,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
        case 'f': /* FALLTHROUGH */
        case 'g': /* FALLTHROUGH */
        case 'n': /* FALLTHROUGH */
+       case 'q': /* FALLTHROUGH */
        case 'x': /* FALLTHROUGH */
        case 'N': /* FALLTHROUGH */
        case 'P': /* FALLTHROUGH */
@@ -712,14 +708,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                free(ifo->script);
                ifo->script = strdup(arg);
                if (ifo->script == NULL)
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                break;
        case 'd':
                ifo->options |= DHCPCD_DEBUG;
                break;
        case 'e':
                ARG_REQUIRED;
-               add_environ(ctx, ifo, arg, 1);
+               add_environ(ifo, arg, 1);
                break;
        case 'h':
                if (!arg) {
@@ -728,11 +724,11 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                }
                s = parse_string(ifo->hostname, HOSTNAME_MAX_LEN, arg);
                if (s == -1) {
-                       logger(ctx, LOG_ERR, "hostname: %m");
+                       syslog(LOG_ERR, "hostname: %m");
                        return -1;
                }
                if (s != 0 && ifo->hostname[0] == '.') {
-                       logger(ctx, LOG_ERR, "hostname cannot begin with .");
+                       syslog(LOG_ERR, "hostname cannot begin with .");
                        return -1;
                }
                ifo->hostname[s] = '\0';
@@ -748,21 +744,11 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                else
                        s = 0;
                if (s == -1) {
-                       logger(ctx, LOG_ERR, "vendorclassid: %m");
+                       syslog(LOG_ERR, "vendorclassid: %m");
                        return -1;
                }
                *ifo->vendorclassid = (uint8_t)s;
                break;
-       case 'j':
-               ARG_REQUIRED;
-               /* per interface logging is not supported
-                * don't want to overide the commandline */
-               if (ifname == NULL && ctx->logfile == NULL) {
-                       logger_close(ctx);
-                       ctx->logfile = strdup(arg);
-                       logger_open(ctx);
-               }
-               break;
        case 'k':
                ifo->options |= DHCPCD_RELEASE;
                break;
@@ -771,7 +757,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                ifo->leasetime = (uint32_t)strtou(arg, NULL,
                    0, 0, UINT32_MAX, &e);
                if (e) {
-                       logger(ctx, LOG_ERR, "failed to convert leasetime %s", arg);
+                       syslog(LOG_ERR, "failed to convert leasetime %s", arg);
                        return -1;
                }
                break;
@@ -779,7 +765,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                ARG_REQUIRED;
                ifo->metric = (int)strtoi(arg, NULL, 0, 0, INT32_MAX, &e);
                if (e) {
-                       logger(ctx, LOG_ERR, "failed to convert metric %s", arg);
+                       syslog(LOG_ERR, "failed to convert metric %s", arg);
                        return -1;
                }
                break;
@@ -791,7 +777,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                    make_option_mask(d, dl, od, odl, no, arg, -1) != 0 ||
                    make_option_mask(d, dl, od, odl, reject, arg, -1) != 0)
                {
-                       logger(ctx, LOG_ERR, "unknown option `%s'", arg);
+                       syslog(LOG_ERR, "unknown option `%s'", arg);
                        return -1;
                }
                break;
@@ -803,26 +789,23 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                    make_option_mask(d, dl, od, odl, request, arg, -1) != 0 ||
                    make_option_mask(d, dl, od, odl, require, arg, -1) != 0)
                {
-                       logger(ctx, LOG_ERR, "unknown option `%s'", arg);
+                       syslog(LOG_ERR, "unknown option `%s'", arg);
                        return -1;
                }
                break;
        case 'p':
                ifo->options |= DHCPCD_PERSISTENT;
                break;
-       case 'q':
-               ifo->options |= DHCPCD_QUIET;
-               break;
        case 'r':
-               if (parse_addr(ctx, &ifo->req_addr, NULL, arg) != 0)
+               if (parse_addr(&ifo->req_addr, NULL, arg) != 0)
                        return -1;
                ifo->options |= DHCPCD_REQUEST;
                ifo->req_mask.s_addr = 0;
                break;
        case 's':
                if (arg && *arg != '\0') {
-                       if (parse_addr(ctx,
-                           &ifo->req_addr, &ifo->req_mask, arg) != 0)
+                       if (parse_addr(&ifo->req_addr, &ifo->req_mask, arg)
+                           != 0)
                                return -1;
                } else {
                        ifo->req_addr.s_addr = 0;
@@ -838,7 +821,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                ARG_REQUIRED;
                ifo->timeout = (time_t)strtoi(arg, NULL, 0, 0, INT32_MAX, &e);
                if (e) {
-                       logger(ctx, LOG_ERR, "failed to convert timeout");
+                       syslog(LOG_ERR, "failed to convert timeout");
                        return -1;
                }
                break;
@@ -847,7 +830,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                s = parse_string((char *)ifo->userclass +
                    ifo->userclass[0] + 2, (size_t)s, arg);
                if (s == -1) {
-                       logger(ctx, LOG_ERR, "userclass: %m");
+                       syslog(LOG_ERR, "userclass: %m");
                        return -1;
                }
                if (s != 0) {
@@ -859,7 +842,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                ARG_REQUIRED;
                p = strchr(arg, ',');
                if (!p || !p[1]) {
-                       logger(ctx, LOG_ERR, "invalid vendor format: %s", arg);
+                       syslog(LOG_ERR, "invalid vendor format: %s", arg);
                        return -1;
                }
 
@@ -869,7 +852,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        s = parse_string((char *)ifo->vendor + 1,
                            VENDOR_MAX_LEN, arg);
                        if (s == -1) {
-                               logger(ctx, LOG_ERR, "vendor: %m");
+                               syslog(LOG_ERR, "vendor: %m");
                                return -1;
                        }
                        ifo->vendor[0] = (uint8_t)s;
@@ -888,7 +871,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                i = (int)strtoi(arg, NULL, 0, 1, 254, &e);
                *p = ',';
                if (e) {
-                       logger(ctx, LOG_ERR, "vendor option should be between"
+                       syslog(LOG_ERR, "vendor option should be between"
                            " 1 and 254 inclusive");
                        return -1;
                }
@@ -909,7 +892,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                            ifo->vendor[0] + 3, (size_t)s, arg);
                }
                if (s == -1) {
-                       logger(ctx, LOG_ERR, "vendor: %m");
+                       syslog(LOG_ERR, "vendor: %m");
                        return -1;
                }
                if (s != 0) {
@@ -931,14 +914,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                ARG_REQUIRED;
                ifo->reboot = (time_t)strtoi(arg, NULL, 0, 0, UINT32_MAX, &e);
                if (e) {
-                       logger(ctx, LOG_ERR, "failed to convert reboot %s", arg);
+                       syslog(LOG_ERR, "failed to convert reboot %s", arg);
                        return -1;
                }
                break;
        case 'z':
                ARG_REQUIRED;
                if (ifname == NULL)
-                       ctx->ifav = splitv(ctx, &ctx->ifac, ctx->ifav, arg);
+                       ctx->ifav = splitv(&ctx->ifac, ctx->ifav, arg);
                break;
        case 'A':
                ifo->options &= ~DHCPCD_ARP;
@@ -956,11 +939,11 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                dl = strlen("skip_hooks=") + strlen(arg) + 1;
                p = malloc(sizeof(char) * dl);
                if (p == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                snprintf(p, dl, "skip_hooks=%s", arg);
-               add_environ(ctx, ifo, p, 0);
+               add_environ(ifo, p, 0);
                free(p);
                break;
        case 'D':
@@ -983,7 +966,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                else if (strcmp(arg, "disable") == 0)
                        ifo->fqdn = FQDN_DISABLE;
                else {
-                       logger(ctx, LOG_ERR, "invalid value `%s' for FQDN", arg);
+                       syslog(LOG_ERR, "invalid value `%s' for FQDN", arg);
                        return -1;
                }
                break;
@@ -1002,7 +985,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                else
                        s = 0;
                if (s == -1) {
-                       logger(ctx, LOG_ERR, "clientid: %m");
+                       syslog(LOG_ERR, "clientid: %m");
                        return -1;
                }
                ifo->options |= DHCPCD_CLIENTID;
@@ -1028,7 +1011,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                    make_option_mask(d, dl, od, odl, require, arg, -1) != 0 ||
                    make_option_mask(d, dl, od, odl, no, arg, 1) != 0)
                {
-                       logger(ctx, LOG_ERR, "unknown option `%s'", arg);
+                       syslog(LOG_ERR, "unknown option `%s'", arg);
                        return -1;
                }
                break;
@@ -1041,7 +1024,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                    make_option_mask(d, dl, od, odl, no, arg, -1) != 0 ||
                    make_option_mask(d, dl, od, odl, reject, arg, -1) != 0)
                {
-                       logger(ctx, LOG_ERR, "unknown option `%s'", arg);
+                       syslog(LOG_ERR, "unknown option `%s'", arg);
                        return -1;
                }
                break;
@@ -1049,12 +1032,12 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                ARG_REQUIRED;
                p = strchr(arg, '=');
                if (p == NULL) {
-                       logger(ctx, LOG_ERR, "static assignment required");
+                       syslog(LOG_ERR, "static assignment required");
                        return -1;
                }
                p++;
                if (strncmp(arg, "ip_address=", strlen("ip_address=")) == 0) {
-                       if (parse_addr(ctx, &ifo->req_addr,
+                       if (parse_addr(&ifo->req_addr,
                            ifo->req_mask.s_addr == 0 ? &ifo->req_mask : NULL,
                            p) != 0)
                                return -1;
@@ -1064,7 +1047,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                } else if (strncmp(arg, "subnet_mask=",
                    strlen("subnet_mask=")) == 0)
                {
-                       if (parse_addr(ctx, &ifo->req_mask, NULL, p) != 0)
+                       if (parse_addr(&ifo->req_mask, NULL, p) != 0)
                                return -1;
                } else if (strncmp(arg, "routes=", strlen("routes=")) == 0 ||
                    strncmp(arg, "static_routes=",
@@ -1078,14 +1061,13 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
 
                        fp = np = strwhite(p);
                        if (np == NULL) {
-                               logger(ctx, LOG_ERR,
-                                   "all routes need a gateway");
+                               syslog(LOG_ERR, "all routes need a gateway");
                                return -1;
                        }
                        *np++ = '\0';
                        np = strskipwhite(np);
-                       if (parse_addr(ctx, &addr, &addr2, p) == -1 ||
-                           parse_addr(ctx, &addr3, NULL, np) == -1)
+                       if (parse_addr(&addr, &addr2, p) == -1 ||
+                           parse_addr(&addr3, NULL, np) == -1)
                        {
                                *fp = ' ';
                                return -1;
@@ -1100,7 +1082,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        TAILQ_INSERT_TAIL(&ifo->routes, rt, rt_next);
                        *fp = ' ';
                } else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
-                       if (parse_addr(ctx, &addr, NULL, p) == -1)
+                       if (parse_addr(&addr, NULL, p) == -1)
                                return -1;
                        if ((rt = rt_new(if_find(ctx->ifaces, ifname))) == NULL)
                                return -1;
@@ -1116,7 +1098,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        ifo->mtu = (unsigned int)strtou(p, NULL, 0,
                            MTU_MIN, MTU_MAX, &e);
                        if (e) {
-                               logger(ctx, LOG_ERR, "invalid MTU %s", p);
+                               syslog(LOG_ERR, "invalid MTU %s", p);
                                return -1;
                        }
                } else if (strncmp(arg, "ip6_address=", strlen("ip6_address=")) == 0) {
@@ -1128,7 +1110,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                        ifo->req_prefix_len = (uint8_t)strtou(np,
                                            NULL, 0, 0, 128, &e);
                                        if (e) {
-                                               logger(ctx, LOG_ERR,
+                                               syslog(LOG_ERR,
                                                    "%s: failed to "
                                                    "convert prefix len",
                                                    ifname);
@@ -1146,7 +1128,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                        {
                                                p = strdup(arg);
                                                if (p == NULL) {
-                                                       logger(ctx, LOG_ERR,
+                                                       syslog(LOG_ERR,
                                                            "%s: %m", __func__);
                                                        return -1;
                                                }
@@ -1159,12 +1141,12 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        }
                        p = strdup(arg);
                        if (p == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return -1;
                        }
                        nconf = realloc(ifo->config, sizeof(char *) * (dl + 2));
                        if (nconf == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                free(p);
                                return -1;
                        }
@@ -1174,14 +1156,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                }
                break;
        case 'W':
-               if (parse_addr(ctx, &addr, &addr2, arg) != 0)
+               if (parse_addr(&addr, &addr2, arg) != 0)
                        return -1;
                if (strchr(arg, '/') == NULL)
                        addr2.s_addr = INADDR_BROADCAST;
                naddr = realloc(ifo->whitelist,
                    sizeof(in_addr_t) * (ifo->whitelist_len + 2));
                if (naddr == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                ifo->whitelist = naddr;
@@ -1189,14 +1171,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                ifo->whitelist[ifo->whitelist_len++] = addr2.s_addr;
                break;
        case 'X':
-               if (parse_addr(ctx, &addr, &addr2, arg) != 0)
+               if (parse_addr(&addr, &addr2, arg) != 0)
                        return -1;
                if (strchr(arg, '/') == NULL)
                        addr2.s_addr = INADDR_BROADCAST;
                naddr = realloc(ifo->blacklist,
                    sizeof(in_addr_t) * (ifo->blacklist_len + 2));
                if (naddr == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                ifo->blacklist = naddr;
@@ -1206,7 +1188,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
        case 'Z':
                ARG_REQUIRED;
                if (ifname == NULL)
-                       ctx->ifdv = splitv(ctx, &ctx->ifdc, ctx->ifdv, arg);
+                       ctx->ifdv = splitv(&ctx->ifdc, ctx->ifdv, arg);
                break;
        case '1':
                ifo->options |= DHCPCD_ONESHOT;
@@ -1237,12 +1219,12 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        fp = strwhite(arg);
                        if (fp)
                                *fp++ = '\0';
-                       if (parse_addr(ctx, &addr, NULL, arg) != 0)
+                       if (parse_addr(&addr, NULL, arg) != 0)
                                return -1;
                        naddr = realloc(ifo->arping,
                            sizeof(in_addr_t) * ((size_t)ifo->arping_len + 1));
                        if (naddr == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return -1;
                        }
                        ifo->arping = naddr;
@@ -1258,10 +1240,10 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                    ifo->dstmask, arg, 2) != 0)
                {
                        if (errno == EINVAL)
-                               logger(ctx, LOG_ERR, "option `%s' does not take"
+                               syslog(LOG_ERR, "option `%s' does not take"
                                    " an IPv4 address", arg);
                        else
-                               logger(ctx, LOG_ERR, "unknown option `%s'", arg);
+                               syslog(LOG_ERR, "unknown option `%s'", arg);
                        return -1;
                }
                break;
@@ -1270,7 +1252,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                free(ifo->fallback);
                ifo->fallback = strdup(arg);
                if (ifo->fallback == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                break;
@@ -1278,12 +1260,12 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
        case O_IAID:
                ARG_REQUIRED;
                if (ifname == NULL) {
-                       logger(ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "IAID must belong in an interface block");
                        return -1;
                }
                if (parse_iaid(ifo->iaid, arg, sizeof(ifo->iaid)) == -1) {
-                       logger(ctx, LOG_ERR, "invalid IAID %s", arg);
+                       syslog(LOG_ERR, "invalid IAID %s", arg);
                        return -1;
                }
                ifo->options |= DHCPCD_IAID;
@@ -1323,14 +1305,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
        case O_IA_PD:
                if (i == 0) {
                        if (ifname == NULL) {
-                               logger(ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "IA PD must belong in an interface block");
                                return -1;
                        }
                        i = D6_OPTION_IA_PD;
                }
                if (ifname == NULL && arg) {
-                       logger(ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "IA with IAID must belong in an interface block");
                        return -1;
                }
@@ -1345,7 +1327,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        if (p)
                                *p++ = '\0';
                        if (parse_iaid(iaid, arg, sizeof(iaid)) == -1) {
-                               logger(ctx, LOG_ERR, "invalid IAID: %s", arg);
+                               syslog(LOG_ERR, "invalid IAID: %s", arg);
                                return -1;
                        }
                }
@@ -1363,14 +1345,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        }
                }
                if (ia && ia->ia_type != (uint16_t)i) {
-                       logger(ctx, LOG_ERR, "Cannot mix IA for the same IAID");
+                       syslog(LOG_ERR, "Cannot mix IA for the same IAID");
                        break;
                }
                if (ia == NULL) {
                        ia = realloc(ifo->ia,
                            sizeof(*ifo->ia) * (ifo->ia_len + 1));
                        if (ia == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return -1;
                        }
                        ifo->ia = ia;
@@ -1396,14 +1378,14 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                if (p)
                                        *p++ = '\0';
                                if (inet_pton(AF_INET6, arg, &ia->addr) == -1) {
-                                       logger(ctx, LOG_ERR, "%s: %m", arg);
+                                       syslog(LOG_ERR, "%s: %m", arg);
                                        memset(&ia->addr, 0, sizeof(ia->addr));
                                }
                                if (p && ia->ia_type == D6_OPTION_IA_PD) {
                                        ia->prefix_len = (uint8_t)strtou(p,
                                            NULL, 0, 8, 120, &e);
                                        if (e) {
-                                               logger(ctx, LOG_ERR,
+                                               syslog(LOG_ERR,
                                                    "%s: failed to convert"
                                                    " prefix len",
                                                    p);
@@ -1426,7 +1408,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        sla = realloc(ia->sla,
                            sizeof(*ia->sla) * (ia->sla_len + 1));
                        if (sla == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return -1;
                        }
                        ia->sla = sla;
@@ -1437,8 +1419,8 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        if (strlcpy(sla->ifname, p,
                            sizeof(sla->ifname)) >= sizeof(sla->ifname))
                        {
-                               logger(ctx, LOG_ERR,
-                                   "%s: interface name too long", arg);
+                               syslog(LOG_ERR,
+                                    "%s: interface name too long", arg);
                                goto err_sla;
                        }
                        sla->sla_set = 0;
@@ -1454,7 +1436,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                            0, 0, UINT32_MAX, &e);
                                        sla->sla_set = 1;
                                        if (e) {
-                                               logger(ctx, LOG_ERR,
+                                               syslog(LOG_ERR,
                                                    "%s: failed to convert sla",
                                                    ifname);
                                                goto err_sla;
@@ -1470,7 +1452,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                        sla->prefix_len = (uint8_t)strtou(p,
                                    NULL, 0, 0, 120, &e);
                                        if (e) {
-                                               logger(ctx, LOG_ERR,
+                                               syslog(LOG_ERR,
                                                    "%s: failed to "
                                                    "convert prefix len",
                                                    ifname);
@@ -1487,7 +1469,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                        sla->suffix = (uint64_t)strtou(p, NULL,
                                            0, 0, UINT64_MAX, &e);
                                        if (e) {
-                                               logger(ctx, LOG_ERR,
+                                               syslog(LOG_ERR,
                                                    "%s: failed to "
                                                    "convert suffix",
                                                    ifname);
@@ -1499,7 +1481,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                        for (sl = 0; sl < ia->sla_len - 1; sl++) {
                                slap = &ia->sla[sl];
                                if (slap->sla_set != sla->sla_set) {
-                                       logger(ctx, LOG_ERR,
+                                       syslog(LOG_ERR,
                                            "%s: cannot mix automatic "
                                            "and fixed SLA",
                                            sla->ifname);
@@ -1509,7 +1491,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                    (sla->prefix_len == ia->prefix_len ||
                                    slap->prefix_len == ia->prefix_len))
                                {
-                                       logger(ctx, LOG_ERR,
+                                       syslog(LOG_ERR,
                                            "%s: cannot delegte the same"
                                            "prefix length more than once",
                                            sla->ifname);
@@ -1518,7 +1500,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                if (sla->sla_set == 0 &&
                                    strcmp(slap->ifname, sla->ifname) == 0)
                                {
-                                       logger(ctx, LOG_WARNING,
+                                       syslog(LOG_WARNING,
                                            "%s: cannot specify the "
                                            "same interface twice with "
                                            "an automatic SLA",
@@ -1528,7 +1510,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
                                if (slap->sla_set && sla->sla_set &&
                                    slap->sla == sla->sla)
                                {
-                                       logger(ctx, LOG_ERR, "%s: cannot"
+                                       syslog(LOG_ERR, "%s: cannot"
                                            " assign the same SLA %u"
                                            " more than once",
                                            sla->ifname, sla->sla);
@@ -1589,7 +1571,7 @@ err_sla:
                                dop = &(*ldop)->embopts;
                                dop_len = &(*ldop)->embopts_len;
                        } else {
-                               logger(ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "embed must be after a define or encap");
                                return -1;
                        }
@@ -1599,7 +1581,7 @@ err_sla:
                ARG_REQUIRED;
                if (dop == NULL) {
                        if (*ldop == NULL) {
-                               logger(ctx, LOG_ERR, "encap must be after a define");
+                               syslog(LOG_ERR, "encap must be after a define");
                                return -1;
                        }
                        dop = &(*ldop)->encopts;
@@ -1614,18 +1596,18 @@ err_sla:
                else {
                        fp = strwhite(arg);
                        if (fp == NULL) {
-                               logger(ctx, LOG_ERR, "invalid syntax: %s", arg);
+                               syslog(LOG_ERR, "invalid syntax: %s", arg);
                                return -1;
                        }
                        *fp++ = '\0';
                        u = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e);
                        if (e) {
-                               logger(ctx, LOG_ERR, "invalid code: %s", arg);
+                               syslog(LOG_ERR, "invalid code: %s", arg);
                                return -1;
                        }
                        arg = strskipwhite(fp);
                        if (arg == NULL) {
-                               logger(ctx, LOG_ERR, "invalid syntax");
+                               syslog(LOG_ERR, "invalid syntax");
                                return -1;
                        }
                }
@@ -1640,7 +1622,7 @@ err_sla:
                        bp = NULL; /* No bitflag */
                        l = (long)strtou(np, NULL, 0, 0, LONG_MAX, &e);
                        if (e) {
-                               logger(ctx,LOG_ERR, "failed to convert length");
+                               syslog(LOG_ERR, "failed to convert length");
                                return -1;
                        }
                } else {
@@ -1655,7 +1637,7 @@ err_sla:
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
-                               logger(ctx, LOG_ERR, "incomplete request type");
+                               syslog(LOG_ERR, "incomplete request type");
                                return -1;
                        }
                        *fp++ = '\0';
@@ -1664,7 +1646,7 @@ err_sla:
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
-                               logger(ctx, LOG_ERR, "incomplete request type");
+                               syslog(LOG_ERR, "incomplete request type");
                                return -1;
                        }
                        *fp++ = '\0';
@@ -1674,8 +1656,7 @@ err_sla:
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
-                               logger(ctx, LOG_ERR,
-                                   "incomplete optional type");
+                               syslog(LOG_ERR, "incomplete optional type");
                                return -1;
                        }
                        *fp++ = '\0';
@@ -1685,7 +1666,7 @@ err_sla:
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
-                               logger(ctx, LOG_ERR, "incomplete index type");
+                               syslog(LOG_ERR, "incomplete index type");
                                return -1;
                        }
                        *fp++ = '\0';
@@ -1695,7 +1676,7 @@ err_sla:
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
-                               logger(ctx, LOG_ERR, "incomplete array type");
+                               syslog(LOG_ERR, "incomplete array type");
                                return -1;
                        }
                        *fp++ = '\0';
@@ -1745,29 +1726,29 @@ err_sla:
                else if (strcasecmp(arg, "option") == 0)
                        t |= OT_OPTION;
                else {
-                       logger(ctx, LOG_ERR, "unknown type: %s", arg);
+                       syslog(LOG_ERR, "unknown type: %s", arg);
                        return -1;
                }
                if (l && !(t & (OT_STRING | OT_BINHEX))) {
-                       logger(ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "ignoring length for type `%s'", arg);
                        l = 0;
                }
                if (t & OT_ARRAY && t & (OT_STRING | OT_BINHEX) &&
                    !(t & (OT_RFC1035 | OT_DOMAIN)))
                {
-                       logger(ctx, LOG_WARNING, "ignoring array for strings");
+                       syslog(LOG_WARNING, "ignoring array for strings");
                        t &= ~OT_ARRAY;
                }
                if (t & OT_BITFLAG) {
                        if (bp == NULL)
-                               logger(ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "missing bitflag assignment");
                }
                /* variable */
                if (!fp) {
                        if (!(t & OT_OPTION)) {
-                               logger(ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "type %s requires a variable name", arg);
                                return -1;
                        }
@@ -1780,8 +1761,7 @@ err_sla:
                        if (strcasecmp(arg, "reserved")) {
                                np = strdup(arg);
                                if (np == NULL) {
-                                       logger(ctx, LOG_ERR,
-                                           "%s: %m", __func__);
+                                       syslog(LOG_ERR, "%s: %m", __func__);
                                        return -1;
                                }
                        } else {
@@ -1805,7 +1785,7 @@ err_sla:
                        if ((ndop = realloc(*dop,
                            sizeof(**dop) * ((*dop_len) + 1))) == NULL)
                        {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                free(np);
                                return -1;
                        }
@@ -1848,23 +1828,23 @@ err_sla:
                        *fp++ = '\0';
                u = (uint32_t)strtou(arg, NULL, 0, 0, UINT32_MAX, &e);
                if (e) {
-                       logger(ctx, LOG_ERR, "invalid code: %s", arg);
+                       syslog(LOG_ERR, "invalid code: %s", arg);
                        return -1;
                }
                if (fp) {
                        s = parse_string(NULL, 0, fp);
                        if (s == -1) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return -1;
                        }
                        dl = (size_t)s;
                        if (dl + (sizeof(uint16_t) * 2) > UINT16_MAX) {
-                               logger(ctx, LOG_ERR, "vendor class is too big");
+                               syslog(LOG_ERR, "vendor class is too big");
                                return -1;
                        }
                        np = malloc(dl);
                        if (np == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return -1;
                        }
                        parse_string(np, dl, fp);
@@ -1875,7 +1855,7 @@ err_sla:
                vivco = realloc(ifo->vivco, sizeof(*ifo->vivco) *
                    (ifo->vivco_len + 1));
                if (vivco == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                ifo->vivco = vivco;
@@ -1897,7 +1877,7 @@ err_sla:
                else if (strcasecmp(arg, "delayedrealm") == 0)
                        ifo->auth.protocol = AUTH_PROTO_DELAYEDREALM;
                else {
-                       logger(ctx, LOG_ERR, "%s: unsupported protocol", arg);
+                       syslog(LOG_ERR, "%s: unsupported protocol", arg);
                        return -1;
                }
                arg = strskipwhite(fp);
@@ -1917,7 +1897,7 @@ err_sla:
                    strcasecmp(arg, "hmac-md5") == 0)
                        ifo->auth.algorithm = AUTH_ALG_HMAC_MD5;
                else {
-                       logger(ctx, LOG_ERR, "%s: unsupported algorithm", arg);
+                       syslog(LOG_ERR, "%s: unsupported algorithm", arg);
                        return 1;
                }
                arg = fp;
@@ -1933,13 +1913,13 @@ err_sla:
                    strcasecmp(arg, "monotime") == 0)
                        ifo->auth.rdm = AUTH_RDM_MONOTONIC;
                else {
-                       logger(ctx, LOG_ERR, "%s: unsupported RDM", arg);
+                       syslog(LOG_ERR, "%s: unsupported RDM", arg);
                        return -1;
                }
                ifo->auth.options |= DHCPCD_AUTH_SEND;
                break;
 #else
-               logger(ctx, LOG_ERR, "no authentication support");
+               syslog(LOG_ERR, "no authentication support");
                return -1;
 #endif
        case O_AUTHTOKEN:
@@ -1947,32 +1927,32 @@ err_sla:
 #ifdef AUTH
                fp = strwhite(arg);
                if (fp == NULL) {
-                       logger(ctx, LOG_ERR, "authtoken requires a realm");
+                       syslog(LOG_ERR, "authtoken requires a realm");
                        return -1;
                }
                *fp++ = '\0';
                token = malloc(sizeof(*token));
                if (token == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        free(token);
                        return -1;
                }
                if (parse_uint32(&token->secretid, arg) == -1) {
-                       logger(ctx, LOG_ERR, "%s: not a number", arg);
+                       syslog(LOG_ERR, "%s: not a number", arg);
                        free(token);
                        return -1;
                }
                arg = fp;
                fp = strend(arg);
                if (fp == NULL) {
-                       logger(ctx, LOG_ERR, "authtoken requies an a key");
+                       syslog(LOG_ERR, "authtoken requies an a key");
                        free(token);
                        return -1;
                }
                *fp++ = '\0';
                s = parse_string(NULL, 0, arg);
                if (s == -1) {
-                       logger(ctx, LOG_ERR, "realm_len: %m");
+                       syslog(LOG_ERR, "realm_len: %m");
                        free(token);
                        return -1;
                }
@@ -1981,7 +1961,7 @@ err_sla:
                        token->realm = malloc(token->realm_len);
                        if (token->realm == NULL) {
                                free(token);
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return -1;
                        }
                        parse_string((char *)token->realm, token->realm_len,
@@ -1993,7 +1973,7 @@ err_sla:
                arg = fp;
                fp = strend(arg);
                if (fp == NULL) {
-                       logger(ctx, LOG_ERR, "authtoken requies an an expiry date");
+                       syslog(LOG_ERR, "authtoken requies an an expiry date");
                        free(token->realm);
                        free(token);
                        return -1;
@@ -2012,13 +1992,13 @@ err_sla:
 
                        memset(&tm, 0, sizeof(tm));
                        if (strptime(arg, "%Y-%m-%d %H:%M", &tm) == NULL) {
-                               logger(ctx, LOG_ERR, "%s: invalid date time", arg);
+                               syslog(LOG_ERR, "%s: invalid date time", arg);
                                free(token->realm);
                                free(token);
                                return -1;
                        }
                        if ((token->expire = mktime(&tm)) == (time_t)-1) {
-                               logger(ctx, LOG_ERR, "%s: mktime: %m", __func__);
+                               syslog(LOG_ERR, "%s: mktime: %m", __func__);
                                free(token->realm);
                                free(token);
                                return -1;
@@ -2027,7 +2007,7 @@ err_sla:
                arg = fp;
                s = parse_string(NULL, 0, arg);
                if (s == -1 || s == 0) {
-                       logger(ctx, LOG_ERR, s == -1 ? "token_len: %m" : 
+                       syslog(LOG_ERR, s == -1 ? "token_len: %m" :
                            "authtoken needs a key");
                        free(token->realm);
                        free(token);
@@ -2038,7 +2018,7 @@ err_sla:
                parse_string((char *)token->key, token->key_len, arg);
                TAILQ_INSERT_TAIL(&ifo->auth.tokens, token, next);
 #else
-               logger(ctx, LOG_ERR, "no authentication support");
+               syslog(LOG_ERR, "no authentication support");
                return -1;
 #endif
                break;
@@ -2067,7 +2047,7 @@ err_sla:
                        dl = (size_t)l;
                p = malloc(dl);
                if (p == NULL) {
-                       logger(ctx, LOG_ERR, "%s: malloc: %m", __func__);
+                       syslog(LOG_ERR, "%s: malloc: %m", __func__);
                        return -1;
                }
                while ((i = getgrnam_r(arg, &grpbuf, p, (size_t)l, &grp)) ==
@@ -2075,14 +2055,14 @@ err_sla:
                {
                        size_t nl = dl * 2;
                        if (nl < dl) {
-                               logger(ctx, LOG_ERR, "control_group: out of buffer");
+                               syslog(LOG_ERR, "control_group: out of buffer");
                                free(p);
                                return -1;
                        }
                        dl = nl;
                        np = realloc(p, dl);
                        if (np == NULL) {
-                               logger(ctx, LOG_ERR, "control_group: realloc: %m");
+                               syslog(LOG_ERR, "control_group: realloc: %m");
                                free(p);
                                return -1;
                        }
@@ -2090,12 +2070,12 @@ err_sla:
                }
                if (i != 0) {
                        errno = i;
-                       logger(ctx, LOG_ERR, "getgrnam_r: %m");
+                       syslog(LOG_ERR, "getgrnam_r: %m");
                        free(p);
                        return -1;
                }
                if (grp == NULL) {
-                       logger(ctx, LOG_ERR, "controlgroup: %s: not found", arg);
+                       syslog(LOG_ERR, "controlgroup: %s: not found", arg);
                        free(p);
                        return -1;
                }
@@ -2104,7 +2084,7 @@ err_sla:
 #else
                grp = getgrnam(arg);
                if (grp == NULL) {
-                       logger(ctx, LOG_ERR, "controlgroup: %s: not found", arg);
+                       syslog(LOG_ERR, "controlgroup: %s: not found", arg);
                        return -1;
                }
                ctx->control_group = grp->gr_gid;
@@ -2138,10 +2118,10 @@ err_sla:
                ifo->options |= DHCPCD_INACTIVE;
                break;
        case O_MUDURL:
-               ARG_REQUIRED;
+               ARG_REQUIRED;
                s = parse_string((char *)ifo->mudurl + 1, MUDURL_MAX_LEN, arg);
                if (s == -1) {
-                       logger(ctx, LOG_ERR, "mudurl: %m");
+                       syslog(LOG_ERR, "mudurl: %m");
                        return -1;
                }
                *ifo->mudurl = (uint8_t)s;
@@ -2154,7 +2134,7 @@ err_sla:
 
 #ifdef ARG_REQUIRED
 arg_required:
-       logger(ctx, LOG_ERR, "option %d requires an argument", opt);
+       syslog(LOG_ERR, "option %d requires an argument", opt);
        return -1;
 #undef ARG_REQUIRED
 #endif
@@ -2183,7 +2163,7 @@ parse_config_line(struct dhcpcd_ctx *ctx, const char *ifname,
                    ldop, edop);
        }
 
-       logger(ctx, LOG_ERR, "unknown option: %s", opt);
+       syslog(LOG_ERR, "unknown option: %s", opt);
        return -1;
 }
 
@@ -2248,7 +2228,7 @@ default_config(struct dhcpcd_ctx *ctx)
 
        /* Seed our default options */
        if ((ifo = calloc(1, sizeof(*ifo))) == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return NULL;
        }
        ifo->options |= DHCPCD_IF_UP | DHCPCD_LINK | DHCPCD_INITIAL_DELAY;
@@ -2322,7 +2302,7 @@ read_config(struct dhcpcd_ctx *ctx,
                ifo->dhcp_override =
                    calloc(INITDEFINES, sizeof(*ifo->dhcp_override));
                if (ifo->dhcp_override == NULL)
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                else
                        ifo->dhcp_override_len = INITDEFINES;
 #endif
@@ -2331,7 +2311,7 @@ read_config(struct dhcpcd_ctx *ctx,
                ifo->nd_override =
                    calloc(INITDEFINENDS, sizeof(*ifo->nd_override));
                if (ifo->nd_override == NULL)
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                else
                        ifo->nd_override_len = INITDEFINENDS;
 #endif
@@ -2339,7 +2319,7 @@ read_config(struct dhcpcd_ctx *ctx,
                ifo->dhcp6_override =
                    calloc(INITDEFINE6S, sizeof(*ifo->dhcp6_override));
                if (ifo->dhcp6_override == NULL)
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                else
                        ifo->dhcp6_override_len = INITDEFINE6S;
 #endif
@@ -2348,14 +2328,14 @@ read_config(struct dhcpcd_ctx *ctx,
 #ifdef EMBEDDED_CONFIG
                fp = fopen(EMBEDDED_CONFIG, "r");
                if (fp == NULL)
-                       logger(ctx, LOG_ERR, "fopen `%s': %m", EMBEDDED_CONFIG);
+                       syslog(LOG_ERR, "fopen `%s': %m", EMBEDDED_CONFIG);
 
                while (fp && (line = get_line(&buf, &buflen, fp))) {
 #else
                buflen = 80;
                buf = malloc(buflen);
                if (buf == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        free_options(ifo);
                        return NULL;
                }
@@ -2368,8 +2348,7 @@ read_config(struct dhcpcd_ctx *ctx,
                                buflen = ol;
                                nbuf = realloc(buf, buflen);
                                if (nbuf == NULL) {
-                                       logger(ctx, LOG_ERR,
-                                           "%s: %m", __func__);
+                                       syslog(LOG_ERR, "%s: %m", __func__);
                                        free(buf);
                                        free_options(ifo);
                                        return NULL;
@@ -2445,7 +2424,7 @@ read_config(struct dhcpcd_ctx *ctx,
        if (fp == NULL) {
                /* dhcpcd can continue without it, but no DNS options
                 * would be requested ... */
-               logger(ctx, LOG_WARNING, "fopen `%s': %m", ctx->cffile);
+               syslog(LOG_WARNING, "fopen `%s': %m", ctx->cffile);
                free(buf);
                return ifo;
        }
@@ -2492,13 +2471,13 @@ read_config(struct dhcpcd_ctx *ctx,
                        n = reallocarray(ctx->ifcv,
                            (size_t)ctx->ifcc + 1, sizeof(char *));
                        if (n == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                continue;
                        }
                        ctx->ifcv = n;
                        ctx->ifcv[ctx->ifcc] = strdup(line);
                        if (ctx->ifcv[ctx->ifcc] == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                continue;
                        }
                        ctx->ifcc++;
index 1c677582334107f503d6e062667c34651c71bf80..3ecc36b9fad373a2fb0558320066d9d3cf6696f6 100644 (file)
@@ -42,7 +42,7 @@
 
 /* Don't set any optional arguments here so we retain POSIX
  * compatibility with getopt */
-#define IF_OPTS "146bc:de:f:gh:i:j:kl:m:no:pqr:s:t:u:v:wxy:z:" \
+#define IF_OPTS "146bc:de:f:gh:i:kl:m:no:pqr:s:t:u:v:wxy:z:" \
                "ABC:DEF:GHI:JKLMNO:PQ:S:TUVW:X:Z:"
 #define NOERR_IF_OPTS          ":" IF_OPTS
 
@@ -77,7 +77,7 @@
 #define DHCPCD_HOSTNAME                        (1ULL << 18)
 #define DHCPCD_CLIENTID                        (1ULL << 19)
 #define DHCPCD_LINK                    (1ULL << 20)
-#define DHCPCD_QUIET                   (1ULL << 21)
+// unused                              (1ULL << 21)
 #define DHCPCD_BACKGROUND              (1ULL << 22)
 #define DHCPCD_VENDORRAW               (1ULL << 23)
 #define DHCPCD_NOWAITIP                        (1ULL << 24) /* To force daemonise */
index f154697ab85a3ee018cd73b73de9770b2bba928c..0e6fb83c7c82fa13c1dfe826ed3ac3ba592b03d9 100644 (file)
--- a/src/if.c
+++ b/src/if.c
@@ -58,6 +58,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -224,7 +225,7 @@ static void if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
                            ifa->ifa_name);
                        if (addrflags == -1) {
                                if (errno != EEXIST)
-                                       logger(ctx, LOG_ERR,
+                                       syslog(LOG_ERR,
                                            "%s: if_addrflags: %s: %m",
                                            __func__,
                                            inet_ntoa(addr->sin_addr));
@@ -251,7 +252,7 @@ static void if_learnaddrs(struct dhcpcd_ctx *ctx, struct if_head *ifs,
                            ifa->ifa_name);
                        if (addrflags == -1) {
                                if (errno != EEXIST)
-                                       logger(ctx, LOG_ERR,
+                                       syslog(LOG_ERR,
                                            "%s: if_addrflags6:  %m", __func__);
                                continue;
                        }
@@ -360,7 +361,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
                }
 
                if (if_vimaster(ctx, spec.devname) == 1) {
-                       logger(ctx, argc ? LOG_ERR : LOG_DEBUG,
+                       syslog(argc ? LOG_ERR : LOG_DEBUG,
                            "%s: is a Virtual Interface Master, skipping",
                            spec.devname);
                        continue;
@@ -368,7 +369,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
 
                ifp = calloc(1, sizeof(*ifp));
                if (ifp == NULL) {
-                       logger(ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        break;
                }
                ifp->ctx = ctx;
@@ -412,7 +413,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
                                    ctx->ifac == 0 && active &&
                                    !if_hasconf(ctx, ifp->name))
                                {
-                                       logger(ifp->ctx, LOG_DEBUG,
+                                       syslog(LOG_DEBUG,
                                            "%s: ignoring due to"
                                            " interface type and"
                                            " no config",
@@ -447,7 +448,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
                                    !if_hasconf(ctx, ifp->name))
                                        active = IF_INACTIVE;
                                if (active)
-                                       logger(ifp->ctx, LOG_WARNING,
+                                       syslog(LOG_WARNING,
                                            "%s: unsupported"
                                            " interface type %.2x",
                                            ifp->name, sdl->sdl_type);
@@ -493,7 +494,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
 #ifndef AF_LINK
                        default:
                                if (active)
-                                       logger(ifp->ctx, LOG_WARNING,
+                                       syslog(LOG_WARNING,
                                            "%s: unsupported"
                                            " interface family %.2x",
                                            ifp->name, ifp->family);
@@ -505,8 +506,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
                if (!(ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST))) {
                        /* Handle any platform init for the interface */
                        if (active != IF_INACTIVE && if_init(ifp) == -1) {
-                               logger(ifp->ctx, LOG_ERR, "%s: if_init: %m",
-                                   ifp->name);
+                               syslog(LOG_ERR, "%s: if_init: %m", ifp->name);
                                if_free(ifp);
                                continue;
                        }
@@ -515,8 +515,7 @@ if_discover(struct dhcpcd_ctx *ctx, int argc, char * const *argv)
                        if (if_getmtu(ifp) < MTU_MIN && active &&
                            if_setmtu(ifp, MTU_MIN) == -1)
                        {
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: if_setmtu: %m", ifp->name);
+                               syslog(LOG_ERR, "%s: if_setmtu: %m", ifp->name);
                                if_free(ifp);
                                continue;
                        }
index 5e5902ddca8e5d1811601e96645b677aa002ab6d..e6d7c55949c9ef16fbdd662d74227195faf29192 100644 (file)
@@ -40,6 +40,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #include "config.h"
@@ -382,7 +383,7 @@ inet_routerhostroute(struct rt_head *routes, struct interface *ifp)
                                char buf[INET_MAX_ADDRSTRLEN];
 
                                ifo->options |= DHCPCD_ROUTER_HOST_ROUTE_WARNED;
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: forcing router %s through interface",
                                    ifp->name,
                                    sa_addrtop(&rt->rt_gateway,
@@ -397,7 +398,7 @@ inet_routerhostroute(struct rt_head *routes, struct interface *ifp)
                        char buf[INET_MAX_ADDRSTRLEN];
 
                        ifo->options |= DHCPCD_ROUTER_HOST_ROUTE_WARNED;
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "%s: router %s requires a host route",
                            ifp->name,
                            sa_addrtop(&rt->rt_gateway, buf, sizeof(buf)));
@@ -465,15 +466,14 @@ ipv4_deladdr(struct ipv4_addr *addr, int keeparp)
        UNUSED(keeparp);
 #endif
 
-       logger(addr->iface->ctx, LOG_DEBUG,
-           "%s: deleting IP address %s", addr->iface->name, addr->saddr);
+       syslog(LOG_DEBUG, "%s: deleting IP address %s",
+           addr->iface->name, addr->saddr);
 
        r = if_address(RTM_DELADDR, addr);
        if (r == -1 &&
            errno != EADDRNOTAVAIL && errno != ESRCH &&
            errno != ENXIO && errno != ENODEV)
-               logger(addr->iface->ctx, LOG_ERR, "%s: %s: %m",
-                   addr->iface->name, __func__);
+               syslog(LOG_ERR, "%s: %s: %m", addr->iface->name, __func__);
 
 #ifdef ARP
        if (!keeparp && (astate = arp_find(addr->iface, &addr->addr)) != NULL)
@@ -529,7 +529,7 @@ ipv4_getstate(struct interface *ifp)
                ifp->if_data[IF_DATA_IPV4] = malloc(sizeof(*state));
                state = IPV4_STATE(ifp);
                if (state == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return NULL;
                }
                TAILQ_INIT(&state->addrs);
@@ -597,7 +597,7 @@ ipv4_addaddr(struct interface *ifp, const struct in_addr *addr,
 #endif
 
        if ((state = ipv4_getstate(ifp)) == NULL) {
-               logger(ifp->ctx, LOG_ERR, "%s: ipv4_getstate: %m", __func__);
+               syslog(LOG_ERR, "%s: ipv4_getstate: %m", __func__);
                return NULL;
        }
        if (ifp->options->options & DHCPCD_NOALIAS) {
@@ -610,7 +610,7 @@ ipv4_addaddr(struct interface *ifp, const struct in_addr *addr,
        }
 
        if ((ia = malloc(sizeof(*ia))) == NULL) {
-               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return NULL;
        }
 
@@ -627,20 +627,19 @@ ipv4_addaddr(struct interface *ifp, const struct in_addr *addr,
 #ifdef ALIAS_ADDR
        blank = (ia->alias[0] == '\0');
        if ((replaced = ipv4_aliasaddr(ia, &replaced_ia)) == -1) {
-               logger(ifp->ctx, LOG_ERR, "%s: ipv4_aliasaddr: %m", ifp->name);
+               syslog(LOG_ERR, "%s: ipv4_aliasaddr: %m", ifp->name);
                free(ia);
                return NULL;
        }
        if (blank)
-               logger(ia->iface->ctx, LOG_DEBUG, "%s: aliased %s",
-                   ia->alias, ia->saddr);
+               syslog(LOG_DEBUG, "%s: aliased %s", ia->alias, ia->saddr);
 #endif
 
-       logger(ifp->ctx, LOG_DEBUG, "%s: adding IP address %s broadcast %s",
+       syslog(LOG_DEBUG, "%s: adding IP address %s broadcast %s",
            ifp->name, ia->saddr, inet_ntoa(*bcast));
        if (if_address(RTM_NEWADDR, ia) == -1) {
                if (errno != EEXIST)
-                       logger(ifp->ctx, LOG_ERR, "%s: if_addaddress: %m",
+                       syslog(LOG_ERR, "%s: if_addaddress: %m",
                            __func__);
                free(ia);
                return NULL;
@@ -755,14 +754,14 @@ ipv4_applyaddr(void *arg)
                    nstate->addr->addr.s_addr == lease->addr.s_addr)
                {
                        if (r == 0) {
-                               logger(ifp->ctx, LOG_INFO,
+                               syslog(LOG_INFO,
                                    "%s: preferring %s on %s",
                                    ifp->name,
                                    inet_ntoa(lease->addr),
                                    ifn->name);
                                return;
                        }
-                       logger(ifp->ctx, LOG_INFO, "%s: preferring %s on %s",
+                       syslog(LOG_INFO, "%s: preferring %s on %s",
                            ifn->name,
                            inet_ntoa(lease->addr),
                            ifp->name);
@@ -787,8 +786,7 @@ ipv4_applyaddr(void *arg)
        if (ia &&
            ia->mask.s_addr == lease->mask.s_addr &&
            ia->brd.s_addr == lease->brd.s_addr)
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: IP address %s already exists",
+               syslog(LOG_DEBUG, "%s: IP address %s already exists",
                    ifp->name, ia->saddr);
        else {
 #if __linux__
@@ -805,7 +803,7 @@ ipv4_applyaddr(void *arg)
 
        ia = ipv4_iffindaddr(ifp, &lease->addr, NULL);
        if (ia == NULL) {
-               logger(ifp->ctx, LOG_ERR, "%s: added address vanished",
+               syslog(LOG_ERR, "%s: added address vanished",
                    ifp->name);
                return;
        }
@@ -874,7 +872,7 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
        case RTM_NEWADDR:
                if (ia == NULL) {
                        if ((ia = malloc(sizeof(*ia))) == NULL) {
-                               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                return;
                        }
                        ia->iface = ifp;
index 828c919041baa28188ce13310eff4660a4e25ab7..b5822a2ca370b46d0e60756a30fe9339ee21ed31 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #define ELOOP_QUEUE 6
@@ -188,7 +189,7 @@ ipv4ll_probed(struct arp_state *astate)
 #ifdef IN_IFF_NOTREADY
        if (ia == NULL || ia->addr_flags & IN_IFF_NOTREADY)
 #endif
-               logger(ifp->ctx, LOG_INFO, "%s: using IPv4LL address %s",
+               syslog(LOG_INFO, "%s: using IPv4LL address %s",
                  ifp->name, inet_ntoa(astate->addr));
        if (ia == NULL) {
                if (ifp->ctx->options & DHCPCD_TEST)
@@ -201,7 +202,7 @@ ipv4ll_probed(struct arp_state *astate)
 #ifdef IN_IFF_NOTREADY
        if (ia->addr_flags & IN_IFF_NOTREADY)
                return;
-       logger(ifp->ctx, LOG_DEBUG, "%s: DAD completed for %s",
+       syslog(LOG_DEBUG, "%s: DAD completed for %s",
            ifp->name, inet_ntoa(astate->addr));
 #endif
 test:
@@ -273,8 +274,7 @@ ipv4ll_conflicted(struct arp_state *astate, const struct arp_msg *amsg)
            astate->failed.s_addr == state->addr->addr.s_addr)
        {
 #ifdef KERNEL_RFC5227
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: IPv4LL defence failed for %s",
+               syslog(LOG_WARNING, "%s: IPv4LL defence failed for %s",
                    ifp->name, state->addr->saddr);
 #else
                struct timespec now, defend;
@@ -291,16 +291,14 @@ ipv4ll_conflicted(struct arp_state *astate, const struct arp_msg *amsg)
                defend.tv_nsec = state->defend.tv_nsec;
                clock_gettime(CLOCK_MONOTONIC, &now);
                if (timespeccmp(&defend, &now, >))
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "%s: IPv4LL %d second defence failed for %s",
                            ifp->name, DEFEND_INTERVAL, state->addr->saddr);
                else if (arp_request(ifp,
                    state->addr->addr.s_addr, state->addr->addr.s_addr) == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: arp_request: %m", __func__);
+                       syslog(LOG_ERR, "%s: arp_request: %m", __func__);
                else {
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: defended IPv4LL address %s",
+                       syslog(LOG_DEBUG, "%s: defended IPv4LL address %s",
                            ifp->name, state->addr->saddr);
                        state->defend = now;
                        return;
@@ -320,8 +318,7 @@ ipv4ll_conflicted(struct arp_state *astate, const struct arp_msg *amsg)
 
        arp_cancel(astate);
        if (++state->conflicts == MAX_CONFLICTS)
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: failed to acquire an IPv4LL address",
+               syslog(LOG_ERR, "%s: failed to acquire an IPv4LL address",
                    ifp->name);
        astate->addr.s_addr = ipv4ll_pickaddr(astate);
        eloop_timeout_add_sec(ifp->ctx->eloop,
@@ -410,20 +407,19 @@ ipv4ll_start(void *arg)
                astate->addr = ia->addr;
 #ifdef IN_IFF_TENTATIVE
                if (ia->addr_flags & (IN_IFF_TENTATIVE | IN_IFF_DETACHED)) {
-                       logger(ifp->ctx, LOG_INFO,
+                       syslog(LOG_INFO,
                            "%s: waiting for DAD to complete on %s",
                            ifp->name, inet_ntoa(ia->addr));
                        return;
                }
-               logger(ifp->ctx, LOG_INFO, "%s: using IPv4LL address %s",
-                 ifp->name, ia->saddr);
+               syslog(LOG_INFO, "%s: using IPv4LL address %s",
+                   ifp->name, ia->saddr);
 #endif
                ipv4ll_probed(astate);
                return;
        }
 
-       logger(ifp->ctx, LOG_INFO, "%s: probing for an IPv4LL address",
-           ifp->name);
+       syslog(LOG_INFO, "%s: probing for an IPv4LL address", ifp->name);
        astate->addr.s_addr = ipv4ll_pickaddr(astate);
 #ifdef IN_IFF_TENTATIVE
        ipv4ll_probed(astate);
index 6b1a529d392d14d5903cab2dc8e7dfc58f77d17f..296ad22758a8e0c60c00b9b0729418d9e423f6fb 100644 (file)
@@ -55,6 +55,7 @@
 #include <inttypes.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #define ELOOP_QUEUE 7
@@ -169,7 +170,7 @@ ipv6_readsecret(struct dhcpcd_ctx *ctx)
                return (ssize_t)ctx->secret_len;
 
        if (errno != ENOENT)
-               logger(ctx, LOG_ERR, "error reading secret: %s: %m", SECRET);
+               syslog(LOG_ERR, "error reading secret: %s: %m", SECRET);
 
        /* Chaining arc4random should be good enough.
         * RFC7217 section 5.1 states the key SHOULD be at least 128 bits.
@@ -177,7 +178,7 @@ ipv6_readsecret(struct dhcpcd_ctx *ctx)
         * 512 bits (64 bytes). */
        if (ctx->secret_len < 64) {
                if ((ctx->secret = malloc(64)) == NULL) {
-                       logger(ctx, LOG_ERR, "%s: malloc: %m", __func__);
+                       syslog(LOG_ERR, "%s: malloc: %m", __func__);
                        return -1;
                }
                ctx->secret_len = 64;
@@ -204,7 +205,7 @@ ipv6_readsecret(struct dhcpcd_ctx *ctx)
                return (ssize_t)ctx->secret_len;
 
 eexit:
-       logger(ctx, LOG_ERR, "error writing secret: %s: %m", SECRET);
+       syslog(LOG_ERR, "error writing secret: %s: %m", SECRET);
        if (fp != NULL)
                fclose(fp);
        unlink(SECRET);
@@ -557,8 +558,7 @@ ipv6_checkaddrflags(void *arg)
        alias = NULL;
 #endif
        if ((flags = if_addrflags6(ia->iface, &ia->addr, alias)) == -1) {
-               logger(ia->iface->ctx, LOG_ERR,
-                   "%s: if_addrflags6: %m", ia->iface->name);
+               syslog(LOG_ERR, "%s: if_addrflags6: %m", ia->iface->name);
                return;
        }
 
@@ -584,12 +584,11 @@ ipv6_deleteaddr(struct ipv6_addr *ia)
        struct ipv6_state *state;
        struct ipv6_addr *ap;
 
-       logger(ia->iface->ctx, LOG_INFO, "%s: deleting address %s",
-           ia->iface->name, ia->saddr);
+       syslog(LOG_INFO, "%s: deleting address %s", ia->iface->name, ia->saddr);
        if (if_address6(RTM_DELADDR, ia) == -1 &&
            errno != EADDRNOTAVAIL && errno != ESRCH &&
            errno != ENXIO && errno != ENODEV)
-               logger(ia->iface->ctx, LOG_ERR, "if_address6: %m");
+               syslog(LOG_ERR, "if_address6: %m");
 
        /* NOREJECT is set if we delegated exactly the prefix to another
         * address.
@@ -635,7 +634,7 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now)
            ipv6_iffindaddr(ap->iface, &ap->addr, IN6_IFF_NOTUSEABLE))
                ap->flags |= IPV6_AF_DADCOMPLETED;
 
-       logger(ap->iface->ctx, ap->flags & IPV6_AF_NEW ? LOG_INFO : LOG_DEBUG,
+       syslog(ap->flags & IPV6_AF_NEW ? LOG_INFO : LOG_DEBUG,
            "%s: adding %saddress %s", ap->iface->name,
 #ifdef IPV6_AF_TEMPORARY
            ap->flags & IPV6_AF_TEMPORARY ? "temporary " : "",
@@ -645,19 +644,18 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now)
            ap->saddr);
        if (ap->prefix_pltime == ND6_INFINITE_LIFETIME &&
            ap->prefix_vltime == ND6_INFINITE_LIFETIME)
-               logger(ap->iface->ctx, LOG_DEBUG,
-                   "%s: pltime infinity, vltime infinity",
+               syslog(LOG_DEBUG, "%s: pltime infinity, vltime infinity",
                    ap->iface->name);
        else if (ap->prefix_pltime == ND6_INFINITE_LIFETIME)
-               logger(ap->iface->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: pltime infinity, vltime %"PRIu32" seconds",
                    ap->iface->name, ap->prefix_vltime);
        else if (ap->prefix_vltime == ND6_INFINITE_LIFETIME)
-               logger(ap->iface->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: pltime %"PRIu32"seconds, vltime infinity",
                    ap->iface->name, ap->prefix_pltime);
        else
-               logger(ap->iface->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: pltime %"PRIu32" seconds, vltime %"PRIu32" seconds",
                    ap->iface->name, ap->prefix_pltime, ap->prefix_vltime);
 
@@ -686,13 +684,13 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now)
                        ap->prefix_vltime -= (uint32_t)n.tv_sec;
 
 #if 0
-               logger(ap->iface->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: acquired %lld.%.9ld, now %lld.%.9ld, diff %lld.%.9ld",
                    ap->iface->name,
                    (long long)ap->acquired.tv_sec, ap->acquired.tv_nsec,
                    (long long)now->tv_sec, now->tv_nsec,
                    (long long)n.tv_sec, n.tv_nsec);
-               logger(ap->iface->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: adj pltime %"PRIu32" seconds, "
                    "vltime %"PRIu32" seconds",
                    ap->iface->name, ap->prefix_pltime, ap->prefix_vltime);
@@ -700,7 +698,7 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now)
        }
 
        if (if_address6(RTM_NEWADDR, ap) == -1) {
-               logger(ap->iface->ctx, LOG_ERR, "if_addaddress6: %m");
+               syslog(LOG_ERR, "if_addaddress6: %m");
                /* Restore real pltime and vltime */
                ap->prefix_pltime = pltime;
                ap->prefix_vltime = vltime;
@@ -836,8 +834,7 @@ ipv6_addaddr(struct ipv6_addr *ia, const struct timespec *now)
        if ((replaced = ipv6_aliasaddr(ia, &replaced_ia)) == -1)
                return -1;
        if (blank)
-               logger(ia->iface->ctx, LOG_DEBUG, "%s: aliased %s",
-                   ia->alias, ia->saddr);
+               syslog(LOG_DEBUG, "%s: aliased %s", ia->alias, ia->saddr);
 #endif
 
        if ((r = ipv6_addaddr1(ia, now)) == 0) {
@@ -920,22 +917,21 @@ ipv6_addaddrs(struct ipv6_addrhead *addrs)
                            &ap->addr, IPV6_AF_ADDED);
                        if (apf && apf->iface != ap->iface) {
                                if (apf->iface->metric <= ap->iface->metric) {
-                                       logger(apf->iface->ctx, LOG_INFO,
+                                       syslog(LOG_INFO,
                                            "%s: preferring %s on %s",
                                            ap->iface->name,
                                            ap->saddr,
                                            apf->iface->name);
                                        continue;
                                }
-                               logger(apf->iface->ctx, LOG_INFO,
+                               syslog(LOG_INFO,
                                    "%s: preferring %s on %s",
                                    apf->iface->name,
                                    ap->saddr,
                                    ap->iface->name);
                                if (if_address6(RTM_DELADDR, apf) == -1 &&
                                    errno != EADDRNOTAVAIL && errno != ENXIO)
-                                       logger(apf->iface->ctx, LOG_ERR,
-                                           "if_address6: %m");
+                                       syslog(LOG_ERR, "if_address6: %m");
                                apf->flags &=
                                    ~(IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED);
                        } else if (apf)
@@ -1028,7 +1024,7 @@ ipv6_getstate(struct interface *ifp)
                ifp->if_data[IF_DATA_IPV6] = calloc(1, sizeof(*state));
                state = IPV6_STATE(ifp);
                if (state == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return NULL;
                }
                TAILQ_INIT(&state->addrs);
@@ -1059,7 +1055,7 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx,
 
        dbp = inet_ntop(AF_INET6, &addr->s6_addr,
            dbuf, INET6_ADDRSTRLEN);
-       logger(ctx, LOG_INFO, "%s: cmd %d addr %s",
+       syslog(LOG_INFO, "%s: cmd %d addr %s",
            ifname, cmd, dbp);
 #endif
 
@@ -1090,8 +1086,7 @@ ipv6_handleifa(struct dhcpcd_ctx *ctx,
                        const char *cbp;
 
                        if ((ia = calloc(1, sizeof(*ia))) == NULL) {
-                               logger(ctx, LOG_ERR,
-                                   "%s: calloc: %m", __func__);
+                               syslog(LOG_ERR, "%s: calloc: %m", __func__);
                                break;
                        }
 #ifdef ALIAS_ADDR
@@ -1268,7 +1263,7 @@ ipv6_addlinklocalcallback(struct interface *ifp,
        if (cb == NULL) {
                cb = malloc(sizeof(*cb));
                if (cb == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return -1;
                }
                cb->callback = callback;
@@ -1396,8 +1391,7 @@ nextslaacprivate:
                                return -1;
                        }
 
-                       logger(ap2->iface->ctx, LOG_WARNING,
-                           "%s: waiting for %s to complete",
+                       syslog(LOG_WARNING, "%s: waiting for %s to complete",
                            ap2->iface->name, ap2->saddr);
                        free(ap);
                        errno = EEXIST;
@@ -1477,10 +1471,10 @@ ipv6_staticdadcallback(void *arg)
        wascompleted = (ia->flags & IPV6_AF_DADCOMPLETED);
        ia->flags |= IPV6_AF_DADCOMPLETED;
        if (ia->flags & IPV6_AF_DUPLICATED)
-               logger(ia->iface->ctx, LOG_WARNING, "%s: DAD detected %s",
-                   ia->iface->name, ia->saddr);
+               syslog(LOG_WARNING, "%s: DAD detected %s", ia->iface->name,
+                   ia->saddr);
        else if (!wascompleted) {
-               logger(ia->iface->ctx, LOG_DEBUG, "%s: IPv6 static DAD completed",
+               syslog(LOG_DEBUG, "%s: IPv6 static DAD completed",
                    ia->iface->name);
        }
 
@@ -1514,10 +1508,11 @@ ipv6_env(char **env, const char *prefix, const struct interface *ifp)
 
        ep = env;
        n = 0;
-       ia = ipv6_iffindaddr(UNCONST(ifp), &ifp->options->req_addr6, IN6_IFF_NOTUSEABLE);
+       ia = ipv6_iffindaddr(UNCONST(ifp), &ifp->options->req_addr6,
+           IN6_IFF_NOTUSEABLE);
        if (ia) {
                if (env)
-                       addvar(ifp->ctx, &ep, prefix, "ip6_address", ia->saddr);
+                       addvar(&ep, prefix, "ip6_address", ia->saddr);
                n++;
        }
 
@@ -1685,8 +1680,7 @@ ipv6_handleifa_addrs(int cmd,
                switch (cmd) {
                case RTM_DELADDR:
                        if (ia->flags & IPV6_AF_ADDED) {
-                               logger(ia->iface->ctx, LOG_INFO,
-                                   "%s: deleted address %s",
+                               syslog(LOG_INFO, "%s: deleted address %s",
                                    ia->iface->name, ia->saddr);
                                ia->flags &= ~IPV6_AF_ADDED;
                        }
@@ -1830,15 +1824,14 @@ ipv6_tempdadcallback(void *arg)
                struct timespec tv;
 
                if (++ia->dadcounter == TEMP_IDGEN_RETRIES) {
-                       logger(ia->iface->ctx, LOG_ERR,
+                       syslog(LOG_ERR,
                            "%s: too many duplicate temporary addresses",
                            ia->iface->name);
                        return;
                }
                clock_gettime(CLOCK_MONOTONIC, &tv);
                if ((ia1 = ipv6_createtempaddr(ia, &tv)) == NULL)
-                       logger(ia->iface->ctx, LOG_ERR,
-                           "ipv6_createtempaddr: %m");
+                       syslog(LOG_ERR, "ipv6_createtempaddr: %m");
                else
                        ia1->dadcounter = ia->dadcounter;
                ipv6_deleteaddr(ia);
@@ -2057,14 +2050,13 @@ ipv6_regentempaddr(void *arg)
        struct ipv6_addr *ia = arg, *ia1;
        struct timespec tv;
 
-       logger(ia->iface->ctx, LOG_DEBUG, "%s: regen temp addr %s",
-           ia->iface->name, ia->saddr);
+       syslog(LOG_DEBUG, "%s: regen temp addr %s", ia->iface->name, ia->saddr);
        clock_gettime(CLOCK_MONOTONIC, &tv);
        ia1 = ipv6_createtempaddr(ia, &tv);
        if (ia1)
                ipv6_addaddr(ia1, &tv);
        else
-               logger(ia->iface->ctx, LOG_ERR, "ipv6_createtempaddr: %m");
+               syslog(LOG_ERR, "ipv6_createtempaddr: %m");
 }
 
 static void
@@ -2131,7 +2123,7 @@ inet6_makeprefix(struct interface *ifp, const struct ra *rap,
                                break;
                }
                if (lo0 == NULL)
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "cannot find a loopback interface to reject via");
                else
                        ifp = lo0;
index 7fc6912c5c7e0d0d70f3930ec25e1bedc3f3da63..c6ec085f73003a253352dbdc4b78b30ac232a993 100644 (file)
@@ -39,6 +39,7 @@
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #define ELOOP_QUEUE 3
@@ -267,7 +268,7 @@ ipv6nd_sendrsprobe(void *arg)
        struct in6_pktinfo pi;
 
        if (ipv6_linklocal(ifp) == NULL) {
-               logger(ifp->ctx, LOG_DEBUG,
+               syslog(LOG_DEBUG,
                    "%s: delaying Router Solicitation for LL address",
                    ifp->name);
                ipv6_addlinklocalcallback(ifp, ipv6nd_sendrsprobe, ifp);
@@ -281,7 +282,7 @@ ipv6nd_sendrsprobe(void *arg)
 #endif
        dst.sin6_scope_id = ifp->index;
        if (inet_pton(AF_INET6, ALLROUTERS, &dst.sin6_addr) != 1) {
-               logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return;
        }
 
@@ -302,11 +303,10 @@ ipv6nd_sendrsprobe(void *arg)
        pi.ipi6_ifindex = ifp->index;
        memcpy(CMSG_DATA(cm), &pi, sizeof(pi));
 
-       logger(ifp->ctx, LOG_DEBUG,
+       syslog(LOG_DEBUG,
            "%s: sending Router Solicitation", ifp->name);
        if (sendmsg(ctx->nd_fd, &ctx->sndhdr, 0) == -1) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: %s: sendmsg: %m", ifp->name, __func__);
+               syslog(LOG_ERR, "%s: %s: sendmsg: %m", ifp->name, __func__);
                /* Allow IPv6ND to continue .... at most a few errors
                 * would be logged.
                 * Generally the error is ENOBUFS when struggling to
@@ -317,8 +317,7 @@ ipv6nd_sendrsprobe(void *arg)
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    RTR_SOLICITATION_INTERVAL, ipv6nd_sendrsprobe, ifp);
        else {
-               logger(ifp->ctx, LOG_WARNING,
-                   "%s: no IPv6 Routers available", ifp->name);
+               syslog(LOG_WARNING, "%s: no IPv6 Routers available", ifp->name);
                ipv6nd_drop(ifp);
                dhcp6_dropnondelegates(ifp);
        }
@@ -365,8 +364,7 @@ ipv6nd_reachable(struct ra *rap, int flags)
 
        if (flags & IPV6ND_REACHABLE) {
                if (rap->lifetime && rap->expired) {
-                       logger(rap->iface->ctx, LOG_INFO,
-                           "%s: %s is reachable again",
+                       syslog(LOG_INFO, "%s: %s is reachable again",
                            rap->iface->name, rap->sfrom);
                        rap->expired = 0;
                        rt_build(rap->iface->ctx, AF_INET6);
@@ -375,7 +373,7 @@ ipv6nd_reachable(struct ra *rap, int flags)
                }
        } else {
                if (rap->lifetime && !rap->expired) {
-                       logger(rap->iface->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "%s: %s is unreachable, expiring it",
                            rap->iface->name, rap->sfrom);
                        rap->expired = 1;
@@ -515,8 +513,7 @@ rtpref(struct ra *rap)
        case ND_RA_FLAG_RTPREF_LOW:
                return (RTPREF_LOW);
        default:
-               logger(rap->iface->ctx, LOG_ERR,
-                   "rtpref: impossible RA flag %x", rap->flags);
+               syslog(LOG_ERR, "rtpref: impossible RA flag %x", rap->flags);
                return (RTPREF_INVALID);
        }
        /* NOTREACHED */
@@ -553,10 +550,11 @@ ipv6nd_scriptrun(struct ra *rap)
                {
                        hasaddress = 1;
                        if (!(ap->flags & IPV6_AF_DADCOMPLETED) &&
-                           ipv6_iffindaddr(ap->iface, &ap->addr, IN6_IFF_TENTATIVE))
+                           ipv6_iffindaddr(ap->iface, &ap->addr,
+                           IN6_IFF_TENTATIVE))
                                ap->flags |= IPV6_AF_DADCOMPLETED;
                        if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0) {
-                               logger(ap->iface->ctx, LOG_DEBUG,
+                               syslog(LOG_DEBUG,
                                    "%s: waiting for Router Advertisement"
                                    " DAD to complete",
                                    rap->iface->name);
@@ -580,8 +578,7 @@ ipv6nd_scriptrun(struct ra *rap)
 #if 0
        else if (options & DHCPCD_DAEMONISE &&
            !(options & DHCPCD_DAEMONISED) && new_data)
-               logger(rap->iface->ctx, LOG_WARNING,
-                   "%s: did not fork due to an absent"
+               syslog(LOG_WARNING, "%s: did not fork due to an absent"
                    " RDNSS option in the RA",
                    ifp->name);
 }
@@ -633,7 +630,7 @@ ipv6nd_dadcallback(void *arg)
        ap->flags |= IPV6_AF_DADCOMPLETED;
        if (ap->flags & IPV6_AF_DUPLICATED) {
                ap->dadcounter++;
-               logger(ifp->ctx, LOG_WARNING, "%s: DAD detected %s",
+               syslog(LOG_WARNING, "%s: DAD detected %s",
                    ifp->name, ap->saddr);
 
                /* Try and make another stable private address.
@@ -642,23 +639,22 @@ ipv6nd_dadcallback(void *arg)
                /* XXX Cache DAD counter per prefix/id/ssid? */
                if (ifp->options->options & DHCPCD_SLAACPRIVATE) {
                        if (ap->dadcounter >= IDGEN_RETRIES) {
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: unable to obtain a"
+                               syslog(LOG_ERR, "%s: unable to obtain a"
                                    " stable private address",
                                    ifp->name);
                                goto try_script;
                        }
-                       logger(ifp->ctx, LOG_INFO, "%s: deleting address %s",
-                               ifp->name, ap->saddr);
+                       syslog(LOG_INFO, "%s: deleting address %s",
+                           ifp->name, ap->saddr);
                        if (if_address6(RTM_DELADDR, ap) == -1 &&
                            errno != EADDRNOTAVAIL && errno != ENXIO)
-                               logger(ifp->ctx, LOG_ERR, "if_address6: %m");
+                               syslog(LOG_ERR, "if_address6: %m");
                        dadcounter = ap->dadcounter;
                        if (ipv6_makestableprivate(&ap->addr,
                            &ap->prefix, ap->prefix_len,
                            ifp, &dadcounter) == -1)
                        {
-                               logger(ifp->ctx, LOG_ERR,
+                               syslog(LOG_ERR,
                                    "%s: ipv6_makestableprivate: %m",
                                    ifp->name);
                                return;
@@ -704,7 +700,7 @@ try_script:
                        }
 
                        if (wascompleted && found) {
-                               logger(rap->iface->ctx, LOG_DEBUG,
+                               syslog(LOG_DEBUG,
                                    "%s: Router Advertisement DAD completed",
                                    rap->iface->name);
                                if (ipv6nd_scriptrun(rap))
@@ -751,34 +747,32 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
 
        if (ifp == NULL) {
 #ifdef DEBUG_RS
-               logger(ctx, LOG_DEBUG,
-                   "RA for unexpected interface from %s", ctx->sfrom);
+               syslog(LOG_DEBUG, "RA for unexpected interface from %s",
+                   ctx->sfrom);
 #endif
                return;
        }
 
        if (len < sizeof(struct nd_router_advert)) {
-               logger(ctx, LOG_ERR,
-                   "IPv6 RA packet too short from %s", ctx->sfrom);
+               syslog(LOG_ERR, "IPv6 RA packet too short from %s", ctx->sfrom);
                return;
        }
 
        /* RFC 4861 7.1.2 */
        if (hoplimit != 255) {
-               logger(ctx, LOG_ERR,
-                   "invalid hoplimit(%d) in RA from %s", hoplimit, ctx->sfrom);
+               syslog(LOG_ERR, "invalid hoplimit(%d) in RA from %s",
+                   hoplimit, ctx->sfrom);
                return;
        }
 
        if (!IN6_IS_ADDR_LINKLOCAL(&ctx->from.sin6_addr)) {
-               logger(ctx, LOG_ERR,
-                   "RA from non local address %s", ctx->sfrom);
+               syslog(LOG_ERR, "RA from non local address %s", ctx->sfrom);
                return;
        }
 
        if (!(ifp->options->options & DHCPCD_IPV6RS)) {
 #ifdef DEBUG_RS
-               logger(ifp->ctx, LOG_DEBUG, "%s: unexpected RA from %s",
+               syslog(LOG_DEBUG, "%s: unexpected RA from %s",
                    ifp->name, ctx->sfrom);
 #endif
                return;
@@ -787,16 +781,15 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
        /* We could receive a RA before we sent a RS*/
        if (ipv6_linklocal(ifp) == NULL) {
 #ifdef DEBUG_RS
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: received RA from %s (no link-local)",
+               syslog(LOG_DEBUG, "%s: received RA from %s (no link-local)",
                    ifp->name, ctx->sfrom);
 #endif
                return;
        }
 
        if (ipv6_iffindaddr(ifp, &ctx->from.sin6_addr, IN6_IFF_TENTATIVE)) {
-               logger(ifp->ctx, LOG_DEBUG,
-                   "%s: ignoring RA from ourself %s", ifp->name, ctx->sfrom);
+               syslog(LOG_DEBUG, "%s: ignoring RA from ourself %s",
+                   ifp->name, ctx->sfrom);
                return;
        }
 
@@ -823,7 +816,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
        if (rap == NULL) {
                rap = calloc(1, sizeof(*rap));
                if (rap == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return;
                }
                rap->iface = ifp;
@@ -836,7 +829,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
        if (rap->data_len == 0) {
                rap->data = malloc(len);
                if (rap->data == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        if (new_rap)
                                free(rap);
                        return;
@@ -849,7 +842,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
         * routers like to decrease the advertised valid and preferred times
         * in accordance with the own prefix times which would result in too
         * much needless log spam. */
-       logger(ifp->ctx, new_rap ? LOG_INFO : LOG_DEBUG,
+       syslog(new_rap ? LOG_INFO : LOG_DEBUG,
            "%s: Router Advertisement from %s",
            ifp->name, ctx->sfrom);
 
@@ -876,20 +869,18 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
        p = ((uint8_t *)icp) + sizeof(struct nd_router_advert);
        for (; len > 0; p += olen, len -= olen) {
                if (len < sizeof(ndo)) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: short option", ifp->name);
+                       syslog(LOG_ERR, "%s: short option", ifp->name);
                        break;
                }
                memcpy(&ndo, p, sizeof(ndo));
                olen = (size_t)ndo.nd_opt_len * 8;
                if (olen == 0) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: zero length option", ifp->name);
+                       syslog(LOG_ERR, "%s: zero length option", ifp->name);
                        break;
                }
                if (olen > len) {
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: option length exceeds message", ifp->name);
+                       syslog(LOG_ERR, "%s: option length exceeds message",
+                           ifp->name);
                        break;
                }
 
@@ -904,11 +895,11 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                                        break;
                        }
                        if (dho != NULL)
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: reject RA (option %s) from %s",
                                    ifp->name, dho->var, ctx->sfrom);
                        else
-                               logger(ifp->ctx, LOG_WARNING,
+                               syslog(LOG_WARNING,
                                    "%s: reject RA (option %d) from %s",
                                    ifp->name, ndo.nd_opt_type, ctx->sfrom);
                        if (new_rap)
@@ -924,31 +915,32 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                switch (ndo.nd_opt_type) {
                case ND_OPT_PREFIX_INFORMATION:
                        if (ndo.nd_opt_len != 4) {
-                               logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG,
+                               syslog(new_data ? LOG_ERR : LOG_DEBUG,
                                    "%s: invalid option len for prefix",
                                    ifp->name);
                                continue;
                        }
                        memcpy(&pi, p, sizeof(pi));
                        if (pi.nd_opt_pi_prefix_len > 128) {
-                               logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG,
+                               syslog(new_data ? LOG_ERR : LOG_DEBUG,
                                    "%s: invalid prefix len",
                                    ifp->name);
                                continue;
                        }
                        /* nd_opt_pi_prefix is not aligned. */
-                       memcpy(&pi_prefix, &pi.nd_opt_pi_prefix, sizeof(pi_prefix));
+                       memcpy(&pi_prefix, &pi.nd_opt_pi_prefix,
+                           sizeof(pi_prefix));
                        if (IN6_IS_ADDR_MULTICAST(&pi_prefix) ||
                            IN6_IS_ADDR_LINKLOCAL(&pi_prefix))
                        {
-                               logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG,
+                               syslog(new_data ? LOG_ERR : LOG_DEBUG,
                                    "%s: invalid prefix in RA", ifp->name);
                                continue;
                        }
                        if (ntohl(pi.nd_opt_pi_preferred_time) >
                            ntohl(pi.nd_opt_pi_valid_time))
                        {
-                               logger(ifp->ctx, new_data ? LOG_ERR : LOG_DEBUG,
+                               syslog(new_data ? LOG_ERR : LOG_DEBUG,
                                    "%s: pltime > vltime", ifp->name);
                                continue;
                        }
@@ -1043,7 +1035,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                                if (new_ap && ap->prefix_pltime) {
                                        if (ipv6_createtempaddr(ap,
                                            &ap->acquired) == NULL)
-                                               logger(ap->iface->ctx, LOG_ERR,
+                                               syslog(LOG_ERR,
                                                    "ipv6_createtempaddr: %m");
                                }
                        }
@@ -1054,7 +1046,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                        memcpy(&mtu, p, sizeof(mtu));
                        mtu.nd_opt_mtu_mtu = ntohl(mtu.nd_opt_mtu_mtu);
                        if (mtu.nd_opt_mtu_mtu < IPV6_MMTU) {
-                               logger(ifp->ctx, LOG_ERR, "%s: invalid MTU %d",
+                               syslog(LOG_ERR, "%s: invalid MTU %d",
                                    ifp->name, mtu.nd_opt_mtu_mtu);
                                break;
                        }
@@ -1079,7 +1071,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                if (has_option_mask(ifp->options->requiremasknd,
                    dho->option))
                {
-                       logger(ifp->ctx, LOG_WARNING,
+                       syslog(LOG_WARNING,
                            "%s: reject RA (no option %s) from %s",
                            ifp->name, dho->var, ctx->sfrom);
                        if (new_rap)
@@ -1125,16 +1117,14 @@ handle_flag:
 #endif
        if (rap->flags & ND_RA_FLAG_MANAGED) {
                if (new_data && dhcp6_start(ifp, DH6S_INIT) == -1)
-                       logger(ifp->ctx, LOG_DHCP6,
-                           "dhcp6_start: %s: %m", ifp->name);
+                       syslog(LOG_DHCP6, "dhcp6_start: %s: %m", ifp->name);
        } else if (rap->flags & ND_RA_FLAG_OTHER) {
                if (new_data && dhcp6_start(ifp, DH6S_INFORM) == -1)
-                       logger(ifp->ctx, LOG_DHCP6,
-                           "dhcp6_start: %s: %m", ifp->name);
+                       syslog(LOG_DHCP6, "dhcp6_start: %s: %m", ifp->name);
        } else {
                if (new_data)
-                       logger(ifp->ctx, LOG_DEBUG,
-                           "%s: No DHCPv6 instruction in RA", ifp->name);
+                       syslog(LOG_DEBUG, "%s: No DHCPv6 instruction in RA",
+                           ifp->name);
 nodhcp6:
                if (ifp->ctx->options & DHCPCD_TEST) {
                        eloop_exit(ifp->ctx->eloop, EXIT_SUCCESS);
@@ -1239,16 +1229,14 @@ ipv6nd_env(char **env, const char *prefix, const struct interface *ifp)
                        snprintf(ndprefix, sizeof(ndprefix),
                            "nd%zu", i);
                if (env)
-                       setvar(rap->iface->ctx, &env[n], ndprefix,
-                           "from", rap->sfrom);
+                       setvar(&env[n], ndprefix, "from", rap->sfrom);
                n++;
                if (env)
-                       setvard(rap->iface->ctx, &env[n], ndprefix,
-                           "acquired", (size_t)rap->acquired.tv_sec);
+                       setvard(&env[n], ndprefix, "acquired",
+                           (size_t)rap->acquired.tv_sec);
                n++;
                if (env)
-                       setvard(rap->iface->ctx, &env[n], ndprefix,
-                           "now", (size_t)now.tv_sec);
+                       setvard(&env[n], ndprefix, "now", (size_t)now.tv_sec);
                n++;
 
                /* Zero our indexes */
@@ -1316,8 +1304,7 @@ ipv6nd_env(char **env, const char *prefix, const struct interface *ifp)
                        j++;
                        if (env) {
                                snprintf(abuf, sizeof(abuf), "addr%zu", j);
-                               setvar(rap->iface->ctx, &env[n], ndprefix,
-                                   abuf, ia->saddr);
+                               setvar(&env[n], ndprefix, abuf, ia->saddr);
                        }
                        n++;
                }
@@ -1368,7 +1355,7 @@ ipv6nd_expirera(void *arg)
                        if (rap->lifetime == 0 || timespeccmp(&now, &expire, >))
                        {
                                if (!rap->expired) {
-                                       logger(ifp->ctx, LOG_WARNING,
+                                       syslog(LOG_WARNING,
                                            "%s: %s: router expired",
                                            ifp->name, rap->sfrom);
                                        rap->expired = expired = 1;
@@ -1395,13 +1382,13 @@ ipv6nd_expirera(void *arg)
                        timespecadd(&ia->acquired, &lt, &expire);
                        if (timespeccmp(&now, &expire, >)) {
                                if (ia->flags & IPV6_AF_ADDED) {
-                                       logger(ia->iface->ctx, LOG_WARNING,
+                                       syslog(LOG_WARNING,
                                            "%s: expired address %s",
                                            ia->iface->name, ia->saddr);
                                        if (if_address6(RTM_DELADDR, ia)== -1 &&
                                            errno != EADDRNOTAVAIL &&
                                            errno != ENXIO)
-                                               logger(ia->iface->ctx, LOG_ERR,
+                                               syslog(LOG_ERR,
                                                    "if_address6: %m");
                                }
                                ia->prefix_vltime = ia->prefix_pltime = 0;
@@ -1485,22 +1472,22 @@ ipv6nd_handlena(struct dhcpcd_ctx *ctx, struct interface *ifp,
 
        if (ifp == NULL) {
 #ifdef DEBUG_NS
-               logger(ctx, LOG_DEBUG, "NA for unexpected interface from %s",
+               syslog(LOG_DEBUG, "NA for unexpected interface from %s",
                    ctx->sfrom);
 #endif
                return;
        }
 
        if ((size_t)len < sizeof(struct nd_neighbor_advert)) {
-               logger(ifp->ctx, LOG_ERR, "%s: IPv6 NA too short from %s",
+               syslog(LOG_ERR, "%s: IPv6 NA too short from %s",
                    ifp->name, ctx->sfrom);
                return;
        }
 
        /* RFC 4861 7.1.2 */
        if (hoplimit != 255) {
-               logger(ctx, LOG_ERR,
-                   "invalid hoplimit(%d) in NA from %s", hoplimit, ctx->sfrom);
+               syslog(LOG_ERR, "invalid hoplimit(%d) in NA from %s",
+                   hoplimit, ctx->sfrom);
                return;
        }
 
@@ -1513,7 +1500,7 @@ ipv6nd_handlena(struct dhcpcd_ctx *ctx, struct interface *ifp,
        /* nd_na->nd_na_target is not aligned. */
        memcpy(&nd_na_target, &nd_na->nd_na_target, sizeof(nd_na_target));
        if (IN6_IS_ADDR_MULTICAST(&nd_na_target)) {
-               logger(ifp->ctx, LOG_ERR, "%s: NA multicast address %s (%s)",
+               syslog(LOG_ERR, "%s: NA multicast address %s (%s)",
                    ifp->name, taddr, ctx->sfrom);
                return;
        }
@@ -1525,20 +1512,20 @@ ipv6nd_handlena(struct dhcpcd_ctx *ctx, struct interface *ifp,
        }
        if (rap == NULL) {
 #ifdef DEBUG_NS
-               logger(ifp->ctx, LOG_DEBUG, "%s: unexpected NA from %s for %s",
+               syslog(LOG_DEBUG, "%s: unexpected NA from %s for %s",
                    ifp->name, ctx->sfrom, taddr);
 #endif
                return;
        }
 
 #ifdef DEBUG_NS
-       logger(ifp->ctx, LOG_DEBUG, "%s: %sNA for %s from %s",
+       syslog(LOG_DEBUG, "%s: %sNA for %s from %s",
            ifp->name, is_solicited ? "solicited " : "", taddr, ctx->sfrom);
 #endif
 
        /* Node is no longer a router, so remove it from consideration */
        if (!is_router && !rap->expired) {
-               logger(ifp->ctx, LOG_INFO, "%s: %s not a router (%s)",
+               syslog(LOG_INFO, "%s: %s not a router (%s)",
                    ifp->name, taddr, ctx->sfrom);
                rap->expired = 1;
                rt_build(ifp->ctx,  AF_INET6);
@@ -1549,7 +1536,7 @@ ipv6nd_handlena(struct dhcpcd_ctx *ctx, struct interface *ifp,
        if (is_solicited && is_router && rap->lifetime) {
                if (rap->expired) {
                        rap->expired = 0;
-                       logger(ifp->ctx, LOG_INFO, "%s: %s reachable (%s)",
+                       syslog(LOG_INFO, "%s: %s reachable (%s)",
                            ifp->name, taddr, ctx->sfrom);
                        rt_build(ifp->ctx, AF_INET6);
                        script_runreason(rap->iface, "ROUTERADVERT"); /* XXX */
@@ -1573,7 +1560,7 @@ ipv6nd_handledata(void *arg)
            CMSG_SPACE(sizeof(int));
        len = recvmsg_realloc(ctx->nd_fd, &ctx->rcvhdr, 0);
        if (len == -1) {
-               logger(ctx, LOG_ERR, "recvmsg: %m");
+               syslog(LOG_ERR, "recvmsg: %m");
                eloop_event_delete(ctx->eloop, ctx->nd_fd);
                close(ctx->nd_fd);
                ctx->nd_fd = -1;
@@ -1582,7 +1569,7 @@ ipv6nd_handledata(void *arg)
        ctx->sfrom = inet_ntop(AF_INET6, &ctx->from.sin6_addr,
            ctx->ntopbuf, INET6_ADDRSTRLEN);
        if ((size_t)len < sizeof(struct icmp6_hdr)) {
-               logger(ctx, LOG_ERR, "IPv6 ICMP packet too short from %s",
+               syslog(LOG_ERR, "IPv6 ICMP packet too short from %s",
                    ctx->sfrom);
                return;
        }
@@ -1608,8 +1595,7 @@ ipv6nd_handledata(void *arg)
        }
 
        if (pkt.ipi6_ifindex == 0) {
-               logger(ctx, LOG_ERR,
-                   "IPv6 RA/NA did not contain index from %s",
+               syslog(LOG_ERR, "IPv6 RA/NA did not contain index from %s",
                    ctx->sfrom);
                return;
        }
@@ -1637,7 +1623,7 @@ ipv6nd_handledata(void *arg)
                }
        }
 
-       logger(ctx, LOG_ERR, "invalid IPv6 type %d or code %d from %s",
+       syslog(LOG_ERR, "invalid IPv6 type %d or code %d from %s",
            icp->icmp6_type, icp->icmp6_code, ctx->sfrom);
 }
 
@@ -1647,9 +1633,9 @@ ipv6nd_startrs1(void *arg)
        struct interface *ifp = arg;
        struct rs_state *state;
 
-       logger(ifp->ctx, LOG_INFO, "%s: soliciting an IPv6 router", ifp->name);
+       syslog(LOG_INFO, "%s: soliciting an IPv6 router", ifp->name);
        if (ipv6nd_open(ifp->ctx) == -1) {
-               logger(ifp->ctx, LOG_ERR, "%s: ipv6nd_open: %m", __func__);
+               syslog(LOG_ERR, "%s: ipv6nd_open: %m", __func__);
                return;
        }
 
@@ -1658,7 +1644,7 @@ ipv6nd_startrs1(void *arg)
                ifp->if_data[IF_DATA_IPV6ND] = calloc(1, sizeof(*state));
                state = RS_STATE(ifp);
                if (state == NULL) {
-                       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+                       syslog(LOG_ERR, "%s: %m", __func__);
                        return;
                }
        }
@@ -1667,8 +1653,7 @@ ipv6nd_startrs1(void *arg)
         * address could have changed. */
        ipv6nd_makersprobe(ifp);
        if (state->rs == NULL) {
-               logger(ifp->ctx, LOG_ERR,
-                   "%s: ipv6ns_makersprobe: %m", __func__);
+               syslog(LOG_ERR, "%s: ipv6ns_makersprobe: %m", __func__);
                return;
        }
 
@@ -1691,7 +1676,7 @@ ipv6nd_startrs(struct interface *ifp)
        tv.tv_nsec = (suseconds_t)arc4random_uniform(
            MAX_RTR_SOLICITATION_DELAY * NSEC_PER_SEC);
        timespecnorm(&tv);
-       logger(ifp->ctx, LOG_DEBUG,
+       syslog(LOG_DEBUG,
            "%s: delaying IPv6 router solicitation for %0.1f seconds",
            ifp->name, timespec_to_double(&tv));
        eloop_timeout_add_tv(ifp->ctx->eloop, &tv, ipv6nd_startrs1, ifp);
index 02f8f12f38fc44ee9095bf8c9634a9a6fda2e7ec..bafc260caca5501c5eb98561864da4a9a8c10739 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #include "config.h"
@@ -57,7 +58,6 @@ rt_desc(const char *cmd, const struct rt *rt)
 {
        char dest[INET_MAX_ADDRSTRLEN], gateway[INET_MAX_ADDRSTRLEN];
        int prefix;
-       struct dhcpcd_ctx *ctx;
        const char *ifname;
        bool gateway_unspec;
 
@@ -65,7 +65,6 @@ rt_desc(const char *cmd, const struct rt *rt)
        assert(rt != NULL);
        assert(rt->rt_ifp != NULL);
 
-       ctx = rt->rt_ifp->ctx;
        ifname = rt->rt_ifp->name;
        sa_addrtop(&rt->rt_dest, dest, sizeof(dest));
        prefix = sa_toprefix(&rt->rt_netmask);
@@ -75,27 +74,27 @@ rt_desc(const char *cmd, const struct rt *rt)
 
        if (rt->rt_flags & RTF_HOST) {
                if (gateway_unspec)
-                       logger(ctx, LOG_INFO, "%s: %s host route to %s",
+                       syslog(LOG_INFO, "%s: %s host route to %s",
                            ifname, cmd, dest);
                else
-                       logger(ctx, LOG_INFO, "%s: %s host route to %s via %s",
+                       syslog(LOG_INFO, "%s: %s host route to %s via %s",
                            ifname, cmd, dest, gateway);
        } else if (sa_is_unspecified(&rt->rt_dest) &&
                   sa_is_unspecified(&rt->rt_netmask))
        {
                if (gateway_unspec)
-                       logger(ctx, LOG_INFO, "%s: %s default route",
+                       syslog(LOG_INFO, "%s: %s default route",
                            ifname, cmd);
                else
-                       logger(ctx, LOG_INFO, "%s: %s default route via %s",
+                       syslog(LOG_INFO, "%s: %s default route via %s",
                            ifname, cmd, gateway);
        } else if (gateway_unspec)
-               logger(ctx, LOG_INFO, "%s: %s%s route to %s/%d",
+               syslog(LOG_INFO, "%s: %s%s route to %s/%d",
                    ifname, cmd,
                    rt->rt_flags & RTF_REJECT ? " reject" : "",
                    dest, prefix);
        else
-               logger(ctx, LOG_INFO, "%s: %s%s route to %s/%d via %s",
+               syslog(LOG_INFO, "%s: %s%s route to %s/%d via %s",
                    ifname, cmd,
                    rt->rt_flags & RTF_REJECT ? " reject" : "",
                    dest, prefix, gateway);
@@ -157,7 +156,7 @@ rt_new(struct interface *ifp)
        if ((rt = TAILQ_FIRST(&ctx->froutes)) != NULL)
                TAILQ_REMOVE(&ctx->froutes, rt, rt_next);
        else if ((rt = malloc(sizeof(*rt))) == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return NULL;
        }
        memset(rt, 0, sizeof(*rt));
@@ -337,7 +336,7 @@ rt_add(struct rt *nrt, struct rt *ort)
                if (if_route(RTM_CHANGE, nrt) != -1)
                        return true;
                if (errno != ESRCH)
-                       logger(ctx, LOG_ERR, "if_route (CHG): %m");
+                       syslog(LOG_ERR, "if_route (CHG): %m");
        }
 
 #ifdef HAVE_ROUTE_METRIC
@@ -346,7 +345,7 @@ rt_add(struct rt *nrt, struct rt *ort)
        if (if_route(RTM_ADD, nrt) != -1) {
                if (ort != NULL) {
                        if (if_route(RTM_DELETE, ort) == -1 && errno != ESRCH)
-                               logger(ctx, LOG_ERR, "if_route (DEL): %m");
+                               syslog(LOG_ERR, "if_route (DEL): %m");
                        rt_kfree(ort);
                }
                return true;
@@ -365,7 +364,7 @@ rt_add(struct rt *nrt, struct rt *ort)
 #endif
        if (ort != NULL) {
                if (if_route(RTM_DELETE, ort) == -1 && errno != ESRCH)
-                       logger(ctx, LOG_ERR, "if_route (DEL): %m");
+                       syslog(LOG_ERR, "if_route (DEL): %m");
                else
                        rt_kfree(ort);
        }
@@ -385,7 +384,7 @@ rt_add(struct rt *nrt, struct rt *ort)
 #ifdef HAVE_ROUTE_METRIC
 logerr:
 #endif
-       logger(ctx, LOG_ERR, "if_route (ADD): %m");
+       syslog(LOG_ERR, "if_route (ADD): %m");
        return false;
 }
 
@@ -397,8 +396,7 @@ rt_delete(struct rt *rt)
        rt_desc("deleting", rt);
        retval = if_route(RTM_DELETE, rt) == -1 ? false : true;
        if (!retval && errno != ENOENT && errno != ESRCH)
-               logger(rt->rt_ifp->ctx, LOG_ERR,
-                   "%s: if_delroute: %m", rt->rt_ifp->name);
+               syslog(LOG_ERR, "%s: if_delroute: %m", rt->rt_ifp->name);
        /* Remove the route from our kernel table so we can add a
         * IPv4LL default route if possible. */
        else
index 429d9494e78b312378300df1b4de2a30a914aea9..dcac0d4bea17e062f1b7b129f9c4fc3d3b83a500 100644 (file)
@@ -38,6 +38,7 @@
 #include <spawn.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 #include "config.h"
@@ -118,14 +119,14 @@ exec_script(const struct dhcpcd_ctx *ctx, char *const *argv, char *const *env)
 
 #ifdef INET
 static char *
-make_var(struct dhcpcd_ctx *ctx, const char *prefix, const char *var)
+make_var(const char *prefix, const char *var)
 {
        size_t len;
        char *v;
 
        len = strlen(prefix) + strlen(var) + 2;
        if ((v = malloc(len)) == NULL) {
-               logger(ctx, LOG_ERR, "%s: %m", __func__);
+               syslog(LOG_ERR, "%s: %m", __func__);
                return NULL;
        }
        snprintf(v, len, "%s_%s", prefix, var);
@@ -134,7 +135,7 @@ make_var(struct dhcpcd_ctx *ctx, const char *prefix, const char *var)
 
 
 static int
-append_config(struct dhcpcd_ctx *ctx, char ***env, size_t *len,
+append_config(char ***env, size_t *len,
     const char *prefix, const char *const *config)
 {
        size_t i, j, e1;
@@ -155,7 +156,7 @@ append_config(struct dhcpcd_ctx *ctx, char ***env, size_t *len,
                            strncmp(ne[j] + strlen(prefix) + 1,
                            config[i], e1) == 0)
                        {
-                               p = make_var(ctx, prefix, config[i]);
+                               p = make_var(prefix, config[i]);
                                if (p == NULL) {
                                        ret = -1;
                                        break;
@@ -167,14 +168,14 @@ append_config(struct dhcpcd_ctx *ctx, char ***env, size_t *len,
                }
                if (j == *len) {
                        j++;
-                       p = make_var(ctx, prefix, config[i]);
+                       p = make_var(prefix, config[i]);
                        if (p == NULL) {
                                ret = -1;
                                break;
                        }
                        nep = realloc(ne, sizeof(char *) * (j + 1));
                        if (nep == NULL) {
-                               logger(ctx, LOG_ERR, "%s: %m", __func__);
+                               syslog(LOG_ERR, "%s: %m", __func__);
                                free(p);
                                ret = -1;
                                break;
@@ -439,7 +440,7 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
                                goto eexit;
                        elen += (size_t)n;
                }
-               if (append_config(ifp->ctx, &env, &elen, "old",
+               if (append_config(&env, &elen, "old",
                    (const char *const *)ifo->config) == -1)
                        goto eexit;
        }
@@ -495,7 +496,7 @@ dumplease:
                                goto eexit;
                        elen += (size_t)n;
                }
-               if (append_config(ifp->ctx, &env, &elen, "new",
+               if (append_config(&env, &elen, "new",
                    (const char *const *)ifo->config) == -1)
                        goto eexit;
        }
@@ -571,7 +572,7 @@ dumplease:
        return (ssize_t)elen;
 
 eexit:
-       logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+       syslog(LOG_ERR, "%s: %m", __func__);
        if (env) {
                nenv = env;
                while (*nenv)
@@ -683,19 +684,18 @@ script_runreason(const struct interface *ifp, const char *reason)
        /* Make our env */
        elen = (size_t)make_env(ifp, reason, &env);
        if (elen == (size_t)-1) {
-               logger(ifp->ctx, LOG_ERR, "%s: make_env: %m", ifp->name);
+               syslog(LOG_ERR, "%s: make_env: %m", ifp->name);
                return -1;
        }
 
        if (ifp->options->script &&
            (ifp->options->script[0] == '\0' ||
            strcmp(ifp->options->script, "/dev/null") == 0))
-               goto send_listeners;
+               goto send_listeners;
 
        argv[0] = ifp->options->script ? ifp->options->script : UNCONST(SCRIPT);
        argv[1] = NULL;
-       logger(ifp->ctx, LOG_DEBUG, "%s: executing `%s' %s",
-           ifp->name, argv[0], reason);
+       syslog(LOG_DEBUG, "%s: executing `%s' %s", ifp->name, argv[0], reason);
 
        /* Resize for PATH and RC_SVCNAME */
        svcname = getenv(RC_SVCNAME);
@@ -735,23 +735,22 @@ script_runreason(const struct interface *ifp, const char *reason)
 
        pid = exec_script(ifp->ctx, argv, env);
        if (pid == -1)
-               logger(ifp->ctx, LOG_ERR, "%s: %s: %m", __func__, argv[0]);
+               syslog(LOG_ERR, "%s: %s: %m", __func__, argv[0]);
        else if (pid != 0) {
                /* Wait for the script to finish */
                while (waitpid(pid, &status, 0) == -1) {
                        if (errno != EINTR) {
-                               logger(ifp->ctx, LOG_ERR, "waitpid: %m");
+                               syslog(LOG_ERR, "waitpid: %m");
                                status = 0;
                                break;
                        }
                }
                if (WIFEXITED(status)) {
                        if (WEXITSTATUS(status))
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: %s: WEXITSTATUS %d",
+                               syslog(LOG_ERR, "%s: %s: WEXITSTATUS %d",
                                    __func__, argv[0], WEXITSTATUS(status));
                } else if (WIFSIGNALED(status))
-                       logger(ifp->ctx, LOG_ERR, "%s: %s: %s",
+                       syslog(LOG_ERR, "%s: %s: %s",
                            __func__, argv[0], strsignal(WTERMSIG(status)));
        }
 
@@ -766,14 +765,13 @@ send_listeners:
                        elen = (size_t)arraytostr((const char *const *)env,
                            &bigenv);
                        if ((ssize_t)elen == -1) {
-                               logger(ifp->ctx, LOG_ERR, "%s: arraytostr: %m",
+                               syslog(LOG_ERR, "%s: arraytostr: %m",
                                    ifp->name);
                                    break;
                        }
                }
                if (control_queue(fd, bigenv, elen, 1) == -1)
-                       logger(ifp->ctx, LOG_ERR,
-                           "%s: control_queue: %m", __func__);
+                       syslog(LOG_ERR, "%s: control_queue: %m", __func__);
                else
                        status = 1;
        }
@@ -787,7 +785,7 @@ out:
                free(*ep++);
        free(env);
        if (elen == 0) {
-               logger(ifp->ctx, LOG_ERR, "%s: malloc: %m", __func__);
+               syslog(LOG_ERR, "%s: malloc: %m", __func__);
                return -1;
        }
        return WEXITSTATUS(status);