aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/rdist/main.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1996-08-10 07:54:17 +0000
committerPeter Wemm <peter@FreeBSD.org>1996-08-10 07:54:17 +0000
commitfb9e3ade6c800a20206bf6e1d77c02ba1dc87250 (patch)
treea7f69e16c74cc884e69d51027b64a2371b6f57ac /usr.bin/rdist/main.c
parentb05a2d987d60d61235918c08370cb9d2f6144a19 (diff)
downloadsrc-fb9e3ade6c800a20206bf6e1d77c02ba1dc87250.tar.gz
src-fb9e3ade6c800a20206bf6e1d77c02ba1dc87250.zip
Remove the need for rdist(1) to run setuid, thus completely closing any
possibility of a security hole. It now does what rdist-6 does, and calls /usr/bin/rsh if not running as root. There are NO protocol changes, this is 100% compatable with the old rdist, except that it does not need setuid root privs. However, there are some minor differences to the base rdist-6 code in that if it is being run by root, it will call rcmd(3) directly rather than piping everything through rsh(1). This is a little more efficient as it doesn't involve context switching on pipe reads/writes. Also, the -P option was added from rdist-6.1.2, which allows an alternative rsh program to be specified, such as ssh. Note that it requires the fixes to the ssh port to disable the unconditional USE_PIPES option that was recently added. The rcmd(3) optimisation is disabled if a non-rsh program is speficied.
Notes
Notes: svn path=/head/; revision=17489
Diffstat (limited to 'usr.bin/rdist/main.c')
-rw-r--r--usr.bin/rdist/main.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/rdist/main.c b/usr.bin/rdist/main.c
index 44b3279a2652..3badde74f73c 100644
--- a/usr.bin/rdist/main.c
+++ b/usr.bin/rdist/main.c
@@ -68,6 +68,7 @@ char user[10]; /* user's name */
char homedir[128]; /* user's home directory */
int userid; /* user's user ID */
int groupid; /* user's group ID */
+char *path_rsh = _PATH_RSH; /* rsh (or equiv command) path */
struct passwd *pw; /* pointer to static area used by getpwent */
struct group *gr; /* pointer to static area used by getgrent */
@@ -107,6 +108,12 @@ main(argc, argv)
iamremote++;
else while (*++arg)
switch (*arg) {
+ case 'P':
+ if (--argc <= 0)
+ usage();
+ path_rsh = *++argv;
+ break;
+
case 'f':
if (--argc <= 0)
usage();
@@ -222,8 +229,9 @@ main(argc, argv)
static void
usage()
{
- printf("Usage: rdist [-nqbhirvwyD] [-f distfile] [-d var=value] [-m host] [file ...]\n");
- printf("or: rdist [-nqbhirvwyD] -c source [...] machine[:dest]\n");
+ printf("Usage: rdist [-nqbhirvwyD] [-P /path/to/rsh ] [-f distfile] [-d var=value]\n");
+ printf(" [-m host] [file ...]\n");
+ printf("or: rdist [-nqbhirvwyD] [-P /path/to/rsh ] -c source [...] machine[:dest]\n");
exit(1);
}
@@ -237,7 +245,7 @@ docmdargs(nargs, args)
{
register struct namelist *nl, *prev;
register char *cp;
- struct namelist *files, *hosts;
+ struct namelist *files = NULL, *hosts;
struct subcmd *cmds;
char *dest;
static struct namelist tnl = { NULL, NULL };