OSSP CVS Repository

ossp - Check-in [4475]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 4475
Date: 2004-Apr-02 15:52:50 (local)
2004-Apr-02 13:52:50 (UTC)
User:thl
Branch:
Comment: print errno and associated message whenever sa returns SA_ERR_SYS
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.94 -> 1.95     72 inserted, 18 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.94 -> 1.95

--- lmtp2nntp_config.c   2004/04/02 08:22:46     1.94
+++ lmtp2nntp_config.c   2004/04/02 13:52:50     1.95
@@ -309,11 +309,17 @@
                 ctx->pacl[i].prefixlen = atoi(cp);
                 logbook(ctx->l2, L2_LEVEL_DEBUG, "ctx->pacl[%d].prefixlen = %d", i, ctx->pacl[i].prefixlen);
                 if ((sa_rc = sa_addr_create(&(ctx->pacl[i].saa))) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create address (internal) failed with \"%s\"", sa_error(sa_rc));
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create address (internal) failed with \"%s\" (%d) %s", sa_error(sa_rc), errno, strerror(errno));
+                    else
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                     }
                 if ((sa_rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing address (%s) failed with \"%s\" (%d) %", ctx->pacl[i].acl, sa_error(sa_rc), errno, strerror(errno));
+                    else
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
                     throw(0,0,0);
                     }
             }
@@ -327,11 +333,17 @@
             ctx->pacl[i].not = FALSE;
             ctx->pacl[i].prefixlen = 0;
             if ((sa_rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv4 pass-through address (internal) failed with \"%s\"", sa_error(sa_rc));
+                if (sa_rc == SA_ERR_SYS)
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv4 pass-through address (internal) failed with \"%s\" (%d) %s", sa_error(sa_rc), errno, strerror(errno));
+                else
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv4 pass-through address (internal) failed with \"%s\"", sa_error(sa_rc));
                 throw(0,0,0);
             }
             if ((sa_rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv4 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
+                if (sa_rc == SA_ERR_SYS)
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv4 pass-through address (%s) failed with \"%s\" (%d) %s", ctx->pacl[i].acl, sa_error(sa_rc), errno, strerror(errno));
+                else
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv4 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
                 throw(0,0,0);
             }
             i++;
@@ -345,11 +357,17 @@
             ctx->pacl[i].not = FALSE;
             ctx->pacl[i].prefixlen = 0;
             if ((sa_rc = sa_addr_create(&ctx->pacl[i].saa)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv6 pass-through address (internal) failed with \"%s\"", sa_error(sa_rc));
+                if (sa_rc == SA_ERR_SYS)
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv6 pass-through address (internal) failed with \"%s\" (%d) %s", sa_error(sa_rc), errno, strerror(errno));
+                else
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, create IPv6 pass-through address (internal) failed with \"%s\"", sa_error(sa_rc));
                 throw(0,0,0);
             }
             if ((sa_rc = sa_addr_u2a(ctx->pacl[i].saa, "inet://%s:0", ctx->pacl[i].acl)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv6 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
+                if (sa_rc == SA_ERR_SYS)
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv6 pass-through address (%s) failed with \"%s\" (%d) %s", ctx->pacl[i].acl, sa_error(sa_rc), errno, strerror(errno));
+                else
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --acl, parsing IPv6 pass-through address (%s) failed with \"%s\"", ctx->pacl[i].acl, sa_error(sa_rc));
                 throw(0,0,0);
             }
             i++;
@@ -374,11 +392,17 @@
             /* dash means stdio */
             if (strcmp(ov->data.s, "-") != 0) {
                 if ((sa_rc = sa_create(&ctx->saServerbind)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, creating TCP socket (internal) failed with \"%s\"", sa_error(sa_rc));
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, creating TCP socket (internal) failed with \"%s\" (%d) %s", sa_error(sa_rc), errno, strerror(errno));
+                    else
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, creating TCP socket (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                 }
                 if ((sa_rc = sa_addr_create(&ctx->saaServerbind)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, create address (internal) failed with \"%s\"", sa_error(sa_rc));
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, create address (internal) failed with \"%s\", (%d) %s", sa_error(sa_rc), errno, strerror(errno));
+                    else
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                 }
             /* slash means UNIX socket */
