[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
socket interface to contentfilter
Matti,
please consider applying the following diff. I am in the process of
building a rather advanced (and hopefully fast) modular contentfilter;
it runs as a separate daemon and talks to smtpserver over the socket.
Naturally, I will publish the thing when it is basically ready.
Thanks.
Index: smtpserver/contentpolicy.c
===================================================================
RCS file: /cvsroot/zmailer/smtpserver/contentpolicy.c,v
retrieving revision 1.19
diff -u -r1.19 contentpolicy.c
--- smtpserver/contentpolicy.c 2003/08/28 12:59:56 1.19
+++ smtpserver/contentpolicy.c 2003/09/03 11:25:24
@@ -52,7 +52,7 @@
*/
-static int init_content_policy()
+static int init_content_policy_prog()
{
int piperd[2], pipewr[2]; /* per parent */
@@ -97,6 +97,46 @@
close(piperd[1]);
return 1; /* Successfull start! (?) */
+}
+
+static int init_content_policy_sock()
+{
+ int msgsock;
+ struct sockaddr_un server;
+
+ memset((char*)&server,0,sizeof(server));
+ server.sun_family = AF_UNIX;
+ strncpy(server.sun_path,contentfilter,sizeof(server.sun_path)-1);
+ server.sun_path[sizeof(server.sun_path)-1]='\0';
+ if ((msgsock=socket(AF_UNIX,SOCK_STREAM,0)) < 0) {
+ type(NULL,0,NULL, "contentfilter socket(%s) error %d (%s)",
+ contentfilter,errno,strerror(errno));
+ return(0);
+ }
+ if (connect(msgsock,(struct sockaddr *)&server,
+ sizeof(server)-sizeof(server.sun_path)+strlen(server.sun_path)+1) < 0) {
+ type(NULL,0,NULL, "contentfilter connect(%s) error %d (%s)",
+ contentfilter,errno,strerror(errno));
+ return 0;
+ }
+ contentpolicypid = 0;
+ cpol_tofp = fdopen(msgsock, "w");
+ cpol_fromfp = fdopen(msgsock, "r");
+ return 1;
+}
+
+static int init_content_policy()
+{
+ struct stat stbuf;
+
+ if (stat(contentfilter,&stbuf)) {
+ type(NULL,0,NULL, "contentfilter stat(%s) error %d",contentfilter,errno);
+ return 0;
+ }
+ if (S_ISREG(stbuf.st_mode))
+ return init_content_policy_prog();
+ else
+ return init_content_policy_sock();
}
static int
-
To unsubscribe from this list: send the line "unsubscribe zmailer" in
the body of a message to majordomo@nic.funet.fi