summaryrefslogtreecommitdiff
path: root/usr.bin/oldrdist/server.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-07-19 21:57:35 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-07-19 21:57:35 +0000
commit1bcf7626ee3d23d7906d15f196d9791bee66cbe0 (patch)
tree0df790e92d55eb42c6fd3f8c13d252077b2632f9 /usr.bin/oldrdist/server.c
parentd62a5c66cb10886e1f037eab3be26d8424fc486e (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/server.c')
-rw-r--r--usr.bin/oldrdist/server.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/usr.bin/oldrdist/server.c b/usr.bin/oldrdist/server.c
index 596deb6f36f..436ede5fd7d 100644
--- a/usr.bin/oldrdist/server.c
+++ b/usr.bin/oldrdist/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.3 1996/06/26 05:37:41 deraadt Exp $ */
+/* $OpenBSD: server.c,v 1.4 1996/07/19 21:57:34 millert Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -35,7 +35,7 @@
#ifndef lint
/* from: static char sccsid[] = "@(#)server.c 8.1 (Berkeley) 6/9/93"; */
-static char *rcsid = "$OpenBSD: server.c,v 1.3 1996/06/26 05:37:41 deraadt Exp $";
+static char *rcsid = "$OpenBSD: server.c,v 1.4 1996/07/19 21:57:34 millert Exp $";
#endif /* not lint */
#include <sys/wait.h>
@@ -96,6 +96,11 @@ server()
(void) sprintf(buf, "V%d\n", VERSION);
(void) write(rem, buf, strlen(buf));
+ if (getuid() != geteuid()) {
+ error("This version of rdist should not be installed setuid.\n");
+ return;
+ }
+
for (;;) {
cp = cmdbuf;
if (read(rem, cp, 1) <= 0)
@@ -267,11 +272,7 @@ install(src, dest, destdir, opts)
rname++;
destdir = 1;
} else {
- rname = rindex(target, '/');
- if (rname == NULL)
- rname = target;
- else
- rname++;
+ rname = xbasename(target);
}
if (debug)
printf("target = %s, rname = %s\n", target, rname);
@@ -796,7 +797,7 @@ recvf(cmd, type)
if (catname)
(void) sprintf(tp, "/%s", cp);
- cp = rindex(target, '/');
+ cp = strrchr(target, '/');
if (cp == NULL)
strcpy(new, tempname);
else if (cp == target)
@@ -1008,7 +1009,7 @@ chkparent(name)
register char *cp;
struct stat stb;
- cp = rindex(name, '/');
+ cp = strrchr(name, '/');
if (cp == NULL || cp == name)
return(0);
*cp = '\0';
@@ -1342,8 +1343,10 @@ dospecial(cmd)
(void) dup(fd[1]);
(void) close(fd[0]);
(void) close(fd[1]);
+#if defined(DIRECT_RCMD)
setgid(groupid);
setuid(userid);
+#endif /* DIRECT_RCMD */
execl(_PATH_BSHELL, "sh", "-c", cmd, 0);
_exit(127);
}
@@ -1435,9 +1438,9 @@ error(fmt, va_alist)
#endif
++nerrs;
- if (!fp && !(fp = fdopen(rem, "w")))
- return;
if (iamremote) {
+ if (!fp && (rem < 0 || !(fp = fdopen(rem, "w"))))
+ return;
(void)fprintf(fp, "%crdist: ", 0x01);
(void)vfprintf(fp, fmt, ap);
fflush(fp);