]> Pileus Git - ~andy/fetchmail/commitdiff
Remove port/service dualism and make everything a service.
authorMatthias Andree <matthias.andree@gmx.de>
Tue, 2 Aug 2005 00:41:50 +0000 (00:41 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Tue, 2 Aug 2005 00:41:50 +0000 (00:41 -0000)
svn path=/trunk/; revision=4219

16 files changed:
conf.c
driver.c
etrn.c
fetchmail.c
fetchmail.h
fetchmailconf
imap.c
odmr.c
options.c
pop2.c
pop3.c
rcfile_y.y
sink.c
socket.c
socket.h
transact.c

diff --git a/conf.c b/conf.c
index 355cc7ca8a71f289a83298d3477e6cb33f938007..f286154e0f4d67f9dd8e373f2bf277aa1b65502c 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -246,11 +246,7 @@ void dump_config(struct runctl *runp, struct query *querylist)
 
            using_kpop =
                (ctl->server.protocol == P_POP3 &&
-#ifndef INET6_ENABLE
-                ctl->server.port == KPOP_PORT &&
-#else
                 ctl->server.service && !strcmp(ctl->server.service, KPOP_PORT ) &&
-#endif
                 ctl->server.authenticate == A_KERBEROS_V4);
 
            stringdump("pollname", ctl->server.pollname); 
@@ -258,11 +254,7 @@ void dump_config(struct runctl *runp, struct query *querylist)
            stringdump("via", ctl->server.via); 
            stringdump("protocol", 
                       using_kpop ? "KPOP" : showproto(ctl->server.protocol));
-#ifndef INET6_ENABLE
-           numdump("port",  ctl->server.port);
-#else
-           stringdump("port",  ctl->server.service);
-#endif
+           stringdump("service",  ctl->server.service);
            numdump("timeout",  ctl->server.timeout);
            numdump("interval", ctl->server.interval);
 
index 5a2c8976b9cbdc9967f9e34b2a26fd3056d06746..71bf3f02846b72267266053ac1ee57e438b08434 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -939,11 +939,7 @@ static int do_session(
        /* setjmp returned zero -> normal operation */
        char buf[MSGBUFSIZE+1], *realhost;
        int count, new, bytes;
-#ifdef INET6_ENABLE
        int fetches, dispatches, oldphase;
-#else /* INET6_ENABLE */
-       int port, fetches, dispatches, oldphase;
-#endif /* INET6_ENABLE */
        struct idlist *idp;
 
        /* execute pre-initialization command, if any */
@@ -959,13 +955,6 @@ static int do_session(
        oldphase = phase;
        phase = OPEN_WAIT;
        set_timeout(mytimeout);
-#ifndef INET6_ENABLE
-#ifdef SSL_ENABLE
-       port = ctl->server.port ? ctl->server.port : ( ctl->use_ssl ? ctl->server.base_protocol->sslport : ctl->server.base_protocol->port );
-#else
-       port = ctl->server.port ? ctl->server.port : ctl->server.base_protocol->port;
-#endif
-#endif /* !INET6_ENABLE */
 
 #ifdef HAVE_PKG_hesiod
        /* If either the pollname or vianame are "hesiod" we want to
@@ -1081,13 +1070,9 @@ static int do_session(
        /* allow time for the port to be set up if we have a plugin */
        if (ctl->server.plugin)
            (void)sleep(1);
-#ifdef INET6_ENABLE
        if ((mailserver_socket = SockOpen(realhost, 
                             ctl->server.service ? ctl->server.service : ( ctl->use_ssl ? ctl->server.base_protocol->sslservice : ctl->server.base_protocol->service ),
                             ctl->server.plugin)) == -1)
-#else /* INET6_ENABLE */
-       if ((mailserver_socket = SockOpen(realhost, port, ctl->server.plugin)) == -1)
-#endif /* INET6_ENABLE */
        {
            char        errbuf[BUFSIZ];
 #ifndef INET6_ENABLE
@@ -1574,7 +1559,7 @@ is restored."));
        break;
     }
     if (msg) {
-       char    *stem;
+       const char *stem;
 
        if (phase == FORWARDING_WAIT || phase == LISTENER_WAIT)
            stem = GT_("%s error while delivering to SMTP host %s\n");
diff --git a/etrn.c b/etrn.c
index 31a28705d2948c8bc919c3738c975c2b6ffb4727..eb953008f0e634ec12e5ff54b47ba1957f715b49 100644 (file)
--- a/etrn.c
+++ b/etrn.c
@@ -122,13 +122,8 @@ static int etrn_logout(int sock, struct query *ctl)
 static const struct method etrn =
 {
     "ETRN",            /* ESMTP ETRN extension */
-#ifdef INET6_ENABLE
     "smtp",            /* standard SMTP port */
     "smtps",           /* ssl SMTP port */
-#else /* INET6_ENABLE */
-    25,                        /* standard SMTP port */
-    465,                       /* ssl SMTP port */
-#endif /* INET6_ENABLE */
     FALSE,             /* this is not a tagged protocol */
     FALSE,             /* this does not use a message delimiter */
     etrn_ok,           /* parse command response */
index 54ba2a81c7e0fc495abf7e1965d83c18cdcf6f60..84fed2c437ea1baf664622bc762c127c6988f1f1 100644 (file)
@@ -840,11 +840,7 @@ static void optmerge(struct query *h2, struct query *h1, int force)
 #define FLAG_MERGE(fld) if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld
     FLAG_MERGE(server.via);
     FLAG_MERGE(server.protocol);
-#ifdef INET6_ENABLE
     FLAG_MERGE(server.service);
-#else /* INET6_ENABLE */
-    FLAG_MERGE(server.port);
-#endif /* INET6_ENABLE */
     FLAG_MERGE(server.interval);
     FLAG_MERGE(server.authenticate);
     FLAG_MERGE(server.timeout);
@@ -1180,24 +1176,27 @@ static int load_params(int argc, char **argv, int optind)
                save_str(&ctl->mailboxes, (char *)NULL, 0);
 
            /* maybe user overrode timeout on command line? */
-           if (ctl->server.timeout == -1)      
+           if (ctl->server.timeout == -1)
                ctl->server.timeout = CLIENT_TIMEOUT;
 
 #ifndef INET6_ENABLE
            /* sanity checks */
-           if (ctl->server.port < 0)
-           {
-               (void) fprintf(stderr,
-                              GT_("%s configuration invalid, port number cannot be negative\n"),
-                              ctl->server.pollname);
-               exit(PS_SYNTAX);
-           }
-           if (ctl->server.protocol == P_RPOP && ctl->server.port >= 1024)
-           {
-               (void) fprintf(stderr,
-                              GT_("%s configuration invalid, RPOP requires a privileged port\n"),
-                              ctl->server.pollname);
-               exit(PS_SYNTAX);
+           if (ctl->server.service) {
+               int port = servport(ctl->server.service);
+               if (port < 0)
+               {
+                   (void) fprintf(stderr,
+                                  GT_("%s configuration invalid, port number cannot be negative\n"),
+                                  ctl->server.pollname);
+                   exit(PS_SYNTAX);
+               }
+               if (ctl->server.protocol == P_RPOP && port >= 1024)
+               {
+                   (void) fprintf(stderr,
+                                  GT_("%s configuration invalid, RPOP requires a privileged port\n"),
+                                  ctl->server.pollname);
+                   exit(PS_SYNTAX);
+               }
            }
            if (ctl->listener == LMTP_MODE)
            {
@@ -1208,7 +1207,8 @@ static int load_params(int argc, char **argv, int optind)
                    char        *cp;
 
                    if (!(cp = strrchr(idp->id, '/')) ||
-                               (atoi(++cp) == SMTP_PORT))
+                           ++cp, (0 == strcmp(cp, SMTP_PORT))
+                               || servport(cp) == SMTP_PORT_NUM)
                    {
                        (void) fprintf(stderr,
                                       GT_("%s configuration invalid, LMTP can't use default SMTP port\n"),
@@ -1528,24 +1528,15 @@ static void dump_params (struct runctl *runp,
        }
 
        if (ctl->server.protocol == P_POP3 
-#ifdef INET6_ENABLE
            && ctl->server.service && !strcmp(ctl->server.service, KPOP_PORT)
-#else /* INET6_ENABLE */
-           && ctl->server.port == KPOP_PORT
-#endif /* INET6_ENABLE */
            && (ctl->server.authenticate == A_KERBEROS_V4 ||
                ctl->server.authenticate == A_KERBEROS_V5))
            printf(GT_("  Protocol is KPOP with Kerberos %s authentication"),
                   ctl->server.authenticate == A_KERBEROS_V5 ? "V" : "IV");
        else
            printf(GT_("  Protocol is %s"), showproto(ctl->server.protocol));
-#ifdef INET6_ENABLE
        if (ctl->server.service)
            printf(GT_(" (using service %s)"), ctl->server.service);
-#else /* INET6_ENABLE */
-       if (ctl->server.port)
-           printf(GT_(" (using port %d)"), ctl->server.port);
-#endif /* INET6_ENABLE */
        else if (outlevel >= O_VERBOSE)
            printf(GT_(" (using default port)"));
        if (ctl->server.uidl && MAILBOX_PROTOCOL(ctl))
index eede713ab47515664467bbe2be449dde87d98c40..7b2076d641afa6e71b5b4cb1993e80aea3e6e9b3 100644 (file)
@@ -42,13 +42,9 @@ char *strstr(const char *, const char *);
 #define                P_ETRN          7
 #define                P_ODMR          8
 
-#ifdef INET6_ENABLE
 #define                SMTP_PORT       "smtp"
+#define                SMTP_PORT_NUM   25
 #define                KPOP_PORT       "kpop"
-#else /* INET6_ENABLE */
-#define                SMTP_PORT       25
-#define                KPOP_PORT       1109
-#endif /* INET6_ENABLE */
 
 #ifdef SSL_ENABLE
 #define                SIMAP_PORT      993
@@ -189,13 +185,8 @@ struct query;
 struct method          /* describe methods for protocol state machine */
 {
     const char *name;          /* protocol name */
-#ifdef INET6_ENABLE
-    const char *service;
-    const char *sslservice;
-#else /* INET6_ENABLE */
-    int        port;                   /* service port */
-    int        sslport;                /* service port for ssl */
-#endif /* INET6_ENABLE */
+    const char *service;       /* service port (unencrypted) */
+    const char *sslservice;    /* service port (SSL) */
     flag tagged;               /* if true, generate & expect command tags */
     flag delimited;            /* if true, accept "." message delimiter */
     int (*parse_response)(int, char *);
@@ -233,11 +224,7 @@ struct hostdata            /* shared among all user connections to given server */
     struct idlist *akalist;            /* server name first, then akas */
     struct idlist *localdomains;       /* list of pass-through domains */
     int protocol;                      /* protocol type */
-#ifdef INET6_ENABLE
-    char *service;                     /* IPv6 service name */
-#else /* INET6_ENABLE */
-    int port;                          /* TCP/IP service port number */
-#endif /* INET6_ENABLE */
+    char *service;                     /* service name */
     int interval;                      /* # cycles to skip between polls */
     int authenticate;                  /* authentication mode to try */
     int timeout;                       /* inactivity timout in seconds */
@@ -716,4 +703,8 @@ size_t
 strlcpy(char *dst, const char *src, size_t siz);
 #endif
 
+/** Resolve the a TCP service name or a string containing only a decimal
+ * positive integer to a port number. Returns -1 for error. */
+int servport(const char *service);
+
 /* fetchmail.h ends here */
index 36bc99fd9be51da2ed246bec83aa32f6deed78fc..4a0140363feb8c2c9a93879d42a327fae496801c 100755 (executable)
@@ -79,7 +79,7 @@ class Server:
        self.active = TRUE              # Poll status
        self.interval = 0               # Skip interval
        self.protocol = 'auto'          # Default to auto protocol
-       self.port = 0                   # Port number to use
+       self.service = None             # Service name to use
        self.uidl = FALSE               # Don't use RFC1725 UIDLs by default
        self.auth = 'any'               # Default to password authentication
        self.timeout = 300              # 5-minute timeout
@@ -104,7 +104,7 @@ class Server:
            ('active',    'Boolean'),
            ('interval',  'Int'),
            ('protocol',  'String'),
-           ('port',      'Int'),
+           ('service',   'String'),
            ('uidl',      'Boolean'),
            ('auth',      'String'),
            ('timeout',   'Int'),
@@ -132,8 +132,8 @@ class Server:
            res = res + (" via " + str(self.via) + "\n");
        if self.protocol != ServerDefaults.protocol:
            res = res + " with proto " + self.protocol
-       if self.port != defaultports[self.protocol] and self.port:
-           res = res + " port " + `self.port`
+       if self.service and self.service != defaultports[self.protocol] and self.service != ianaservices[defaultports[self.protocol]]:
+           res = res + " service " + self.service
        if self.timeout != ServerDefaults.timeout:
            res = res + " timeout " + `self.timeout`
        if self.interval != ServerDefaults.interval:
@@ -410,14 +410,23 @@ class User:
 # Helper code
 #
 
-defaultports = {"auto":0,
-               "POP2":109,
-               "POP3":110,
-               "APOP":110,
-               "KPOP":1109,
-               "IMAP":143,
-               "ETRN":25,
-               "ODMR":366}
+# IANA port assignments and bogus 1109 entry
+ianaservices = {"pop2":109,
+               "pop3":110,
+               "1109":1109,
+               "imap":143,
+               "smtp":25,
+               "odmr":366}
+
+# fetchmail protocol to IANA service name
+defaultports = {"auto":None,
+               "POP2":"pop2",
+               "POP3":"pop3",
+               "APOP":"pop3",
+               "KPOP":"1109",
+               "IMAP":"imap",
+               "ETRN":"smtp",
+               "ODMR":"odmr"}
 
 authlist = ("any", "password", "gssapi", "kerberos", "ssh", "otp")
 
@@ -944,9 +953,9 @@ ports for POP3 and IMAP to see if either is
 available.
 
 Normally the TCP/IP service port to use is
-dictated by the protocol choice.  The `Port'
+dictated by the protocol choice.  The `Service'
 field (only present in expert mode) lets you
-set a non-standard port.
+set a non-standard service (port).
 """}
 
 sechelp = {
@@ -1055,7 +1064,7 @@ class ServerEdit(Frame, MyWidget):
        # Now we reset unconditionally on the theory that if you're setting
        # a custom port number you should be in expert mode and playing
        # close enough attention to notice this...
-       self.port.set(defaultports[proto])
+       self.service.set(defaultports[proto])
        if not proto in ("POP3", "APOP", "KPOP"): self.uidl.state = DISABLED
 
     def user_edit(self, username, mode):
@@ -1107,8 +1116,8 @@ class ServerEdit(Frame, MyWidget):
                  self.protocol, protolist, 2,
                  self.defaultPort)
        if mode != 'novice':
-           LabeledEntry(protwin, 'On server TCP/IP port:',
-                     self.port, leftwidth).pack(side=TOP, fill=X)
+           LabeledEntry(protwin, 'On server TCP/IP service:',
+                     self.service, leftwidth).pack(side=TOP, fill=X)
            self.defaultPort()
            Checkbutton(protwin,
                text="POP3: track `seen' with client-side UIDLs?",
@@ -1186,10 +1195,11 @@ class ServerEdit(Frame, MyWidget):
        else:
            realhost = self.server.pollname
        greetline = None
-       for (protocol, port) in (("IMAP",143), ("POP3",110), ("POP2",109)):
+       for protocol in ("IMAP","POP3","POP2"):
+           service = defaultports[protocol]
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            try:
-               sock.connect((realhost, port))
+               sock.connect((realhost, ianaservices[service]))
                greetline = sock.recv(1024)
                sock.close()
            except:
diff --git a/imap.c b/imap.c
index 4642dad48aaa3c3d3c8c27c7403b12a1d0287b9c..7440abb09529717b28a3b27337006649a2343320 100644 (file)
--- a/imap.c
+++ b/imap.c
@@ -1124,13 +1124,8 @@ static int imap_logout(int sock, struct query *ctl)
 static const struct method imap =
 {
     "IMAP",            /* Internet Message Access Protocol */
-#ifdef INET6_ENABLE
     "imap",
     "imaps",
-#else /* INET6_ENABLE */
-    143,                /* standard IMAP2bis/IMAP4 port */
-    993,                /* ssl IMAP2bis/IMAP4 port */
-#endif /* INET6_ENABLE */
     TRUE,              /* this is a tagged protocol */
     FALSE,             /* no message delimiter */
     imap_ok,           /* parse command response */
diff --git a/odmr.c b/odmr.c
index ea12c7c6b8ab4923a267ffd878cb863857316db8..d1af7361734f41fd214f70d22e46c2048a1c3795 100644 (file)
--- a/odmr.c
+++ b/odmr.c
@@ -211,13 +211,8 @@ static int odmr_logout(int sock, struct query *ctl)
 static const struct method odmr =
 {
     "ODMR",            /* ODMR protocol */
-#ifdef INET6_ENABLE
-    "odmr",            /* standard SMTP port */
-    "odmrs",           /* ssl SMTP port */
-#else /* INET6_ENABLE */
-    366,               /* standard SMTP port */
-    2366,              /* ssl SMTP port (BOGUS! RANDOM VALUE) */
-#endif /* INET6_ENABLE */
+    "odmr",            /* standard ODMR port */
+    "odmrs",           /* ssl ODMR port */
     FALSE,             /* this is not a tagged protocol */
     FALSE,             /* this does not use a message delimiter */
     odmr_ok,           /* parse command response */
index 38c46eb5503dcbe4b6aa63add4b74a0742b13de4..25c1c5e3b295c36b6dc33023f8dc241295665734 100644 (file)
--- a/options.c
+++ b/options.c
@@ -358,11 +358,7 @@ struct query *ctl; /* option record to be initialized */
            else if (strcasecmp(optarg,"kpop") == 0)
            {
                ctl->server.protocol = P_POP3;
-#ifdef INET6_ENABLE
                ctl->server.service = KPOP_PORT;
-#else /* INET6_ENABLE */
-               ctl->server.port = KPOP_PORT;
-#endif /* INET6_ENABLE */
 #ifdef KERBEROS_V5
                ctl->server.authenticate =  A_KERBEROS_V5;
 #else
@@ -386,11 +382,7 @@ struct query *ctl; /* option record to be initialized */
            break;
        case 'P':
        case LA_PORT:
-#ifdef INET6_ENABLE
            ctl->server.service = optarg;
-#else /* INET6_ENABLE */
-           ctl->server.port = xatoi(optarg, &errflag);
-#endif /* INET6_ENABLE */
            break;
        case LA_AUTH:
            if (strcmp(optarg, "password") == 0)
diff --git a/pop2.c b/pop2.c
index bfccac179115e2cb950606730b8fb0530473be6f..18d4cccdcd2562ac91cc496569f4fcfc7d2fffe6 100644 (file)
--- a/pop2.c
+++ b/pop2.c
@@ -132,13 +132,8 @@ static int pop2_logout(int sock, struct query *ctl)
 static const struct method pop2 =
 {
     "POP2",                            /* Post Office Protocol v2 */
-#if INET6_ENABLE
-    "pop2",                            /* standard POP2 port */
-    "pop2",                            /* ssl POP2 port */
-#else /* INET6_ENABLE */
     109,                               /* standard POP2 port */
     109,                               /* ssl POP2 port - not */
-#endif /* INET6_ENABLE */
     FALSE,                             /* this is not a tagged protocol */
     FALSE,                             /* does not use message delimiter */
     pop2_ok,                           /* parse command response */
diff --git a/pop3.c b/pop3.c
index 3ea79fb2a739dc0eb6f8ead2c5ef95a933a647db..13f51409912306cb0fe48874cdf472dfda8c3899 100644 (file)
--- a/pop3.c
+++ b/pop3.c
@@ -449,11 +449,7 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting)
         * rather than doing SASL.
         */
        if (has_kerberos &&
-#ifdef INET6_ENABLE
            ctl->server.service && (strcmp(ctl->server.service, KPOP_PORT)!=0)
-#else /* INET6_ENABLE */
-           ctl->server.port != KPOP_PORT
-#endif /* INET6_ENABLE */
            && (ctl->server.authenticate == A_KERBEROS_V4
             || ctl->server.authenticate == A_KERBEROS_V5
             || ctl->server.authenticate == A_ANY))
@@ -1243,13 +1239,8 @@ static int pop3_logout(int sock, struct query *ctl)
 static const struct method pop3 =
 {
     "POP3",            /* Post Office Protocol v3 */
-#ifdef INET6_ENABLE
     "pop3",            /* standard POP3 port */
     "pop3s",           /* ssl POP3 port */
-#else /* INET6_ENABLE */
-    110,               /* standard POP3 port */
-    995,               /* ssl POP3 port */
-#endif /* INET6_ENABLE */
     FALSE,             /* this is not a tagged protocol */
     TRUE,              /* this uses a message delimiter */
     pop3_ok,           /* parse command response */
index cbbf6b077c3bd3f0957e7ea0fe7f475b3bb6920e..518b0ecb01664407196c530a27ab3f891cb25697 100644 (file)
@@ -153,11 +153,7 @@ serv_option        : AKA alias_list
 #else
                                                current.server.authenticate = A_KERBEROS_V4;
 #endif /* KERBEROS_V5 */
-#ifdef INET6_ENABLE
                                            current.server.service = KPOP_PORT;
-#else /* INET6_ENABLE */
-                                           current.server.port = KPOP_PORT;
-#endif /* INET6_ENABLE */
                                        }
                | PRINCIPAL STRING      {current.server.principal = xstrdup($2);}
                | ESMTPNAME STRING      {current.server.esmtp_name = xstrdup($2);}
@@ -175,19 +171,13 @@ serv_option       : AKA alias_list
                | CHECKALIAS            {current.server.checkalias = FLAG_TRUE;}
                | NO CHECKALIAS         {current.server.checkalias  = FLAG_FALSE;}
                | SERVICE STRING        {
-#ifdef INET6_ENABLE
                                        current.server.service = $2;
-#endif /* INET6_ENABLE */
                                        }
                | PORT NUMBER           {
-#ifdef INET6_ENABLE
                                        int port = $2;
                                        char buf[10];
-                                       sprintf(buf, "%d", port);
+                                       snprintf(buf, sizeof buf, "%d", port);
                                        current.server.service = xstrdup(buf);
-#else
-                                       current.server.port = $2;
-#endif /* INET6_ENABLE */
                }
                | INTERVAL NUMBER
                        {current.server.interval = $2;}
diff --git a/sink.c b/sink.c
index 62cc8fdd9b9ed9dcbdf667dc3f967d909cd9bdaa..a3c52a5b222423575d598d6344e40f7c0420c1df 100644 (file)
--- a/sink.c
+++ b/sink.c
@@ -121,11 +121,7 @@ int smtp_open(struct query *ctl)
        for (idp = ctl->smtphunt; idp; idp = idp->next)
        {
            char        *cp;
-#ifdef INET6_ENABLE 
            char        *portnum = SMTP_PORT;
-#else
-           int         portnum = SMTP_PORT;
-#endif /* INET6_ENABLE */
 
            ctl->smtphost = idp->id;  /* remember last host tried. */
            if(ctl->smtphost[0]=='/')
@@ -136,11 +132,7 @@ int smtp_open(struct query *ctl)
            if ((cp = strrchr(parsed_host, '/')))
            {
                *cp++ = 0;
-#ifdef INET6_ENABLE 
                portnum = cp;
-#else
-               portnum = atoi(cp);
-#endif /* INET6_ENABLE */
            }
 
            if (ctl->smtphost[0]=='/'){
index 80caa30332a64fd3f8391f03c2b85ec070714f97..dc1d960dd78f796efba2748af25305ad9c76d262 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -319,7 +319,7 @@ int SockOpen(const char *host, const char *service,
 #endif
 #endif /* HAVE_INET_ATON */
 
-int SockOpen(const char *host, int clientPort,
+int SockOpen(const char *host, const char *service,
             const char *plugin)
 {
     int sock = -1;     /* pacify -Wall */
@@ -328,6 +328,7 @@ int SockOpen(const char *host, int clientPort,
 #endif /* HAVE_INET_ATON */
     struct sockaddr_in ad, **pptr;
     struct hostent *hp;
+    int clientPort = servport(service);
 
 #ifdef HAVE_SOCKETPAIR
     if (plugin) {
@@ -337,6 +338,9 @@ int SockOpen(const char *host, int clientPort,
     }
 #endif /* HAVE_SOCKETPAIR */
 
+    if (clientPort < 0)
+       return sock;
+
     memset(&ad, 0, sizeof(ad));
     ad.sin_family = AF_INET;
 
@@ -359,11 +363,11 @@ int SockOpen(const char *host, int clientPort,
             return -1;
         }
 
-               /* Socket opened saved. Usefull if connect timeout because
-                * it can be closed
-                */
-               mailserver_socket_temp = sock;
-               
+       /* Socket opened saved. Usefull if connect timeout because
+        * it can be closed
+        */
+       mailserver_socket_temp = sock;
+
         if (connect(sock, (struct sockaddr *) &ad, sizeof(ad)) < 0)
         {
             int olderr = errno;
@@ -1072,7 +1076,7 @@ static ssize_t cygwin_read(int sock, void *buf, size_t count)
  * inetd.conf (and then SIGHUP inetd) for this to work.  */
 main()
 {
-    int                sock = SockOpen("localhost", 19, NULL);
+    int                sock = SockOpen("localhost", "chargen", NULL);
     char       buf[80];
 
     while (SockRead(sock, buf, sizeof(buf)-1))
index d7c3ad2588e6e478a9f4ccc28d333bfcde89b5a4..d4fc947ebc640717aef925f8c6a7c8eece5d68fe 100644 (file)
--- a/socket.h
+++ b/socket.h
@@ -7,14 +7,8 @@
 #ifndef SOCKET__
 #define SOCKET__
 
-/* Create a new client socket; returns (FILE *)NULL on error */
-#ifdef INET6_ENABLE
-int SockOpen(const char *host, const char *service,
-            const char *plugin);
-#else /* INET6_ENABLE */
-int SockOpen(const char *host, int clientPort,
-            const char *plugin);
-#endif /* INET6_ENABLE */
+/* Create a new client socket; returns -1 on error */
+int SockOpen(const char *host, const char *service, const char *plugin);
 
 /* Returns 1 if this socket is OK, 0 if it isn't select()able
  * on - probably because it's been closed. You should
index 8dfa7b2db41b77d760f43bd13672669c2f97df3a..d7389b1e679815e1a27161c289696e20b1d3669a 100644 (file)
@@ -611,15 +611,11 @@ int readheaders(int sock,
 #ifdef POP2_ENABLE
        /*
         * We disable this check under POP2 because there's no way to
-        * prevent deletion of the message.  So at least we ought to 
+        * prevent deletion of the message.  So at least we ought to
         * forward it to the user so he or she will have some clue
         * that things have gone awry.
         */
-#if INET6_ENABLE
-       if (strncmp(protocol->service, "pop2", 4))
-#else /* INET6_ENABLE */
-       if (protocol->port != 109)
-#endif /* INET6_ENABLE */
+       if (servport("pop2") != servport(protocol->service))
 #endif /* POP2_ENABLE */
            if (num == 1 && !strncasecmp(line, "X-IMAP:", 7)) {
                free(line);