Source-Changes-HG archive

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

[src/trunk]: src reduce diffs from the original, using dummy impl. of openlog...



details:   https://anonhg.NetBSD.org/src/rev/baa0e517ad23
branches:  trunk
changeset: 571123:baa0e517ad23
user:      yamt <yamt%NetBSD.org@localhost>
date:      Thu Nov 11 11:27:34 2004 +0000

description:
reduce diffs from the original, using dummy impl. of openlog_r and syslog_r.

diffstat:

 dist/pf/libexec/spamd/grey.c        |  59 +---------------------------------
 dist/pf/libexec/spamd/spamd.c       |  64 ++----------------------------------
 dist/pf/libexec/spamlogd/spamlogd.c |  35 +-------------------
 libexec/spamd/Makefile              |   6 ++-
 libexec/spamlogd/Makefile           |   6 ++-
 5 files changed, 17 insertions(+), 153 deletions(-)

diffs (truncated from 473 to 300 lines):

diff -r 37184e34de7d -r baa0e517ad23 dist/pf/libexec/spamd/grey.c
--- a/dist/pf/libexec/spamd/grey.c      Thu Nov 11 10:58:29 2004 +0000
+++ b/dist/pf/libexec/spamd/grey.c      Thu Nov 11 11:27:34 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: grey.c,v 1.2 2004/06/22 16:04:40 itojun Exp $  */
+/*     $NetBSD: grey.c,v 1.3 2004/11/11 11:27:34 yamt Exp $    */
 /*     $OpenBSD: grey.c,v 1.12 2004/03/13 17:46:15 beck Exp $  */
 
 /*
@@ -96,11 +96,7 @@
                return(-1);
        pargv[2] = fdpath;
        if (pipe(pdes) != 0) {
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_INFO, &sdata, "pipe failed (%m)");
-#else
-               syslog(LOG_INFO, "pipe failed (%m)");
-#endif
                free(fdpath);
                fdpath = NULL;
                return(-1);
@@ -108,11 +104,7 @@
        signal(SIGCHLD, SIG_DFL);
        switch (pid = fork()) {
        case -1:
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_INFO, &sdata, "fork failed (%m)");
-#else
-               syslog(LOG_INFO, "fork failed (%m)");
-#endif
                free(fdpath);
                fdpath = NULL;
                close(pdes[0]);
@@ -127,11 +119,7 @@
                        close(pdes[0]);
                }
                execvp(PATH_PFCTL, pargv);
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_ERR, &sdata, "can't exec %s:%m", PATH_PFCTL);
-#else
-               syslog(LOG_ERR, "can't exec %s:%m", PATH_PFCTL);
-#endif
                _exit(1);
        }
 
@@ -141,11 +129,7 @@
        close(pdes[0]);
        pf = fdopen(pdes[1], "w");
        if (pf == NULL) {
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_INFO, &sdata, "fdopen failed (%m)");
-#else
-               syslog(LOG_INFO, "fdopen failed (%m)");
-#endif
                close(pdes[1]);
                signal(SIGCHLD, sig_term_chld);
                return(-1);
@@ -217,11 +201,7 @@
        memset(&btreeinfo, 0, sizeof(btreeinfo));
        db = dbopen(dbname, O_EXLOCK|O_RDWR, 0600, DB_BTREE, &btreeinfo);
        if (db == NULL) {
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_INFO, &sdata, "dbopen failed (%m)");
-#else
-               syslog(LOG_INFO, "dbopen failed (%m)");
-#endif
                return(-1);
        }
        memset(&dbk, 0, sizeof(dbk));
@@ -242,13 +222,8 @@
                                memset(a, 0, sizeof(a));
                                memcpy(a, dbk.data, MIN(sizeof(a),
                                    dbk.size));
-#ifdef HAVE_SYSLOG_R
                                syslog_r(LOG_DEBUG, &sdata,
                                    "deleting %s from %s", a, dbname);
-#else
-                               syslog(LOG_DEBUG,
-                                   "deleting %s from %s", a, dbname);
-#endif
                        }
                        if (db->del(db, &dbk, 0)) {
                                db->close(db);
@@ -294,13 +269,8 @@
                                        goto bad;
                                }
                                db->sync(db, 0);
-#ifdef HAVE_SYSLOG_R
                                syslog_r(LOG_DEBUG, &sdata,
                                    "whitelisting %s in %s", a, dbname);
-#else
-                               syslog(LOG_DEBUG,
-                                   "whitelisting %s in %s", a, dbname);
-#endif
                        }
                        if (debug)
                                fprintf(stderr, "whitelisted %s\n", a);
@@ -412,11 +382,7 @@
 
        state = 0;
        if (grey == NULL) {
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_ERR, &sdata, "No greylist pipe stream!\n");
-#else
-               syslog(LOG_ERR, "No greylist pipe stream!\n");
-#endif
                exit(1);
        }
        while ((buf = fgetln(grey, &len))) {
@@ -473,13 +439,8 @@
                sleep(DB_SCAN_INTERVAL);
                i = greyscan(PATH_SPAMD_DB);
                if (i == -1) {
-#ifdef HAVE_SYSLOG_R
                        syslog_r(LOG_NOTICE, &sdata, "scan of %s failed",
                            PATH_SPAMD_DB);
-#else
-                       syslog(LOG_NOTICE, "scan of %s failed",
-                           PATH_SPAMD_DB);
-#endif
                }
        }
        /* NOTREACHED */
