diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-07-19 21:57:35 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-07-19 21:57:35 +0000 |
commit | 1bcf7626ee3d23d7906d15f196d9791bee66cbe0 (patch) | |
tree | 0df790e92d55eb42c6fd3f8c13d252077b2632f9 /usr.bin/oldrdist/main.c | |
parent | d62a5c66cb10886e1f037eab3be26d8424fc486e (diff) |
oldrdist now uses rsh so doesn't need to be setuid.
Incorporates some changes from Chris Siebenmann <cks@utcc.utoronto.ca>
and rdist 6.1.2. Also fixes at least one possible core dump and
uses strr?chr() instead of r?index().
Diffstat (limited to 'usr.bin/oldrdist/main.c')
-rw-r--r-- | usr.bin/oldrdist/main.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/usr.bin/oldrdist/main.c b/usr.bin/oldrdist/main.c index 60b6cc7cf9f..ab1679d6a17 100644 --- a/usr.bin/oldrdist/main.c +++ b/usr.bin/oldrdist/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.2 1996/06/26 05:37:39 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.3 1996/07/19 21:57:33 millert Exp $ */ /* * Copyright (c) 1983, 1993 @@ -41,7 +41,7 @@ static char copyright[] = #ifndef lint /* from: static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$OpenBSD: main.c,v 1.2 1996/06/26 05:37:39 deraadt Exp $"; +static char *rcsid = "$OpenBSD: main.c,v 1.3 1996/07/19 21:57:33 millert Exp $"; #endif /* not lint */ #include "defs.h" @@ -98,10 +98,7 @@ main(argc, argv) gethostname(host, sizeof(host)); strcpy(tempfile, _PATH_TMP); strcat(tempfile, _RDIST_TMP); - if ((tempname = rindex(tempfile, '/')) != 0) - tempname++; - else - tempname = tempfile; + tempname = xbasename(tempfile); while (--argc > 0) { if ((arg = *++argv)[0] != '-') @@ -192,7 +189,14 @@ main(argc, argv) } *hp = NULL; +#if defined(DIRECT_RCMD) seteuid(userid); +#else /* DIRECT_RCMD */ + if (!iamremote && getuid() != geteuid()) { + error("This version of rdist should not be installed setuid.\n"); + exit(1); + } +#endif /* DIRECT_RCMD */ mktemp(tempfile); if (iamremote) { @@ -209,7 +213,7 @@ main(argc, argv) fin = fopen("Distfile", "r"); } else fin = fopen(distfile, "r"); - if(fin == NULL) { + if (fin == NULL) { perror(distfile ? distfile : "distfile"); exit(1); } @@ -261,7 +265,7 @@ docmdargs(nargs, args) } cp = args[i]; - if ((dest = index(cp, ':')) != NULL) + if ((dest = strchr(cp, ':')) != NULL) *dest++ = '\0'; tnl.n_name = cp; hosts = expand(&tnl, E_ALL); @@ -328,3 +332,17 @@ warn(fmt, va_alist) (void)fprintf(stderr, "\n"); va_end(ap); } + +/* + * Private version of basename() + */ +char *xbasename(path) + char *path; +{ + register char *cp; + + if (cp = strrchr(path, '/')) + return(cp+1); + else + return(path); +} |