]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Remove support for rlogind in login(1), that is, remove the '-r' flag
authorAlejandro Colomar <alx@kernel.org>
Fri, 17 May 2024 23:57:40 +0000 (01:57 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 14 Jun 2024 00:39:26 +0000 (19:39 -0500)
The "quick hack" finally disappeared.  Probably nobody noticed.  ;)
(See the changes in <configure.ac> for the context of this pun.)

Probably everybody uses SSH these days for remote login.  Let's remove
this insecure method.

Closes: <https://github.com/shadow-maint/shadow/issues/992>
Reviewed-by: dkwo <nicolopiazzalunga@gmail.com>
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Michael Vetter <jubalh@iodoru.org>
Cc: Sam James <sam@gentoo.org>
Cc: Benedikt Brinkmann <datacobra@thinkbot.de>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
configure.ac
lib/Makefile.am
lib/prototypes.h
lib/rlogin.c [deleted file]
man/login.1.xml
po/POTFILES.in
src/login.c
tests/bug332198-test.exp [deleted file]

index 9e4e353a88e49801f38d6f22db9970cffad120da..5a470e5b3bd4f2ed57799949388600ae4b5d536f 100644 (file)
@@ -159,13 +159,6 @@ fi])
 AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$shadow_cv_passwd_dir/passwd",
        [Path to passwd program.])
 
