=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/oldrdist/Attic/docmd.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/oldrdist/Attic/docmd.c 1996/06/26 05:37:38 1.3 --- src/usr.bin/oldrdist/Attic/docmd.c 1996/07/19 21:57:31 1.4 *************** *** 1,4 **** ! /* $OpenBSD: docmd.c,v 1.3 1996/06/26 05:37:38 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 --- 1,4 ---- ! /* $OpenBSD: docmd.c,v 1.4 1996/07/19 21:57:31 millert Exp $ */ /* * Copyright (c) 1983, 1993 *************** *** 35,41 **** #ifndef lint /* from: static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; */ ! static char *rcsid = "$OpenBSD: docmd.c,v 1.3 1996/06/26 05:37:38 deraadt Exp $"; #endif /* not lint */ #include "defs.h" --- 35,41 ---- #ifndef lint /* from: static char sccsid[] = "@(#)docmd.c 8.1 (Berkeley) 6/9/93"; */ ! static char *rcsid = "$OpenBSD: docmd.c,v 1.4 1996/07/19 21:57:31 millert Exp $"; #endif /* not lint */ #include "defs.h" *************** *** 161,168 **** for (cpp = filev; *cpp; cpp++) if (strcmp(f->n_name, *cpp) == 0) goto found; ! if (!nflag) (void) fclose(lfp); continue; } found: --- 161,170 ---- for (cpp = filev; *cpp; cpp++) if (strcmp(f->n_name, *cpp) == 0) goto found; ! if (!nflag && lfp) { (void) fclose(lfp); + lfp = NULL; + } continue; } found: *************** *** 181,187 **** done: if (!nflag) { (void) signal(SIGPIPE, cleanup); ! (void) fclose(lfp); lfp = NULL; } for (sc = cmds; sc != NULL; sc = sc->sc_next) --- 183,190 ---- done: if (!nflag) { (void) signal(SIGPIPE, cleanup); ! if (lfp) ! (void) fclose(lfp); lfp = NULL; } for (sc = cmds; sc != NULL; sc = sc->sc_next) *************** *** 208,214 **** --- 211,219 ---- { register char *ruser, *cp; static char *cur_host = NULL; + #if defined(DIRECT_RCMD) static int port = -1; + #endif /* DIRECT_RCMD */ char tuser[20]; int n; extern char user[]; *************** *** 223,229 **** closeconn(); } cur_host = rhost; ! cp = index(rhost, '@'); if (cp != NULL) { char c = *cp; --- 228,234 ---- closeconn(); } cur_host = rhost; ! cp = strchr(rhost, '@'); if (cp != NULL) { char c = *cp; *************** *** 241,246 **** --- 246,252 ---- if (!qflag) printf("updating host %s\n", rhost); (void) sprintf(buf, "%s -Server%s", _PATH_RDIST, qflag ? " -q" : ""); + #if defined(DIRECT_RCMD) if (port < 0) { struct servent *sp; *************** *** 248,263 **** --- 254,278 ---- fatal("shell/tcp: unknown service"); port = sp->s_port; } + #endif /* !DIRECT_RCMD */ if (debug) { + #if defined(DIRECT_RCMD) printf("port = %d, luser = %s, ruser = %s\n", ntohs(port), user, ruser); + #else /* !DIRECT_RCMD */ + printf("luser = %s, ruser = %s\n", user, ruser); + #endif /* !DIRECT_RCMD */ printf("buf = %s\n", buf); } fflush(stdout); + #if defined(DIRECT_RCMD) seteuid(0); rem = rcmd(&rhost, port, user, ruser, buf, 0); seteuid(userid); + #else /* !DIRECT_RCMD */ + rem = rshrcmd(&rhost, -1, user, ruser, buf, 0); + #endif /* !DIRECT_RCMD */ if (rem < 0) return(0); cp = buf; *************** *** 297,303 **** --- 312,321 ---- printf("closeconn()\n"); if (rem >= 0) { + void (*osig)(); + osig = signal(SIGPIPE, SIG_IGN); (void) write(rem, "\2\n", 2); + (void) signal(SIGPIPE, osig); (void) close(rem); rem = -1; } *************** *** 310,315 **** --- 328,337 ---- if (iamremote) cleanup(0); log(lfp, "rdist: lost connection\n"); + if (rem >= 0) { + (void) close(rem); + rem = -1; + } longjmp(env, 1); }