			  Rdist for Darwin 6.x/7.x

			       Eric Myers
			     Vassar College
		 Department of Physics and Astronomy
		    Poughkeepsie, New York 12604 USA
			    <myers@vassar.edu>


			     6 January 2004

  This file contains the diffs required to get the handy Unix tool rdist
to build on Darwin, aka Mac OS X, including both 10.2 (Darwin 6.x, aka
"Jaguar") and 10.3 (Darwin 7.x, aka "Panther").  The diffs are against
the source code in the file rdist-6.1.5.tar as distributed from
http://www.MagniComp.com/rdist/ , which you will have to obtain separately.

  For security reasons ssh is prefered over rsh for transport, so the
default transport path is set to /usr/bin/ssh on Darwin, not rsh.

  Be warned that the code for detecting an NFS mount (i.e. -ochknfs)
probably won't work (it has not been tested).  If someone fixes this in
the future it would be nice to also be able to detect an AFS mount.

    To apply the patches, begin with the source tar file from MagniComp
and this patch file in the same directory.  Unpack the tar file, cd into
the directory it creates , and then run `patch -p1` from that directory,
like so:

      %  tar xf rdist-6.1.5.tar
      %  cd rdist-6.1.5
      %  patch -p1 <../rdist-6.1.5-darwin.patch

Then build rdist as usual (see the README file for details):

      % make
      % make install
      % make install.man

The rdist and rdistd executables are installed in /usr/local/bin, while
the man pages are installed in /usr/local/share/man/man{1,8}.
You can change these destinations by editing config/mf.darwin .



----------PATCHES-BEGIN-HERE---------------------------------------------

diff -Naurb rdist-6.1.5/ChangeLog rdist-6.1.5-darwin/ChangeLog
--- rdist-6.1.5/ChangeLog	Mon Nov  9 23:26:38 1998
+++ rdist-6.1.5-darwin/ChangeLog	Tue Jan  6 11:44:21 2004
@@ -1,3 +1,13 @@
+2004-01-06 Eric Myers <myers@vassar.edu>
+	
+	* Ported more generally to Darwin 6.x and 7.x, which includes
+	  changing to VAR_STDARG
+	
+2003-07-31  Eric Myers <myers@vassar.edu>
+
+	* Ported to Darwin 6.6  (Mac OS X 10.2.6)
+
+	
 1998-11-09  Michael A. Cooper  <mcooper@magnicomp.com>
 
 	* Version 6.1.5-RELEASE
diff -Naurb rdist-6.1.5/README rdist-6.1.5-darwin/README
--- rdist-6.1.5/README	Fri Jul 19 13:24:09 1996
+++ rdist-6.1.5-darwin/README	Tue Jan  6 10:39:57 2004
@@ -19,9 +19,9 @@
 indirectly provide full backward compatibility.  See COMPATIBILITY
 below for details.
 
-The current official version of rdist is available via anonymous ftp
-on usc.edu under /pub/rdist.  The current version is always
-retrievable as file "/pub/rdist/rdist.tar.gz".
+The official home of RDist has moved to http://www.MagniComp.com as
+of 12-April-98.
+
 
 			   CHANGES/FEATURES
 
@@ -80,7 +80,7 @@
 			     INSTALLATION
 
 1) Determine whether the local machine is running a supported OS by
-   running the command "config/os-type".  If the command reports the
+   running the command "build/os-type".  If the command reports the
    local OS is "unknown", then you cannot proceed until rdist is
    ported to the local system OS.  (See the PORTING section).
 
@@ -158,6 +158,7 @@
 6) Send me your "os-YOUR_OS.h" and "mf.YOUR_OS" files, along with context
    diffs to any other files you changed.
 
+
 				NOTES
 
 rcmd() vs. rsh(1c)
@@ -179,29 +180,31 @@
 	All of this information on HP/UX is third-hand.  I don't have 
 	access to any HP/UX machines to test rdist on.
 