-dnl XXX - quick hack, should disappear before anyone notices :).
-dnl XXX - I just read the above message :).
-if test "$ac_cv_func_ruserok" = "yes"; then
-       AC_DEFINE(RLOGIN, 1, [Define if login should support the -r flag for rlogind.])
-       AC_DEFINE(RUSEROK, 0, [Define to the ruserok() "success" return value (0 or 1).])
-fi
-
 AC_ARG_ENABLE(shadowgrp,
        [AS_HELP_STRING([--enable-shadowgrp], [enable shadow group support @<:@default=yes@:>@])],
        [case "${enableval}" in
index 22abb97840445c4b990856ba9eaba9e34d444026..adcd9fbf9ceb1dac50f6f7188de37ff22165dcfe 100644 (file)
@@ -119,7 +119,6 @@ libshadow_la_SOURCES = \
        pwdcheck.c \
        pwmem.c \
        remove_tree.c \
-       rlogin.c \
        root_flag.c \
        run_part.h \
        run_part.c \
index 1307c132f477bca13833f0817eaa0800480564c5..91ff368b79b6e51522950d8932500bf1b677f659 100644 (file)
@@ -369,10 +369,6 @@ unsigned long csrand_interval (unsigned long min, unsigned long max);
 /* remove_tree.c */
 extern int remove_tree (const char *root, bool remove_root);
 
-/* rlogin.c */
-extern int do_rlogin(const char *remote_host, char *name, size_t namesize,
-                     char *term, size_t termsize);
-
 /* root_flag.c */
 extern void process_root_flag (const char* short_opt, int argc, char **argv);
 
diff --git a/lib/rlogin.c b/lib/rlogin.c
deleted file mode 100644 (file)
index cbc05dd..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
- * SPDX-FileCopyrightText: 1996 - 1999, Marek Michałkiewicz
- * SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
- * SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <config.h>
-
-#ifdef RLOGIN
-
-#ident "$Id$"
-
-#include "prototypes.h"
-#include "defines.h"
-#include <stdio.h>
-#include <pwd.h>
-#include <netdb.h>
-
-#include "atoi/str2i.h"
-
-
-static struct {
-       int spd_name;
-       int spd_baud;
-} speed_table[] =
-{
-       { B50, 50},
-       { B75, 75},
-       { B110, 110},
-       { B134, 134},
-       { B150, 150},
-       { B200, 200},
-       { B300, 300},
-       { B600, 600},
-       { B1200, 1200},
-       { B1800, 1800},
-       { B2400, 2400},
-       { B4800, 4800},
-       { B9600, 9600},
-       { B19200, 19200},
-       { B38400, 38400},
-       { -1, -1}
-};
-
-
-static void
-get_remote_string(char *buf, size_t size)
-{
-       for (;;) {
-               if (read (0, buf, 1) != 1) {
-                       exit (EXIT_FAILURE);
-               }
-               if ('\0' == *buf) {
-                       return;
-               }
-               --size;
-               if (size > 0) {
-                       ++buf;
-               }
-       }
-       /*NOTREACHED*/
-}
-
-
-int
-do_rlogin(const char *remote_host, char *name, size_t namesize, char *term,
-          size_t termsize)
-{
-       struct passwd *pwd;
-       char remote_name[32];
-       char *cp;
-       unsigned long remote_speed = 9600;
-       int speed_name = B9600;
-       int i;
-       TERMIO termio;
-
-       get_remote_string(remote_name, sizeof(remote_name));
-       get_remote_string(name, namesize);
-       get_remote_string(term, termsize);
-
-       cp = strchr (term, '/');
-       if (NULL != cp) {
-               *cp = '\0';
-               cp++;
-
-               if (str2ul(&remote_speed, cp) == -1)
-                       remote_speed = 9600;
-       }
-       for (i = 0;
-            (   (speed_table[i].spd_baud != remote_speed)
-             && (speed_table[i].spd_name != -1));
-            i++);
-
-       if (-1 != speed_table[i].spd_name) {
-               speed_name = speed_table[i].spd_name;
-       }
-
-       /*
-        * Put the terminal in cooked mode with echo turned on.
-        */
-
-       GTTY (0, &termio);
-       termio.c_iflag |= ICRNL | IXON;
-       termio.c_oflag |= OPOST | ONLCR;
-       termio.c_lflag |= ICANON | ECHO | ECHOE;
-#ifdef CBAUD
-       termio.c_cflag = (termio.c_cflag & ~CBAUD) | speed_name;
-#else
-       termio.c_cflag = (termio.c_cflag) | speed_name;
-#endif
-       STTY (0, &termio);
-
-       pwd = getpwnam (name); /* local, no need for xgetpwnam */
-       if (NULL == pwd) {
-               return 0;
-       }
-
-       /*
-        * ruserok() returns 0 for success on modern systems, and 1 on
-        * older ones.  If you are having trouble with people logging
-        * in without giving a required password, THIS is the culprit -
-        * go fix the #define in config.h.
-        */
-
-#ifndef        RUSEROK
-       return 0;
-#else
-       return ruserok (remote_host, pwd->pw_uid == 0,
-                       remote_name, name) == RUSEROK;
-#endif
-}
-#endif                         /* RLOGIN */
index 0826b1f01f0da546ea6f64bed46847a1b9065c72..26e6ea44098f7f02009f9c576d165520513a2a25 100644 (file)
          <para>Preserve environment.</para>
        </listitem>
       </varlistentry>
-      <varlistentry>
-       <term>
-         <option>-r</option>
-       </term>
-       <listitem>
-         <para>Perform autologin protocol for rlogin.</para>
-       </listitem>
-      </varlistentry>
     </variablelist>
 
     <para>
index 9ff6100b74bf70ac851eeb6631c818dc3c781a80..6d2c0521c0ccf5a10992767d69ea7e870e6ee812 100644 (file)
@@ -53,7 +53,6 @@ lib/pwdcheck.c
 lib/pwio.c
 lib/pwmem.c
 lib/remove_tree.c
-lib/rlogin.c
 lib/root_flag.c
 lib/salt.c
 lib/selinux.c
index 9fed7b38511a54bc09a497f3ad4d1b189dc8765b..3a302983f9749a3cc0c355e028f6ec74eb2ea754 100644 (file)
@@ -85,11 +85,6 @@ static struct lastlog ll;
 static bool pflg = false;
 static bool fflg = false;
 
-#ifdef RLOGIN
-static bool rflg = false;
-#else                          /* RLOGIN */
-#define rflg false
-#endif                         /* !RLOGIN */
 static bool hflg = false;
 static bool preauth_flag = false;
 
@@ -134,7 +129,6 @@ static void exit_handler (int);
  * usage - print login command usage and exit
  *
  * login [ name ]
- * login -r hostname   (for rlogind)
  * login -h hostname   (for telnetd, etc.)
  * login -f name       (for pre-authenticated login: datakit, xterm, etc.)
  */
@@ -145,9 +139,6 @@ static void usage (void)
                exit (1);
        }
        fprintf (stderr, _("       %s [-p] [-h host] [-f name]\n"), Prog);
-#ifdef RLOGIN
-       fprintf (stderr, _("       %s [-p] -r host\n"), Prog);
-#endif                         /* RLOGIN */
        exit (1);
 }
 
