X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/80babee1e855bed4cc8fca4d1bb7e23c23f9ac06..bf766a3770736e890c75df2a66b09b4a40baca69:/usr/src/usr.bin/rdist/docmd.c diff --git a/usr/src/usr.bin/rdist/docmd.c b/usr/src/usr.bin/rdist/docmd.c index 0c744126b5..448c707a59 100644 --- a/usr/src/usr.bin/rdist/docmd.c +++ b/usr/src/usr.bin/rdist/docmd.c @@ -1,13 +1,27 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + #ifndef lint -static char *sccsid = "@(#)docmd.c 4.22 (Berkeley) 84/12/06"; -#endif +static char sccsid[] = "@(#)docmd.c 5.4 (Berkeley) %G%"; +#endif /* not lint */ #include "defs.h" #include - -#ifndef RDIST -#define RDIST "/usr/local/rdist" -#endif +#include FILE *lfp; /* log file for recording files updated */ struct subcmd *subcmds; /* list of sub-commands for current cmd */ @@ -19,7 +33,8 @@ int lostconn(); /* * Do the commands in cmds (initialized by yyparse). */ -docmds(argc, argv) +docmds(dhosts, argc, argv) + char **dhosts; int argc; char **argv; { @@ -34,6 +49,13 @@ docmds(argc, argv) signal(SIGTERM, cleanup); for (c = cmds; c != NULL; c = c->c_next) { + if (dhosts != NULL && *dhosts != NULL) { + for (cpp = dhosts; *cpp; cpp++) + if (strcmp(c->c_name, *cpp) == 0) + goto fndhost; + continue; + } + fndhost: if (argc) { for (cpp = argv; *cpp; cpp++) { if (c->c_label != NULL && @@ -151,6 +173,8 @@ makeconn(rhost) { register char *ruser, *cp; static char *cur_host = NULL; + static int port = -1; + char tuser[20]; int n; extern char user[]; extern int userid; @@ -163,27 +187,41 @@ makeconn(rhost) return(1); closeconn(); } - - ruser = rindex(rhost, '.'); - if (ruser != NULL) { - *ruser++ = '\0'; - if (!okname(ruser)) + cur_host = rhost; + cp = index(rhost, '@'); + if (cp != NULL) { + char c = *cp; + + *cp = '\0'; + strncpy(tuser, rhost, sizeof(tuser)-1); + *cp = c; + rhost = cp + 1; + ruser = tuser; + if (*ruser == '\0') + ruser = user; + else if (!okname(ruser)) return(0); } else ruser = user; if (!qflag) printf("updating host %s\n", rhost); - (void) sprintf(buf, "%s -Server%s", RDIST, qflag ? " -q" : ""); + (void) sprintf(buf, "%s -Server%s", _PATH_RDIST, qflag ? " -q" : ""); + if (port < 0) { + struct servent *sp; + + if ((sp = getservbyname("shell", "tcp")) == NULL) + fatal("shell/tcp: unknown service"); + port = sp->s_port; + } if (debug) { - printf("luser = %s, ruser = %s\n", user, ruser); + printf("port = %d, luser = %s, ruser = %s\n", ntohs(port), user, ruser); printf("buf = %s\n", buf); } fflush(stdout); - cur_host = rhost; setreuid(userid, 0); - rem = rcmd(&rhost, IPPORT_CMDSERVER, user, ruser, buf, 0); + rem = rcmd(&rhost, port, user, ruser, buf, 0); setreuid(0, userid); if (rem < 0) return(0); @@ -451,9 +489,10 @@ notify(file, rhost, to, lmod) /* * Create a pipe to mailling program. */ - pf = popen(MAILCMD, "w"); + (void)sprintf(buf, "%s -oi -t", _PATH_SENDMAIL); + pf = popen(buf, "w"); if (pf == NULL) { - error("notify: \"%s\" failed\n", MAILCMD); + error("notify: \"%s\" failed\n", _PATH_SENDMAIL); (void) close(fd); return; }