Index: makeconfig
--- makeconfig.orig	2005-06-10 09:21:48 +0200
+++ makeconfig	2006-10-30 11:31:20 +0100
@@ -74,8 +74,8 @@
 LINK=${LINK:-$CC}
 
 cd develop
-rm -f config.cache
 ./configure \
+    --cache-file=./config.cache \
     --libexecdir=$SERVERDIR \
     --bindir=$BINDIR \
     --mandir=$MANDIR \
@@ -99,7 +99,7 @@
   *next*)	SYSTEM=NEXT;;
   *convex*)	SYSTEM=CONVEXOS;;
   *osf*)	SYSTEM=OSF1;;
-  *bsd*)	SYSTEM=BSD;;
+  *bsd*)	SYSTEM=XBSD;;
   *darwin*)	SYSTEM=DARWIN;;
   *)		SYSTEM=UNKNOWN;;
 #  *)		SYSTEM=`uname -a | tr '[a-z]' '[A-Z]'`
@@ -198,11 +198,11 @@
   #define __EXTENSIONS__
 #endif
 
-#if defined(LINUX) || defined(BSD)
+#if defined(LINUX) || defined(XBSD)
   #ifndef HAVE_STRERROR
     #define HAVE_STRERROR
   #endif
-  #ifndef _POSIX_SOURCE
+  #if !defined(_POSIX_SOURCE) && !defined(__FreeBSD__)
     #define _POSIX_SOURCE
   #endif
   #ifndef __USE_BSD
Index: src/io.h
--- src/io.h.orig	2005-06-06 23:14:16 +0200
+++ src/io.h	2006-10-30 11:29:20 +0100
@@ -34,6 +34,8 @@
   #define O_LARGEFILE 0
 #endif
 
+#include <sys/types.h>
+
 /* read n bytes from network socket */
 int readn(int, char *, int);
 
Index: src/sendfiled.c
--- src/sendfiled.c.orig	2005-06-10 09:24:13 +0200
+++ src/sendfiled.c	2006-10-30 11:29:20 +0100
@@ -199,6 +199,10 @@
 #include "address.h"	/* address routines */
 #include "lock.h"       /* file locking */
 
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
 #if defined(HAVE_GETOPT_H)
   #include <getopt.h>
 #else
@@ -233,7 +237,7 @@
 #elif defined(HAVE_SYS_STATVFS_H)
   #include <sys/statvfs.h>
   #define statfs statvfs
-#elif defined(BSD) || defined(ULTRIX)
+#elif defined(XBSD) || defined(ULTRIX)
   #include <sys/param.h>
   #include <sys/mount.h>
 #else
@@ -265,13 +269,13 @@
   int statfs(char *, struct statfs *);
 #endif
 
-#ifdef BSD
+#ifdef XBSD
   #ifndef O_SYNC
     #define O_SYNC O_FSYNC
   #endif
 #endif
 
-#if defined(HPUX) || defined(BSD)
+#if defined(HPUX) || defined(XBSD)
   #define seteuid(a) setuid(a)
   #define setegid(a) setgid(a)
 #endif
@@ -2581,7 +2585,7 @@
     /* scan through utmp (currently logged in users) */
     while (read(utmpfd,(char *)&uinfo,sizeof(uinfo))>0) {
       
-#if defined(NEXT) || defined(BSD) || defined(ULTRIX) || defined(SOLARIS1)
+#if defined(NEXT) || defined(XBSD) || defined(ULTRIX) || defined(SOLARIS1)
       strncpy(user,uinfo.ut_name,8);
       if (str_eq(recipient,user)) {
 	
@@ -4168,11 +4172,13 @@
  * RETURN: nothing, but terminates program on error
  */
 void setreugid() {
+  if (rgid != getegid())
   if (rgid && setegid(rgid)<0) {
     printf("490 Internal error on setegid(%u): %s\r\n",
 	   (unsigned int)rgid,strerror(errno));
     exit(1);
   }
+  if (ruid != geteuid())
   if (ruid && seteuid(ruid)<0) {
     printf("490 Internal error on seteuid(%u): %s\r\n",
 	   (unsigned int)ruid,strerror(errno));
Index: src/spool.c
--- src/spool.c.orig	2005-06-06 23:14:16 +0200
+++ src/spool.c	2006-10-30 11:29:20 +0100
@@ -64,6 +64,10 @@
 #include "string.h"     /* extended string functions */
 #include "reply.h"	/* the 3 digit reply codes with text messages */
 
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
 
 /*
  * scanspool - scan through spool directory, build list-structures and
Index: src/string.c
--- src/string.c.orig	2005-06-06 23:14:16 +0200
+++ src/string.c	2006-10-30 11:29:20 +0100
@@ -358,7 +358,7 @@
  * RETURN: string  - string of the error number
  */
 char *strerror(int errornumber) {
-#if __GLIBC__ < 2 && !defined(BSD)
+#if __GLIBC__ < 2 && !defined(XBSD)
   extern int sys_nerr;
   extern char *sys_errlist[];
 #endif