@@ -492,11 +453,7 @@
 
        pfdev = open("/dev/pf", O_RDWR);
        if (pfdev == -1) {
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_ERR, &sdata, "open of /dev/pf failed (%m)");
-#else
-               syslog(LOG_ERR, "open of /dev/pf failed (%m)");
-#endif
                exit(1);
        }
 
@@ -504,24 +461,14 @@
        if ((i = open(PATH_SPAMD_DB, O_RDWR, 0)) == -1 && errno == ENOENT) {
                i = open(PATH_SPAMD_DB, O_RDWR|O_CREAT, 0644);
                if (i == -1) {
-#ifdef HAVE_SYSLOG_R
                        syslog_r(LOG_ERR, &sdata, "create %s failed (%m)", 
                            PATH_SPAMD_DB);
-#else
-                       syslog(LOG_ERR, "create %s failed (%m)", 
-                           PATH_SPAMD_DB);
-#endif
                        exit(1);
                }
                /* if we are dropping privs, chown to that user */
                if (pw && (fchown(i, pw->pw_uid, pw->pw_gid) == -1)) {
-#ifdef HAVE_SYSLOG_R
                        syslog_r(LOG_ERR, &sdata, "chown %s failed (%m)", 
                            PATH_SPAMD_DB);
-#else
-                       syslog(LOG_ERR, "chown %s failed (%m)", 
-                           PATH_SPAMD_DB);
-#endif
                        exit(1);
                }
        }
