diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1996-08-30 02:20:58 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1996-08-30 02:20:58 +0000 |
commit | fd8775d80c674f79324a50ba2731836fb4a3dfc3 (patch) | |
tree | 32c17e259d1a805cc0e02f5a8c16a3b9fd257a55 /usr.bin/rsh/rsh.c | |
parent | ad58988394293a638b442f2a8c6ac8dbafc6405a (diff) |
bail if euid != 0; keeps us from fork-bombing with rcmd that calls rsh(1).
Diffstat (limited to 'usr.bin/rsh/rsh.c')
-rw-r--r-- | usr.bin/rsh/rsh.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/rsh/rsh.c b/usr.bin/rsh/rsh.c index 1d92b968805..bdde174f353 100644 --- a/usr.bin/rsh/rsh.c +++ b/usr.bin/rsh/rsh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsh.c,v 1.7 1996/08/11 08:46:44 tholo Exp $ */ +/* $OpenBSD: rsh.c,v 1.8 1996/08/30 02:20:57 millert Exp $ */ /*- * Copyright (c) 1983, 1990 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)rsh.c 5.24 (Berkeley) 7/1/91";*/ -static char rcsid[] = "$OpenBSD: rsh.c,v 1.7 1996/08/11 08:46:44 tholo Exp $"; +static char rcsid[] = "$OpenBSD: rsh.c,v 1.8 1996/08/30 02:20:57 millert Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -101,7 +101,7 @@ main(argc, argv) host = user = NULL; /* if called as something other than "rsh", use it as the host name */ - if (p = rindex(argv[0], '/')) + if (p = strrchr(argv[0], '/')) ++p; else p = argv[0]; @@ -177,6 +177,10 @@ main(argc, argv) argc -= optind; argv += optind; + if (geteuid()) { + (void)fprintf(stderr, "rsh: must be setuid root.\n"); + exit(1); + } if (!(pw = getpwuid(uid = getuid()))) { (void)fprintf(stderr, "rsh: unknown user id.\n"); exit(1); |