Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/blacklist Add autoconf infrastructure



details:   https://anonhg.NetBSD.org/src/rev/e02bfb46cce3
branches:  trunk
changeset: 805849:e02bfb46cce3
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 22 01:39:18 2015 +0000

description:
Add autoconf infrastructure

diffstat:

 external/bsd/blacklist/bin/blacklistctl.c       |   37 ++
 external/bsd/blacklist/bin/blacklistd.c         |   23 +-
 external/bsd/blacklist/bin/run.c                |    9 +-
 external/bsd/blacklist/bin/state.c              |    8 +-
 external/bsd/blacklist/include/bl.h             |    9 +-
 external/bsd/blacklist/lib/bl.c                 |   53 +++-
 external/bsd/blacklist/port/Makefile.am         |   20 +
 external/bsd/blacklist/port/clock_gettime.c     |   17 +
 external/bsd/blacklist/port/configure.ac        |   79 +++++
 external/bsd/blacklist/port/m4/.cvsignore       |    1 +
 external/bsd/blacklist/port/popenve.c           |  275 ++++++++++++++++++++
 external/bsd/blacklist/port/port.h              |   21 +
 external/bsd/blacklist/port/sockaddr_snprintf.c |  326 ++++++++++++++++++++++++
 external/bsd/blacklist/port/strtoi.c            |   63 ++++
 14 files changed, 908 insertions(+), 33 deletions(-)

diffs (truncated from 1167 to 300 lines):

diff -r 19eb305a6a1e -r e02bfb46cce3 external/bsd/blacklist/bin/blacklistctl.c
--- a/external/bsd/blacklist/bin/blacklistctl.c Wed Jan 21 23:28:02 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistctl.c Thu Jan 22 01:39:18 2015 +0000
@@ -1,3 +1,40 @@
+/*     $NetBSD: blacklistctl.c,v 1.5 2015/01/22 01:39:18 christos Exp $        */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "port.h"
+#endif
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: blacklistctl.c,v 1.5 2015/01/22 01:39:18 christos Exp $");
 
 #include <stdio.h>
 #include <time.h>
