Hi folks.
Current rdist will timeout with files >2GB, log as finished, but will
not die.
The bug (system/6586) was originally noted by IBM (AIX) in 2006:
        https://www-304.ibm.com/support/docview.wss?uid=isg1IY85396
I have patches for the client rdist and server rdistd.
I have tested i386 and amd64, in both directions.  Please continue this.
Testing on alpha would be especially welcomed.
Thanks to everyone in advance.

Steven
****************************************************************
client.c
I did check into the comparison at line 689. Basically, it is ASSUMED
that link files (not the actual files) will be tiny.
        The only attributes returned from an lstat() that refer to the symbolic
link itself are the file type (S_IFLNK), size, blocks, and link count
(always 1).
That code is safe FOR NOW ...
IF the (meta)data in the link grows a lot THEN it could be a problem.

This should be a good state.
1. FIXED bug of filesize >2GB -- calculations and messages
2. FIXED similar in minimum freespace (and free files)
3. verified/fixed system write (and read) calls
4. TODO improve buffering
****************************************************************
i386 -> i386    <install BIG file>      OK
i386 -> i386    <BIG file already installed>    OK
amd64 -> i386   <install BIG file>      OK
amd64 -> i386   <BIG file already installed>    OK
i386 -> amd64   <install BIG file>      OK
i386 -> amd64   <BIG file already installed>    OK
****************************************************************
****************************************************************
diff -uw /usr/src/usr.bin/rdist/Makefile rdist/Makefile
--- /usr/src/usr.bin/rdist/Makefile     Sun Jan  4 21:55:28 2004
+++ rdist/Makefile      Mon Mar 28 22:03:24 2011
@@ -3,6 +3,7 @@

 PROG=  rdist
 CFLAGS+=-I. -I${.CURDIR} -DOS_H=\"os-openbsd.h\"
+#CFLAGS+=-Wall -pedantic
 SRCS=  gram.y child.c client.c common.c distopt.c docmd.c expand.c \
        isexec.c lookup.c message.c rdist.c
 CLEANFILES+=gram.c y.tab.h
diff -uw /usr/src/usr.bin/rdist/child.c rdist/child.c
--- /usr/src/usr.bin/rdist/child.c      Thu Oct 29 00:34:05 2009
+++ rdist/child.c       Sun Mar 27 16:36:19 2011
@@ -177,7 +177,7 @@
 readchild(CHILD *child)
 {
        char rbuf[BUFSIZ];
-       int amt;
+       ssize_t amt;

        debugmsg(DM_CALL, "[readchild(%s, %d, %d) start]",
                 child->c_name, child->c_pid, child->c_readfd);
@@ -196,7 +196,7 @@
         */
        while ((amt = read(child->c_readfd, rbuf, sizeof(rbuf))) > 0) {
                /* XXX remove these debug calls */
-               debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %d bytes]",
+               debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %ld bytes]",
                         child->c_name, child->c_pid, child->c_readfd, amt);

                (void) xwrite(fileno(stdout), rbuf, amt);
@@ -205,7 +205,7 @@
                         child->c_name, child->c_pid, child->c_readfd);
        }

