rlogin/slogin handling [PATCH]

Irving Popovetsky irving at uscybernetics.com
Sat Jul 15 03:34:15 EST 2000


Hello.

	I noticed that OpenSSH 2.1.1p3 does not check whether it is being
called as rlogin or slogin, like it's siblings do.   This can get ugly if
you have rlogin and rsh symlinked to ssh, and old r* commands are
moved off in another place, as I do.

Since Solaris rsh is hardcoded to call /usr/bin/rlogin, it will get stuck
in an infinite loop.

Below is a quick patch I hacked up, based on the functionality in
ssh-1.2.27,   tested under Solaris 2.6,7 and 8. 

Thanks,
-Irving Popovetsky




--- ssh.c.orig  Wed Jul 12 15:54:55 2000
+++ ssh.c       Fri Jul 14 13:15:45 2000
@@ -160,11 +160,26 @@
 {
        char *args[10];
        int i;
+       char rsh_program_name[256];
 
        log("Using rsh.  WARNING: Connection will not be encrypted.");
+
+/*  Check case for rlogin/slogin */
+       if (strncmp(av0, "rlogin", strlen(av0)) == 0 || strncmp(av0, "slogin", strlen(av0)) == 0)+         {
+               strncpy(rsh_program_name, _PATH_RSH, sizeof(rsh_program_name));
+               if (strchr(rsh_program_name, '/'))
+                *strrchr(rsh_program_name, '/') = '\0';
+               sprintf(rsh_program_name + strlen(rsh_program_name), "/rlogin");
+         }
+       else
+         {
+               strncpy(rsh_program_name, _PATH_RSH, sizeof(rsh_program_name));
+         }
+
        /* Build argument list for rsh. */
        i = 0;
-       args[i++] = _PATH_RSH;
+       args[i++] = rsh_program_name;
        /* host may have to come after user on some systems */
        args[i++] = host;
        if (user) {
@@ -184,8 +199,8 @@
                }
                fprintf(stderr, "\n");
        }
-       execv(_PATH_RSH, args);
-       perror(_PATH_RSH);
+       execv(rsh_program_name, args);
+       perror(rsh_program_name);
        exit(1);
 }






More information about the openssh-unix-dev mailing list