On  8 Nov 2000, Martin Pool <[EMAIL PROTECTED]> wrote:

> > The unlink message went to the console not the file, it was:
> > 
> >  unlink rsync-2.4.6/lib : Not privileged
> 
> That's pretty strange, for two reasons: as far as I knew, everything
> ought to go to stderr, stdout, or the log file.  When you say
> "console", do you mean it comes out in your current window, or it goes
> to the actual VGA adapter/serial console of the server?

Oh... and the second reason it's strange is that rsync is deleting
anything at all.  Todd, would you mind please

1. running with just the -r (recursive) flag, not -a (archive)

2. confirming that when copying the rsync source, the error occurs
even if the source directory is empty

3. Applying the attached patch (or equivalently building from CVS);
this will produce better explanations of where the error occurs.  If
you're concerned about disrupting the machines then it's OK to just
build and not install the daemon; you can then run it with a command
like

  # ./rsync-patched/rsync --daemon --port 8129 

Thanks, 
-- 
Martin Pool, Linuxcare, Inc.
+61 2 6262 8990
[EMAIL PROTECTED], http://www.linuxcare.com/
Linuxcare. Support for the revolution.




Index: .cvsignore
===================================================================
RCS file: /data/cvs//rsync/.cvsignore,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- .cvsignore  1997/12/16 09:14:18     1.13
+++ .cvsignore  2000/10/13 03:28:12     1.14
@@ -1,5 +1,7 @@
-.ignore
+
 .cvsignore
+.ignore
+ID
 Makefile
 a
 b
@@ -18,4 +20,3 @@
 tech_report.log
 tech_report.ps
 test
-
Index: README
===================================================================
RCS file: /data/cvs//rsync/README,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- README      2000/09/06 02:39:45     1.24
+++ README      2000/11/02 11:38:13     1.25
@@ -90,11 +90,14 @@
 SETUP
 -----
 
