--- ../pop3proxy-1.3.0-beta4.org/clamav.c	2005-03-30 05:05:59.000000000 +0900
+++ ./clamav.c	2005-12-15 22:50:04.000000000 +0900
@@ -27,7 +27,9 @@
 
 #include <errno.h>
 #include <syslog.h>
+#if !defined(__APPLE__)
 #include <wait.h>
+#endif
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -193,6 +195,7 @@
 	char	*p;
 
 	memset(&x->clamav.bio, 0, sizeof(x->clamav.bio));
+	if ((x->clamav.bio.fd = openup(x->clamav.socket)) >= 0) ; else
 	if ((x->clamav.bio.fd = openip(x->clamav.adress, x->clamav.port, NULL, 0)) < 0)
 		printerror(1, "-PROXY", "can't get clamav version: error= %s", strerror(errno));
 
@@ -259,6 +262,7 @@
 	 */
 
 	memset(&x->clamav.bio, 0, sizeof(x->clamav.bio));
+	if ((x->clamav.bio.fd = openup(x->clamav.socket)) >= 0) ; else
 	if ((x->clamav.bio.fd = openip(x->clamav.adress, x->clamav.port, NULL, 0)) < 0)
 		printerror(1, "-PROXY", "can't connect to clamav daemon: error= %s", strerror(errno));
 
@@ -319,8 +323,8 @@
 		if ((fp = fopen(x->spoolfile, "w")) == NULL)
 			printerror(1, "-PROXY", "can't rewrite email: filename= %s", x->spoolfile);
 
-		fprintf (fp, "From: Virus-Scanner\r\n");
-		fprintf (fp, "Subject: pop3proxy - virus found: %s\r\n", virusname);
+		fprintf (fp, "From: pop3proxy+clamd\r\n");
+		fprintf (fp, "Subject: virus(%s) found\r\n", virusname);
 		fprintf (fp, "\r\n");
 
 		fprintf (fp, "E-Mail headers follow:\r\n");
@@ -329,7 +333,7 @@
 		p = x->clamav.header.string;
 		while (*p != 0) {
 			get_quoted(&p, '\n', line, sizeof(line));
-			fprintf (fp, ">  %s\n", line);
+			fprintf (fp, "| %s\n", line);
 			}
 
 		fprintf (fp, "\r\n");
--- ../pop3proxy-1.3.0-beta4.org/ip-lib.c	2004-11-16 07:58:35.000000000 +0900
+++ ./ip-lib.c	2005-12-15 23:16:01.000000000 +0900
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/un.h>
 #include <sys/wait.h>
 #include <netinet/in.h>
 #include <netdb.h>
@@ -291,3 +292,21 @@
 	return (0);
 }
 