@@ -543,11 +490,7 @@
        db_pid = fork();
        switch(db_pid) {
        case -1:
-#ifdef HAVE_SYSLOG_R
                syslog_r(LOG_ERR, &sdata, "fork failed (%m)"); 
-#else
-               syslog(LOG_ERR, "fork failed (%m)"); 
-#endif
                exit(1);
        case 0:
                /*
diff -r 37184e34de7d -r baa0e517ad23 dist/pf/libexec/spamd/spamd.c
--- a/dist/pf/libexec/spamd/spamd.c     Thu Nov 11 10:58:29 2004 +0000
+++ b/dist/pf/libexec/spamd/spamd.c     Thu Nov 11 11:27:34 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spamd.c,v 1.3 2004/06/25 15:54:31 itojun Exp $ */
+/*     $NetBSD: spamd.c,v 1.4 2004/11/11 11:27:34 yamt Exp $   */
 /*     $OpenBSD: spamd.c,v 1.64 2004/03/17 14:42:20 beck Exp $ */
 
 /*
@@ -587,17 +587,10 @@
        time_t t;
 
        time(&t);
-#ifdef HAVE_SYSLOG_R
        syslog_r(LOG_INFO, &sdata, "%s: disconnected after %ld seconds.%s%s",
            cp->addr, (long)(t - cp->s),
            ((cp->lists == NULL) ? "" : " lists:"),
            ((cp->lists == NULL) ? "": cp->lists));
-#else
-       syslog(LOG_INFO, "%s: disconnected after %ld seconds.%s%s",
-           cp->addr, (long)(t - cp->s),
-           ((cp->lists == NULL) ? "" : " lists:"),
-           ((cp->lists == NULL) ? "": cp->lists));
-#endif
        if (debug > 0)
                printf("%s connected for %ld seconds.\n", cp->addr,
                    (long)(t - cp->s));
@@ -697,21 +690,12 @@
                        cp->state = 6;
                        cp->w = t + cp->stutter;
                        if (cp->mail[0] && cp->rcpt[0]) {
-                               if (verbose) {
-#ifdef HAVE_SYSLOG_R
+                               if (verbose)
                                        syslog_r(LOG_DEBUG, &sdata,
                                            "(%s) %s: %s -> %s",
                                            cp->blacklists ? "BLACK" : "GREY",
                                            cp->addr, cp->mail,
                                            cp->rcpt);
-#else
-                                       syslog(LOG_DEBUG,
-                                           "(%s) %s: %s -> %s",
-                                           cp->blacklists ? "BLACK" : "GREY",
-                                           cp->addr, cp->mail,
-                                           cp->rcpt);
-#endif
-                               }
                                if (debug)
                                        fprintf(stderr, "(%s) %s: %s -> %s\n",
                                            cp->blacklists ? "BLACK" : "GREY",
@@ -747,11 +731,7 @@
                        cp->state = 60;
                        if (window && setsockopt(cp->fd, SOL_SOCKET, SO_RCVBUF,
                            &window, sizeof(window)) == -1) {
-#ifdef HAVE_SYSLOG_R
                                syslog_r(LOG_DEBUG, &sdata,"setsockopt: %m");
-#else
-                               syslog(LOG_DEBUG,"setsockopt: %m");
-#endif
                                /* don't fail if this doesn't work. */
                        }
                } else {
@@ -774,25 +754,13 @@
                }
                if (!cp->data_body && !*cp->ibuf)
                        cp->data_body = 1;
-               if (verbose && cp->data_body && *cp->ibuf) {
-#ifdef HAVE_SYSLOG_R
+               if (verbose && cp->data_body && *cp->ibuf)
                        syslog_r(LOG_DEBUG, &sdata, "%s: Body: %s", cp->addr,
                            cp->ibuf);
-#else
-                       syslog(LOG_DEBUG, "%s: Body: %s", cp->addr,
-                           cp->ibuf);
-#endif
-               }
                else if (verbose && (match(cp->ibuf, "FROM:") ||
-                   match(cp->ibuf, "TO:") || match(cp->ibuf, "SUBJECT:"))) {
-#ifdef HAVE_SYSLOG_R
+                   match(cp->ibuf, "TO:") || match(cp->ibuf, "SUBJECT:")))
                        syslog_r(LOG_INFO, &sdata, "%s: %s", cp->addr,
                            cp->ibuf);
-#else
-                       syslog(LOG_INFO, "%s: %s", cp->addr,
-                           cp->ibuf);
-#endif
-               }
                cp->ip = cp->ibuf;
                cp->il = sizeof(cp->ibuf) - 1;
                cp->r = t;
@@ -844,15 +812,9 @@
                        cp->ip--;
                *cp->ip = '\0';
                cp->r = 0;
-               if (verbose) {
-#ifdef HAVE_SYSLOG_R
+               if (verbose)
                        syslog_r(LOG_DEBUG, &sdata, "%s: says '%s'", cp->addr,
                            cp->ibuf);
-#else
-                       syslog(LOG_DEBUG, "%s: says '%s'", cp->addr,
-                           cp->ibuf);
-#endif
-               }
                nextstate(cp);
        }
 }
@@ -915,9 +877,7 @@
        long p, g, w;
 
        tzset();
-#ifdef HAVE_SYSLOG_R
        openlog_r("spamd", LOG_PID | LOG_NDELAY, LOG_DAEMON, &sdata);
-#endif
 
        if ((ent = getservbyname("spamd", "tcp")) == NULL)
                errx(1, "Can't find service \"spamd\" in /etc/services");
@@ -1128,11 +1088,7 @@
 
        if (debug != 0)
                printf("listening for incoming connections.\n");
-#ifdef HAVE_SYSLOG_R
        syslog_r(LOG_WARNING, &sdata, "listening for incoming connections.");
-#else
-       syslog(LOG_WARNING, "listening for incoming connections.");
-#endif
 
        while (1) {



Home | Main Index | Thread Index | Old Index