This patch:

  a) patches configure instead of configure.in (I have no autoconf, so
     will have no way to check a patch to configure.in.  But it should
     be very easy to backpropagate it to configure.in;

  b) Similarly, a chunk for config.h.in is included.  Should be
     ignored with a patch to configure.in;

  c) There is one system-specific hack: a check for __EMX__ in
     ./lib/getopt.c: the prototype for getopt() in unistd.h conflicts
     with its definition;

  d) The rest is generic: support for systems without SUPPORT_LINKS
     (probably not during write), without HAVE_CHOWN, without
     HAVE_CHROOT, withoug HAVE_SYMLINK, without syslog.h, without
     _S_IFBLK and S_IFLNK, without F_SETLK, support for str[n]icmp(),
     and relocatable SHELL in the Makefile.

  e) A couple of sys/type.h are included in configure, since the
     compiler will emit warnings if they are not included.

Enjoy,
Ilya

--- ./backup.c~ Sat Aug 19 08:10:38 2000
+++ ./backup.c  Fri Nov 17 22:54:36 2000
@@ -103,6 +103,7 @@ static int make_bak_dir(char *fname,char
         /* Make the directories */
         while ((p=strchr(p,'/'))) {
                 *p = 0;
+#if SUPPORT_LINKS
                 if(do_lstat(fullpath,&st)!=0) {
                         do_mkdir(fullpath,0777 & ~orig_umask);
                         if(p>q) {
@@ -120,6 +121,27 @@ static int make_bak_dir(char *fname,char
                                 };
                         }
                 };
+#else  /* !( SUPPORT_LINKS ) */ 
+                if(do_stat(fullpath,&st)!=0) {
+                        do_mkdir(fullpath,0777 & ~orig_umask);
+                        if(p>q) {
+                                if(do_stat(q,&st)!=0) {
+                                        rprintf(FERROR,"make_bak_dir stat %s : 
+%s\n",fullpath,strerror(errno));
+                                } else {
+                                        st2=&st;
+                                        set_modtime(fullpath,st2->st_mtime);
+#if HAVE_LCHOWN || HAVE_CHOWN
+                                        
+if(do_lchown(fullpath,st2->st_uid,st2->st_gid)!=0) {
+                                                rprintf(FERROR,"make_bak_dir chown %s 
+: %s\n",fullpath,strerror(errno));
+                                        };
+#endif
+                                        if(do_chmod(fullpath,st2->st_mode)!=0) {
+                                                rprintf(FERROR,"make_bak_dir failed 
+to set permissions on %s : %s\n",fullpath,strerror(errno));
+                                        };
+                                };
+                        }
+                };
+#endif /* SUPPORT_LINKS */ 
                 *p = '/';
                 p++;
         }
--- ./clientserver.c~   Tue Sep  5 21:46:42 2000
+++ ./clientserver.c    Fri Nov 17 23:09:12 2000
@@ -209,7 +209,10 @@ static int rsync_module(int fd, int i)
        log_open();
 
        if (use_chroot) {
-               if (chroot(lp_path(i))) {
+#if HAVE_CHROOT
+               if (chroot(lp_path(i)))
+#endif
+               {
                        rprintf(FERROR,"chroot %s failed\n", lp_path(i));
                        io_printf(fd,"@ERROR: chroot failed\n");
                        return -1;
--- ./log.c~    Sat Jan 29 06:35:02 2000
+++ ./log.c     Fri Nov 17 23:17:04 2000
@@ -33,7 +33,9 @@ static void logit(int priority, char *bu
                        timestring(time(NULL)), (int)getpid(), buf);
                fflush(logfile);
        } else {
+#if HAVE_SYSLOG_H
                syslog(priority, "%s", buf);
+#endif
        }
 }
 
@@ -62,7 +64,7 @@ void log_open(void)
                umask(old_umask);
                return;
        }
-
+#if HAVE_SYSLOG_H
 #ifdef LOG_NDELAY
        options |= LOG_NDELAY;
 #endif
@@ -75,6 +77,9 @@ void log_open(void)
 
 #ifndef LOG_NDELAY
        logit(LOG_INFO,"rsyncd started\n");
+#endif
+#else  /* !( HAVE_SYSLOG_H ) */
+       logfile = stderr;
 #endif
 }
 
--- ./rsync.c~  Tue Sep  5 21:46:42 2000
+++ ./rsync.c   Fri Nov 17 22:56:30 2000
@@ -183,6 +183,7 @@ int set_perms(char *fname,struct file_st
                    change to groups that the user is a member of */
                change_gid = is_in_group(file->gid);
        }
+#if HAVE_LCHOWN || HAVE_CHOWN
        if (change_uid || change_gid) {
                if (do_lchown(fname,
                              change_uid?file->uid:st->st_uid,
@@ -200,6 +201,7 @@ int set_perms(char *fname,struct file_st
                }
                updated = 1;
        }
+#endif /* HAVE_LCHOWN || HAVE_CHOWN */
 
 #ifdef HAVE_CHMOD
        if (!S_ISLNK(st->st_mode)) {
--- ./rsync.h~  Sat Aug 19 08:10:38 2000
+++ ./rsync.h   Fri Nov 17 23:20:26 2000
@@ -183,9 +183,16 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <syslog.h>
 #include <sys/file.h>
 
+#if HAVE_SYSLOG_H
+# include <syslog.h>
+#else  /* !( HAVE_SYSLOG_H ) */
+# define LOG_PID       0
+# define LOG_INFO      0
+# define LOG_WARNING   0
+#endif
+
 #if HAVE_DIRENT_H
 # include <dirent.h>
 #else
@@ -439,6 +446,14 @@ extern int errno;
 #define S_ISBLK(mode) (((mode) & (_S_IFMT)) == (_S_IFBLK))
 #endif
 
+#ifndef _S_IFBLK
+#define _S_IFBLK       -1              /* For DOSISH systems */
+#endif
+
+#ifndef S_IFLNK
+#define S_IFLNK                -1              /* For DOSISH systems */
+#endif
+
 #ifndef S_ISCHR
 #define S_ISCHR(mode) (((mode) & (_S_IFMT)) == (_S_IFCHR))
 #endif
@@ -515,3 +530,8 @@ size_t strlcat(char *d, const char *s, s
 #endif
 
 #define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__)
+
+#ifndef HAVE_STRCASECMP
+#define strcasecmp     stricmp
+#define strncasecmp    strnicmp
+#endif
--- ./syscall.c~        Sat Jan 29 06:35:02 2000
+++ ./syscall.c Fri Nov 17 22:57:18 2000
@@ -35,12 +35,14 @@ int do_unlink(char *fname)
        return unlink(fname);
 }
 
+#if HAVE_SYMLINK
 int do_symlink(char *fname1, char *fname2)
 {
        if (dry_run) return 0;
        CHECK_RO
        return symlink(fname1, fname2);
 }
+#endif
 
 #if HAVE_LINK
 int do_link(char *fname1, char *fname2)
@@ -51,12 +53,14 @@ int do_link(char *fname1, char *fname2)
 }
 #endif
 
+#if HAVE_LCHOWN || HAVE_CHOWN
 int do_lchown(const char *path, uid_t owner, gid_t group)
 {
        if (dry_run) return 0;
        CHECK_RO
        return lchown(path, owner, group);
 }
+#endif
 
 #if HAVE_MKNOD
 int do_mknod(char *pathname, mode_t mode, dev_t dev)
--- ./util.c~   Tue Sep  5 21:46:42 2000
+++ ./util.c    Fri Nov 17 04:02:40 2000
@@ -494,6 +494,7 @@ int name_to_gid(char *name, gid_t *gid)
 /* lock a byte range in a open file */
 int lock_range(int fd, int offset, int len)
 {
+#ifdef F_SETLK
        struct flock lock;
 
        lock.l_type = F_WRLCK;
@@ -503,6 +504,9 @@ int lock_range(int fd, int offset, int l
        lock.l_pid = 0;
        
        return fcntl(fd,F_SETLK,&lock) == 0;
+#else
+       return 0;
+#endif
 }
 
 
--- ./lib/getopt.c~     Sat Jun 22 00:04:22 1996
+++ ./lib/getopt.c      Fri Nov 17 04:47:10 2000
@@ -650,6 +650,8 @@ _getopt_internal (argc, argv, optstring,
   }
 }
 
+#ifndef __EMX__                                /* prototype conflict */
+
 int
 getopt (argc, argv, optstring)
      int argc;
@@ -661,6 +663,8 @@ getopt (argc, argv, optstring)
                           (int *) 0,
                           0);
 }
+
+#endif
 
 int
 getopt_long (argc, argv, options, long_options, opt_index)
--- ./Makefile.in-ini   Tue Sep  5 21:46:42 2000
+++ ./Makefile.in       Fri Nov 17 04:41:34 2000
@@ -15,7 +15,7 @@ INSTALLCMD=@INSTALL@
 
 srcdir=@srcdir@
 VPATH=$(srcdir)
-SHELL=/bin/sh
+SHELL=@SHELL@
 
 
 .SUFFIXES:
--- ./config.h.in-ini   Sat Jul 29 00:05:08 2000
+++ ./config.h.in       Fri Nov 17 23:07:26 2000
@@ -81,6 +81,9 @@
 /* Define if you have the chown function.  */
 #undef HAVE_CHOWN
 
+/* Define if you have the chown function.  */
+#undef HAVE_CHROOT
+
 /* Define if you have the connect function.  */
 #undef HAVE_CONNECT
 
@@ -141,6 +144,9 @@
 /* Define if you have the strpbrk function.  */
 #undef HAVE_STRPBRK
 
+/* Define if you have the symlink function.  */
+#undef HAVE_SYMLINK
+
 /* Define if you have the utime function.  */
 #undef HAVE_UTIME
 
@@ -182,6 +188,9 @@
 
 /* Define if you have the <string.h> header file.  */
 #undef HAVE_STRING_H
+
+/* Define if you have the <syslog.h> header file.  */
+#undef HAVE_SYSLOG_H
 
 /* Define if you have the <sys/dir.h> header file.  */
 #undef HAVE_SYS_DIR_H
--- ./configure.cmd-ini Fri Nov 17 03:33:52 2000
+++ ./configure.cmd     Fri Nov 17 23:06:54 2000
@@ -1492,7 +1493,7 @@ else
 fi
 done
 
-for ac_hdr in sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h
+for ac_hdr in sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h syslog.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
@@ -1503,6 +1504,7 @@ else
   cat > conftest.$ac_ext <<EOF
 #line 1480 "configure"
 #include "confdefs.h"
+#include <sys/types.h>
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
@@ -2735,7 +2737,7 @@ else
 fi
 done
 
-for ac_func in fchmod fstat strchr readlink link utime utimes strftime
+for ac_func in fchmod fstat strchr readlink link utime utimes strftime symlink
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:2717: checking for $ac_func" >&5
@@ -2790,7 +2792,7 @@ else
 fi
 done
 
-for ac_func in memmove lchown vsnprintf snprintf setsid glob strpbrk
+for ac_func in memmove lchown chown vsnprintf snprintf setsid glob strpbrk chroot
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:2772: checking for $ac_func" >&5
@@ -3075,6 +3077,7 @@ else
 #line 3051 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+#include <sys/types.h>
 #include <sys/stat.h>
 main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); 
exit((lstat64("/dev/null", &st)==0)?0:1); }
 EOF

Reply via email to