Path: utzoo!hoptoad!mejac!decwrl!ucbvax!cgl.ucsf.edu!gregc From: gregc@cgl.ucsf.edu (Greg Couch) Newsgroups: alt.sources Subject: diffs to run rdist on System 5 machines Message-ID: <25822@ucbvax.BERKELEY.EDU> Date: 26 Aug 88 21:26:32 GMT Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: gregc@cgl.ucsf.edu (Greg Couch) Organization: UCSF Computer Graphics Lab Lines: 1473 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # README # Berklib.c # patches # This archive created: Fri Aug 26 14:05:44 1988 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'README' then echo shar: "will not over-write existing file 'README'" else cat << \SHAR_EOF > 'README' August 26, 1988 This distribution of the diffs to get rdist running on a System 5 machine contains 3 files, README (this file), Berklib.c, and patches. In addition, you will need the source for /src/ucb/rdist and /src/lib/libc/gen/regex.c from a BSD source distribution. The patches file contains patches for various rdist source files -- I believe Larry Wall's patch program can apply the patches automatically for you. You will probably have to modify the Makefile to reflect which Berkeley extentions your System 5 port has. Also, change the LIBS= line to reflect where your system keeps the Berkeley networking library and the CFLAGS= line for where the Berkeley networking include files are. The two System 5 machines I use (an SGI Iris 4D and a HP 350 running HP-UX 6.0) both have symbolic links (lstat) and the rename system call. Make sure rdist is installed as /usr/ucb/rdist if you want to be able to rdist to/from BSD machines on the same network. If you don't care and will never care, then change the Makefile RDIST= line as you see fit. Conversion notes: Most of the changes were to allow rdist not to run as a setuid program. Rdist uses the setreuid() system call -- which can't be mimicked on System 5 -- to become root long enough to make direct calls to rshd on remote hosts. The workaround is to fork off a rsh to make the remote connection and use pipes to communicate instead of a socket. The changes for machines without symbolic links have not been tested. The diffs include the bug fix I posted recently to comp.bugs.4bsd. - Greg Couch gregc@cgl.ucsf.edu ucsfcgl!gregc SHAR_EOF fi if test -f 'Berklib.c' then echo shar: "will not over-write existing file 'Berklib.c'" else cat << \SHAR_EOF > 'Berklib.c' /* * These are routines are needed by rdist, found in BSD, and generally * not found in System V. */ # ifdef SYS5 # ifndef HAS_UTIMES # include # include # include utimes(file, tvp) char *file; struct timeval tvp[2]; { struct utimbuf utbuf; utbuf.actime = tvp[0].tv_sec; utbuf.modtime = tvp[1].tv_sec; return utime(file, &utbuf); } # endif /* HAS_UTIMES */ # ifndef HAS_RENAME rename(from, to) char *from, *to; { unlink(to); if (link(from, to) < 0) return(-1); if (unlink(from) < 0) return(-1); return 0; } # endif /* HAS_RENAME */ # ifndef HAS_LSTAT # include # include lstat(path, buf) char *path; struct stat *buf; { return stat(path, buf); } # endif /* HAS_LSTAT */ # endif /* SYS5 */ SHAR_EOF fi if test -f 'patches' then echo shar: "will not over-write existing file 'patches'" else cat << \SHAR_EOF > 'patches' RCS file: RCS/Makefile,v retrieving revision 1.1 diff -c -r1.1 Makefile *** /tmp/,RCSt1a03695 Thu Aug 25 15:13:37 1988 --- Makefile Thu Aug 25 14:56:36 1988 *************** *** 5,10 # # @(#)Makefile 5.1 (Berkeley) 6/6/85 # RDIST = /usr/ucb/rdist DESTDIR= SRCS = docmd.c expand.c gram.y lookup.c main.c server.c --- 5,11 ----- # # @(#)Makefile 5.1 (Berkeley) 6/6/85 # + # System 5 sites should look at Berklib.c RDIST = /usr/ucb/rdist # RSH is needed for System 5 machines only RSH= /usr/ucb/rsh *************** *** 6,11 # @(#)Makefile 5.1 (Berkeley) 6/6/85 # RDIST = /usr/ucb/rdist DESTDIR= SRCS = docmd.c expand.c gram.y lookup.c main.c server.c OBJS = docmd.o expand.o gram.o lookup.o main.o server.o --- 7,14 ----- # # System 5 sites should look at Berklib.c RDIST = /usr/ucb/rdist + # RSH is needed for System 5 machines only + RSH= /usr/ucb/rsh DESTDIR= SRCS = docmd.c expand.c gram.y lookup.c main.c server.c Berklib.c regex.c OBJS = docmd.o expand.o gram.o lookup.o main.o server.o Berklib.o regex.o *************** *** 7,16 # RDIST = /usr/ucb/rdist DESTDIR= ! SRCS = docmd.c expand.c gram.y lookup.c main.c server.c ! OBJS = docmd.o expand.o gram.o lookup.o main.o server.o ! LINT = lint -ps ! CFLAGS= -O -DRDIST=\"${RDIST}\" rdist: ${OBJS} ${CC} -o rdist ${OBJS} --- 10,23 ----- # RSH is needed for System 5 machines only RSH= /usr/ucb/rsh DESTDIR= ! SRCS = docmd.c expand.c gram.y lookup.c main.c server.c Berklib.c regex.c ! OBJS = docmd.o expand.o gram.o lookup.o main.o server.o Berklib.o regex.o ! LIBS = -lbsd ! LINT = lint ! #CFLAGS= -O -DRDIST=\"${RDIST}\" ! # the following is for System 5 machines ! CFLAGS= -O -DRDIST=\"${RDIST}\" \ ! -DSYS5 -DHAS_RENAME -DHAS_LSTAT -DRSH=\"${RSH}\" -I/usr/include/bsd rdist: ${OBJS} ${CC} -o rdist ${OBJS} ${LIBS} *************** *** 13,19 CFLAGS= -O -DRDIST=\"${RDIST}\" rdist: ${OBJS} ! ${CC} -o rdist ${OBJS} ${OBJS}: defs.h --- 20,26 ----- -DSYS5 -DHAS_RENAME -DHAS_LSTAT -DRSH=\"${RSH}\" -I/usr/include/bsd rdist: ${OBJS} ! ${CC} -o rdist ${OBJS} ${LIBS} ${OBJS}: defs.h *************** *** 24,30 install -s -m 4751 rdist ${DESTDIR}${RDIST} lint: docmd.c expand.c gram.c lookup.c main.c server.c ! ${LINT} docmd.c expand.c gram.c lookup.c main.c server.c print: ${SRCS} lpr -p ${SRCS} defs.h --- 31,37 ----- install -s -m 4751 rdist ${DESTDIR}${RDIST} lint: docmd.c expand.c gram.c lookup.c main.c server.c ! ${LINT} ${CFLAGS} docmd.c expand.c gram.c lookup.c main.c server.c print: ${SRCS} lpr -p ${SRCS} defs.h RCS file: RCS/defs.h,v retrieving revision 1.1 diff -c -r1.1 defs.h *** /tmp/,RCSt1a03700 Thu Aug 25 15:13:38 1988 --- defs.h Thu Aug 25 14:52:04 1988 *************** *** 17,22 #include #include /* * The version number should be changed whenever the protocol changes. */ --- 17,42 ----- #include #include + # ifdef SYS5 + /* signal.h not included in sys/param.h */ + # include + /* avoid conflict of stdio routine named tmpfile */ + # define tmpfile rdtmpfile + /* get sys5 equivalent string functions */ + # define index strchr + # define rindex strrchr + # include + # define bzero(a,c) memset(a,c,'\0') + # define bcopy(a,b,c) memcpy(b,a,c) + # define bcmp memcmp + + extern struct passwd *getpwent(), *getpwnam(), *getpwuid(); + extern struct group *getgrent(), *getgrnam(), *getgrgid(); + # if !defined(HAS_LSTAT) && !defined(S_IFLNK) + # define S_IFLNK 0120000 + # endif + # endif + /* * The version number should be changed whenever the protocol changes. */ *************** *** 110,115 extern int options; /* global options */ extern int nerrs; /* number of errors seen */ extern int rem; /* remote file descriptor */ extern int iamremote; /* acting as remote server */ extern char tmpfile[]; /* file name for logging changes */ --- 130,138 ----- extern int options; /* global options */ extern int nerrs; /* number of errors seen */ + # ifdef SYS5 + extern int irem, orem; /* remote file descriptor */ + # else extern int rem; /* remote file descriptor */ # define irem rem # define orem rem *************** *** 111,116 extern int nerrs; /* number of errors seen */ extern int rem; /* remote file descriptor */ extern int iamremote; /* acting as remote server */ extern char tmpfile[]; /* file name for logging changes */ extern struct linkbuf *ihead; /* list of files with more than one link */ --- 134,142 ----- extern int irem, orem; /* remote file descriptor */ # else extern int rem; /* remote file descriptor */ + # define irem rem + # define orem rem + # endif extern int iamremote; /* acting as remote server */ extern char tmpfile[]; /* file name for logging changes */ extern struct linkbuf *ihead; /* list of files with more than one link */ RCS file: RCS/docmd.c,v retrieving revision 1.1 diff -c -r1.1 docmd.c *** /tmp/,RCSt1a03705 Thu Aug 25 15:13:39 1988 --- docmd.c Tue Aug 16 19:06:24 1988 *************** *** 175,181 if (debug) printf("makeconn(%s)\n", rhost); ! if (cur_host != NULL && rem >= 0) { if (strcmp(cur_host, rhost) == 0) return(1); closeconn(); --- 175,181 ----- if (debug) printf("makeconn(%s)\n", rhost); ! if (cur_host != NULL && irem >= 0) { if (strcmp(cur_host, rhost) == 0) return(1); closeconn(); *************** *** 199,204 if (!qflag) printf("updating host %s\n", rhost); (void) sprintf(buf, "%s -Server%s", RDIST, qflag ? " -q" : ""); if (port < 0) { struct servent *sp; --- 199,207 ----- if (!qflag) printf("updating host %s\n", rhost); (void) sprintf(buf, "%s -Server%s", RDIST, qflag ? " -q" : ""); + #ifdef SYS5 + dorsh(rhost, ruser, buf); + #else if (port < 0) { struct servent *sp; *************** *** 216,222 setreuid(userid, 0); rem = rcmd(&rhost, port, user, ruser, buf, 0); setreuid(0, userid); ! if (rem < 0) return(0); cp = buf; if (read(rem, cp, 1) != 1) --- 219,226 ----- setreuid(userid, 0); rem = rcmd(&rhost, port, user, ruser, buf, 0); setreuid(0, userid); ! #endif /* !SYS5 */ ! if (irem < 0) return(0); cp = buf; if (read(irem, cp, 1) != 1) *************** *** 219,225 if (rem < 0) return(0); cp = buf; ! if (read(rem, cp, 1) != 1) lostconn(); if (*cp == 'V') { do { --- 223,229 ----- if (irem < 0) return(0); cp = buf; ! if (read(irem, cp, 1) != 1) lostconn(); if (*cp == 'V') { do { *************** *** 223,229 lostconn(); if (*cp == 'V') { do { ! if (read(rem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); *--cp = '\0'; --- 227,233 ----- lostconn(); if (*cp == 'V') { do { ! if (read(irem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); *--cp = '\0'; *************** *** 248,257 if (debug) printf("closeconn()\n"); ! if (rem >= 0) { ! (void) write(rem, "\2\n", 2); ! (void) close(rem); ! rem = -1; } } --- 252,265 ----- if (debug) printf("closeconn()\n"); ! if (orem >= 0) { ! (void) write(orem, "\2\n", 2); ! (void) close(orem); ! orem = -1; ! # ifdef SYS5 ! (void) close(irem); ! irem = -1; ! # endif } } *************** *** 577,579 } return(0); } --- 585,625 ----- } return(0); } + + # ifdef SYS5 + + dorsh(rhost, ruser, cmd) + char *rhost, *ruser, *cmd; + { + int pid, to_rsh_input[2], from_rsh_output[2]; + char *argv[5]; + + pipe(to_rsh_input); + pipe(from_rsh_output); + if ((pid = fork()) < 0) + return; + if (pid == 0) { + dup2(to_rsh_input[0], 0); + dup2(from_rsh_output[1], 1); + (void) close(to_rsh_input[0]); + (void) close(to_rsh_input[1]); + (void) close(from_rsh_output[0]); + (void) close(from_rsh_output[1]); + + argv[0] = rhost; + argv[1] = "-l"; + argv[2] = ruser; + argv[3] = cmd; + argv[4] = NULL; + + execv(RSH, argv); + perror("execvp of rsh"); + abort(); + /* NOTREACHED */ + } + irem = from_rsh_output[0]; + orem = to_rsh_input[1]; + (void) close(to_rsh_input[0]); + (void) close(from_rsh_output[1]); + } + #endif /* SYS5 */ RCS file: RCS/main.c,v retrieving revision 1.1 diff -c -r1.1 main.c *** /tmp/,RCSt1a03710 Thu Aug 25 15:13:40 1988 --- main.c Tue Aug 16 19:06:23 1988 *************** *** 33,38 int iamremote; /* act as remote server for transfering files */ FILE *fin = NULL; /* input file pointer */ int rem = -1; /* file descriptor to remote source/sink process */ char host[32]; /* host name */ int nerrs; /* number of errors while sending/receiving */ --- 33,42 ----- int iamremote; /* act as remote server for transfering files */ FILE *fin = NULL; /* input file pointer */ + # ifdef SYS5 + int irem = -1; /* file descriptor to remote source/sink process */ + int orem = -1; /* file descriptor to remote source/sink process */ + # else int rem = -1; /* file descriptor to remote source/sink process */ # endif char host[32]; /* host name */ *************** *** 34,39 FILE *fin = NULL; /* input file pointer */ int rem = -1; /* file descriptor to remote source/sink process */ char host[32]; /* host name */ int nerrs; /* number of errors while sending/receiving */ char user[10]; /* user's name */ --- 38,44 ----- int orem = -1; /* file descriptor to remote source/sink process */ # else int rem = -1; /* file descriptor to remote source/sink process */ + # endif char host[32]; /* host name */ int nerrs; /* number of errors while sending/receiving */ char user[10]; /* user's name */ *************** *** 151,156 } *hp = NULL; setreuid(0, userid); mktemp(tmpfile); --- 156,162 ----- } *hp = NULL; + #ifndef SYS5 setreuid(0, userid); #endif mktemp(tmpfile); *************** *** 152,157 *hp = NULL; setreuid(0, userid); mktemp(tmpfile); if (iamremote) { --- 158,164 ----- #ifndef SYS5 setreuid(0, userid); + #endif mktemp(tmpfile); if (iamremote) { RCS file: RCS/server.c,v retrieving revision 1.1 diff -c -r1.1 server.c *** /tmp/,RCSt1a03715 Thu Aug 25 15:13:42 1988 --- server.c Thu Aug 25 14:52:09 1988 *************** *** 10,17 #include "defs.h" ! #define ack() (void) write(rem, "\0\n", 2) ! #define err() (void) write(rem, "\1\n", 2) struct linkbuf *ihead; /* list of files with more than one link */ char buf[BUFSIZ]; /* general purpose buffer */ --- 10,17 ----- #include "defs.h" ! #define ack() (void) write(orem, "\0\n", 2) ! #define err() (void) write(orem, "\1\n", 2) struct linkbuf *ihead; /* list of files with more than one link */ char buf[BUFSIZ]; /* general purpose buffer */ *************** *** 45,51 signal(SIGTERM, cleanup); signal(SIGPIPE, cleanup); ! rem = 0; oumask = umask(0); (void) sprintf(buf, "V%d\n", VERSION); (void) write(rem, buf, strlen(buf)); --- 45,54 ----- signal(SIGTERM, cleanup); signal(SIGPIPE, cleanup); ! irem = 0; ! # ifdef SYS5 ! orem = 1; ! # endif oumask = umask(0); (void) sprintf(buf, "V%d\n", VERSION); (void) write(orem, buf, strlen(buf)); *************** *** 48,54 rem = 0; oumask = umask(0); (void) sprintf(buf, "V%d\n", VERSION); ! (void) write(rem, buf, strlen(buf)); for (;;) { cp = cmdbuf; --- 51,57 ----- # endif oumask = umask(0); (void) sprintf(buf, "V%d\n", VERSION); ! (void) write(orem, buf, strlen(buf)); for (;;) { cp = cmdbuf; *************** *** 52,58 for (;;) { cp = cmdbuf; ! if (read(rem, cp, 1) <= 0) return; if (*cp++ == '\n') { error("server: expected control record\n"); --- 55,61 ----- for (;;) { cp = cmdbuf; ! if (read(irem, cp, 1) <= 0) return; if (*cp++ == '\n') { error("server: expected control record\n"); *************** *** 59,65 continue; } do { ! if (read(rem, cp, 1) != 1) cleanup(); } while (*cp++ != '\n' && cp < &cmdbuf[BUFSIZ]); *--cp = '\0'; --- 62,68 ----- continue; } do { ! if (read(irem, cp, 1) != 1) cleanup(); } while (*cp++ != '\n' && cp < &cmdbuf[BUFSIZ]); *--cp = '\0'; *************** *** 234,240 (void) sprintf(buf, "%c%s\n", destdir ? 'T' : 't', dest); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); if (response() < 0) return; --- 237,243 ----- (void) sprintf(buf, "%c%s\n", destdir ? 'T' : 't', dest); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); if (response() < 0) return; *************** *** 312,318 stb.st_mode & 07777, protoname(), protogroup(), rname); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); if (response() < 0) { closedir(d); return; --- 315,321 ----- stb.st_mode & 07777, protoname(), protogroup(), rname); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); if (response() < 0) { closedir(d); return; *************** *** 341,347 sendf(dp->d_name, opts); } closedir(d); ! (void) write(rem, "E\n", 2); (void) response(); tp = otp; *tp = '\0'; --- 344,350 ----- sendf(dp->d_name, opts); } closedir(d); ! (void) write(orem, "E\n", 2); (void) response(); tp = otp; *tp = '\0'; *************** *** 348,353 return; case S_IFLNK: if (u != 1) opts |= COMPARE; if (stb.st_nlink > 1) { --- 351,359 ----- return; case S_IFLNK: + # ifndef HAS_LSTAT + return; /* should never happen */ + # else if (u != 1) opts |= COMPARE; if (stb.st_nlink > 1) { *************** *** 363,369 lp->target, lp->pathname, rname); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); (void) response(); return; } --- 369,375 ----- lp->target, lp->pathname, rname); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); (void) response(); return; } *************** *** 373,379 protoname(), protogroup(), rname); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); if (response() < 0) return; sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size); --- 379,385 ----- protoname(), protogroup(), rname); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); if (response() < 0) return; sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size); *************** *** 377,383 if (response() < 0) return; sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size); ! (void) write(rem, buf, stb.st_size); if (debug) printf("readlink = %.*s\n", stb.st_size, buf); goto done; --- 383,389 ----- if (response() < 0) return; sizerr = (readlink(target, buf, BUFSIZ) != stb.st_size); ! (void) write(orem, buf, stb.st_size); if (debug) printf("readlink = %.*s\n", stb.st_size, buf); goto done; *************** *** 381,386 if (debug) printf("readlink = %.*s\n", stb.st_size, buf); goto done; case S_IFREG: break; --- 387,393 ----- if (debug) printf("readlink = %.*s\n", stb.st_size, buf); goto done; + # endif case S_IFREG: break; *************** *** 411,417 lp->target, lp->pathname, rname); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); (void) response(); return; } --- 418,424 ----- lp->target, lp->pathname, rname); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); (void) response(); return; } *************** *** 426,432 protoname(), protogroup(), rname); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); if (response() < 0) { (void) close(f); return; --- 433,439 ----- protoname(), protogroup(), rname); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); if (response() < 0) { (void) close(f); return; *************** *** 438,444 amt = stb.st_size - i; if (sizerr == 0 && read(f, buf, amt) != amt) sizerr = 1; ! (void) write(rem, buf, amt); } (void) close(f); done: --- 445,451 ----- amt = stb.st_size - i; if (sizerr == 0 && read(f, buf, amt) != amt) sizerr = 1; ! (void) write(orem, buf, amt); } (void) close(f); done: *************** *** 462,468 (void) sprintf(buf, "SFILE=%s;%s\n", target, sc->sc_name); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); while (response() > 0) ; } --- 469,475 ----- (void) sprintf(buf, "SFILE=%s;%s\n", target, sc->sc_name); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); while (response() > 0) ; } *************** *** 521,527 (void) sprintf(buf, "Q%s\n", rname); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); again: cp = s = buf; do { --- 528,534 ----- (void) sprintf(buf, "Q%s\n", rname); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); again: cp = s = buf; do { *************** *** 525,531 again: cp = s = buf; do { ! if (read(rem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); --- 532,538 ----- again: cp = s = buf; do { ! if (read(irem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); *************** *** 612,618 if (lstat(target, &stb) < 0) { if (errno == ENOENT) ! (void) write(rem, "N\n", 2); else error("%s:%s: %s\n", host, target, sys_errlist[errno]); *tp = '\0'; --- 619,625 ----- if (lstat(target, &stb) < 0) { if (errno == ENOENT) ! (void) write(orem, "N\n", 2); else error("%s:%s: %s\n", host, target, sys_errlist[errno]); *tp = '\0'; *************** *** 622,628 switch (stb.st_mode & S_IFMT) { case S_IFREG: (void) sprintf(buf, "Y%ld %ld\n", stb.st_size, stb.st_mtime); ! (void) write(rem, buf, strlen(buf)); break; case S_IFLNK: --- 629,635 ----- switch (stb.st_mode & S_IFMT) { case S_IFREG: (void) sprintf(buf, "Y%ld %ld\n", stb.st_size, stb.st_mtime); ! (void) write(orem, buf, strlen(buf)); break; case S_IFLNK: *************** *** 627,633 case S_IFLNK: case S_IFDIR: ! (void) write(rem, "Y\n", 2); break; default: --- 634,640 ----- case S_IFLNK: case S_IFDIR: ! (void) write(orem, "Y\n", 2); break; default: *************** *** 724,730 (void) sprintf(buf + 1, "%s: Warning: remote mode %o != local mode %o\n", target, stb.st_mode & 07777, mode); ! (void) write(rem, buf, strlen(buf + 1) + 1); return; } errno = ENOTDIR; --- 731,737 ----- (void) sprintf(buf + 1, "%s: Warning: remote mode %o != local mode %o\n", target, stb.st_mode & 07777, mode); ! (void) write(orem, buf, strlen(buf + 1) + 1); return; } errno = ENOTDIR; *************** *** 756,761 if (type == S_IFLNK) { int j; ack(); cp = buf; for (i = 0; i < size; i += j) { --- 763,772 ----- if (type == S_IFLNK) { int j; + # ifndef HAS_LSTAT + error("symbolic links are not supported"); + return; + # else ack(); cp = buf; for (i = 0; i < size; i += j) { *************** *** 759,765 ack(); cp = buf; for (i = 0; i < size; i += j) { ! if ((j = read(rem, cp, size - i)) <= 0) cleanup(); cp += j; } --- 770,776 ----- ack(); cp = buf; for (i = 0; i < size; i += j) { ! if ((j = read(irem, cp, size - i)) <= 0) cleanup(); cp += j; } *************** *** 787,792 goto differ; } goto fixup; } if ((f = creat(new, mode)) < 0) { --- 798,804 ----- goto differ; } goto fixup; + # endif } if ((f = creat(new, mode)) < 0) { *************** *** 804,810 if (i + amt > size) amt = size - i; do { ! int j = read(rem, cp, amt); if (j <= 0) { (void) close(f); --- 816,822 ----- if (i + amt > size) amt = size - i; do { ! int j = read(irem, cp, amt); if (j <= 0) { (void) close(f); *************** *** 860,866 (void) unlink(new); buf[0] = '\0'; (void) sprintf(buf + 1, "need to update: %s\n",target); ! (void) write(rem, buf, strlen(buf + 1) + 1); return; } } --- 872,878 ----- (void) unlink(new); buf[0] = '\0'; (void) sprintf(buf + 1, "need to update: %s\n",target); ! (void) write(orem, buf, strlen(buf + 1) + 1); return; } } *************** *** 889,895 if (opts & COMPARE) { buf[0] = '\0'; (void) sprintf(buf + 1, "updated %s\n", target); ! (void) write(rem, buf, strlen(buf + 1) + 1); } else ack(); } --- 901,907 ----- if (opts & COMPARE) { buf[0] = '\0'; (void) sprintf(buf + 1, "updated %s\n", target); ! (void) write(orem, buf, strlen(buf + 1) + 1); } else ack(); } *************** *** 1025,1030 } else gid = gr->gr_gid; if (userid && gid >= 0) { if (gr) for (i = 0; gr->gr_mem[i] != NULL; i++) if (!(strcmp(user, gr->gr_mem[i]))) goto ok; --- 1037,1044 ----- } else gid = gr->gr_gid; if (userid && gid >= 0) { + if (pw && gid == pw->pw_gid) + goto ok; if (gr) for (i = 0; gr->gr_mem[i] != NULL; i++) if (!(strcmp(user, gr->gr_mem[i]))) goto ok; *************** *** 1032,1037 gid = -1; } ok: if (userid) setreuid(userid, 0); if (chown(file, uid, gid) < 0 || --- 1046,1052 ----- gid = -1; } ok: + #ifndef SYS5 if (userid) setreuid(userid, 0); #endif *************** *** 1034,1039 ok: if (userid) setreuid(userid, 0); if (chown(file, uid, gid) < 0 || (mode & 06000) && chmod(file, mode) < 0) { note("%s: chown or chmod failed: file %s: %s", --- 1049,1055 ----- #ifndef SYS5 if (userid) setreuid(userid, 0); + #endif if (chown(file, uid, gid) < 0 || (mode & 06000) && chmod(file, mode) < 0) { note("%s: chown or chmod failed: file %s: %s", *************** *** 1039,1044 note("%s: chown or chmod failed: file %s: %s", host, file, sys_errlist[errno]); } if (userid) setreuid(0, userid); return(0); --- 1055,1061 ----- note("%s: chown or chmod failed: file %s: %s", host, file, sys_errlist[errno]); } + #ifndef SYS5 if (userid) setreuid(0, userid); #endif *************** *** 1041,1046 } if (userid) setreuid(0, userid); return(0); } --- 1058,1064 ----- #ifndef SYS5 if (userid) setreuid(0, userid); + #endif return(0); } *************** *** 1063,1069 (void) sprintf(buf, "C%o\n", opts & VERIFY); if (debug) printf("buf = %s", buf); ! (void) write(rem, buf, strlen(buf)); if (response() < 0) return; for (;;) { --- 1081,1087 ----- (void) sprintf(buf, "C%o\n", opts & VERIFY); if (debug) printf("buf = %s", buf); ! (void) write(orem, buf, strlen(buf)); if (response() < 0) return; for (;;) { *************** *** 1069,1075 for (;;) { cp = s = buf; do { ! if (read(rem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); --- 1087,1093 ----- for (;;) { cp = s = buf; do { ! if (read(irem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); *************** *** 1085,1091 if (debug) printf("check %s\n", target); if (except(target)) ! (void) write(rem, "N\n", 2); else if (lstat(target, &stb) < 0) (void) write(rem, "Y\n", 2); else --- 1103,1109 ----- if (debug) printf("check %s\n", target); if (except(target)) ! (void) write(orem, "N\n", 2); else if (lstat(target, &stb) < 0) (void) write(orem, "Y\n", 2); else *************** *** 1087,1093 if (except(target)) (void) write(rem, "N\n", 2); else if (lstat(target, &stb) < 0) ! (void) write(rem, "Y\n", 2); else (void) write(rem, "N\n", 2); break; --- 1105,1111 ----- if (except(target)) (void) write(orem, "N\n", 2); else if (lstat(target, &stb) < 0) ! (void) write(orem, "Y\n", 2); else (void) write(orem, "N\n", 2); break; *************** *** 1089,1095 else if (lstat(target, &stb) < 0) (void) write(rem, "Y\n", 2); else ! (void) write(rem, "N\n", 2); break; case '\0': --- 1107,1113 ----- else if (lstat(target, &stb) < 0) (void) write(orem, "Y\n", 2); else ! (void) write(orem, "N\n", 2); break; case '\0': *************** *** 1172,1178 continue; } (void) sprintf(buf, "Q%s\n", dp->d_name); ! (void) write(rem, buf, strlen(buf)); cp = buf; do { if (read(rem, cp, 1) != 1) --- 1190,1196 ----- continue; } (void) sprintf(buf, "Q%s\n", dp->d_name); ! (void) write(orem, buf, strlen(buf)); cp = buf; do { if (read(irem, cp, 1) != 1) *************** *** 1175,1181 (void) write(rem, buf, strlen(buf)); cp = buf; do { ! if (read(rem, cp, 1) != 1) cleanup(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); *--cp = '\0'; --- 1193,1199 ----- (void) write(orem, buf, strlen(buf)); cp = buf; do { ! if (read(irem, cp, 1) != 1) cleanup(); } while (*cp++ != '\n' && cp < &buf[BUFSIZ]); *--cp = '\0'; *************** *** 1186,1192 cp = buf; *cp++ = '\0'; (void) sprintf(cp, "need to remove: %s\n", target); ! (void) write(rem, buf, strlen(cp) + 1); } else remove(&stb); } --- 1204,1210 ----- cp = buf; *cp++ = '\0'; (void) sprintf(cp, "need to remove: %s\n", target); ! (void) write(orem, buf, strlen(cp) + 1); } else remove(&stb); } *************** *** 1191,1197 remove(&stb); } closedir(d); ! (void) write(rem, "E\n", 2); (void) response(); tp = otp; *tp = '\0'; --- 1209,1215 ----- remove(&stb); } closedir(d); ! (void) write(orem, "E\n", 2); (void) response(); tp = otp; *tp = '\0'; *************** *** 1263,1269 cp = buf; *cp++ = '\0'; (void) sprintf(cp, "removed %s\n", target); ! (void) write(rem, buf, strlen(cp) + 1); } /* --- 1281,1287 ----- cp = buf; *cp++ = '\0'; (void) sprintf(cp, "removed %s\n", target); ! (void) write(orem, buf, strlen(cp) + 1); } /* *************** *** 1317,1323 s--; continue; } ! (void) write(rem, sbuf, s - sbuf); s = &sbuf[1]; } while (--i); } --- 1335,1341 ----- s--; continue; } ! (void) write(orem, sbuf, s - sbuf); s = &sbuf[1]; } while (--i); } *************** *** 1323,1329 } if (s > &sbuf[1]) { *s++ = '\n'; ! (void) write(rem, sbuf, s - sbuf); } while ((i = wait(&status)) != pid && i != -1) ; --- 1341,1347 ----- } if (s > &sbuf[1]) { *s++ = '\n'; ! (void) write(orem, sbuf, s - sbuf); } while ((i = wait(&status)) != pid && i != -1) ; *************** *** 1363,1369 fflush(stdout); (void) write(2, buf+1, strlen(buf+1)); } else ! (void) write(rem, buf, strlen(buf)); if (lfp != NULL) (void) fwrite(buf+1, 1, strlen(buf+1), lfp); } --- 1381,1387 ----- fflush(stdout); (void) write(2, buf+1, strlen(buf+1)); } else ! (void) write(orem, buf, strlen(buf)); if (lfp != NULL) (void) fwrite(buf+1, 1, strlen(buf+1), lfp); } *************** *** 1380,1386 fflush(stdout); (void) write(2, buf+1, strlen(buf+1)); } else ! (void) write(rem, buf, strlen(buf)); if (lfp != NULL) (void) fwrite(buf+1, 1, strlen(buf+1), lfp); cleanup(); --- 1398,1404 ----- fflush(stdout); (void) write(2, buf+1, strlen(buf+1)); } else ! (void) write(orem, buf, strlen(buf)); if (lfp != NULL) (void) fwrite(buf+1, 1, strlen(buf+1), lfp); cleanup(); *************** *** 1396,1402 cp = s = resp; do { ! if (read(rem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &resp[BUFSIZ]); --- 1414,1420 ----- cp = s = resp; do { ! if (read(irem, cp, 1) != 1) lostconn(); } while (*cp++ != '\n' && cp < &resp[BUFSIZ]); *************** *** 1453,1460 char *s; { char c = '\3'; ! write(rem, &c, 1); ! write(rem, s, strlen(s)); c = '\n'; write(rem, &c, 1); } --- 1471,1478 ----- char *s; { char c = '\3'; ! write(orem, &c, 1); ! write(orem, s, strlen(s)); c = '\n'; write(orem, &c, 1); } *************** *** 1456,1460 write(rem, &c, 1); write(rem, s, strlen(s)); c = '\n'; ! write(rem, &c, 1); } --- 1474,1478 ----- write(orem, &c, 1); write(orem, s, strlen(s)); c = '\n'; ! write(orem, &c, 1); } SHAR_EOF fi exit 0 # End of shell archive