Summary for making sdist: - Take rdist-6.1.0 - Make the patches below - Write a front-end script "sdist", that essentially runs "rdist -P ssh" Sdist will later be merged into the distribution (probably in ssh-1.3.1). 12 January 1996 //ylo From ssh-owner@clinet.fi Mon Oct 16 21:05:04 1995 Subject: Re: Follow-up: rdist via ssh To: cbh@cs.washington.edu (craig horman) Date: Mon, 16 Oct 1995 20:05:04 +0100 (MET) In-Reply-To: from "craig horman" at Oct 15, 95 02:02:46 pm From: Thomas.Koenig@ciw.uni-karlsruhe.de (Thomas König) X-Mailer: ELM [version 2.4 PL24 ME8b] Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Content-Length: 7976 Sender: ig25@mvmampc66.ciw.uni-karlsruhe.de craig horman wrote: >The problem: rdistd writes to stdin (!?) when it begins dialogue with >the rdist client end. Please try the following patch, against stock rdist-6.1.0 (you might need to unapply the Linux patches before, with "patch -p1 -R < README.Linux", if you've got the Linux version of rdist), and see wether this helps. I'll forward this to the rdist maintainers if it works, but they haven't even integrated the other set of patches yet *sigh*. Thomas diff -u --recursive rdist-6.1.0/include/defs.h rdist-6.1.0-l2/include/defs.h --- rdist-6.1.0/include/defs.h Tue Apr 12 01:19:22 1994 +++ rdist-6.1.0-l2/include/defs.h Mon Oct 16 19:43:18 1995 @@ -325,7 +325,8 @@ extern opt_t options; /* Global options */ extern int proto_version; /* Protocol version number */ extern int realargc; /* Real argc */ -extern int rem; /* Remote file descriptor */ +extern int rem_r; /* Remote file descriptor, reading */ +extern int rem_w; /* Remote file descriptor, writing */ extern int rtimeout; /* Response time out in seconds */ extern UID_T userid; /* User ID of rdist user */ extern jmp_buf finish_jmpbuf; /* Setjmp buffer for finish() */ diff -u --recursive rdist-6.1.0/mf/Makefile.var rdist-6.1.0-l2/mf/Makefile.var --- rdist-6.1.0/mf/Makefile.var Tue Apr 12 01:20:17 1994 +++ rdist-6.1.0-l2/mf/Makefile.var Mon Jun 5 16:57:30 1995 @@ -95,7 +95,7 @@ # #YACC = bison -y -OPT = -g +OPT = -O2 -fomit-frame-pointer RM = rm AR = ar RANLIB = ranlib diff -u --recursive rdist-6.1.0/src/child.c rdist-6.1.0-l2/src/child.c --- rdist-6.1.0/src/child.c Thu Mar 31 04:56:26 1994 +++ rdist-6.1.0-l2/src/child.c Mon Jun 5 16:49:38 1995 @@ -203,8 +203,16 @@ debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %d bytes]", child->c_name, child->c_pid, child->c_readfd, amt); - write(fileno(stdout), rbuf, amt); - + { + int wamt=amt, ramt, woff=0; + while ((ramt = write(fileno(stdout), rbuf+woff, wamt)) > 0) { + woff += ramt; wamt -= ramt; + debugmsg(DM_MISC, + "[readchild(%s, %d, %d) only wrote %d/%d bytes]", + child->c_name, child->c_pid, child->c_readfd, + ramt, wamt); + } + } debugmsg(DM_MISC, "[readchild(%s, %d, %d) write done]", child->c_name, child->c_pid, child->c_readfd); } diff -u --recursive rdist-6.1.0/src/client.c rdist-6.1.0-l2/src/client.c --- rdist-6.1.0/src/client.c Fri Apr 22 19:24:01 1994 +++ rdist-6.1.0-l2/src/client.c Mon Oct 16 19:44:27 1995 @@ -429,12 +429,18 @@ * this situation gracefully. */ } - if (write(rem, buf, amt) == -1) { - error("%s: Error writing to client: %s", - target, SYSERR); - err(); - ++goterr; - break; + { + int ramt, wamt=amt, woff=0; + while((ramt=write(rem_w,buf+woff,wamt)) > 0) { + woff += ramt; wamt -= ramt; + } + if (ramt < 0) { + error("%s: Error writing to client: %s", + target, SYSERR); + err(); + ++goterr; + break; + } } (void) alarm(0); } diff -u --recursive rdist-6.1.0/src/common.c rdist-6.1.0-l2/src/common.c --- rdist-6.1.0/src/common.c Wed Apr 20 20:11:03 1994 +++ rdist-6.1.0-l2/src/common.c Mon Oct 16 19:53:09 1995 @@ -64,7 +64,8 @@ int do_fork = 1; /* Fork child process */ char *currenthost = NULL; /* Current client hostname */ char *progname = NULL; /* Name of this program */ -int rem = -1; /* Client file descriptor */ +int rem_r = -1; /* Client file descriptor */ +int rem_w = -1; /* Client file descriptor */ struct passwd *pw = NULL; /* Local user's pwd entry */ int contimedout = FALSE; /* Connection timed out */ int proto_version = -1; /* Protocol version */ @@ -176,7 +177,7 @@ /* Prevent looping */ (void) signal(SIGPIPE, SIG_IGN); - rem = -1; /* Ensure we don't try to send to server */ + rem_r = rem_w = -1; /* Ensure we don't try to send to server */ checkhostname(); error("Lost connection to %s", (currenthost) ? currenthost : "(unknown)"); @@ -247,7 +248,7 @@ { int len; - if (rem < 0) + if (rem_w < 0) return(-1); /* @@ -268,7 +269,13 @@ (cmd == C_NONE) ? len-1 : len-2, (cmd == C_NONE) ? msg : msg + 1); - return(!(write(rem, msg, len) == len)); + { + int ramt, wamt=len, woff=0; + while((ramt = write(rem_w,msg+woff,wamt)) > 0) { + woff += ramt; wamt -= ramt; + } + return ramt<0; + } } /* @@ -368,7 +375,7 @@ (void) signal(SIGALRM, sighandler); (void) alarm(rtimeout); - remleft = remread(rem, rembuf, sizeof(rembuf)); + remleft = remread(rem_r, rembuf, sizeof(rembuf)); (void) alarm(0); @@ -396,7 +403,7 @@ register int c, left = space; register u_char *p = buffer; - if (rem < 0) { + if (rem_r < 0) { error("Cannot read remote input: Remote descriptor not open."); return(-1); } @@ -460,7 +467,7 @@ (void) signal(SIGALRM, sighandler); (void) alarm(rtimeout); - remleft = remread(rem, rembuf, sizeof(rembuf)); + remleft = remread(rem_r, rembuf, sizeof(rembuf)); (void) alarm(0); remptr = rembuf; @@ -808,7 +815,7 @@ continue; } if (isserver) - (void) write(rem, sbuf, s - sbuf); + (void) write(rem_w, sbuf, s - sbuf); else { *s = CNULL; message(MT_INFO, "%s", sbuf+1); @@ -819,7 +826,7 @@ if (s > (char *) &sbuf[1]) { *s++ = '\n'; if (isserver) - (void) write(rem, sbuf, s - sbuf); + (void) write(rem_w, sbuf, s - sbuf); else { *s = CNULL; message(MT_INFO, "%s", sbuf+1); @@ -885,7 +892,7 @@ } extern char *basename(path) - char *path; + const char *path; { register char *cp; diff -u --recursive rdist-6.1.0/src/docmd.c rdist-6.1.0-l2/src/docmd.c --- rdist-6.1.0/src/docmd.c Tue Apr 26 19:10:09 1994 +++ rdist-6.1.0-l2/src/docmd.c Mon Oct 16 19:47:20 1995 @@ -72,13 +72,15 @@ { debugmsg(DM_CALL, "closeconn() called\n"); - if (rem >= 0) { + if (rem_w >= 0) { /* We don't care if the connection is still good or not */ signal(SIGPIPE, SIG_IGN); (void) sendcmd(C_FERRMSG, NULL); - (void) close(rem); - rem = -1; + (void) close(rem_w); + (void) close(rem_r); /* This can't hurt */ + rem_w = -1; + rem_r = -1; } } @@ -313,7 +315,7 @@ /* * See if we're already connected to this host */ - if (cur_host != NULL && rem >= 0) { + if (cur_host != NULL && rem_w >= 0) { if (strcmp(cur_host, rhost) == 0) return(1); closeconn(); @@ -345,7 +347,7 @@ (void) sprintf(buf, "%.*s -S", sizeof(buf)-5, path_rdistd); - if ((rem = remotecmd(rhost, locuser, ruser, buf)) < 0) + if ((rem_r = rem_w = remotecmd(rhost, locuser, ruser, buf)) < 0) return(0); /* diff -u --recursive rdist-6.1.0/src/message.c rdist-6.1.0-l2/src/message.c --- rdist-6.1.0/src/message.c Wed Apr 20 19:53:29 1994 +++ rdist-6.1.0-l2/src/message.c Mon Oct 16 19:48:25 1995 @@ -325,7 +325,7 @@ char cmd; if (isserver) { - if (rem < 0 || IS_ON(flags, MT_NOREMOTE)) + if (rem_w < 0 || IS_ON(flags, MT_NOREMOTE)) return; cmd = CNULL; diff -u --recursive rdist-6.1.0/src/rdistd.c rdist-6.1.0-l2/src/rdistd.c --- rdist-6.1.0/src/rdistd.c Sat Feb 26 00:53:38 1994 +++ rdist-6.1.0-l2/src/rdistd.c Mon Oct 16 19:53:52 1995 @@ -95,8 +95,9 @@ exit(1); } - /* Use stdin for remote descriptor */ - rem = fileno(stdin); + /* Use stdin and stdout for remote descriptors */ + rem_r = fileno(stdin); + rem_w = fileno(stdout); /* Set logging */ if (cp = msgparseopts(localmsglist, TRUE)) diff -u --recursive rdist-6.1.0/src/server.c rdist-6.1.0-l2/src/server.c --- rdist-6.1.0/src/server.c Tue Apr 26 18:58:56 1994 +++ rdist-6.1.0-l2/src/server.c Mon Jun 5 17:03:51 1995 @@ -230,7 +230,7 @@ } else gid = gr->gr_gid; - if (userid && gid >= 0 && gid != primegid) { + if (userid && gid >= 0x7fff && gid != primegid) { if (gr) for (i = 0; gr->gr_mem[i] != NULL; i++) if (strcmp(locuser, gr->gr_mem[i]) == 0) -- Thomas König, Thomas.Koenig@ciw.uni-karlsruhe.de, ig25@dkauni2.bitnet. The joy of engineering is to find a straight line on a double logarithmic diagram.