Index: aliases.c =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/aliases.c,v retrieving revision 1.22 diff -N -u aliases.c --- aliases.c 12 Oct 2009 23:57:44 -0000 1.22 +++ aliases.c 14 Oct 2009 16:04:33 -0000 @@ -30,7 +30,11 @@ #include #include #include -#include +#if defined(__FreeBSD__) +# include +#else +# include +#endif #include "smtpd.h" Index: authenticate.c =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/authenticate.c,v retrieving revision 1.1 diff -N -u authenticate.c --- authenticate.c 7 Aug 2009 19:02:55 -0000 1.1 +++ authenticate.c 14 Oct 2009 16:04:33 -0000 @@ -22,7 +22,12 @@ #include #include -#include +#if defined(USE_OPENPAM) +# include +# include +#else +# include +#endif #include #include #include @@ -37,5 +42,26 @@ int authenticate_user(char *username, char *password) { +#if defined(USE_OPENPAM) + static struct pam_conv conv = { &openpam_nullconv, NULL }; + pam_handle_t *pamh = NULL; + + if (pam_start("auth-smtp", username, &conv, &pamh) != PAM_SUCCESS) { + return 0; + } + + if (pam_set_item(pamh, PAM_AUTHTOK, password) != PAM_SUCCESS) { + return 0; + } + + if (pam_authenticate(pamh, 0) != PAM_SUCCESS) { + return 0; + } + + pam_end(pamh, PAM_SUCCESS); + + return 1; +#else return auth_userokay(username, NULL, "auth-smtp", password); +#endif } Index: dns.c =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/dns.c,v retrieving revision 1.16 diff -N -u dns.c --- dns.c 3 Sep 2009 08:19:13 -0000 1.16 +++ dns.c 14 Oct 2009 16:04:33 -0000 @@ -344,7 +344,11 @@ free_mxlist(mx0); if (success == 0) +#if defined(__FreeBSD__) + query->error = EAI_NONAME; +#else query->error = EAI_NODATA; +#endif end: log_debug("lookup_mx %s", query->error ? "failed" : "success"); @@ -504,7 +508,11 @@ hints.ai_flags = AI_NUMERICHOST; if (getaddrinfo(query->host, NULL, &hints, &res) == 0) { +#if defined(__FreeBSD__) + query->error = EAI_NONAME; +#else query->error = EAI_NODATA; +#endif freeaddrinfo(res); } end: Index: makemap.c =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/makemap.c,v retrieving revision 1.21 diff -N -u makemap.c --- makemap.c 12 Oct 2009 18:19:46 -0000 1.21 +++ makemap.c 14 Oct 2009 16:04:33 -0000 @@ -34,7 +34,11 @@ #include #include #include -#include +#if defined(__FreeBSD__) +# include +#else +# include +#endif #include "smtpd.h" Index: parse.y =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v retrieving revision 1.40 diff -N -u parse.y --- parse.y 11 Oct 2009 17:40:49 -0000 1.40 +++ parse.y 14 Oct 2009 16:04:34 -0000 @@ -1526,7 +1526,11 @@ hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; /* DUMMY */ error = getaddrinfo(s, NULL, &hints, &res0); +#if defined(__FreeBSD__) + if (error == EAI_AGAIN || error == EAI_NONAME) +#else if (error == EAI_AGAIN || error == EAI_NODATA || error == EAI_NONAME) +#endif return (0); if (error) { log_warnx("host_dns: could not parse \"%s\": %s", s, Index: smtp.c =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/smtp.c,v retrieving revision 1.62 diff -N -u smtp.c --- smtp.c 18 Sep 2009 00:04:26 -0000 1.62 +++ smtp.c 14 Oct 2009 16:04:34 -0000 @@ -24,6 +24,10 @@ #include #include +#if defined(__FreeBSD__) +# include +#endif + #include #include #include Index: smtpd.c =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/smtpd.c,v retrieving revision 1.86 diff -N -u smtpd.c --- smtpd.c 7 Oct 2009 18:19:39 -0000 1.86 +++ smtpd.c 14 Oct 2009 16:04:34 -0000 @@ -1365,8 +1365,12 @@ if (chdir(pw->pw_dir) == -1 && chdir("/") == -1) fatal("chdir"); +#if defined(__FreeBSD__) + closefrom(STDERR_FILENO + 1); +#else if (closefrom(STDERR_FILENO + 1) == -1) fatal("closefrom"); +#endif /* avoid hangs by setting a 5m timeout */ alarm(300); @@ -1448,10 +1452,17 @@ bzero(&args, sizeof(args)); +#if defined(__FreeBSD__) + closefrom(STDERR_FILENO + 1); if (setgroups(1, &pw->pw_gid) || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || + setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) { +#else + if (setgroups(1, &pw->pw_gid) || + setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) || closefrom(STDERR_FILENO + 1) == -1) { +#endif unlink(path); _exit(1); } Index: makemap/Makefile =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/makemap/Makefile,v retrieving revision 1.7 diff -N -u makemap/Makefile --- makemap/Makefile 23 Mar 2009 15:14:54 -0000 1.7 +++ makemap/Makefile 14 Oct 2009 16:04:34 -0000 @@ -14,9 +14,15 @@ CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes CFLAGS+= -Wmissing-declarations CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual -CFLAGS+= -Wsign-compare -Wbounded +CFLAGS+= -Wsign-compare SRCS= parse.y makemap.c aliases.c map.c log.c util.c DPADD+= ${LIBUTIL} LDADD+= -lutil + +# FreeBSD-specific. +CFLAGS+= -I/usr/local/include -D__dead= +LDFLAGS+= -L/usr/local/lib +LDADD+= -levent + .include Index: smtpctl/Makefile =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/smtpctl/Makefile,v retrieving revision 1.10 diff -N -u smtpctl/Makefile --- smtpctl/Makefile 15 Sep 2009 16:50:07 -0000 1.10 +++ smtpctl/Makefile 14 Oct 2009 16:04:34 -0000 @@ -14,11 +14,15 @@ CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes CFLAGS+= -Wmissing-declarations CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual -CFLAGS+= -Wsign-compare -Wbounded +CFLAGS+= -Wsign-compare CFLAGS+= -DCLIENT_NO_SSL SRCS= smtpctl.c parser.c buffer.c imsg.c log.c enqueue.c \ queue_shared.c util.c client.c LDADD+= -lutil DPADD+= ${LIBUTIL} + +# FreeBSD-specific. +CFLAGS+= -I/usr/local/include -D__dead= + .include Index: smtpd/Makefile =================================================================== RCS file: /cvs/src/usr.sbin/smtpd/smtpd/Makefile,v retrieving revision 1.13 diff -N -u smtpd/Makefile --- smtpd/Makefile 4 Sep 2009 11:49:23 -0000 1.13 +++ smtpd/Makefile 14 Oct 2009 16:04:34 -0000 @@ -16,9 +16,14 @@ CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes CFLAGS+= -Wmissing-declarations CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual -CFLAGS+= -Wsign-compare -Wbounded +CFLAGS+= -Wsign-compare #CFLAGS+= -Werror # during development phase (breaks some archs) YFLAGS= + +# FreeBSD-specific. +CFLAGS+= -I/usr/local/include -DUSE_OPENPAM=1 -D__dead= +LDFLAGS+= -L/usr/local/lib +LDADD+= -lpam -levent .PATH: ${.CURDIR}/..