X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/a3e6fd64959ed0653e4f36fcbd8b4b9e3b4fe6be..435e8dffcf378b5a0513c17aabf4f32096c20da8:/usr/src/usr.bin/rdist/main.c diff --git a/usr/src/usr.bin/rdist/main.c b/usr/src/usr.bin/rdist/main.c index 674977235f..c707890c84 100644 --- a/usr/src/usr.bin/rdist/main.c +++ b/usr/src/usr.bin/rdist/main.c @@ -1,15 +1,40 @@ +/* + * 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 = "@(#)main.c 4.12 (Berkeley) 84/06/28"; -#endif +char copyright[] = +"@(#) Copyright (c) 1983 Regents of the University of California.\n\ + All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char sccsid[] = "@(#)main.c 5.4 (Berkeley) %G%"; +#endif /* not lint */ #include "defs.h" +#define NHOSTS 100 + /* * Remote distribution program. */ -char *distfile = "distfile"; -char tmpfile[] = "/tmp/rdistXXXXXX"; +char *distfile = NULL; +char tmpfile[] = _PATH_TMP; char *tmpname = &tmpfile[5]; int debug; /* debugging flag */ @@ -36,6 +61,7 @@ main(argc, argv) { register char *arg; int cmdargs = 0; + char *dhosts[NHOSTS], **hp = dhosts; pw = getpwuid(userid = getuid()); if (pw == NULL) { @@ -62,6 +88,16 @@ main(argc, argv) fin = stdin; break; + case 'm': + if (--argc <= 0) + usage(); + if (hp >= &dhosts[NHOSTS-2]) { + fprintf(stderr, "rdist: too many destination hosts\n"); + exit(1); + } + *hp++ = *++argv; + break; + case 'd': if (--argc <= 0) usage(); @@ -124,32 +160,41 @@ main(argc, argv) usage(); } } + *hp = NULL; + setreuid(0, userid); mktemp(tmpfile); if (iamremote) { server(); - exit(nerrs); + exit(nerrs != 0); } if (cmdargs) docmdargs(argc, argv); else { - if (fin == NULL && (fin = fopen(distfile, "r")) == NULL) { - perror(distfile); - exit(1); + if (fin == NULL) { + if(distfile == NULL) { + if((fin = fopen("distfile","r")) == NULL) + fin = fopen("Distfile", "r"); + } else + fin = fopen(distfile, "r"); + if(fin == NULL) { + perror(distfile ? distfile : "distfile"); + exit(1); + } } yyparse(); if (nerrs == 0) - docmds(argc, argv); + docmds(dhosts, argc, argv); } - exit(nerrs); + exit(nerrs != 0); } usage() { - printf("Usage: rdist [-nqbhirvwyD] [-f distfile] [-d var=value] [file ...]\n"); + printf("Usage: rdist [-nqbhirvwyD] [-f distfile] [-d var=value] [-m host] [file ...]\n"); printf("or: rdist [-nqbhirvwyD] -c source [...] machine[:dest]\n"); exit(1); } @@ -188,6 +233,8 @@ docmdargs(nargs, args) *dest++ = '\0'; tnl.n_name = cp; hosts = expand(&tnl, E_ALL); + if (nerrs) + exit(1); if (dest == NULL || *dest == '\0') cmds = NULL; @@ -204,7 +251,7 @@ docmdargs(nargs, args) prnames(hosts); } insert(NULL, files, hosts, cmds); - docmds(0, NULL); + docmds(NULL, 0, NULL); } /*