-Unlike HPUX version 7, version 8 does not come standard with yacc
-which is now part of the C/ANSI C Development Bundle.  If that bundle
-is on the system, then rdist compiles fine with the changes to the
-Makefile to include regex.o and strcasecmp.o.  If you don't have yacc
-and instead use the GNU bison in the yacc mode (-y option) it compiles
-fine but needs to have the PW library included (-lPW) in order to find
-an alloca.o when linking.
-
-The regex that is part of the HPUX C library is not compatible with
-the BSD style regex that rdist uses.  Someone who leaves regex.o out
-of the MISSINGOBJS line in the Makefile because they noticed a
-regex(3) in the HPUX manual set is going to have a problem.
+	Unlike HPUX version 7, version 8 does not come standard with
+	yacc which is now part of the C/ANSI C Development Bundle.  If
+	that bundle is on the system, then rdist compiles fine with the
+	changes to the Makefile to include regex.o and strcasecmp.o.  If
+	you don't have yacc and instead use the GNU bison in the yacc
+	mode (-y option) it compiles fine but needs to have the PW
+	library included (-lPW) in order to find an alloca.o when
+	linking.
+
+	The regex that is part of the HPUX C library is not compatible
+	with the BSD style regex that rdist uses.  Someone who leaves
+	regex.o out of the MISSINGOBJS line in the Makefile because they
+	noticed a regex(3) in the HPUX manual set is going to have a
+	problem.
 
 OLD rcmd() LIBRARY BUG
 
-Very Old 4.2BSD-based Unix systems may have a bug in their rcmd()
-library function.  The bug allowed a user process to run out of file
-descriptors if too many connection attempts failed.  The problem is
-that the socket would never be closed if the connect() failed.  This
-could eventually lead to running out of file descriptors if enough
-connections failed.  Most current Unix's like SunOS 4.0.3 and later
-have this fixed.  Here is a diff to (I think) the SunOS 3.5 rcmd() to
-fix the problem:
+	Very Old 4.2BSD-based Unix systems may have a bug in their rcmd()
+	library function.  The bug allowed a user process to run out of file
+	descriptors if too many connection attempts failed.  The problem is
+	that the socket would never be closed if the connect() failed.  This
+	could eventually lead to running out of file descriptors if enough
+	connections failed.  Most current Unix's like SunOS 4.0.3 and later
+	have this fixed.  Here is a diff to (I think) the SunOS 3.5 rcmd() to
+	fix the problem:
 
 ***************
 *** 51,56 ****
@@ -213,6 +216,7 @@
   		perror(hp->h_name);
   		return (-1);
   	}
+
 
 			       RCS INFO
 
diff -Naurb rdist-6.1.5/README.darwin rdist-6.1.5-darwin/README.darwin
--- rdist-6.1.5/README.darwin	Wed Dec 31 19:00:00 1969
+++ rdist-6.1.5-darwin/README.darwin	Tue Jan  6 12:55:36 2004
@@ -0,0 +1,27 @@
+			  Rdist for Darwin 6.x/7.x
+
+			       Eric Myers
+			     Vassar College
+		 Department of Physics and Astronomy
+		    Poughkeepsie, New York 12604 USA
+			    myers@vassar.edu
+
+			     6 January 2004
+
+
+  This distribution of rdist has been patched to compile on Darwin 6.x 
+and 7.x (Mac OS X "Jaguar" and "Panther").
+
+  For improved security and flexibility the default transport mechanism
+has been changed to ssh rather than rsh or remsh.
+
+  Just build rdist as usual (see the README file for details):
+
+      % make
+      % make install
+      % make install.man
+
+  The rdist and rdistd executables are installed in /usr/local/bin, while
+the man pages are installed in /usr/local/share/man/man{1,8}.
+You can change these by editing config/mf.darwin
+
diff -Naurb rdist-6.1.5/build/os-type rdist-6.1.5-darwin/build/os-type
--- rdist-6.1.5/build/os-type	Mon Nov  9 22:37:27 1998
+++ rdist-6.1.5-darwin/build/os-type	Tue Jan  6 11:06:50 2004
@@ -116,6 +116,7 @@
 		"openbsd"*)	OS="freebsd2";;
 		"dgux"*)	OS=dgux;;
 		"unicos"*)	OS=unicos;;
+		"darwin"*)	OS=darwin;;
 		*)		OS="${osname}${osver}";;
 	esac
 fi
