Bug 2455 - rsync --daemon segfaults if "log file = <file>" dir does not exist
rsync --daemon segfaults if "log file = <file>" dir does not exist
Status: CLOSED FIXED
Product: rsync
Classification: Unclassified
Component: core
2.6.3
Sparc Solaris
: P3 normal
: ---
Assigned To: Wayne Davison
Rsync QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-03-15 12:58 UTC by J.D. Baldwin
Modified: 2005-04-01 11:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description J.D. Baldwin 2005-03-15 12:58:38 UTC
# ./rsync --version
rsync  version 2.6.2  protocol version 28
[etc. ... same bug with 2.6.3 and others]
# ./rsync --daemon --no-detach
Segmentation Fault(coredump)
# grep log /etc/rsyncd.conf
log file = /var/rsyncd/rsyncd.log
syslog facility = daemon
# ls -l /var/rsyncd
/var/rsyncd: No such file or directory
# mkdir /var/rsyncd
# ./rsync --daemon --no-detach
(runs great)

This was mystifying and required truss and/or gdb to figure out.

I added some code for a new category of error, a printed error message and a
proper error-exit.  Here is the context diff of the changes; I hope this is helpful:

Common subdirectories: rsync-2.6.3/doc and rsync-2.6.3_jdb/doc
diff -c rsync-2.6.3/errcode.h rsync-2.6.3_jdb/errcode.h
*** rsync-2.6.3/errcode.h       Mon Dec 15 08:04:14 2003
--- rsync-2.6.3_jdb/errcode.h   Tue Mar 15 19:36:28 2005
***************
*** 42,48 ****
  #define RERR_VANISHED   24      /* file(s) vanished on sender side */
  
  #define RERR_TIMEOUT    30      /* timeout in data send/receive */
! 
  /* Although it doesn't seem to be specified anywhere,
   * ssh and the shell seem to return these values:
   *
--- 42,49 ----
  #define RERR_VANISHED   24      /* file(s) vanished on sender side */
  
  #define RERR_TIMEOUT    30      /* timeout in data send/receive */
! #define RERR_LOG_NOTOPENED 31   /* logfile could not be opened for appending */
!       
  /* Although it doesn't seem to be specified anywhere,
   * ssh and the shell seem to return these values:
   *
Common subdirectories: rsync-2.6.3/lib and rsync-2.6.3_jdb/lib
diff -c rsync-2.6.3/log.c rsync-2.6.3_jdb/log.c
*** rsync-2.6.3/log.c   Sun Sep  5 21:30:00 2004
--- rsync-2.6.3_jdb/log.c       Tue Mar 15 19:47:19 2005
***************
*** 63,68 ****
--- 63,69 ----
        { RERR_PARTIAL    , "some files could not be transferred" },
        { RERR_VANISHED   , "some files vanished before they could be
transferred" },
        { RERR_TIMEOUT    , "timeout in data send/receive" },
+       { RERR_LOG_NOTOPENED, "log file could not be opened" },
        { RERR_CMD_FAILED , "remote shell failed" },
        { RERR_CMD_KILLED , "remote shell killed" },
        { RERR_CMD_RUN,     "remote command could not be run" },
***************
*** 89,96 ****
  static void logit(int priority, char *buf)
  {
        if (logfname) {
!               if (!logfile)
                        log_open();
                fprintf(logfile,"%s [%d] %s",
                        timestring(time(NULL)), (int)getpid(), buf);
                fflush(logfile);
--- 90,103 ----
  static void logit(int priority, char *buf)
  {
        if (logfname) {
!               if (!logfile)     /* Try opening log file for appending */
                        log_open();
+ 
+               if (!logfile) {   /* log file is still not open for some reason */
+                       printf("ERROR: log file %s cannot be opened for
append\n", logfname);
+                       exit_cleanup(RERR_LOG_NOTOPENED);
+               }
+ 
                fprintf(logfile,"%s [%d] %s",
                        timestring(time(NULL)), (int)getpid(), buf);
                fflush(logfile);
Common subdirectories: rsync-2.6.3/packaging and rsync-2.6.3_jdb/packaging
Common subdirectories: rsync-2.6.3/patches and rsync-2.6.3_jdb/patches
Common subdirectories: rsync-2.6.3/popt and rsync-2.6.3_jdb/popt
diff -c rsync-2.6.3/rsync.yo rsync-2.6.3_jdb/rsync.yo
*** rsync-2.6.3/rsync.yo        Thu Sep 30 16:35:56 2004
--- rsync-2.6.3_jdb/rsync.yo    Tue Mar 15 19:36:23 2005
***************
*** 1389,1394 ****
--- 1389,1395 ----
  dit(bf(23)) Partial transfer due to error
  dit(bf(24)) Partial transfer due to vanished source files
  dit(bf(30)) Timeout in data send/receive 
+ dit(bf(31)) Log file could not be opened for appending
  enddit()
  
  manpagesection(ENVIRONMENT VARIABLES)
Common subdirectories: rsync-2.6.3/testhelp and rsync-2.6.3_jdb/testhelp
Common subdirectories: rsync-2.6.3/testsuite and rsync-2.6.3_jdb/testsuite
Common subdirectories: rsync-2.6.3/zlib and rsync-2.6.3_jdb/zlib
Comment 1 Wayne Davison 2005-03-15 16:25:49 UTC
This has been fixed in CVS for a while now, and is mentioned in the NEWS file
for the two pre-release versions of 2.6.4.

I did notice that I failed to add a new error-code for this situation, so I have
checked in a change to implement that.  Thanks.