@@ -271,7 +262,7 @@ static void process_flags (int argc, char *const *argv)
        /*
         * Check the flags for proper form. Every argument starting with
         * "-" must be exactly two characters long. This closes all the
-        * clever rlogin, telnet, and getty holes.
+        * clever telnet, and getty holes.
         */
        for (arg = 1; arg < argc; arg++) {
                if (argv[arg][0] == '-' && strlen (argv[arg]) > 2) {
@@ -298,13 +289,6 @@ static void process_flags (int argc, char *const *argv)
                        hostname = optarg;
                        reason = PW_TELNET;
                        break;
-#ifdef RLOGIN
-               case 'r':
-                       rflg = true;
-                       hostname = optarg;
-                       reason = PW_RLOGIN;
-                       break;
-#endif                         /* RLOGIN */
                case 'p':
                        pflg = true;
                        break;
@@ -313,21 +297,11 @@ static void process_flags (int argc, char *const *argv)
                }
        }
 
-#ifdef RLOGIN
-       /*
-        * Neither -h nor -f should be combined with -r.
-        */
-
-       if (rflg && (hflg || fflg)) {
-               usage ();
-       }
-#endif                         /* RLOGIN */
-
        /*
         * Allow authentication bypass only if real UID is zero.
         */
 
-       if ((rflg || fflg || hflg) && !amroot) {
+       if ((fflg || hflg) && !amroot) {
                fprintf (stderr, _("%s: Permission denied.\n"), Prog);
                exit (1);
        }
@@ -342,11 +316,6 @@ static void process_flags (int argc, char *const *argv)
                ++optind;
        }
 
-#ifdef RLOGIN
-       if (rflg && (NULL != username)) {
-               usage ();
-       }
-#endif                         /* RLOGIN */
        if (fflg && (NULL == username)) {
                usage ();
        }
@@ -474,7 +443,6 @@ static /*@observer@*/const char *get_failent_user (/*@returned@*/const char *use
  *     the flags which login supports are
  *
  *     -p - preserve the environment
- *     -r - perform autologin protocol for rlogin
  *     -f - do not perform authentication, user is preauthenticated
  *     -h - the name of the remote host
  */
@@ -505,9 +473,6 @@ int main (int argc, char **argv)
 # if defined(ENABLE_LASTLOG)
        char           ptime[80];
 # endif
-#endif
-#if defined(RLOGIN)
-       char           term[128] = "";
 #endif
 
        /*
@@ -559,7 +524,7 @@ int main (int argc, char **argv)
        is_console = console (tty);
 #endif
 
-       if (rflg || hflg) {
+       if (hflg) {
                /*
                 * Add remote hostname to the environment. I think
                 * (not sure) I saw it once on Irix.  --marekm
@@ -572,23 +537,6 @@ int main (int argc, char **argv)
        if (hflg) {
                reason = PW_RLOGIN;
        }
-#ifdef RLOGIN
-       if (rflg) {
-               size_t  max_size;
-
-               max_size = login_name_max_size();
-               assert (NULL == username);
-               username = XMALLOC(max_size, char);
-               username[max_size - 1] = '\0';
-               if (do_rlogin(hostname, username, max_size, term, sizeof(term)))
-               {
-                       preauth_flag = true;
-               } else {
-                       free (username);
-                       username = NULL;
-               }
-       }
-#endif                         /* RLOGIN */
 
        OPENLOG (Prog);
 
@@ -623,18 +571,11 @@ int main (int argc, char **argv)
                }
        }
 