diff -Naurb rdist-6.1.5/config/mf.darwin rdist-6.1.5-darwin/config/mf.darwin
--- rdist-6.1.5/config/mf.darwin	Wed Dec 31 19:00:00 1969
+++ rdist-6.1.5-darwin/config/mf.darwin	Tue Jan  6 12:08:24 2004
@@ -0,0 +1,47 @@
+#
+# Copyright (c) 1992-1998 Michael A. Cooper.  
+# This software may be freely used and distributed provided it is not
+# sold for profit or used in part or in whole for commercial gain
+# without prior written agreement, and the author is credited
+# appropriately.
+#
+# $Id: mf.darwin,v 0.3 2003/29/07 19:44:25 myers Exp $
+#
+
+#
+# DARWIN 6.x/7.x Makefile
+#
+
+# Where to install.  Could be either /usr or /usr/local
+
+PREFIX=/usr/local
+
+#
+# Installation parameters for Darwin:
+#
+INSTALL         = /usr/bin/install
+BIN_DIR         = $(PREFIX)/bin
+MAN_1_DIR       = $(PREFIX)/share/man/man1
+MAN_8_DIR       = $(PREFIX)/share/man/man8
+MAN_OWNER       = root
+MAN_GROUP       = wheel
+MAN_MODE        = 644
+
+
+#
+# Functions that are missing in this OS are contained in the
+# files specified in ${MISSINGOBJS}.
+#
+MISSINGOBJS 	= $(O)regex.o
+
+#
+# System libraries that we need to load.
+#
+##LIB_SYS	= -lcompat
+
+#
+# System dependent options for compiling
+#
+##CFLAGS_OS	= -DBSDI2 
+
+##
diff -Naurb rdist-6.1.5/config/os-darwin.h rdist-6.1.5-darwin/config/os-darwin.h
--- rdist-6.1.5/config/os-darwin.h	Wed Dec 31 19:00:00 1969
+++ rdist-6.1.5-darwin/config/os-darwin.h	Tue Jan  6 11:18:49 2004
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 1992-1998 Michael A. Cooper.
+ * This software may be freely used and distributed provided it is not
+ * sold for profit or used in part or in whole for commercial gain
+ * without prior written agreement, and the author is credited
+ * appropriately.
+ */
+
+/*
+ * $Id: os-darwin.h,v 0.3 2003/29/07 19:59:50 myers Exp $
+ */
+
+/*
+ * Darwin  os-*.h file
+ */
+
+/*
+ * Define the following name for use in #ifdef's.
+ * The value should be all upper-case with no periods (.).
+ */
+#if	!defined(DARWIN)
+#define DARWIN 
+#endif
+
+/*
+ * Kludge to compile, but this doesn't really do anything.
+ * NFS detection ( -ochknfs ) is likely broken on Darwin, which
+ * doesn't seem to use filesystem type numbers.  Someone will need
+ * to re-code the test in filesys-os.c to fix this.
+ */
+#define MOUNT_NFS  -1
+
+
+/*
+ * Set process args to messages that show up when running ps(1)
+ *
+ * Under some OS's, the SETARGS code will cause ": is not an identifier"
+ * errors for "special" commands.
+ */
+#define SETARGS
+
+/*
+ * Define the type of directory routines your system has.
+ */
+#define DIR_TYPE	DIR_DIRENT
+
+/*
+ * Determine what routines we have to get filesystem info.
+ */
+#define FSI_TYPE	FSI_GETFSSTAT
+
+/*
+ * Type of non-blocking I/O.
+ */
+#define NBIO_TYPE	NBIO_FCNTL
+
+/*
+ * Type of wait() function to use.
+ */
+#define WAIT_TYPE	WAIT_WAIT3
+
+/*
+ * Type of argument passed to wait() (above).
+ */
+#define WAIT_ARG_TYPE	int
+
+/*
+ * Select the type of executable file format.
+ */
+#define EXE_TYPE	EXE_MACHO
+
+/*
+ * Select the type of statfs() system call (if any).
+ */
+#define STATFS_TYPE	STATFS_BSD
+
+
+/*
+ * Type of arg functions we have.
+ *    In Darwin 6.x ARG_TYPE is unset, so set it
+ *    In Darwin 7.x ARG_TYPE is already ARG_STDARG
+ */
+#ifndef ARG_TYPE
+#define ARG_TYPE	ARG_STDARG
+#endif
+
+
+/*
+ * UID argument type for chown()
+ */
+typedef uid_t CHOWN_UID_T;
+
+/*
+ * GID argument type for chown()
+ */
+typedef gid_t CHOWN_GID_T;
+
+/*
+ * Our types, usually these are uid_t and gid_t.
+ */
+typedef unsigned long UID_T;	/* Must be signed */
+typedef unsigned long GID_T;	/* Must be signed */
+
+/*
+ * Generic pointer, used by memcpy, malloc, etc.  Usually char or void.
+ */
+typedef void POINTER;
+
+/*
+ * Type of set file time function available
+ */
+#define SETFTIME_TYPE	SETFTIME_UTIMES
+
+/*
+ * Type of set line buffering function available
+ */
+#define SETBUF_TYPE	SETLINEBUF
+
+/*
+ * Things we have
+ */
+#define HAVE_FCHOWN			/* Have fchown() */
+#define HAVE_FCHMOD			/* Have fchmod() */
+#define HAVE_SELECT			/* Have select() */
+#define HAVE_SAVED_IDS			/* Have POSIX style saved [ug]id's */
+#define POSIX_SIGNALS			/* Have POSIX signals */
+
+/*
+ * Things we need
+ */
+/**#define NEED_UNISTD_H			/* Need <unistd.h> */
+
+/*
+ * Path to the remote shell command.   
+ * Define this only if the pathname is different than
+ * that which appears in "include/paths.h".
+ * 
+ * SSH should now be default!!  Both remsh and rsh are insecure
+ */
+#define _PATH_REMSH	"/usr/bin/ssh"		
+
+/*
+ * Path to the 'old' rdist (which is just rdist)
+ */
+#define _PATH_OLDRDIST	"/usr/bin/rdist"
+
+
+
+
diff -Naurb rdist-6.1.5/doc/rdist.man rdist-6.1.5-darwin/doc/rdist.man
--- rdist-6.1.5/doc/rdist.man	Tue Nov 10 00:38:53 1998
+++ rdist-6.1.5-darwin/doc/rdist.man	Tue Jan  6 10:29:17 2004
@@ -185,7 +185,10 @@
 The method used is selected at compile-time.
 However, if the later method is used, the transport program can be
 specified at run-time on the command line with the default being 
