Crontab on Win9X works

Pierre A. Humblet Pierre.Humblet@ieee.org
Tue Apr 15 03:27:00 GMT 2003


Corinna,

The attached patch modifies crontab.c to let cron run as it
should on Win9x.

The change in env.c reverts to ignoring the daemon environment, 
on Win9x only.
USE_SIGCHLD is now left undefined in compat.h to get
rid of a syslog message about the mail command failing.
 
In addition I would like to allow the use of mailers other
than ssmtp while preserving current installations.
This is done by patching compat.h to remove
#define _PATH_SENDMAIL  "/usr/sbin/ssmtp"
and patching /etc/postinstall/cron.sh to
ln -s /usr/sbin/ssmtp.exe /usr/sbin/sendmail
Users are free to point /usr/sbin/sendmail as they wish.

Pierre
-------------- next part --------------
--- crontab.c.orig	2001-09-19 13:09:56.000000000 -0400
+++ crontab.c	2003-04-14 20:19:50.000000000 -0400
@@ -694,6 +694,17 @@ poke_daemon() {
 		return;
 	}
 #else
+#ifdef __CYGWIN__
+        if (GetVersion() & 0x80000000) {
+		if (utime(SYSCRONTAB, NULL) < OK &&
+		    (errno != ENOENT ||
+		     open(SYSCRONTAB, O_RDONLY | O_CREAT, 0644) < 0)) {
+			fprintf(stderr, "crontab: can't update mtime on crontab\n");
+			perror(SYSCRONTAB);
+		}
+		return;
+	}
+#endif
 	if (utime(SPOOL_DIR, NULL) < OK) {
 		fprintf(stderr, "crontab: can't update mtime on spooldir\n");
 		perror(SPOOL_DIR);
--- env.c.orig	2002-07-05 05:56:22.000000000 -0400
+++ env.c	2003-04-14 19:50:16.000000000 -0400
@@ -59,14 +59,14 @@ env_init()
 {
 #ifdef __CYGWIN__
 	static char **int_env_copy();
-	return int_env_copy(environ, cyg_exclude);
-#else
+        if ((GetVersion() & 0x80000000) == 0)
+		return int_env_copy(environ, cyg_exclude);
+#endif
 	register char	**p = (char **) malloc(sizeof(char **));

 	if (p)
 		p[0] = NULL;
 	return (p);
-#endif
 }


--- compat.h.orig	2001-06-07 12:11:28.000000000 -0400
+++ compat.h	2003-04-14 22:00:24.000000000 -0400
@@ -113,7 +113,8 @@
 # define HAVE_SAVED_UIDS
 #endif

-#if !defined(ATT) && !defined(__linux) && !defined(IRIX) && !defined(UNICOS)
+#if !defined(ATT) && !defined(__linux) && !defined(IRIX) && \
+        !defined(UNICOS) && !defined(__CYGWIN__)
 # define USE_SIGCHLD
 #endif

@@ -148,7 +149,7 @@
 #endif

 #if defined(__CYGWIN__)
-#define _PATH_SENDMAIL	"/usr/sbin/ssmtp"
+#include <windows.h>
 #define CRONDIR		"/var/cron"
 #define _PATH_VARRUN	"/var/run/"
 #endif
--- cron.sh.done	2003-04-11 15:43:12.000000000 -0400
+++ cron.sh	2003-04-14 20:32:04.000000000 -0400
@@ -13,3 +13,12 @@ then
   mkdir /var/cron/tabs
 fi
 chmod 1777 /var/cron/tabs
+
+if [ ! -d /usr/sbin ]
+then
+  mkdir -p /usr/sbin
+fi
+if [ ! -e /usr/sbin/sendmail -a ! -L /usr/sbin/sendmail ]
+then
+  ln -s /usr/sbin/ssmtp.exe /usr/sbin/sendmail
+fi

-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list