-       debugmsg(DM_MISC, "readchild(%s, %d, %d) done: amt = %d errno = %d\n",
+       debugmsg(DM_MISC, "readchild(%s, %d, %d) done: amt = %ld errno = %d\n",
                 child->c_name, child->c_pid, child->c_readfd, amt, errno);

        /*
diff -uw /usr/src/usr.bin/rdist/client.c rdist/client.c
--- /usr/src/usr.bin/rdist/client.c     Thu Oct 29 00:34:06 2009
+++ rdist/client.c      Sun Mar 27 16:05:15 2011
@@ -399,8 +399,8 @@
         */
        ENCODE(ername, rname);

-       (void) sendcmd(C_RECVREG, "%o %04o %ld %ld %ld %s %s %s",
-                      opts, stb->st_mode & 07777, (long) stb->st_size,
+       (void) sendcmd(C_RECVREG, "%o %04o %lld %ld %ld %s %s %s",
+               opts, stb->st_mode & 07777, stb->st_size,
                       stb->st_mtime, stb->st_atime,
                       user, group, ername);
        if (response() < 0) {
@@ -409,8 +409,8 @@
        }


-       debugmsg(DM_MISC, "Send file '%s' %ld bytes\n", rname,
-                (long) stb->st_size);
+       debugmsg(DM_MISC, "Send file '%s' %lld bytes\n", rname,
+               stb->st_size);

        /*
         * Set remote time out alarm handler.
@@ -666,8 +666,8 @@
         * Gather and send basic link info
         */
        ENCODE(ername, rname);
-       (void) sendcmd(C_RECVSYMLINK, "%o %04o %ld %ld %ld %s %s %s",
-                      opts, stb->st_mode & 07777, (long) stb->st_size,
+       (void) sendcmd(C_RECVSYMLINK, "%o %04o %lld %ld %ld %s %s %s",
+               opts, stb->st_mode & 07777, stb->st_size,
                       stb->st_mtime, stb->st_atime,
                       user, group, ername);
        if (response() < 0)
@@ -869,7 +869,7 @@
        /*
         * Parse size
         */
-       size = (off_t) strtol(cp, (char **)&cp, 10);
+       size = (off_t) strtoll(cp, (char **)&cp, 10);
        if (*cp++ != ' ') {
                error("update: size not delimited");
                return(US_NOTHING);
@@ -878,7 +878,7 @@
        /*
         * Parse mtime
         */
-       mtime = strtol(cp, (char **)&cp, 10);
+       mtime = (time_t) strtol(cp, (char **)&cp, 10);
        if (*cp++ != ' ') {
                error("update: mtime not delimited");
                return(US_NOTHING);
@@ -921,8 +921,8 @@

        debugmsg(DM_MISC, "update(%s,) local mode %04o remote mode %04o\n",
                 rname, lmode, rmode);
-       debugmsg(DM_MISC, "update(%s,) size %ld mtime %d owner '%s' grp '%s'\n",
-                rname, (long) size, mtime, owner, group);
+       debugmsg(DM_MISC, "update(%s,) size %lld mtime %d owner '%s' grp 
'%s'\n",
+               rname, size, mtime, owner, group);

        if (statp->st_mtime != mtime) {
                if (statp->st_mtime < mtime && IS_ON(opts, DO_YOUNGER)) {
@@ -935,8 +935,8 @@
        }

        if (statp->st_size != size) {
-               debugmsg(DM_MISC, "size does not match (%ld != %ld).\n",
-                        (long) statp->st_size, (long) size);
+               debugmsg(DM_MISC, "size does not match (%lld != %lld).\n",
+                       statp->st_size, size);
                return(US_OUTDATE);
        }

diff -uw /usr/src/usr.bin/rdist/common.c rdist/common.c
--- /usr/src/usr.bin/rdist/common.c     Thu Oct 29 00:34:06 2009
+++ rdist/common.c      Sun Mar 27 16:05:16 2011
@@ -69,7 +69,7 @@
 char                   defgroup[64] = "bin";   /* Default group */

 static int sendcmdmsg(int, char *, size_t);
-static int remread(int, u_char *, int);
+static ssize_t remread(int, u_char *, size_t);
 static int remmore(void);

 /*
@@ -354,17 +354,17 @@
  */
 static u_char rembuf[BUFSIZ];
 static u_char *remptr;
-static int remleft;
+static ssize_t remleft;

 #define remc() (--remleft < 0 ? remmore() : *remptr++)

 /*
  * Back end to remote read()
  */
-static int
-remread(int fd, u_char *buf, int bufsiz)
+static ssize_t
+remread(int fd, u_char *buf, size_t bufsiz)
 {
-       return(read(fd, (char *)buf, bufsiz));
+       return(read(fd, buf, bufsiz));
 }

 static int
@@ -452,8 +452,8 @@
 /*
  * Non-line-oriented remote read.
  */
-int
-readrem(char *p, int space)
+ssize_t
+readrem(char *p, size_t space)
 {
        if (remleft <= 0) {
                /*
diff -uw /usr/src/usr.bin/rdist/config-data.h rdist/config-data.h
--- /usr/src/usr.bin/rdist/config-data.h        Mon Jun  2 22:56:14 2003
+++ rdist/config-data.h Sun Mar 27 16:05:11 2011
@@ -82,10 +82,10 @@
  * Set default write(2) return and amount types.
  */
 #if    !defined(WRITE_RETURN_T)
-#define                WRITE_RETURN_T          int     /* What write() returns 
*/
+#define        WRITE_RETURN_T  ssize_t /* What write() returns */
 #endif /* WRITE_RETURN_T */
 #if    !defined(WRITE_AMT_T)
-#define                WRITE_AMT_T             int     /* Amount to write */
+#define WRITE_AMT_T    size_t  /* Amount to write */
 #endif /* WRITE_AMT_T */

 #endif /* __configdata_h__ */
diff -uw /usr/src/usr.bin/rdist/defs.h rdist/defs.h
--- /usr/src/usr.bin/rdist/defs.h       Wed Jan  2 12:44:11 2008
+++ rdist/defs.h        Sun Mar 27 16:05:11 2011
@@ -370,7 +370,7 @@
 void sighandler(int);
 int sendcmd(char, char *, ...);
 int remline(u_char *, int, int);
-int readrem(char *, int);
+ssize_t readrem(char *, size_t);
 char *getusername(UID_T, char *, opt_t);
 char *getgroupname(GID_T, char *, opt_t);
 int response(void);
@@ -420,7 +420,7 @@
 int is_nfs_mounted(char *, struct stat *, int *);
 int is_ro_mounted(char *, struct stat *, int *);
 int is_symlinked(char *, struct stat *, int *);
-int getfilesysinfo(char *, long *, long *);
+int getfilesysinfo(char *, off_t *, off_t *);

 /* gram.c */
 int yylex(void);
diff -uw /usr/src/usr.bin/rdist/docmd.c rdist/docmd.c
--- /usr/src/usr.bin/rdist/docmd.c      Thu Oct 29 00:34:06 2009
+++ rdist/docmd.c       Sun Mar 27 16:05:11 2011
@@ -308,7 +308,7 @@
        char *ruser, *cp;
        static char *cur_host = NULL;
        extern char *locuser;
-       extern long min_freefiles, min_freespace;
+       extern off_t    min_freefiles, min_freespace;
        extern char *remotemsglist;
        char tuser[BUFSIZ], buf[BUFSIZ];
        u_char respbuff[BUFSIZ];
@@ -404,7 +404,7 @@
                        return(0);
        }
        if (min_freespace) {
-               (void) sendcmd(C_SETCONFIG, "%c%d", SC_FREESPACE,
+               (void) sendcmd(C_SETCONFIG, "%c%lld", SC_FREESPACE,
                               min_freespace);
                if (response() < 0)
                        return(0);
diff -uw /usr/src/usr.bin/rdist/rdist.c rdist/rdist.c
--- /usr/src/usr.bin/rdist/rdist.c      Thu Oct 29 00:34:06 2009
+++ rdist/rdist.c       Sun Mar 27 16:05:11 2011
@@ -42,8 +42,8 @@
 char                  *distfile = NULL;                /* Name of distfile to 
use */
 int            maxchildren = MAXCHILDREN;      /* Max no of concurrent PIDs */
 int            nflag = 0;                      /* Say without doing */
-long           min_freespace = 0;              /* Min filesys free space */
-long           min_freefiles = 0;              /* Min filesys free # files */
+off_t  min_freespace = 0;      /* Min filesys free space */
+off_t  min_freefiles = 0;              /* Min filesys free # files */
 FILE                  *fin = NULL;                     /* Input file pointer */
 char           localmsglist[] = "stdout=all:notify=all:syslog=nerror,ferror";
 char                  *remotemsglist = NULL;
@@ -161,7 +161,7 @@
                                usage();
                        }
                        if (c == 'a')
-                               min_freespace = atoi(optarg);
+                               min_freespace = atoll(optarg);
                        else if (c == 'A')
                                min_freefiles = atoi(optarg);
                        else if (c == 'M')

****************************************************************
diff -uw /usr/src/usr.bin/rdistd/Makefile rdistd/Makefile
--- /usr/src/usr.bin/rdistd/Makefile    Tue May  6 18:10:11 2003
+++ rdistd/Makefile     Mon Mar 28 22:03:04 2011
@@ -4,5 +4,6 @@
 SRCS=  common.c filesys-os.c filesys.c message.c rdistd.c server.c
 .PATH:  ${.CURDIR}/../rdist
 CFLAGS+=-I${.CURDIR}/../rdist -DOS_H=\"os-openbsd.h\"
+#CFLAGS+=-Wall -pedantic

 .include <bsd.prog.mk>
diff -uw /usr/src/usr.bin/rdistd/filesys.c rdistd/filesys.c
--- /usr/src/usr.bin/rdistd/filesys.c   Thu Oct 29 00:34:06 2009
+++ rdistd/filesys.c    Mon Mar 28 16:28:11 2011
@@ -402,7 +402,7 @@
  * information.
  */
 int
-getfilesysinfo(char *file, long *freespace, long *freefiles)
+getfilesysinfo(char *file, off_t *freespace, off_t *freefiles)
 {
 #if    defined(STATFS_TYPE)
        static statfs_t statfsbuf;
diff -uw /usr/src/usr.bin/rdistd/server.c rdistd/server.c
--- /usr/src/usr.bin/rdistd/server.c    Thu Oct 29 00:34:06 2009
+++ rdistd/server.c     Mon Mar 28 16:28:11 2011
@@ -41,8 +41,8 @@
 int    catname = 0;            /* cat name to target name */
 char   *sptarget[32];          /* stack of saved ptarget's for directories */
 char   *fromhost = NULL;       /* Client hostname */
-static long min_freespace = 0; /* Minimium free space on a filesystem */
-static long min_freefiles = 0; /* Minimium free # files on a filesystem */
+static off_t   min_freespace = 0;      /* Minimium free space on a filesystem 
*/
+static off_t   min_freefiles = 0;      /* Minimium free # files on a 
filesystem */
 int    oumask;                 /* Old umask */

 static int cattarget(char *);
@@ -656,8 +656,8 @@
        case S_IFIFO:
 #endif
 #endif
-               (void) sendcmd(QC_YES, "%ld %ld %o %s %s",
-                              (long) stb.st_size, stb.st_mtime,
+               (void) sendcmd(QC_YES, "%lld %ld %o %s %s",
+                              stb.st_size, stb.st_mtime,
                               stb.st_mode & 07777,
                               getusername(stb.st_uid, target, options),
                               getgroupname(stb.st_gid, target, options));
@@ -794,13 +794,13 @@
        wrerr = 0;
        olderrno = 0;
        for (i = 0; i < size; i += BUFSIZ) {
-               int amt = BUFSIZ;
+               size_t  amt = BUFSIZ;

                cp = buf;
                if (i + amt > size)
                        amt = size - i;
                do {
-                       int j;
+                       size_t  j;

                        j = readrem(cp, amt);
                        if (j <= 0) {
@@ -1350,7 +1350,7 @@
                        fatalerr("Expected digit, got '%s'.", cp);
                        return;
                }
-               min_freespace = (unsigned long) atoi(cp);
+               min_freespace = (off_t) atoll(cp);
                break;

        case SC_FREEFILES:      /* Minimium free files */
@@ -1358,7 +1358,7 @@
                        fatalerr("Expected digit, got '%s'.", cp);
                        return;
                }
-               min_freefiles = (unsigned long) atoi(cp);
+               min_freefiles = (off_t) atoll(cp);
                break;

        case SC_LOGGING:        /* Logging options */
@@ -1396,7 +1396,7 @@
        char *owner, *group, *file;
        char new[MAXPATHLEN];
        char fileb[MAXPATHLEN];
-       long freespace = -1, freefiles = -1;
+       off_t   freespace = -1, freefiles = -1;
        char *cp = cmd;

        /*
@@ -1420,7 +1420,7 @@
        /*
         * Get file size
         */
-       size = strtol(cp, &cp, 10);
+       size = (off_t) strtoll(cp, &cp, 10);
        if (*cp++ != ' ') {
                error("recvit: size not delimited");
                return;
@@ -1429,7 +1429,7 @@
        /*
         * Get modification time
         */
-       mtime = strtol(cp, &cp, 10);
+       mtime = (time_t) strtol(cp, &cp, 10);
        if (*cp++ != ' ') {
                error("recvit: mtime not delimited");
                return;
@@ -1438,7 +1438,7 @@
        /*
         * Get access time
         */
-       atime = strtol(cp, &cp, 10);
+       atime = (time_t) strtol(cp, &cp, 10);
        if (*cp++ != ' ') {
                error("recvit: atime not delimited");
                return;
@@ -1478,7 +1478,7 @@
        file = fileb;

        debugmsg(DM_MISC,
-                "recvit: opts = %04o mode = %04o size = %d mtime = %d",
+                "recvit: opts = %04o mode = %04o size = %lld mtime = %d",
                 opts, mode, size, mtime);
        debugmsg(DM_MISC,
        "recvit: owner = '%s' group = '%s' file = '%s' catname = %d
isdir = %d",
@@ -1523,7 +1523,7 @@
         */
        if (min_freespace || min_freefiles) {
                /* Convert file size to kilobytes */
-               long fsize = (long) (size / 1024);
+               off_t   fsize = (off_t) (size / ((off_t) 1024));

                if (getfilesysinfo(target, &freespace, &freefiles) != 0)
                        return;
@@ -1535,14 +1535,14 @@
                if (min_freespace && (freespace >= 0) &&
                    (freespace - fsize < min_freespace)) {
                        error(
-                    "%s: Not enough free space on filesystem: min %d free %d",
+                    "%s: Not enough free space on filesystem: min %lld free 
%lld",
                              target, min_freespace, freespace);
                        return;
                }
                if (min_freefiles && (freefiles >= 0) &&
                    (freefiles - 1 < min_freefiles)) {
                        error(
-                    "%s: Not enough free files on filesystem: min %d free %d",
+                    "%s: Not enough free files on filesystem: min %lld free 
%lld",
                              target, min_freefiles, freefiles);
                        return;
                }
@@ -1594,7 +1594,7 @@
        /*
         * Get file mode
         */
-       mode = strtol(cp, &cp, 8);
+       mode = (int) strtol(cp, &cp, 8);
        if (*cp++ != ' ') {
                error("dochmog: mode not delimited");
                return;
****************************************************************

Reply via email to