From de2bed8da8ca1878a155681b9f954e44b0612e11 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 5 Mar 2000 07:42:00 +0000 Subject: [PATCH] * Add Unix domain socket support to citmail.c --- citadel/citmail.c | 26 ++++++++++++++++++++++++++ citadel/sysconfig.h | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/citadel/citmail.c b/citadel/citmail.c index ff0ea6586..83c54ea66 100644 --- a/citadel/citmail.c +++ b/citadel/citmail.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,31 @@ int connectsock(char *host, char *service, char *protocol) struct protoent *ppe; struct sockaddr_in sin; int s, type; + struct sockaddr_un sun; + + if ( (!strcmp(protocol, "unix")) || (atoi(service)<0) ) { + memset(&sun, 0, sizeof(sun)); + sun.sun_family = AF_UNIX; + sprintf(sun.sun_path, USOCKPATH, 0-atoi(service) ); + + s = socket(AF_UNIX, SOCK_STREAM, 0); + if (s < 0) { + fprintf(stderr, "Can't create socket: %s\n", + strerror(errno)); + exit(3); + } + + if (connect(s, (struct sockaddr *) &sun, sizeof(sun)) < 0) { + fprintf(stderr, "can't connect: %s\n", + strerror(errno)); + exit(3); + } + + return s; + } + + + /* otherwise it's a network connection */ memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; diff --git a/citadel/sysconfig.h b/citadel/sysconfig.h index 70e2162d8..70f6d01d0 100644 --- a/citadel/sysconfig.h +++ b/citadel/sysconfig.h @@ -84,6 +84,11 @@ /* * These define what port to listen on for various services. + * If you don't want to run these services on the network, you can specify + * a negative port number to create Unix domain sockets. This will allow, + * for example, the "citmail" utility to connect to the Citadel SMTP server + * to import email, without having to actually run Citadel SMTP on the network. + * * FIXME ... put this in a programmable config somewhere */ #define POP3_PORT 110 -- 2.30.2