From: Christian Kastner <ckk@kvr.at>
Date: Sun, 20 Dec 2015 12:04:41 +0100
Subject: Legacy porting issues

Various fixes, additions or updates regarding portability. These are quite
numerous because the upstream code is from 1993, and does not even assume POSIX
compatibility, which is why we declare it.

Based on the changes originally made by Steve Greenland <stevegr@debian.org>.

Forwarded: no
Last-Update: 2015-12-20
Index: cron/externs.h
===================================================================
--- cron.orig/externs.h
+++ cron/externs.h
@@ -20,6 +20,7 @@
 # include <unistd.h>
 # include <string.h>
 # include <dirent.h>
+# include <errno.h>
 # define DIR_T	struct dirent
 # define WAIT_T	int
 # define WAIT_IS_INT 1
Index: cron/cron.c
===================================================================
--- cron.orig/cron.c
+++ cron/cron.c
@@ -24,7 +24,7 @@ static char rcsid[] = "$Id: cron.c,v 2.1
 
 
 #include "cron.h"
-#include <sys/signal.h>
+#include <signal.h>
 #if SYS_TIME_H
 # include <sys/time.h>
 #else
Index: cron/popen.c
===================================================================
--- cron.orig/popen.c
+++ cron/popen.c
@@ -29,7 +29,7 @@ static char sccsid[] = "@(#)popen.c	5.7
 #endif /* not lint */
 
 #include "cron.h"
-#include <sys/signal.h>
+#include <signal.h>
 
 
 #define WANT_GLOBBING 0
Index: cron/do_command.c
===================================================================
--- cron.orig/do_command.c
+++ cron/do_command.c
@@ -21,7 +21,8 @@ static char rcsid[] = "$Id: do_command.c
 
 
 #include "cron.h"
-#include <sys/signal.h>
+#include <signal.h>
+#include <grp.h>
 #if defined(sequent)
 # include <sys/universe.h>
 #endif
@@ -207,7 +208,7 @@ child_process(e, u)
 		 * we set uid, we've lost root privledges.
 		 */
 		setgid(e->gid);
-# if defined(BSD)
+# if defined(BSD) || defined(POSIX)
 		initgroups(env_get("LOGNAME", e->envp), e->gid);
 # endif
 		setuid(e->uid);		/* we aren't root after this... */
Index: cron/compat.h
===================================================================
--- cron.orig/compat.h
+++ cron/compat.h
@@ -62,7 +62,7 @@
 #endif
 
 #ifndef POSIX
-# if (BSD >= 199103) || defined(__linux) || defined(ultrix) || defined(AIX) ||\
+# if (BSD >= 199103) || defined(__linux__) || defined(ultrix) || defined(AIX) ||\
 	defined(HPUX) || defined(CONVEX) || defined(IRIX)
 #  define POSIX
 # endif
@@ -76,17 +76,17 @@
 
 /*****************************************************************/
 
-#if !defined(BSD) && !defined(HPUX) && !defined(CONVEX) && !defined(__linux)
+#if !defined(BSD) && !defined(HPUX) && !defined(CONVEX) && !defined(__linux__) && !defined(__GLIBC__)
 # define NEED_VFORK
 #endif
 
-#if (!defined(BSD) || (BSD < 198902)) && !defined(__linux) && \
-	!defined(IRIX) && !defined(NeXT) && !defined(HPUX)
+#if (!defined(BSD) || (BSD < 198902)) && !defined(__linux__) && \
+	!defined(IRIX) && !defined(NeXT) && !defined(HPUX) && !defined(__GLIBC__)
 # define NEED_STRCASECMP
 #endif
 
-#if (!defined(BSD) || (BSD < 198911)) && !defined(__linux) &&\
-	!defined(IRIX) && !defined(UNICOS) && !defined(HPUX)
+#if (!defined(BSD) || (BSD < 198911)) && !defined(__linux__) &&\
+	!defined(IRIX) && !defined(UNICOS) && !defined(HPUX) && !defined(__GLIBC__)
 # define NEED_STRDUP
 #endif
 
@@ -102,19 +102,19 @@
 # define NEED_SETSID
 #endif
 
-#if (defined(POSIX) && !defined(BSD)) && !defined(__linux)
+#if (defined(POSIX) && !defined(BSD)) && !defined(__linux__) && !defined(__GLIBC__)
 # define NEED_GETDTABLESIZE
 #endif
 
-#if (BSD >= 199103)
+#if (BSD >= 199103) || defined(__linux)
 # define HAVE_SAVED_UIDS
 #endif
 
-#if !defined(ATT) && !defined(__linux) && !defined(IRIX) && !defined(UNICOS)
+#if (!defined(ATT) && !defined(IRIX) && !defined(UNICOS)) || defined(POSIX)
 # define USE_SIGCHLD
 #endif
 
-#if !defined(AIX) && !defined(UNICOS)
+#if !defined(AIX) && !defined(UNICOS) && !defined(POSIX)
 # define SYS_TIME_H 1
 #else
 # define SYS_TIME_H 0
Index: cron/pathnames.h
===================================================================
--- cron.orig/pathnames.h
+++ cron/pathnames.h
@@ -19,7 +19,7 @@
  * $Id: pathnames.h,v 1.3 1994/01/15 20:43:43 vixie Exp $
  */
 
-#if (defined(BSD)) && (BSD >= 199103) || defined(__linux) || defined(AIX)
+#if (defined(BSD)) && (BSD >= 199103) || defined(__linux__) || defined(AIX) || defined(__GLIBC__)
 # include <paths.h>
 #endif /*BSD*/
 
Index: cron/Makefile
===================================================================
--- cron.orig/Makefile
+++ cron/Makefile
@@ -65,7 +65,7 @@ OPTIM		=	-g
 #(BSD is only needed if <sys/params.h> does not define it, as on ULTRIX)
 #COMPAT		=	-DBSD
 # (POSIX)
-#COMPAT		=	-DPOSIX
+COMPAT		=	-DPOSIX
 #<<lint flags of choice?>>
 LINTFLAGS	=	-hbxa $(INCLUDE) $(COMPAT) $(DEBUGGING)
 #<<want to use a nonstandard CC?>>
