+/*
+ * 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 <setjmp.h>
-
-#ifndef RDIST
-#define RDIST "/usr/local/rdist"
-#endif
+#include <netdb.h>
FILE *lfp; /* log file for recording files updated */
struct subcmd *subcmds; /* list of sub-commands for current cmd */
/*
* Do the commands in cmds (initialized by yyparse).
*/
-docmds(argc, argv)
+docmds(dhosts, argc, argv)
+ char **dhosts;
int argc;
char **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 &&
{
register char *ruser, *cp;
static char *cur_host = NULL;
+ static int port = -1;
+ char tuser[20];
int n;
extern char user[];
extern int userid;
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);
/*
* 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;
}