+int openup(char *localsocket)
+{
+	int	socketd;
+	struct sockaddr_un server;
+
+	if (localsocket == NULL || *localsocket == 0)
+		return (-1);
+
+	if ((socketd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+		return (-1);
+  
+	server.sun_family = AF_UNIX;
+	strncpy(server.sun_path, localsocket, sizeof(server.sun_path));
+	if (connect(socketd, (struct sockaddr *) &server, sizeof(server)) < 0)
+		return (-1);
+
+	return (socketd);
+}	
--- ../pop3proxy-1.3.0-beta4.org/ip-lib.h	2004-11-16 05:57:59.000000000 +0900
+++ ./ip-lib.h	2005-12-15 22:40:41.000000000 +0900
@@ -32,5 +32,6 @@
 int bind_to_port(char *interface, unsigned int port);
 int acceptloop(int sock);
 int getpeerinfo(int pfd, char *ipnum, int ipsize, char *name, int namesize, int interface);
+int openup(char *localsocket);
 
 #endif
--- ../pop3proxy-1.3.0-beta4.org/makefile	2005-03-29 21:55:48.000000000 +0900
+++ ./makefile	2005-12-15 20:13:08.000000000 +0900
@@ -1,4 +1,4 @@
-
+PREFIX =	/usr/local
 CC =		gcc
 CFLAGS =	-ggdb -Wall -D'VERSION="$(VERSION)"'
 
@@ -17,19 +17,19 @@
 
 install:	all
 	strip $(TARGETS)
-	cp $(TARGETS) /usr/local/sbin
-	cp *.1 /usr/local/man/man1
+	cp $(TARGETS) $(PREFIX)/sbin
+	cp *.1 $(PREFIX)/man/man1
 
 
 pop3.proxy:	$(POP3PROXY)
-	$(CC) -o $@ $+
+	$(CC) -o $@ $+ $(LDLIBS)
 
 
 
 tar:		clean
 	cd ..; tar cvf $(TAR).tar $(DIR); gzip $(TAR).tar
 	mv ../$(TAR).tar.gz .
-	
+
 clean:
 	-rm -f *.o cut out $(TARGETS) $(TAR).tar.gz
 
--- ../pop3proxy-1.3.0-beta4.org/pop3.c	2005-03-30 00:26:34.000000000 +0900
+++ ./pop3.c	2005-12-15 22:38:46.000000000 +0900
@@ -37,7 +37,9 @@
 #include <netinet/in.h>
 #include <syslog.h>
 #include <time.h>
+#if !defined(__APPLE__)
 #include <wait.h>
+#endif
 
 #include "pop3.h"
 #include "ip-lib.h"
@@ -219,6 +221,38 @@
 
 int set_variables(pop3_t *x)
 {
+#if defined(sun)
+	char	*vp, env[400];
+
+	vp = x->config->varname;
+
+	snprintf (env, sizeof(env) - 2, "%sINTERFACE=%s", vp, x->interface);
+	putenv(strdup(env));
+	
+	snprintf (env, sizeof(env) - 2, "%sPORT=%u", vp, x->port);
+	putenv(strdup(env));
+
+	snprintf (env, sizeof(env) - 2, "%sCLIENT=%s", vp, x->client.ipnum);
+	putenv(strdup(env));
+
+	snprintf (env, sizeof(env) - 2, "%sCLIENTNAME=%s", vp, x->client.name);
+	putenv(strdup(env));
+
+	snprintf (env, sizeof(env) - 2, "%sSERVER=%s", vp, x->server.hostname);
+	putenv(strdup(env));
+	
+	snprintf (env, sizeof(env) - 2, "%sSERVERPORT=%u", vp, x->server.port);
+	putenv(strdup(env));
+
+	snprintf (env, sizeof(env) - 2, "%sSERVERLOGIN=%s", vp, x->client.username);
+	putenv(strdup(env));
+	
+	snprintf (env, sizeof(env) - 2, "%sUSERNAME=%s", vp, x->local.username);
+	putenv(strdup(env));
+	
+	snprintf (env, sizeof(env) - 2, "%sPASSWD=%s", vp, x->local.password);
+	putenv(strdup(env));
+#else
 	char	*vp, var[200], val[200];
 
 	vp = x->config->varname;
@@ -251,6 +285,7 @@
 	
 	snprintf (var, sizeof(var) - 2, "%sPASSWD", vp);
 	setenv(var, x->local.password, 1);
+#endif
 	
 	return (0);
 }
@@ -497,6 +532,19 @@
 		}
 
 	cfputs(x, "+OK maildrop ready", 1);
+#if defined(USE_DRAC)
+	{
+		int	dracauth(char *server, unsigned long userip, char **errmsg);
+		char	*e = NULL;
+		int	r;
+
+		if ((r=dracauth("localhost", inet_addr(x->client.ipnum), &e)) != 0) {
+			;
+		}
+		if (verbose)
+			syslog(LOG_NOTICE, "drac %s code=%d client=%s", e, r, x->client.ipnum);
+	}
+#endif
 	if (verbose)
 		syslog(LOG_NOTICE, "login user=%s host=%s", x->client.username, x->client.name);
 
@@ -539,6 +587,7 @@
 	x = allocate(sizeof(pop3_t));
 	x->config = config;
 
+	strcpy(x->clamav.socket, "/tmp/clamd");
 	strcpy(x->clamav.adress, "127.0.0.1");
 	x->clamav.port = 3310;
 	if (x->config->scanmail != 0)
--- ../pop3proxy-1.3.0-beta4.org/pop3.h	2004-11-23 05:40:02.000000000 +0900
+++ ./pop3.h	2005-12-15 22:27:50.000000000 +0900
@@ -108,6 +108,7 @@
     channel_t	server;
 
     struct {
+	char	socket[100];
 	char	adress[80];
 	unsigned int port;
 	char	version[200];