-#ifdef RLOGIN
-       if (term[0] != '\0') {
-               addenv ("TERM", term);
-       } else
-#endif                         /* RLOGIN */
-       {
-               /* preserve TERM from getty */
-               if (!pflg) {
-                       tmp = getenv ("TERM");
-                       if (NULL != tmp) {
-                               addenv ("TERM", tmp);
-                       }
+       /* preserve TERM from getty */
+       if (!pflg) {
+               tmp = getenv ("TERM");
+               if (NULL != tmp) {
+                       addenv ("TERM", tmp);
                }
        }
 
@@ -644,7 +585,7 @@ int main (int argc, char **argv)
                set_env (argc - optind, &argv[optind]);
        }
 
-       if (rflg || hflg) {
+       if (hflg) {
                cp = hostname;
        } else if ((host != NULL) && (host[0] != '\0')) {
                cp = host;
@@ -954,7 +895,7 @@ int main (int argc, char **argv)
                }
 
                /*
-                * The -r and -f flags provide a name which has already
+                * The -f flag provides a name which has already
                 * been authenticated by some server.
                 */
                if (preauth_flag) {
@@ -1043,8 +984,8 @@ int main (int argc, char **argv)
 
                (void) puts (_("Login incorrect"));
 
-               /* allow only one attempt with -r or -f */
-               if (rflg || fflg || (retries <= 0)) {
+               /* allow only one attempt with -f */
+               if (fflg || (retries <= 0)) {
                        closelog ();
                        exit (1);
                }
diff --git a/tests/bug332198-test.exp b/tests/bug332198-test.exp
deleted file mode 100755 (executable)
index fd365bb..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/expect -f
-
-# This is a script for repeatedly logging into the localhost
-# using `rlogin` in order to apparently see a symptoms described
-# in bug #332198.
-# As described in the bug log, sometimes `rlogind` will fail to
-# establish a connection, because it starts "login" process and
-# the latter fails with "unable to determine TTY name, got /dev/pts/1"
-# message.
-# 
-# BUGS
-# 
-# * the script rlogins to localhost
-# * the script doesn't handle passwdord prompt, because it's intended
-#   to use .rhosts auth and expects shell prompt immediately after
-#   `rlogin`
-# * the regexp for shell prompt is hardcoded
-
-log_user 0
-match_max 8192
-
-while {1} {
-    set rlogin_spawn [spawn rlogin localhost]
-    if { $rlogin_spawn == 0 } { exit 1 }
-    expect {
-       -timeout 10 -re "^.*(Last login\[^\r\n\]*).*\n(\[^\r\n\]*\[#$\] )$" {
-           send_error "$expect_out(1,string)\n"
-           send_error "$expect_out(2,string)\n"
-#          send_error "$expect_out(0,string)\n"
-       }
-       timeout {
-           send_error "TIMEOUT/prompt\n"
-           send_error "$expect_out(buffer)\n"
-           send_error "RETRYING\n"
-           log_user 1
-           send "tty /\r"
-           expect -timeout 2 -re "^.*\r?\n(\[^\r\n\]*# )$" {}
-           send "tty /\r"
-           expect -timeout 2 -re "^.*\r?\n(\[^\r\n\]*# )$" {}
-           send_error "\n"
-           exit 2
-       }
-    }
-    send "tty\r"
-    expect {
-       -timeout 4 -re "tty\r?\n(\[^\r\n\]*)\r?\n(\[^\r\n\]*\[#$\] )$" {
-           send_error "$expect_out(2,string)$expect_out(1,string)\n"
-#          send_error "$expect_out(0,string)\n"
-       }
-       timeout { send_error "TIMEOUT/tty\n" ; exit 3 }
-    }
-    send "exit\r"
-    expect {
-       -timeout 2 eof {
-#          send_error "OK4: EOF\n"
-       }
-       timeout { send_error "TIMEOUT/eof\n" ; exit 4 }
-    }
-    wait
-}
-# vi: set sw=4: