On Mon, May 14, 2018 at 12:45:18PM +0200, Reyk Floeter wrote:
> Hi,
> 
> the following patch updates ldapd to use log.c from vmd/relayd/etc.
> 
> Notes:
> 
> - This log.c uses format attributes that helped to fix some format
> errors and two actual bugs:
>    - There was a missing argument in a log_warn in namespace.c
>    - the ldape child never inherited the log level correctly (-vv)
> 
> - This change removes the timestamp from log_debug() - we usually don't
> do that and you can still prepend a timestamp by piping it through an
> additional tool if you're using a foreground process supervisor (such
> as daemontool's multilog TAI).
> 
> - The BER dump and hexdump are only printed with loglevel > 2
> (logmsg.c).  Without this patch, this code was never used as the
> parent only passed a single -v to the exec'ed ldape child.
> 
> OK?
> 

While here, fix an old typo in the namespace.c bit: alreay -> already
(pointed out by Aaron Miller).

OK?  Anyone?

Reyk

Index: usr.sbin/ldapd/conn.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/conn.c,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 conn.c
--- usr.sbin/ldapd/conn.c       8 Feb 2018 18:02:06 -0000       1.15
+++ usr.sbin/ldapd/conn.c       15 May 2018 07:34:04 -0000
@@ -132,7 +132,7 @@ request_dispatch(struct request *req)
        }
 
        if (requests[i].fn == NULL) {
-               log_warnx("unhandled request %d (not implemented)", req->type);
+               log_warnx("unhandled request %lu (not implemented)", req->type);
                ldap_respond(req, LDAP_PROTOCOL_ERROR);
        }
 }
@@ -166,7 +166,7 @@ conn_dispatch(struct conn *conn)
                request_free(req);
                return -1;
        }
-       log_debug("consumed %d bytes", conn->ber.br_rptr - rptr);
+       log_debug("consumed %ld bytes", conn->ber.br_rptr - rptr);
 
        /* Read message id and request type.
         */
@@ -183,7 +183,7 @@ conn_dispatch(struct conn *conn)
        ldap_debug_elements(req->root, req->type,
            "received request on fd %d", conn->fd);
 
-       log_debug("got request type %d, id %lld", req->type, req->msgid);
+       log_debug("got request type %lu, id %lld", req->type, req->msgid);
        request_dispatch(req);
        return 0;
 }
Index: usr.sbin/ldapd/control.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/control.c,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 control.c
--- usr.sbin/ldapd/control.c    20 Jan 2017 11:55:08 -0000      1.15
+++ usr.sbin/ldapd/control.c    15 May 2018 07:34:04 -0000
@@ -261,7 +261,7 @@ control_imsgev(struct imsgev *iev, int c
                imsgev_compose(iev_ldapd, IMSG_CTL_LOG_VERBOSE, 0, 0, -1,
                    &verbose, sizeof(verbose));
 
-               log_verbose(verbose);
+               log_setverbose(verbose);
                break;
        default:
                log_warnx("%s: unexpected imsg %d", __func__, imsg->hdr.type);
Index: usr.sbin/ldapd/filter.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/filter.c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 filter.c
--- usr.sbin/ldapd/filter.c     20 Jan 2017 11:55:08 -0000      1.4
+++ usr.sbin/ldapd/filter.c     15 May 2018 07:34:04 -0000
@@ -101,7 +101,7 @@ ldap_filt_subs_value(struct ber_element 
                                return 1; /* no match */
                        break;
                default:
-                       log_warnx("invalid subfilter type %d", type);
+                       log_warnx("invalid subfilter type %lu", type);
                        return -1;
                }
        }
Index: usr.sbin/ldapd/ldapd.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/ldapd.c,v
retrieving revision 1.23
diff -u -p -u -p -r1.23 ldapd.c
--- usr.sbin/ldapd/ldapd.c      1 Mar 2017 00:50:12 -0000       1.23
+++ usr.sbin/ldapd/ldapd.c      15 May 2018 07:34:05 -0000
@@ -36,6 +36,7 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <syslog.h>
 
 #include "ldapd.h"
 #include "log.h"
@@ -123,7 +124,7 @@ main(int argc, char *argv[])
        struct event             ev_sighup;
        struct stat              sb;
 
-       log_init(1);            /* log to stderr until daemonized */
+       log_init(1, LOG_DAEMON);        /* log to stderr until daemonized */
 
        saved_argv0 = argv[0];
        if (saved_argv0 == NULL)
@@ -180,7 +181,7 @@ main(int argc, char *argv[])
        if (getpwnam(LDAPD_USER) == NULL)
                errx(1, "unknown user %s", LDAPD_USER);
 
-       log_verbose(verbose);
+       log_setverbose(verbose);
        stats.started_at = time(0);
        tls_init();
 
@@ -192,6 +193,8 @@ main(int argc, char *argv[])
                exit(0);
        }
 
+       log_init(debug, LOG_DAEMON);
+
        if (eflag)
                ldape(debug, verbose, csockpath);
 
@@ -205,7 +208,6 @@ main(int argc, char *argv[])
                        err(1, "failed to daemonize");
        }
 
-       log_init(debug);
        log_info("startup");
 
        if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
@@ -215,6 +217,7 @@ main(int argc, char *argv[])
        ldape_pid = start_child(PROC_LDAP_SERVER, saved_argv0,
            pipe_parent2ldap[1], debug, verbose, csockpath, conffile);
 
+       ldap_loginit("auth", debug, verbose);
        setproctitle("auth");
        event_init();
 
@@ -374,7 +377,7 @@ ldapd_log_verbose(struct imsg *imsg)
                fatal("invalid size of log verbose request");
 
        bcopy(imsg->data, &verbose, sizeof(verbose));
-       log_verbose(verbose);
+       log_setverbose(verbose);
 }
 
 static void
@@ -439,7 +442,11 @@ start_child(enum ldapd_process p, char *
        }
        if (debug)
                argv[argc++] = "-d";
-       if (verbose)
+       if (verbose >= 3)
+               argv[argc++] = "-vvv";
+       else if (verbose == 2)
+               argv[argc++] = "-vv";
+       else if (verbose == 1)
                argv[argc++] = "-v";
        if (csockpath) {
                argv[argc++] = "-s";
Index: usr.sbin/ldapd/ldapd.h
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/ldapd.h,v
retrieving revision 1.29
diff -u -p -u -p -r1.29 ldapd.h
--- usr.sbin/ldapd/ldapd.h      14 May 2018 07:53:47 -0000      1.29
+++ usr.sbin/ldapd/ldapd.h      15 May 2018 07:34:05 -0000
@@ -471,6 +471,7 @@ SPLAY_PROTOTYPE(ssltree, ssl, ssl_nodes,
 
 
 /* logmsg.c */
+void                    ldap_loginit(const char *, int, int);
 const char             *print_host(struct sockaddr_storage *ss, char *buf,
                                size_t len);
 void                    hexdump(void *data, size_t len, const char *fmt, ...);
Index: usr.sbin/ldapd/ldape.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/ldape.c,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 ldape.c
--- usr.sbin/ldapd/ldape.c      24 Feb 2017 14:28:31 -0000      1.26
+++ usr.sbin/ldapd/ldape.c      15 May 2018 07:34:05 -0000
@@ -76,7 +76,7 @@ send_ldap_extended_response(struct conn 
        struct ber_element      *root, *elm;
        void                    *buf;
 
-       log_debug("sending response %u with result %lld", type, result_code);
+       log_debug("sending response %lu with result %lld", type, result_code);
 
        if ((root = ber_add_sequence(NULL)) == NULL)
                goto fail;
@@ -133,7 +133,7 @@ ldap_refer(struct request *req, const ch
                        scope_str = "sub";
        }
 
-       log_debug("sending referral in response %u on msgid %lld",
+       log_debug("sending referral in response %lu on msgid %lld",
            type, req->msgid);
 
        if ((root = ber_add_sequence(NULL)) == NULL)
@@ -346,11 +346,9 @@ ldape(int debug, int verbose, char *csoc
        char                     host[128];
        mode_t                  old_umask = 0;
        
-       log_init(debug);
-       log_verbose(verbose);
-
        TAILQ_INIT(&conn_list);
 
+       ldap_loginit("ldap server", debug, verbose);
        setproctitle("ldap server");
        event_init();
 
@@ -443,7 +441,7 @@ ldape(int debug, int verbose, char *csoc
 
        TAILQ_FOREACH(ns, &conf->namespaces, next) {
                if (!namespace_has_referrals(ns) && namespace_open(ns) != 0)
-                       fatal(ns->suffix);
+                       fatal("%s", ns->suffix);
        }
 
        if ((pw = getpwnam(LDAPD_USER)) == NULL)
Index: usr.sbin/ldapd/log.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/log.c,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 log.c
--- usr.sbin/ldapd/log.c        21 Mar 2017 12:06:55 -0000      1.8
+++ usr.sbin/ldapd/log.c        15 May 2018 07:34:05 -0000
@@ -1,4 +1,4 @@
-/*     $OpenBSD: log.c,v 1.8 2017/03/21 12:06:55 bluhm Exp $   */
+/*     $OpenBSD: log.c,v 1.8 2017/03/21 12:06:56 bluhm Exp $   */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henn...@openbsd.org>
@@ -16,40 +16,73 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/time.h>
-#include <errno.h>
-#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <string.h>
 #include <syslog.h>
+#include <errno.h>
 #include <time.h>
-#include <unistd.h>
-
-#include "log.h"
 
-int             debug;
-int             verbose;
+static int      debug;
+static int      verbose;
+const char     *log_procname;
+
+void   log_init(int, int);
+void   log_procinit(const char *);
+void   log_setverbose(int);
+int    log_getverbose(void);
+void   log_warn(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   log_warnx(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   log_info(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   log_debug(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   logit(int, const char *, ...)
+           __attribute__((__format__ (printf, 2, 3)));
+void   vlog(int, const char *, va_list)
+           __attribute__((__format__ (printf, 2, 0)));
+__dead void fatal(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+__dead void fatalx(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
 
 void
-log_init(int n_debug)
+log_init(int n_debug, int facility)
 {
        extern char     *__progname;
 
        debug = n_debug;
+       verbose = n_debug;
+       log_procinit(__progname);
 
        if (!debug)
-               openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+               openlog(__progname, LOG_PID | LOG_NDELAY, facility);
 
        tzset();
 }
 
 void
-log_verbose(int v)
+log_procinit(const char *procname)
+{
+       if (procname != NULL)
+               log_procname = procname;
+}
+
+void
+log_setverbose(int v)
 {
        verbose = v;
 }
 
+int
+log_getverbose(void)
+{
+       return (verbose);
+}
+
 void
 logit(int pri, const char *fmt, ...)
 {
@@ -63,23 +96,10 @@ logit(int pri, const char *fmt, ...)
 void
 vlog(int pri, const char *fmt, va_list ap)
 {
-       char             datebuf[24];
-       struct timeval   tv;
-       struct tm       *tm;
-       char            *nfmt;
-       size_t           rc;
-       time_t           now;
+       char    *nfmt;
+       int      saved_errno = errno;
 
        if (debug) {
-               gettimeofday(&tv, NULL);
-               now = tv.tv_sec;
-               tm = localtime(&now);
-               rc = strftime(datebuf, sizeof(datebuf), "%b %e %H:%M:%S", tm);
-               if (rc == 0)
-                       datebuf[0] = 0;
-               fprintf(stderr, "%s.%03ld [%d] ", datebuf,
-                   tv.tv_usec / 1000, getpid());
-
                /* best effort in out of mem situations */
                if (asprintf(&nfmt, "%s\n", fmt) == -1) {
                        vfprintf(stderr, fmt, ap);
@@ -91,30 +111,36 @@ vlog(int pri, const char *fmt, va_list a
                fflush(stderr);
        } else
                vsyslog(pri, fmt, ap);
+
+       errno = saved_errno;
 }
 
 void
 log_warn(const char *emsg, ...)
 {
-       char    *nfmt;
-       va_list  ap;
+       char            *nfmt;
+       va_list          ap;
+       int              saved_errno = errno;
 
        /* best effort to even work in out of memory situations */
        if (emsg == NULL)
-               logit(LOG_ERR, "%s", strerror(errno));
+               logit(LOG_ERR, "%s", strerror(saved_errno));
        else {
                va_start(ap, emsg);
 
-               if (asprintf(&nfmt, "%s: %s", emsg, strerror(errno)) == -1) {
+               if (asprintf(&nfmt, "%s: %s", emsg,
+                   strerror(saved_errno)) == -1) {
                        /* we tried it... */
                        vlog(LOG_ERR, emsg, ap);
-                       logit(LOG_ERR, "%s", strerror(errno));
+                       logit(LOG_ERR, "%s", strerror(saved_errno));
                } else {
                        vlog(LOG_ERR, nfmt, ap);
                        free(nfmt);
                }
                va_end(ap);
        }
+
+       errno = saved_errno;
 }
 
 void
@@ -142,31 +168,51 @@ log_debug(const char *emsg, ...)
 {
        va_list  ap;
 
-       if (verbose) {
+       if (verbose > 1) {
                va_start(ap, emsg);
                vlog(LOG_DEBUG, emsg, ap);
                va_end(ap);
        }
 }
 
-void
-fatal(const char *emsg)
+static void
+vfatalc(int code, const char *emsg, va_list ap)
 {
-       if (emsg == NULL)
-               logit(LOG_CRIT, "fatal: %s", strerror(errno));
+       static char     s[BUFSIZ];
+       const char      *sep;
+
+       if (emsg != NULL) {
+               (void)vsnprintf(s, sizeof(s), emsg, ap);
+               sep = ": ";
+       } else {
+               s[0] = '\0';
+               sep = "";
+       }
+       if (code)
+               logit(LOG_CRIT, "%s: %s%s%s",
+                   log_procname, s, sep, strerror(code));
        else
-               if (errno)
-                       logit(LOG_CRIT, "fatal: %s: %s",
-                           emsg, strerror(errno));
-               else
-                       logit(LOG_CRIT, "fatal: %s", emsg);
+               logit(LOG_CRIT, "%s%s%s", log_procname, sep, s);
+}
+
+void
+fatal(const char *emsg, ...)
+{
+       va_list ap;
 
+       va_start(ap, emsg);
+       vfatalc(errno, emsg, ap);
+       va_end(ap);
        exit(1);
 }
 
 void
-fatalx(const char *emsg)
+fatalx(const char *emsg, ...)
 {
-       errno = 0;
-       fatal(emsg);
+       va_list ap;
+
+       va_start(ap, emsg);
+       vfatalc(0, emsg, ap);
+       va_end(ap);
+       exit(1);
 }
Index: usr.sbin/ldapd/log.h
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/log.h,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 log.h
--- usr.sbin/ldapd/log.h        20 Jan 2017 11:55:08 -0000      1.1
+++ usr.sbin/ldapd/log.h        15 May 2018 07:34:05 -0000
@@ -19,13 +19,23 @@
 #include <stdarg.h>
 #include <sys/cdefs.h>
 
-void    log_init(int);
-void    log_verbose(int);
-void    logit(int, const char *, ...);
-void    vlog(int, const char *, va_list);
-void    log_warn(const char *, ...);
-void    log_warnx(const char *, ...);
-void    log_info(const char *, ...);
-void    log_debug(const char *, ...);
-void    fatal(const char *) __dead;
-void    fatalx(const char *) __dead;
+void   log_init(int, int);
+void   log_procinit(const char *);
+void   log_setverbose(int);
+int    log_getverbose(void);
+void   log_warn(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   log_warnx(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   log_info(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   log_debug(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+void   logit(int, const char *, ...)
+           __attribute__((__format__ (printf, 2, 3)));
+void   vlog(int, const char *, va_list)
+           __attribute__((__format__ (printf, 2, 0)));
+__dead void fatal(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
+__dead void fatalx(const char *, ...)
+           __attribute__((__format__ (printf, 1, 2)));
Index: usr.sbin/ldapd/logmsg.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/logmsg.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 logmsg.c
--- usr.sbin/ldapd/logmsg.c     20 Jan 2017 11:55:08 -0000      1.1
+++ usr.sbin/ldapd/logmsg.c     15 May 2018 07:34:05 -0000
@@ -35,8 +35,16 @@
 #include "ldapd.h"
 #include "log.h"
 
-extern int     debug;
-extern int     verbose;
+static int     debug;
+
+void
+ldap_loginit(const char *name, int d, int v)
+{
+       log_setverbose(v);
+       if (name != NULL)
+               log_procinit(name);
+       debug = d;
+}
 
 const char *
 print_host(struct sockaddr_storage *ss, char *buf, size_t len)
@@ -55,7 +63,7 @@ hexdump(void *data, size_t len, const ch
        uint8_t *p = data;
        va_list ap;
 
-       if (verbose < 2 || !debug)
+       if (log_getverbose() <= 2 || !debug)
                return;
 
        va_start(ap, fmt);
@@ -90,7 +98,7 @@ ldap_debug_elements(struct ber_element *
        int              constructed;
        struct ber_oid   o;
 
-       if (verbose < 2 || !debug)
+       if (log_getverbose() <= 2 || !debug)
                return;
 
        if (fmt != NULL) {
Index: usr.sbin/ldapd/namespace.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/namespace.c,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 namespace.c
--- usr.sbin/ldapd/namespace.c  20 Jan 2017 11:55:08 -0000      1.17
+++ usr.sbin/ldapd/namespace.c  15 May 2018 07:34:05 -0000
@@ -472,7 +472,8 @@ int
 namespace_queue_request(struct namespace *ns, struct request *req)
 {
        if (ns->queued_requests > MAX_REQUEST_QUEUE) {
-               log_warn("%u requests alreay queued, sorry");
+               log_warn("%u requests already queued, sorry",
+                   ns->queued_requests);
                return -1;
        }
 
Index: usr.sbin/ldapd/search.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/search.c,v
retrieving revision 1.19
diff -u -p -u -p -r1.19 search.c
--- usr.sbin/ldapd/search.c     14 May 2018 07:53:47 -0000      1.19
+++ usr.sbin/ldapd/search.c     15 May 2018 07:34:05 -0000
@@ -330,7 +330,7 @@ conn_search(struct search *search)
                op = BT_NEXT;
 
                if (rc == BT_SUCCESS && search->plan->indexed) {
-                       log_debug("found index %.*s", key.size, key.data);
+                       log_debug("found index %.*s", (int)key.size, key.data);
 
                        if (!has_prefix(&key, search->cindx->prefix)) {
                                log_debug("scanned past index prefix [%s]",
@@ -438,7 +438,7 @@ conn_search(struct search *search)
                /* Check if we have passed the size limit. */
                if (rc == BT_SUCCESS && search->szlim > 0 &&
                    search->nmatched >= search->szlim) {
-                       log_debug("search %d/%lld has reached size limit (%u)",
+                       log_debug("search %d/%lld has reached size limit 
(%lld)",
                            search->conn->fd, search->req->msgid,
                            search->szlim);
                        reason = LDAP_SIZELIMIT_EXCEEDED;
@@ -450,7 +450,7 @@ conn_search(struct search *search)
        now = time(0);
        if (rc == 0 && search->tmlim > 0 &&
            search->started_at + search->tmlim <= now) {
-               log_debug("search %d/%lld has reached time limit (%u)",
+               log_debug("search %d/%lld has reached time limit (%lld)",
                    search->conn->fd, search->req->msgid,
                    search->tmlim);
                reason = LDAP_TIMELIMIT_EXCEEDED;
@@ -803,7 +803,7 @@ search_planner(struct namespace *ns, str
                break;
 
        default:
-               log_warnx("filter type %d not implemented", filter->be_type);
+               log_warnx("filter type %lu not implemented", filter->be_type);
                plan->undefined = 1;
                break;
        }
@@ -875,7 +875,7 @@ ldap_search(struct request *req)
        }
 
        normalize_dn(search->basedn);
-       log_debug("base dn = %s, scope = %d", search->basedn, search->scope);
+       log_debug("base dn = %s, scope = %lld", search->basedn, search->scope);
 
        if (*search->basedn == '\0') {
                /* request for the root DSE */
Index: usr.sbin/ldapd/util.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/util.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 util.c
--- usr.sbin/ldapd/util.c       8 Feb 2018 18:02:06 -0000       1.9
+++ usr.sbin/ldapd/util.c       15 May 2018 07:34:05 -0000
@@ -122,7 +122,7 @@ ber2db(struct ber_element *root, struct 
                val->size = compressBound(len);
                val->data = malloc(val->size + sizeof(uint32_t));
                if (val->data == NULL) {
-                       log_warn("malloc(%u)", val->size + sizeof(uint32_t));
+                       log_warn("malloc(%zu)", val->size + sizeof(uint32_t));
                        ber_free(&ber);
                        return -1;
                }
@@ -135,7 +135,7 @@ ber2db(struct ber_element *root, struct 
                        ber_free(&ber);
                        return -1;
                }
-               log_debug("compressed entry from %u -> %u byte",
+               log_debug("compressed entry from %zd -> %lu byte",
                    len, destlen + sizeof(uint32_t));
 
                *(uint32_t *)val->data = len;
@@ -174,7 +174,7 @@ db2ber(struct btval *val, int compressio
 
                len = *(uint32_t *)val->data;
                if ((buf = malloc(len)) == NULL) {
-                       log_warn("malloc(%u)", len);
+                       log_warn("malloc(%lu)", len);
                        return NULL;
                }
 
@@ -187,7 +187,7 @@ db2ber(struct btval *val, int compressio
                        return NULL;
                }
 
-               log_debug("uncompressed entry from %u -> %u byte",
+               log_debug("uncompressed entry from %zu -> %lu byte",
                    val->size, len);
 
                ber_set_readbuf(&ber, buf, len);
Index: usr.sbin/ldapd/validate.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapd/validate.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 validate.c
--- usr.sbin/ldapd/validate.c   20 Jan 2017 11:55:08 -0000      1.10
+++ usr.sbin/ldapd/validate.c   15 May 2018 07:34:05 -0000
@@ -80,7 +80,7 @@ validate_attribute(struct attr_type *at,
                    !at->syntax->is_valid(conf->schema, val, elm->be_len)) {
                        log_debug("%s: invalid syntax", ATTR_NAME(at));
                        log_debug("syntax = %s", at->syntax->desc);
-                       log_debug("value: [%.*s]", elm->be_len, val);
+                       log_debug("value: [%.*s]", (int)elm->be_len, val);
                        return LDAP_INVALID_SYNTAX;
                }
        }
Index: usr.sbin/ldapctl/ldapctl.c
===================================================================
RCS file: /cvs/src/usr.sbin/ldapctl/ldapctl.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 ldapctl.c
--- usr.sbin/ldapctl/ldapctl.c  20 Jan 2017 11:55:08 -0000      1.10
+++ usr.sbin/ldapctl/ldapctl.c  15 May 2018 07:34:05 -0000
@@ -255,7 +255,7 @@ main(int argc, char *argv[])
        struct imsg              imsg;
        struct imsgbuf           ibuf;
 
-       log_init(1);
+       log_init(1, 0);
 
        while ((ch = getopt(argc, argv, "f:r:s:v")) != -1) {
                switch (ch) {
@@ -287,7 +287,7 @@ main(int argc, char *argv[])
        if (!S_ISDIR(sb.st_mode))
                errx(1, "%s is not a directory", datadir);
 
-       log_verbose(verbose);
+       ldap_loginit(NULL, 1, verbose);
 
        if (strcmp(argv[0], "stats") == 0)
                action = SHOW_STATS;

Reply via email to