-.I rsh(1c).
+.I rsh(1c)
+(or
+.I ssh(1)
+on Darwin/MacOSX).
 If the
 .I rsh(1c)
 method is used and
@@ -881,6 +884,7 @@
 .B csh(1),
 .B stat(2),
 .B rsh(1c),
+.B ssh(1),
 .B rcmd(3)
 .SH DIAGNOSTICS
 .SH NOTES
@@ -915,3 +919,8 @@
 .I rdist 
 will report missing links.
 Only one instance of a link should be listed in each target.
+.PP
+The 
+.B chknfs
+option does not presently work on Darwin (MacOSX).
+
diff -Naurb rdist-6.1.5/include/filesys.h rdist-6.1.5-darwin/include/filesys.h
--- rdist-6.1.5/include/filesys.h	Mon Nov  9 23:02:48 1998
+++ rdist-6.1.5-darwin/include/filesys.h	Tue Jan  6 11:48:08 2004
@@ -89,8 +89,14 @@
 #if defined(BSD386) || defined(__bsdi__) || defined(FREEBSD) || STATFS_TYPE == STATFS_OSF1
 	typedef struct statfs		statfs_t;
 #else
-#	include <sys/vfs.h>
+#if defined(DARWIN)
+#	include <sys/param.h>
+#	include <sys/mount.h>
 	typedef struct statfs 		statfs_t;
+#else
+	include <sys/vfs.h>
+	typedef struct statfs 		statfs_t;
+#endif  /* DARWIN */
 #endif	/* BSD386 */
 #endif	/* SVR4 */
 #endif	/* _AIX */
@@ -98,7 +104,7 @@
 #endif	/* STATFS_TYPE */
 
 /*
- * Mount Entry definetions
+ * Mount Entry definitions
  */
 #ifndef METYPE_OTHER
 #define METYPE_OTHER			"other"
diff -Naurb rdist-6.1.5/src/isexec.c rdist-6.1.5-darwin/src/isexec.c
--- rdist-6.1.5/src/isexec.c	Mon Nov  9 23:11:42 1998
+++ rdist-6.1.5-darwin/src/isexec.c	Tue Jan  6 10:29:17 2004
@@ -173,11 +173,13 @@
  * Mach-O format
  */
 
-#if	defined(NEXTSTEP) && NEXTSTEP >= 3
+#if	defined(DARWIN) || ( defined(NEXTSTEP) && NEXTSTEP >= 3 )
 #	include <mach-o/loader.h>
 #else
 #	include <sys/loader.h>
-#endif	/* NEXTSTEP */
+
+#endif	/* DARWIN||NEXTSTEP */
+
 
 #ifndef MH_CIGAM
 #define MH_CIGAM  	0xcefaedfe
@@ -201,7 +203,8 @@
 	else
 		return(FALSE);
 }
-#endif /* EXE_COFF */
+#endif /* EXE_MACHO */
+
 
 
 #if	EXE_TYPE == EXE_HPEXEC