diff -r 19eb305a6a1e -r e02bfb46cce3 external/bsd/blacklist/bin/blacklistd.c
--- a/external/bsd/blacklist/bin/blacklistd.c   Wed Jan 21 23:28:02 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistd.c   Thu Jan 22 01:39:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: blacklistd.c,v 1.11 2015/01/21 23:26:26 christos Exp $ */
+/*     $NetBSD: blacklistd.c,v 1.12 2015/01/22 01:39:18 christos Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -28,8 +28,12 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "port.h"
+#endif
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistd.c,v 1.11 2015/01/21 23:26:26 christos Exp $");
+__RCSID("$NetBSD: blacklistd.c,v 1.12 2015/01/22 01:39:18 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -69,25 +73,25 @@
 static sig_atomic_t done;
 
 static void
-sigusr1(int n)
+sigusr1(int n __unused)
 {
        debug++;
 }
 
 static void
-sigusr2(int n)
+sigusr2(int n __unused)
 {
        debug--;
 }
 
 static void
-sighup(int n)
+sighup(int n __unused)
 {
        rconf++;
 }
 
 static void
-sigdone(int n)
+sigdone(int n __unused)
 {
        done++;
 }
@@ -123,12 +127,11 @@
                return;
 
        if (debug)
-               printf("got type=%d fd=%d msg=%s cred=[u=%lu, g=%lu]\n",
+               printf("got type=%d fd=%d msg=%s uid=%lu\n",
                    bi->bi_type, bi->bi_fd, bi->bi_msg,
-                   (unsigned long)bi->bi_cred.sc_euid,
-                   (unsigned long)bi->bi_cred.sc_egid);
+                   (unsigned long)bi->bi_uid);
 
-       if (conf_find(bi->bi_fd, bi->bi_cred.sc_euid, &c) == NULL)
+       if (conf_find(bi->bi_fd, bi->bi_uid, &c) == NULL)
                goto out;
 
        rfd = bi->bi_fd;
diff -r 19eb305a6a1e -r e02bfb46cce3 external/bsd/blacklist/bin/run.c
--- a/external/bsd/blacklist/bin/run.c  Wed Jan 21 23:28:02 2015 +0000
+++ b/external/bsd/blacklist/bin/run.c  Thu Jan 22 01:39:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: run.c,v 1.4 2015/01/21 19:24:03 christos Exp $ */
+/*     $NetBSD: run.c,v 1.5 2015/01/22 01:39:18 christos Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -28,8 +28,13 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "port.h"
+#endif
+
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: run.c,v 1.4 2015/01/21 19:24:03 christos Exp $");
+__RCSID("$NetBSD: run.c,v 1.5 2015/01/22 01:39:18 christos Exp $");
 
 #include <stdio.h>
 #include <util.h>
diff -r 19eb305a6a1e -r e02bfb46cce3 external/bsd/blacklist/bin/state.c
--- a/external/bsd/blacklist/bin/state.c        Wed Jan 21 23:28:02 2015 +0000
+++ b/external/bsd/blacklist/bin/state.c        Thu Jan 22 01:39:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: state.c,v 1.5 2015/01/21 23:09:44 christos Exp $       */
+/*     $NetBSD: state.c,v 1.6 2015/01/22 01:39:18 christos Exp $       */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -28,9 +28,13 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "port.h"
+#endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: state.c,v 1.5 2015/01/21 23:09:44 christos Exp $");
+__RCSID("$NetBSD: state.c,v 1.6 2015/01/22 01:39:18 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
diff -r 19eb305a6a1e -r e02bfb46cce3 external/bsd/blacklist/include/bl.h
--- a/external/bsd/blacklist/include/bl.h       Wed Jan 21 23:28:02 2015 +0000
+++ b/external/bsd/blacklist/include/bl.h       Thu Jan 22 01:39:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bl.h,v 1.7 2015/01/21 16:16:00 christos Exp $  */
+/*     $NetBSD: bl.h,v 1.8 2015/01/22 01:39:18 christos Exp $  */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,8 +36,6 @@
 #include <sys/socket.h>
 #include "blacklist.h"
 
-struct sockcred;
-
 typedef enum {
        BL_INVALID,
        BL_ADD,
@@ -47,10 +45,7 @@
 typedef struct {
        bl_type_t bi_type;
        int bi_fd;
-       union {
-               char bi_space[SOCKCREDSIZE(NGROUPS_MAX)];
-               struct sockcred _bi_cred;
-       } bi_u;
+       uid_t bi_uid;
        char bi_msg[1024];
 } bl_info_t;
 
diff -r 19eb305a6a1e -r e02bfb46cce3 external/bsd/blacklist/lib/bl.c
--- a/external/bsd/blacklist/lib/bl.c   Wed Jan 21 23:28:02 2015 +0000
+++ b/external/bsd/blacklist/lib/bl.c   Thu Jan 22 01:39:18 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bl.c,v 1.8 2015/01/21 16:16:00 christos Exp $  */
+/*     $NetBSD: bl.c,v 1.9 2015/01/22 01:39:18 christos Exp $  */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -29,11 +29,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: bl.c,v 1.8 2015/01/21 16:16:00 christos Exp $");
+__RCSID("$NetBSD: bl.c,v 1.9 2015/01/22 01:39:18 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/stat.h>
 #include <sys/un.h>
 
 #include <stdio.h>
@@ -86,7 +87,9 @@
 static int
 bl_init(bl_t b, bool srv)
 {
+#ifdef LOCAL_CREDS
        static int one = 1;
+#endif
        /* AF_UNIX address of local logger */
        struct sockaddr_un sun = {
                .sun_family = AF_LOCAL,
@@ -100,6 +103,15 @@
        if (srv)
                (void)unlink(b->b_path);
 
+#ifndef SOCK_NONBLOCK
+#define SOCK_NONBLOCK 0
+#endif
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
+#ifndef SOCK_NOSIGPIPE
+#define SOCK_NOSIGPIPE 0
+#endif
        if (b->b_fd == -1) {
                b->b_fd = socket(PF_LOCAL,
                    SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK|SOCK_NOSIGPIPE, 0);
@@ -108,6 +120,16 @@
                            __func__);
                        return 0;
                }
+#if SOCK_CLOEXEC == 0
+               fcntl(b->b_fd, F_SETFD, FD_CLOEXEC);
+#endif
+#if SOCK_NONBLOCK == 0
+               fcntl(b->b_fd, F_SETFL, fcntl(b->b_fd, F_GETFL) | O_NONBLOCK);
+#endif
+#if SOCK_NOSIGPIPE == 0
+               int o = 1;
+               setsockopt(b->b_fd, SOL_SOCKET, SO_NOSIGPIPE, &o, sizeof(o));
+#endif
        }
 
        if (b->b_connected)
@@ -124,12 +146,14 @@
        }
 
        b->b_connected = true;
+#ifdef LOCAL_CREDS
        if (setsockopt(b->b_fd, 0, LOCAL_CREDS,
            &one, (socklen_t)sizeof(one)) == -1) {
                (*b->b_fun)(LOG_ERR, "%s: setsockopt LOCAL_CREDS "
                    "failed (%m)", __func__);
                goto out;
        }
+#endif
 
        if (srv)
                if (listen(b->b_fd, 5) == -1) {
@@ -182,7 +206,6 @@
                bl_message_t bl;
                char buf[512];
        } ub;
-       int *fd;
        size_t ctxlen, tried;
 #define NTRIES 5
 
@@ -210,8 +233,7 @@
        cmsg->cmsg_level = SOL_SOCKET;
        cmsg->cmsg_type = SCM_RIGHTS;
 
-       fd = CMSG_DATA(cmsg);
-       *fd = pfd;
+       memcpy(CMSG_DATA(cmsg), &pfd, sizeof(pfd));
 
        tried = 0;
 again:
@@ -231,13 +253,20 @@
         struct msghdr   msg;
         struct iovec    iov;
        union {
-               char ctrl[CMSG_SPACE(sizeof(int)) +
-                       CMSG_SPACE(SOCKCREDSIZE(NGROUPS_MAX))];
+               char ctrl[CMSG_SPACE(sizeof(int))
+#ifdef SOCKCREDSIZE
+                       + CMSG_SPACE(SOCKCREDSIZE(NGROUPS_MAX))
+#endif



Home | Main Index | Thread Index | Old Index