-Rsync uses rsh or ssh for communication. It does not need to be setuid
-and requires no special privileges for installation. It does not
-require a inetd entry or a daemon. You must, however, have a working
-rsh or ssh system. Using ssh is recommended for its security
-features. 
+Rsync normally uses rsh or ssh for communication.  It does not need to
+be setuid and requires no special privileges for installation.  You
+must, however, have a working rsh or ssh system. Using ssh is
+recommended for its security features.
+
+Alternatively, rsync can run in `daemon' mode, listening on a socket.
+This is generally used for public file distribution, although
+authentication and access control are available.
 
 To install rsync, first run the "configure" script. This will create a
 Makefile and config.h appropriate for your system. Then type
@@ -152,19 +155,20 @@
 source code repository then you can use anonymous cvs. You will need a
 recent version of cvs then use the following commands:
 
-       cvs -d :pserver:[EMAIL PROTECTED]:/cvsroot login
+       cvs -d :pserver:[EMAIL PROTECTED]:/cvsroot login
        Password: cvs
 
-       cvs -d :pserver:[EMAIL PROTECTED]:/cvsroot co rsync
+       cvs -d :pserver:[EMAIL PROTECTED]:/cvsroot co rsync
 
-Look at the cvs documentation for more details.
+Look at the cvs documentation, or http://samba.org/cvs.html, for more
+details.
 
 
 COPYRIGHT
 ---------
 
 Rsync was written by Andrew Tridgell and Paul Mackerras, and is
-available under the Gnu Public License.
+available under the GNU General Public License.
 
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
Index: authenticate.c
===================================================================
RCS file: /data/cvs//rsync/authenticate.c,v
retrieving revision 1.14
retrieving revision 1.16
diff -u -r1.14 -r1.16
--- authenticate.c      2000/08/19 15:25:05     1.14
+++ authenticate.c      2000/10/26 07:31:29     1.16
@@ -1,6 +1,7 @@
-/* 
-   Copyright (C) Andrew Tridgell 1998
+/* -*- c-file-style: "linux"; -*-
    
+   Copyright (C) 1998-2000 by Andrew Tridgell 
+   
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
@@ -85,7 +86,7 @@
        if (fd == -1) return 0;
 
        if (do_stat(fname, &st) == -1) {
-               rprintf(FERROR,"stat(%s) : %s\n", fname, strerror(errno));
+               rsyserr(FERROR, errno, "stat(%s)", fname);
                ok = 0;
        } else if (lp_strict_modes(module)) {
                if ((st.st_mode & 06) != 0) {
@@ -144,13 +145,13 @@
        if (!filename) return NULL;
 
        if ( (fd=open(filename,O_RDONLY)) == -1) {
-               rprintf(FERROR,"could not open password file \"%s\"\n",filename);
+               rsyserr(FERROR, errno, "could not open password file \"%s\"",filename);
                if (envpw) rprintf(FERROR,"falling back to RSYNC_PASSWORD environment 
variable.\n");    
                return NULL;
        }
        
        if (do_stat(filename, &st) == -1) {
-               rprintf(FERROR,"stat(%s) : %s\n", filename, strerror(errno));
+               rsyserr(FERROR, errno, "stat(%s)", filename);
                ok = 0;
        } else if ((st.st_mode & 06) != 0) {
                rprintf(FERROR,"password file must not be other-accessible\n");
Index: backup.c
===================================================================
RCS file: /data/cvs//rsync/backup.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- backup.c    2000/08/19 12:51:26     1.7
+++ backup.c    2000/10/26 07:24:18     1.8
@@ -43,7 +43,7 @@
        if (do_rename(fname,fnamebak) != 0) {
                /* cygwin (at least version b19) reports EINVAL */
                if (errno != ENOENT && errno != EINVAL) {
-                       rprintf(FERROR,"rename %s %s : 
%s\n",fname,fnamebak,strerror(errno));
+                       rsyserr(FERROR, errno, "rename %s to backup %s", fname, 
+fnamebak);
                        return 0;
                }
        } else if (verbose > 1) {
Index: clientserver.c
===================================================================
RCS file: /data/cvs//rsync/clientserver.c,v
retrieving revision 1.58
retrieving revision 1.61
diff -u -r1.58 -r1.61
--- clientserver.c      2000/08/29 04:47:08     1.58
+++ clientserver.c      2000/10/31 01:05:42     1.61
@@ -1,6 +1,7 @@
-/* 
-   Copyright (C) Andrew Tridgell 1998
+/* -*- c-file-style: "linux"; -*-
    
+   Copyright (C) 1998-2000 by Andrew Tridgell
+   
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +17,7 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* the socket based protocol for setting up a connection wit rsyncd */
+/* the socket based protocol for setting up a connection with rsyncd */
 
 #include "rsync.h"
 
@@ -27,6 +28,11 @@
 char *auth_user;
 int sanitize_paths = 0;
 
+
+/*
+ * Run a client connected to an rsyncd.  The alternative to this
+ * function for remote-shell connections is do_cmd.
+ */
 int start_socket_client(char *host, char *path, int argc, char *argv[])
 {
        int fd, i;
@@ -37,12 +43,25 @@
        extern int remote_version;
        extern int am_sender;
        extern struct in_addr socket_address;
+       extern char *shell_cmd;
 
        if (argc == 0 && !am_sender) {
                extern int list_only;
                list_only = 1;
        }
 
+        /* This is just a friendliness enhancement: if the connection
+         * is to an rsyncd then there is no point specifying the -e option.
+         * Note that this is only set if the -e was explicitly specified,
+         * not if the environment variable just happens to be set.
+         * See http://lists.samba.org/pipermail/rsync/2000-September/002744.html
+         */
+        if (shell_cmd) {
+                rprintf(FERROR, "WARNING: --rsh or -e option ignored when "
+                        "connecting to rsync daemon\n");
+                /* continue */
+        }
+        
        if (*path == '/') {
                rprintf(FERROR,"ERROR: The remote path must start with a module 
name\n");
                return -1;
@@ -206,24 +225,24 @@
        p = lp_exclude(i);
        add_exclude_line(p);
 
-       log_open();
+       log_init();
 
        if (use_chroot) {
                if (chroot(lp_path(i))) {
-                       rprintf(FERROR,"chroot %s failed\n", lp_path(i));
+                       rsyserr(FERROR, errno, "chroot %s failed", lp_path(i));
                        io_printf(fd,"@ERROR: chroot failed\n");
                        return -1;
                }
 
                if (!push_dir("/", 0)) {
-                       rprintf(FERROR,"chdir %s failed\n", lp_path(i));
+                        rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
                        io_printf(fd,"@ERROR: chdir failed\n");
                        return -1;
                }
 
        } else {
                if (!push_dir(lp_path(i), 0)) {
-                       rprintf(FERROR,"chdir %s failed\n", lp_path(i));
+                       rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
                        io_printf(fd,"@ERROR: chdir failed\n");
                        return -1;
                }
@@ -232,13 +251,13 @@
 
        if (am_root) {
                if (setgid(gid)) {
-                       rprintf(FERROR,"setgid %d failed\n", gid);
+                       rsyserr(FERROR, errno, "setgid %d failed", gid);
                        io_printf(fd,"@ERROR: setgid failed\n");
                        return -1;
                }
 
                if (setuid(uid)) {
-                       rprintf(FERROR,"setuid %d failed\n", uid);
+                       rsyserr(FERROR, errno, "setuid %d failed", uid);
                        io_printf(fd,"@ERROR: setuid failed\n");
                        return -1;
                }
@@ -449,7 +468,7 @@
                exit_cleanup(RERR_SYNTAX);
        }
 
-       log_open();
+       log_init();
 
        rprintf(FINFO,"rsyncd version %s starting\n",VERSION);
 
@@ -461,7 +480,7 @@
                if ((fd = do_open(lp_pid_file(), O_WRONLY|O_CREAT|O_TRUNC,
                                        0666 & ~orig_umask)) == -1) {
                    cleanup_set_pid(0);
-                   rprintf(FLOG,"failed to create pid file %s\n", pid_file);
+                   rsyserr(FLOG, errno, "failed to create pid file %s", pid_file);
                    exit_cleanup(RERR_FILEIO);
                }
                slprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
Index: configure
===================================================================
RCS file: /data/cvs//rsync/configure,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- configure   2000/09/05 23:21:27     1.62
+++ configure   2000/11/02 11:37:34     1.63
@@ -671,12 +671,12 @@
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
     if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_HAVE_GETCONF="1"
+      ac_cv_prog_HAVE_GETCONF=""yes""
       break
     fi
   done
   IFS="$ac_save_ifs"
-  test -z "$ac_cv_prog_HAVE_GETCONF" && ac_cv_prog_HAVE_GETCONF="0"
+  test -z "$ac_cv_prog_HAVE_GETCONF" && ac_cv_prog_HAVE_GETCONF=""no""
 fi
 fi
 HAVE_GETCONF="$ac_cv_prog_HAVE_GETCONF"
@@ -686,9 +686,9 @@
   echo "$ac_t""no" 1>&6
 fi
 
-if test $HAVE_GETCONF = 1; then
-       CFLAGS=$CFLAGS" "`getconf LFS_CFLAGS`
-       LDFLAGS=$LDFLAGS" "`getconf LFS_LDFLAGS`
+if test $HAVE_GETCONF = "yes"; then
+       CFLAGS=$CFLAGS" "`getconf LFS_CFLAGS 2> /dev/null`
+       LDFLAGS=$LDFLAGS" "`getconf LFS_LDFLAGS 2> /dev/null`
 fi
 
 # Extract the first word of "gcc", so it can be a program name with args.
@@ -1678,7 +1678,7 @@
 #include "confdefs.h"
 
 int main() {
-} $ac_kw foo() {
+} int $ac_kw foo() {
 ; return 0; }
 EOF
 if { (eval echo configure:1685: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; 
then
Index: configure.in
===================================================================
RCS file: /data/cvs//rsync/configure.in,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- configure.in        2000/09/05 23:21:27     1.64
+++ configure.in        2000/09/06 07:15:37     1.65
@@ -10,10 +10,10 @@
 AC_VALIDATE_CACHE_SYSTEM_TYPE
 
 # look for getconf early as this affects just about everything
-AC_CHECK_PROG(HAVE_GETCONF, getconf, 1, 0)
-if test $HAVE_GETCONF = 1; then
-       CFLAGS=$CFLAGS" "`getconf LFS_CFLAGS`
-       LDFLAGS=$LDFLAGS" "`getconf LFS_LDFLAGS`
+AC_CHECK_PROG(HAVE_GETCONF, getconf, "yes", "no")
+if test $HAVE_GETCONF = "yes"; then
+       CFLAGS=$CFLAGS" "`getconf LFS_CFLAGS 2> /dev/null`
+       LDFLAGS=$LDFLAGS" "`getconf LFS_LDFLAGS 2> /dev/null`
 fi
 
 dnl Checks for programs.
Index: exclude.c
===================================================================
RCS file: /data/cvs//rsync/exclude.c,v
retrieving revision 1.32
retrieving revision 1.35
diff -u -r1.32 -r1.35
--- exclude.c   2000/08/29 04:45:49     1.32
+++ exclude.c   2000/10/26 07:24:18     1.35
@@ -20,6 +20,8 @@
 /* a lot of this stuff was originally derived from GNU tar, although
    it has now changed so much that it is hard to tell :) */
 
+/* include/exclude cluestick added by Martin Pool <[EMAIL PROTECTED]> */
+
 #include "rsync.h"
 
 extern int verbose;
@@ -84,8 +86,8 @@
        free(ex);
 }
 
-static int check_one_exclude(char *name,struct exclude_struct *ex,
-                            STRUCT_STAT *st)
+static int check_one_exclude(char *name, struct exclude_struct *ex,
+                             STRUCT_STAT *st)
 {
        char *p;
        int match_start=0;
@@ -120,26 +122,56 @@
        return 0;
 }
 
+
+static void report_exclude_result(char const *name,
+                                  struct exclude_struct const *ent,
+                                  STRUCT_STAT const *st)
+{
+        /* If a trailing slash is present to match only directories,
+         * then it is stripped out by make_exclude.  So as a special
+         * case we add it back in here. */
+        
+        if (verbose >= 2)
+                rprintf(FINFO, "%s %s %s because of pattern %s%s\n",
+                        ent->include ? "including" : "excluding",
+                        S_ISDIR(st->st_mode) ? "directory" : "file",
+                        name, ent->pattern,
+                        ent->directory ? "/" : "");
+}
+
 
-int check_exclude(char *name,struct exclude_struct **local_exclude_list,
+/*
+ * Return true if file NAME is defined to be excluded by either
+ * LOCAL_EXCLUDE_LIST or the globals EXCLUDE_LIST.
+ */
+int check_exclude(char *name, struct exclude_struct **local_exclude_list,
                  STRUCT_STAT *st)
 {
        int n;
+        struct exclude_struct *ent;
 
        if (name && (name[0] == '.') && !name[1])
                /* never exclude '.', even if somebody does --exclude '*' */
                return 0;
 
        if (exclude_list) {
-               for (n=0; exclude_list[n]; n++)
-                       if (check_one_exclude(name,exclude_list[n],st))
-                               return !exclude_list[n]->include;
+               for (n=0; exclude_list[n]; n++) {
+                        ent = exclude_list[n];
+                       if (check_one_exclude(name, ent, st)) {
+                                report_exclude_result(name, ent, st);
+                               return !ent->include;
+                        }
+                }
        }
 
        if (local_exclude_list) {
-               for (n=0; local_exclude_list[n]; n++)
-                       if (check_one_exclude(name,local_exclude_list[n],st))
-                               return !local_exclude_list[n]->include;
+               for (n=0; local_exclude_list[n]; n++) {
+                        ent = exclude_list[n];
+                       if (check_one_exclude(name, ent, st)) {
+                                report_exclude_result(name, ent, st);
+                               return !ent->include;
+                        }
+                }
        }
 
        return 0;
@@ -188,7 +220,10 @@
        char line[MAXPATHLEN];
        if (!f) {
                if (fatal) {
-                       rprintf(FERROR,"%s : %s\n",fname,strerror(errno));
+                       rsyserr(FERROR, errno,
+                                "failed to open %s file %s",
+                                include ? "include" : "exclude",
+                                fname);
                        exit_cleanup(RERR_FILEIO);
                }
                return list;
Index: flist.c
===================================================================
RCS file: /data/cvs//rsync/flist.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- flist.c     2000/08/31 23:01:28     1.88
+++ flist.c     2000/10/09 03:46:38     1.89
@@ -185,8 +185,6 @@
 static int match_file_name(char *fname,STRUCT_STAT *st)
 {
   if (check_exclude(fname,local_exclude_list,st)) {
-    if (verbose > 2)
-      rprintf(FINFO,"excluding file %s\n",fname);
     return 0;
   }
   return 1;
@@ -700,6 +698,8 @@
 
        if (verbose && recurse && !am_server && f != -1) {
                rprintf(FINFO,"building file list ... ");
+                if (verbose > 1)
+                        rprintf(FINFO, "\n");
                rflush(FINFO);
        }
 
Index: generator.c
===================================================================
RCS file: /data/cvs//rsync/generator.c,v
retrieving revision 1.19
diff -u -r1.19 generator.c
--- generator.c 2000/09/06 02:12:13     1.19
+++ generator.c 2000/11/08 09:55:08
@@ -217,7 +217,7 @@
                if (dry_run) return;
                if (statret == 0 && !S_ISDIR(st.st_mode)) {
                        if (robust_unlink(fname) != 0) {
-                               rprintf(FERROR,"unlink %s : 
%s\n",fname,strerror(errno));
+                               rprintf(FERROR,"recv_generator: unlink %s: 
+%s\n",fname,strerror(errno));
                                return;
                        }
                        statret = -1;
@@ -226,7 +226,7 @@
                        if (!(relative_paths && errno==ENOENT && 
                              create_directory_path(fname)==0 && 
                              do_mkdir(fname,file->mode)==0)) {
-                               rprintf(FERROR,"mkdir %s : %s (2)\n",
+                               rprintf(FERROR,"recv_generator: mkdir %s: %s (2)\n",
                                        fname,strerror(errno));
                        }
                }
Index: io.c
===================================================================
RCS file: /data/cvs//rsync/io.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- io.c        2000/08/29 05:07:08     1.76
+++ io.c        2000/11/02 11:37:34     1.77
@@ -455,6 +455,8 @@
        io_buffer_count = 0;
 }
 
+
+/* XXX: fd is ignored, which seems a little strange. */
 void io_end_buffering(int fd)
 {
        io_flush();
Index: log.c
===================================================================
RCS file: /data/cvs//rsync/log.c,v
retrieving revision 1.40
retrieving revision 1.43
diff -u -r1.40 -r1.43
--- log.c       2000/01/29 05:16:13     1.40
+++ log.c       2000/10/26 07:24:18     1.43
@@ -1,6 +1,7 @@
-/* 
-   Copyright (C) Andrew Tridgell 1998
+/* -*- c-file-style: "linux"; -*-
    
+   Copyright (C) 1998-2000 by Andrew Tridgell
+   
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
@@ -23,12 +24,15 @@
   */
 #include "rsync.h"
 
+static char *logfname;
 static FILE *logfile;
 static int log_error_fd = -1;
 
 static void logit(int priority, char *buf)
 {
-       if (logfile) {
+       if (logfname) {
+               if (!logfile)
+                       log_open();
                fprintf(logfile,"%s [%d] %s", 
                        timestring(time(NULL)), (int)getpid(), buf);
                fflush(logfile);
@@ -37,12 +41,11 @@
        }
 }
 
-void log_open(void)
+void log_init(void)
 {
        static int initialised;
        int options = LOG_PID;
        time_t t;
-       char *logf;
 
        if (initialised) return;
        initialised = 1;
@@ -54,13 +57,13 @@
        localtime(&t);
 
        /* optionally use a log file instead of syslog */
-       logf = lp_log_file();
-       if (logf && *logf) {
-               extern int orig_umask;
-               int old_umask = umask(022 | orig_umask);
-               logfile = fopen(logf, "a");
-               umask(old_umask);
-               return;
+       logfname = lp_log_file();
+       if (logfname) {
+               if (*logfname) {
+                       log_open();
+                       return;
+               }
+               logfname = NULL;
        }
 
 #ifdef LOG_NDELAY
@@ -78,6 +81,24 @@
 #endif
 }
 
+void log_open()
+{
+       if (logfname && !logfile) {
+               extern int orig_umask;
+               int old_umask = umask(022 | orig_umask);
+               logfile = fopen(logfname, "a");
+               umask(old_umask);
+       }
+}
+
+void log_close()
+{
+       if (logfile) {
+               fclose(logfile);
+               logfile = NULL;
+       }
+}
+
 /* setup the error file descriptor - used when we are a server
    that is receiving files */
 void set_error_fd(int fd)
@@ -125,7 +146,7 @@
 
                depth++;
 
-               log_open();
+               log_init();
                logit(priority, buf);
 
                depth--;
@@ -151,8 +172,9 @@
 }
                
 
-/* this is the rsync debugging function. Call it with FINFO, FERROR or FLOG */
- void rprintf(enum logcode code, const char *format, ...)
+/* This is the rsync debugging function. Call it with FINFO, FERROR or
+ * FLOG. */
+void rprintf(enum logcode code, const char *format, ...)
 {
        va_list ap;  
        char buf[1024];
@@ -166,6 +188,45 @@
 
        rwrite(code, buf, len);
 }
+
+
+/* This is like rprintf, but it also tries to print some
+ * representation of the error code.  Normally errcode = errno.
+ *
+ * Unlike rprintf, this always adds a newline and there should not be
+ * one in the format string.
+ *
+ * Note that since strerror might involve dynamically loading a
+ * message catalog we need to call it once before chroot-ing. */
+void rsyserr(enum logcode code, int errcode, const char *format, ...)
+{
+       va_list ap;  
+       char buf[1024];
+       int len, sys_len;
+        char *sysmsg;
+
+       va_start(ap, format);
+       len = vslprintf(buf, sizeof(buf), format, ap);
+       va_end(ap);
+
+       if (len > sizeof(buf)-1) exit_cleanup(RERR_MESSAGEIO);
+
+        sysmsg = strerror(errcode);
+        sys_len = strlen(sysmsg);
+        if (len + 3 + sys_len > sizeof(buf) - 1)
+                exit_cleanup(RERR_MESSAGEIO);
+
+        strcpy(buf + len, ": ");
+        len += 2;
+        strcpy(buf + len, sysmsg);
+        len += sys_len;
+        strcpy(buf + len, "\n");
+        len++;
+
+       rwrite(code, buf, len);
+}
+
+
 
 void rflush(enum logcode code)
 {
Index: main.c
===================================================================
RCS file: /data/cvs//rsync/main.c,v
retrieving revision 1.117
retrieving revision 1.121
diff -u -r1.117 -r1.121
--- main.c      2000/08/29 04:46:50     1.117
+++ main.c      2000/11/02 11:37:34     1.121
@@ -1,5 +1,6 @@
-/* 
-   Copyright (C) Andrew Tridgell 1996
+/* -*- c-file-style: "linux" -*-
+   
+   Copyright (C) 1996-2000 by Andrew Tridgell 
    Copyright (C) Paul Mackerras 1996
    
    This program is free software; you can redistribute it and/or modify
@@ -458,6 +459,11 @@
        exit_cleanup(0);
 }
 
+
+/*
+ * This is called once the connection has been negotiated.  It is used
+ * for rsyncd, remote-shell, and local connections.
+ */
 int client_run(int f_in, int f_out, int pid, int argc, char *argv[])
 {
        struct file_list *flist;
@@ -510,7 +516,9 @@
        
        flist = recv_file_list(f_in);
        if (!flist || flist->count == 0) {
-               rprintf(FINFO,"client: nothing to do\n");
+               rprintf(FINFO, "client: nothing to do: "
+                        "perhaps you need to specify some filenames or "
+                        "the --recursive option?\n");
                exit_cleanup(0);
        }
        
@@ -543,6 +551,12 @@
        return p;
 }
 
+
+/*
+ * Start a client for either type of remote connection.  Work out
+ * whether the arguments request a remote shell or rsyncd connection,
+ * and call the appropriate connection function, then run_client.
+ */
 static int start_client(int argc, char *argv[])
 {
        char *p;
@@ -555,11 +569,12 @@
        extern int am_sender;
        extern char *shell_cmd;
        extern int rsync_port;
+       char *argv0 = strdup(argv[0]);
 
-       if (strncasecmp(URL_PREFIX, argv[0], strlen(URL_PREFIX)) == 0) {
+       if (strncasecmp(URL_PREFIX, argv0, strlen(URL_PREFIX)) == 0) {
                char *host, *path;
 
-               host = argv[0] + strlen(URL_PREFIX);
+               host = argv0 + strlen(URL_PREFIX);
                p = strchr(host,'/');
                if (p) {
                        *p = 0;
@@ -575,12 +590,12 @@
                return start_socket_client(host, path, argc-1, argv+1);
        }
 
-       p = find_colon(argv[0]);
+       p = find_colon(argv0);
 
        if (p) {
                if (p[1] == ':') {
                        *p = 0;
-                       return start_socket_client(argv[0], p+2, argc-1, argv+1);
+                       return start_socket_client(argv0, p+2, argc-1, argv+1);
                }
 
                if (argc < 1) {
@@ -590,7 +605,7 @@
 
                am_sender = 0;
                *p = 0;
-               shell_machine = argv[0];
+               shell_machine = argv0;
                shell_path = p+1;
                argc--;
                argv++;
Index: receiver.c
===================================================================
RCS file: /data/cvs//rsync/receiver.c,v
retrieving revision 1.29
retrieving revision 1.31
diff -u -r1.29 -r1.31
--- receiver.c  2000/03/21 04:06:04     1.29
+++ receiver.c  2000/11/08 09:32:38     1.31
@@ -1,5 +1,6 @@
-/* 
-   Copyright (C) Andrew Tridgell 1996
+/* -*- c-file-style: "linux" -*-
+   
+   Copyright (C) 1996-2000 by Andrew Tridgell
    Copyright (C) Paul Mackerras 1996
    
    This program is free software; you can redistribute it and/or modify
@@ -82,14 +83,15 @@
 {
        if (!S_ISDIR(f->mode)) {
                if (robust_unlink(f_name(f)) != 0) {
-                       rprintf(FERROR,"unlink %s : %s\n",f_name(f),strerror(errno));
+                       rprintf(FERROR,"delete_one: unlink %s: 
+%s\n",f_name(f),strerror(errno));
                } else if (verbose) {
                        rprintf(FINFO,"deleting %s\n",f_name(f));
                }
        } else {    
                if (do_rmdir(f_name(f)) != 0) {
                        if (errno != ENOTEMPTY && errno != EEXIST)
-                               rprintf(FERROR,"rmdir %s : 
%s\n",f_name(f),strerror(errno));
+                               rprintf(FERROR,"delete_one: rmdir %s: %s\n",
+                                        f_name(f), strerror(errno));
                } else if (verbose) {
                        rprintf(FINFO,"deleting directory %s\n",f_name(f));      
                }
Index: rsync.1
===================================================================
RCS file: /data/cvs//rsync/rsync.1,v
retrieving revision 1.85
retrieving revision 1.87
diff -u -r1.85 -r1.87
--- rsync.1     2000/09/06 02:12:13     1.85
+++ rsync.1     2000/10/13 03:25:35     1.87
@@ -242,7 +242,7 @@
 to the detailed description below for a complete description\&.
 .PP 
 
-.DS 
+.nf 
  
 
  -v, --verbose               increase verbosity
@@ -307,7 +307,7 @@
      --bwlimit=KBPS          limit I/O bandwidth, KBytes per second
  -h, --help                  show this help screen
 
-.DE 
+.fi 
  
 
 .PP 
@@ -386,10 +386,10 @@
 example, if you used the command
 .IP 
 
-.DS 
+.nf 
  
 rsync foo/bar/foo\&.c remote:/tmp/
-.DE 
+.fi 
  
 
 .IP 
@@ -397,10 +397,10 @@
 machine\&. If instead you used
 .IP 
 
-.DS 
+.nf 
  
 rsync -R foo/bar/foo\&.c remote:/tmp/
-.DE 
+.fi 
  
 
 .IP 
@@ -665,7 +665,7 @@
 .IP 
 .IP "\fB-z, --compress\fP" 
 With this option, rsync compresses any data from
-the source file(s) which it sends to the destination machine\&.  This
+the source \fBs\fP which it sends to the destination machine\&.  This
 option is useful on slow links\&.  The compression method used is the
 same method that gzip uses\&.
 .IP 
@@ -884,12 +884,12 @@
 remote shell like this:
 .PP 
 
-.DS 
+.nf 
  
 
    rsh remotehost /bin/true > out\&.dat
 
-.DE 
+.fi 
  
 
 .PP 
@@ -900,6 +900,10 @@
 it\&. The most common cause is incorrectly configured shell startup
 scripts (such as \&.cshrc or \&.profile) that contain output statements
 for non-interactive logins\&.
+.PP 
+If you are having trouble debugging include and exclude patterns, then
+try specifying the -vv option\&.  At this level of verbosity rsync will
+show why each individual file is included or excluded\&.
 .PP 
 .SH "ENVIRONMENT VARIABLES" 
 .PP 
Index: rsync.c
===================================================================
RCS file: /data/cvs//rsync/rsync.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -r1.115 -r1.116
--- rsync.c     2000/09/06 02:12:13     1.115
+++ rsync.c     2000/11/08 09:32:11     1.116
@@ -67,21 +67,21 @@
 
        if (!S_ISDIR(st.st_mode)) {
                if (robust_unlink(fname) == 0 || errno == ENOENT) return 0;
-               rprintf(FERROR,"unlink(%s) : %s\n", fname, strerror(errno));
+               rprintf(FERROR,"delete_file: unlink(%s) : %s\n", fname, 
+strerror(errno));
                return -1;
        }
 
        if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
        if (!force_delete || !recurse || 
            (errno != ENOTEMPTY && errno != EEXIST)) {
-               rprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
+               rprintf(FERROR,"delete_file: rmdir(%s) : %s\n", fname, 
+strerror(errno));
                return -1;
        }
 
        /* now we do a recsursive delete on the directory ... */
        d = opendir(fname);
        if (!d) {
-               rprintf(FERROR,"opendir(%s): %s\n",
+               rprintf(FERROR,"delete_file: opendir(%s): %s\n",
                        fname,strerror(errno));
                return -1;
        }
@@ -103,7 +103,7 @@
        closedir(d);
        
        if (do_rmdir(fname) != 0) {
-               rprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
+               rprintf(FERROR,"delete_file: rmdir(%s) : %s\n", fname, 
+strerror(errno));
                return -1;
        }
 
Index: rsync.h
===================================================================
RCS file: /data/cvs//rsync/rsync.h,v
retrieving revision 1.94
retrieving revision 1.96
diff -u -r1.94 -r1.96
--- rsync.h     2000/08/16 08:34:18     1.94
+++ rsync.h     2000/10/26 07:24:18     1.96
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) Andrew Tridgell 1996
+   Copyright (C) by Andrew Tridgell 1996, 2000
    Copyright (C) Paul Mackerras 1996
    
    This program is free software; you can redistribute it and/or modify
@@ -63,7 +63,7 @@
 
 #define MPLEX_BASE 7
 
-enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3};
+enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
 
 #include "errcode.h"
 
@@ -344,7 +344,6 @@
 };
 
 struct exclude_struct {
-       char *orig;
        char *pattern;
        int regular_exp;
        int fnmatch_flags;
@@ -496,6 +495,14 @@
      __attribute__ ((format (printf, 2, 3)))
 #endif
 ;
+
+/* This is just like rprintf, but it also tries to print some
+ * representation of the error code.  Normally errcode = errno. */
+void rsyserr(enum logcode, int, const char *, ...)
+#ifdef __GNUC__
+     __attribute__ ((format (printf, 3, 4)))
+#endif
+     ;
 
 #ifdef REPLACE_INET_NTOA
 #define inet_ntoa rep_inet_ntoa
Index: rsync.yo
===================================================================
RCS file: /data/cvs//rsync/rsync.yo,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- rsync.yo    2000/09/06 02:12:13     1.69
+++ rsync.yo    2000/10/13 03:25:07     1.70
@@ -779,6 +779,10 @@
 scripts (such as .cshrc or .profile) that contain output statements
 for non-interactive logins.
 
+If you are having trouble debugging include and exclude patterns, then
+try specifying the -vv option.  At this level of verbosity rsync will
+show why each individual file is included or excluded.
+
 manpagesection(ENVIRONMENT VARIABLES)
 
 startdit()
Index: rsyncd.conf.5
===================================================================
RCS file: /data/cvs//rsync/rsyncd.conf.5,v
retrieving revision 1.35
retrieving revision 1.37
diff -u -r1.35 -r1.37
--- rsyncd.conf.5       2000/08/19 13:04:48     1.35
+++ rsyncd.conf.5       2000/10/13 13:49:31     1.37
@@ -44,8 +44,13 @@
 .SH "LAUNCHING THE RSYNC DAEMON" 
 .PP 
 The rsync daemon is launched by specifying the --daemon option to
-rsync\&. The daemon must run with root privileges\&.
+rsync\&. 
 .PP 
+The daemon must run with root privileges if you wish to use chroot, to
+bind to a port numbered under 1024 (as is the default 873), or to set
+file ownership\&.  Otherwise, it must just have permission to read and
+write the appropriate data, log, and lock files\&.
+.PP 
 You can launch it either via inetd or as a stand-alone daemon\&. If run
 as a daemon then just run the command "rsync --daemon" from a suitable
 startup script\&.
@@ -243,7 +248,8 @@
 you may find that passwords longer than 8 characters don\'t work\&. 
 .IP 
 There is no default for the "secrets file" option, you must choose a name
-(such as \f(CW/etc/rsyncd\&.secrets\fP)\&.
+(such as \f(CW/etc/rsyncd\&.secrets\fP)\&.  The file must normally not be
+readable by "other"; see "strict modes"\&.
 .IP 
 .IP "\fBstrict modes\fP" 
 The "strict modes" option determines whether or not 
@@ -394,10 +400,10 @@
 of the patterns will not be compressed during transfer\&.
 .IP 
 The default setting is 
-.DS 
+.nf 
  
 *\&.gz *\&.tgz *\&.zip *\&.z *\&.rpm *\&.deb *\&.iso *\&.bz2 *\&.tbz
-.DE 
+.fi 
  
 
 .IP 
@@ -425,14 +431,14 @@
 \f(CW/home/ftp\fP would be:
 .PP 
 
-.DS 
+.nf 
  
 
 [ftp]
         path = /home/ftp
         comment = ftp export area
 
-.DE 
+.fi 
  
 
 .PP 
@@ -451,7 +457,7 @@
 pid file = /etc/rsyncd\&.pid
 .PP 
 
-.DS 
+.nf 
  
 [ftp]
         path = /var/ftp/pub
@@ -475,7 +481,7 @@
         auth users = tridge, susan
         secrets file = /etc/rsyncd\&.secrets
 
-.DE 
+.fi 
  
 
 .PP 
Index: rsyncd.conf.yo
===================================================================
RCS file: /data/cvs//rsync/rsyncd.conf.yo,v
retrieving revision 1.38
retrieving revision 1.40
diff -u -r1.38 -r1.40
--- rsyncd.conf.yo      2000/08/19 13:04:48     1.38
+++ rsyncd.conf.yo      2000/10/13 13:49:31     1.40
@@ -44,8 +44,13 @@
 manpagesection(LAUNCHING THE RSYNC DAEMON)
 
 The rsync daemon is launched by specifying the --daemon option to
-rsync. The daemon must run with root privileges.
+rsync. 
 
+The daemon must run with root privileges if you wish to use chroot, to
+bind to a port numbered under 1024 (as is the default 873), or to set
+file ownership.  Otherwise, it must just have permission to read and
+write the appropriate data, log, and lock files.
+
 You can launch it either via inetd or as a stand-alone daemon. If run
 as a daemon then just run the command "rsync --daemon" from a suitable
 startup script.
@@ -223,7 +228,8 @@
 you may find that passwords longer than 8 characters don't work. 
 
 There is no default for the "secrets file" option, you must choose a name
-(such as tt(/etc/rsyncd.secrets)).
+(such as tt(/etc/rsyncd.secrets)).  The file must normally not be readable
+by "other"; see "strict modes".
 
 dit(bf(strict modes)) The "strict modes" option determines whether or not 
 the permissions on the secrets file will be checked.  If "strict modes" is
Index: socket.c
===================================================================
RCS file: /data/cvs//rsync/socket.c,v
retrieving revision 1.22
retrieving revision 1.24
diff -u -r1.22 -r1.24
--- socket.c    2000/01/10 04:49:51     1.22
+++ socket.c    2000/10/25 19:57:43     1.24
@@ -247,6 +247,11 @@
                struct sockaddr addr;
                int in_addrlen = sizeof(addr);
 
+               /* close log file before the potentially very long select so
+                  file can be trimmed by another process instead of growing
+                  forever */
+               log_close();
+
                FD_ZERO(&fds);
                FD_SET(s, &fds);
 
@@ -271,6 +276,10 @@
 
                if (fork()==0) {
                        close(s);
+
+                       /* open log file in child before possibly giving
+                          up privileges  */
+                       log_open();
 
                        _exit(fn(fd));
                }

PGP signature

Reply via email to