@@ -413,11 +437,17 @@
                         }
                     }
                     if ((sa_rc = sa_addr_u2a(ctx->saaServerbind, "unix:%s", cpPath)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing UNIX socket (%s) failed with \"%s\"", cpPath, sa_error(sa_rc));
+                        if (sa_rc == SA_ERR_SYS)
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing UNIX socket (%s) failed with \"%s\" (%d) %s", cpPath, sa_error(sa_rc), errno, strerror(errno));
+                        else
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing UNIX socket (%s) failed with \"%s\"", cpPath, sa_error(sa_rc));
                         throw(0,0,0);
                     }
                     if ((sa_rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", cpPath, sa_error(sa_rc));
+                        if (sa_rc == SA_ERR_SYS)
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\" (%d) %s", cpPath, sa_error(sa_rc), errno, strerror(errno));
+                        else
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", cpPath, sa_error(sa_rc));
                         throw(0,0,0);
                     }
                     if (nPerm != -1) {
@@ -443,19 +473,28 @@
                         cp = str_concat(cp, NULL); /* prepare for free() */
                     logbook(ctx->l2, L2_LEVEL_DEBUG, "data.s = \"%s\", cp = \"%s\"", ov->data.s, cp);
                     if ((sa_rc = sa_addr_u2a(ctx->saaServerbind, "inet://%s", cp)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
+                        if (sa_rc == SA_ERR_SYS)
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing INET socket (%s) failed with \"%s\" (%d) %s", ov->data.s, sa_error(sa_rc), errno, strerror(errno));
+                        else
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
                         throw(0,0,0);
                     }
                     if ((sa_rc = sa_bind(ctx->saServerbind, ctx->saaServerbind)) != SA_OK) {
-                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
+                        if (sa_rc == SA_ERR_SYS)
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\" (%d) %s", ov->data.s, sa_error(sa_rc), errno, strerror(errno));
+                        else
+                            logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, bind (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
                         throw(0,0,0);
                     }
                     free(cp);
                 }
             /* for either sockets */
                 if ((sa_rc = sa_listen(ctx->saServerbind, -1)) != SA_OK) {
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, listen (%s) failed with \"%s\" (%d) %s", ov->data.s, sa_error(sa_rc), errno, strerror(errno));
+                    else
                         logbook(ctx->l2, L2_LEVEL_ERROR, "option --bind, listen (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
-                        throw(0,0,0);
+                    throw(0,0,0);
                 }
             }
         }
@@ -474,13 +513,19 @@
 
         if (ov->ndata == 1) {
             if ((sa_rc = sa_addr_create(&ctx->saaClientbind)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, create address (internal) failed with \"%s\"", sa_error(sa_rc));
+                if (sa_rc == SA_ERR_SYS)
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, create address (internal) failed with \"%s\" (%d) %s", sa_error(sa_rc), errno, strerror(errno));
+                else
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                 throw(0,0,0);
             }
             if ((sa_rc = sa_addr_u2a(ctx->saaClientbind,
                                   (strchr(ov->data.s, ':') == NULL) ?  "inet://%s:0" : "inet://%s",
                                   ov->data.s)) != SA_OK) {
-                logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
+                if (sa_rc == SA_ERR_SYS)
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\" (%d) %s", ov->data.s, sa_error(sa_rc), errno, strerror(errno));
+                else
+                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --client, parsing alternate IO guessing INET socket (%s) failed with \"%s\"", ov->data.s, sa_error(sa_rc));
                 throw(0,0,0);
             }
         }
@@ -511,15 +556,24 @@
                     cp = str_concat(cp, NULL); /* prepare for free() */
                 logbook(ctx->l2, L2_LEVEL_DEBUG, "(data.m)[%d] = \"%s\", cp = \"%s\"", i, (ov->data.m)[i], cp);
                 if ((sa_rc = sa_addr_create(&ctx->pns[i].saa)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, create address (internal) failed with \"%s\"", sa_error(sa_rc));
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, create address (internal) failed with \"%s\" (%d) %s", sa_error(sa_rc), errno, strerror(errno));
+                    else
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, create address (internal) failed with \"%s\"", sa_error(sa_rc));
                     throw(0,0,0);
                 }
                 if ((sa_rc = sa_addr_u2a(ctx->pns[i].saa, "inet://%s", cp)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, parsing host address (%s) failed with \"%s\"", cp, sa_error(sa_rc));
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, parsing host address (%s) failed with \"%s\", (%d) %s", cp, sa_error(sa_rc), errno, strerror(errno));
+                    else
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, parsing host address (%s) failed with \"%s\"", cp, sa_error(sa_rc));
                     throw(0,0,0);
                 }
                 if ((sa_rc = sa_create(&ctx->pns[i].sa)) != SA_OK) {
-                    logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\"", cp, sa_error(sa_rc));
+                    if (sa_rc == SA_ERR_SYS)
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\" (%d) %s", cp, sa_error(sa_rc), errno, strerror(errno));
+                    else
+                        logbook(ctx->l2, L2_LEVEL_ERROR, "option --destination, creating TCP socket (%s) failed with \"%s\"", cp, sa_error(sa_rc));
                     throw(0,0,0);
                 }
                 ctx->pns[i].nntp = NULL;

CVSTrac 2.0.1