Subject: bug#56891: [PATCH] Make "rlogin" method obsolete in url*.el

From: Stefan Kangas <[email-masked]>
Date: Tue, 2 Aug 2022 15:19:20 +0000

Severity: wishlist

Any comments on making "rlogin" obsolete in the url package?  (We have
already obsoleted rlogin.el and are phasing it out from TRAMP, Ange FTP,
etc.)

Please see the attached patch.
From d0165a3eb7bf3961dbc17e6295c798a2196eb999 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Tue, 2 Aug 2022 15:02:56 +0200
Subject: [PATCH] Make "rlogin" method obsolete in url*.el

* lisp/url/url-about.el (url-probe-protocols): Remove "rlogin".
* lisp/url/url-gw.el (url-gateway-rlogin-host)
(url-gateway-rlogin-user-name, url-gateway-rlogin-parameters)
(url-open-rlogin): Make obsolete.
(url-open-stream):
* lisp/url/url-misc.el (url-do-terminal-emulator): Warn when using
"rlogin".
(url-rlogin): Make obsolete.
* lisp/url/url-vars.el (url-gateway-method): Remove "rlogin"
choice.

* lisp/url/url-gw.el (url-gw-rlogin-obsolete-warned-once)
* lisp/url/url-misc.el (url-misc-rlogin-obsolete-warned-once): New
variables, immediately marked obsolete.

* doc/misc/url.texi (telnet/tn3270): Rename section from
"rlogin/telnet/tn3270".
(Gateways in general, Customization): Don't mention "rlogin"
method.
---
 doc/misc/url.texi     | 36 +++++++-----------------------------
 etc/NEWS              | 12 ++++++++++++
 lisp/url/url-about.el |  2 +-
 lisp/url/url-gw.el    | 15 ++++++++++++---
 lisp/url/url-misc.el  |  8 +++++++-
 lisp/url/url-vars.el  |  2 --
 6 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/doc/misc/url.texi b/doc/misc/url.texi
index a9d06d7f5b..776740b50f 100644
--- a/doc/misc/url.texi
+++ b/doc/misc/url.texi
@@ -380,7 +380,7 @@ Supported URL Types
 * info::                        Emacs "Info" pages.
 * mailto::                      Sending email.
 * news/nntp/snews::             Usenet news.
-* rlogin/telnet/tn3270::        Remote host connectivity.
+* telnet/tn3270::               Remote host connectivity.
 * irc::                         Internet Relay Chat.
 * data::                        Embedded data URLs.
 * nfs::                         Networked File System.
@@ -675,9 +675,8 @@ news/nntp/snews
 environment variable is unset.
 @end defopt
 
-@node rlogin/telnet/tn3270
-@section rlogin, telnet and tn3270
-@cindex rlogin
+@node telnet/tn3270
+@section telnet and tn3270
 @cindex telnet
 @cindex tn3270
 @cindex terminal emulation
@@ -694,10 +693,10 @@ rlogin/telnet/tn3270
 but the @var{password} component is ignored.  By default, the
 @code{telnet} scheme is handled via Tramp (@pxref{Tramp}).
 
-To handle rlogin, telnet and tn3270 URLs, a @code{rlogin},
-@code{telnet} or @code{tn3270} (the program names and arguments are
-hardcoded) session is run in a @code{terminal-emulator} buffer.
-Well-known ports are used if the URL does not specify a port.
+To handle telnet and tn3270 URLs, a @code{telnet} or @code{tn3270}
+(the program names and arguments are hardcoded) session is run in a
+@code{terminal-emulator} buffer.  Well-known ports are used if the URL
+does not specify a port.
 
 @node irc
 @section irc
@@ -1040,12 +1039,6 @@ Gateways in general
 Use this method if you must first telnet and log into a gateway host,
 and then run telnet from that host to connect to outside machines.
 
-@item rlogin
-@cindex @command{rlogin}
-This method is identical to @code{telnet}, but uses @command{rlogin}
-to log into the remote machine without having to send the username and
-password over the wire every time.
-
 @item socks
 @cindex @sc{socks}
 Use if the firewall has a @sc{socks} gateway running on it.  The
@@ -1088,19 +1081,6 @@ Gateways in general
 This is a regular expression that matches the shell prompt.
 @end defopt
 
-@defopt url-gateway-rlogin-host
-Host to @samp{rlogin} to before telnetting out.
-@end defopt
-@defopt url-gateway-rlogin-parameters
-Parameters to pass to @samp{rsh}.
-@end defopt
-@defopt url-gateway-rlogin-user-name
-User name to use when logging in to the gateway.
-@end defopt
-@defopt url-gateway-prompt-pattern
-This is a regular expression that matches the shell prompt.
-@end defopt
-
 @defopt socks-server
 This specifies the default server, it takes the form
 @w{@code{("Default server" @var{server} @var{port} @var{version})}}
@@ -1328,8 +1308,6 @@ Customization
 @table @code
 @item telnet
 Run telnet in a subprocess to connect;
-@item rlogin
-Rlogin to another machine to connect;
 @item socks
 Connect through a socks server;
 @item ssl
diff --git a/etc/NEWS b/etc/NEWS
index 475ceeb396..b1bb7dfd0c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -335,6 +335,18 @@ the major mode according to 'initial-major-mode', like at Emacs
 startup.  Previously, these functions ignored
 'initial-scratch-message' and left "*scratch*" in 'fundamental-mode'.
 
+---
+** The 'rlogin' method in the URL library is now obsolete.
+Emacs will now display a warning if you request a URL like
+"rlogin://[email-masked]".
+
+---
+** Setting 'url-gateway-method' to 'rlogin' is now obsolete.
+Emacs will now display a warning when setting it to that value.
+The user options 'url-gateway-rlogin-host',
+'url-gateway-rlogin-parameters', and 'url-gateway-rlogin-user-name'
+are also obsolete.
+
 ---
 ** The autoarg.el library is now marked obsolete.
 This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor
diff --git a/lisp/url/url-about.el b/lisp/url/url-about.el
index a50986d511..3eabd19f55 100644
--- a/lisp/url/url-about.el
+++ b/lisp/url/url-about.el
@@ -31,7 +31,7 @@ url-probe-protocols
   (or (get 'url-extension-protocols 'probed)
       (mapc (lambda (s) (url-scheme-get-property s 'name))
 	    (or (get 'url-extension-protocols 'schemes)
-		(let ((schemes '("info" "man" "rlogin" "telnet"
+                (let ((schemes '("info" "man" "telnet"
 				 "tn3270" "data" "snews")))
 		  (mapc (lambda (d)
 			  (mapc (lambda (f)
diff --git a/lisp/url/url-gw.el b/lisp/url/url-gw.el
index c4a41f56b3..e4d1ca72a0 100644
--- a/lisp/url/url-gw.el
+++ b/lisp/url/url-gw.el
@@ -28,8 +28,6 @@
 (require 'url-vars)
 (require 'url-parse)
 
-;; Fixme: support SSH explicitly or via a url-gateway-rlogin-program?
-
 (autoload 'socks-open-network-stream "socks")
 
 (defgroup url-gateway nil
@@ -51,17 +49,20 @@ url-gateway-rlogin-host
   "What hostname to actually rlog into before doing a telnet."
   :type '(choice (const nil) string)
   :group 'url-gateway)
+(make-obsolete-variable 'url-gateway-rlogin-host nil "29.1")
 
 (defcustom url-gateway-rlogin-user-name nil
   "Username to log into the remote machine with when using rlogin."
   :type '(choice (const nil) string)
   :group 'url-gateway)
+(make-obsolete-variable 'url-gateway-rlogin-user-name nil "29.1")
 
 (defcustom url-gateway-rlogin-parameters '("telnet" "-8")
   "Parameters to `url-open-rlogin'.
 This list will be used as the parameter list given to rsh."
   :type '(repeat string)
   :group 'url-gateway)
+(make-obsolete-variable 'url-gateway-rlogin-parameters nil "29.1")
 
 (defcustom url-gateway-telnet-host nil
   "What hostname to actually login to before doing a telnet."
@@ -141,6 +142,7 @@ url-wait-for-string
 ;; Stolen from red gnus nntp.el
 (defun url-open-rlogin (name buffer host service)
   "Open a connection using rsh."
+  (declare (obsolete nil "29.1"))
   (if (not (stringp service))
       (setq service (int-to-string service)))
   (let ((proc (if url-gateway-rlogin-user-name
@@ -205,6 +207,9 @@ url-open-telnet
 	(delete-region (point) (point-max)))
       proc)))
 
+(defvar url-gw-rlogin-obsolete-warned-once nil)
+(make-obsolete-variable url-gw-rlogin-obsolete-warned-once nil "29.1")
+
 ;;;###autoload
 (defun url-open-stream (name buffer host service &optional gateway-method)
   "Open a stream to HOST, possibly via a gateway.
@@ -255,7 +260,11 @@ url-open-stream
 			 ('telnet
 			  (url-open-telnet name buffer host service))
 			 ('rlogin
-			  (url-open-rlogin name buffer host service))
+                          (unless url-gw-rlogin-obsolete-warned-once
+                            (lwarn 'url :error "Setting `url-gateway-method' to `rlogin' is obsolete")
+                            (setq url-gw-rlogin-obsolete-warned-once t))
+                          (with-suppressed-warnings ((obsolete url-open-rlogin))
+                            (url-open-rlogin name buffer host service)))
 			 (_
 			  (error "Bad setting of url-gateway-method: %s"
 				 url-gateway-method))))))
diff --git a/lisp/url/url-misc.el b/lisp/url/url-misc.el
index 479f64c3e0..0c1f79a0c5 100644
--- a/lisp/url/url-misc.el
+++ b/lisp/url/url-misc.el
@@ -47,6 +47,9 @@ url-info
       (error "Malformed url: %s" (url-recreate-url url)))
     nil))
 
+(defvar url-misc-rlogin-obsolete-warned-once nil)
+(make-obsolete-variable url-misc-rlogin-obsolete-warned-once nil "29.1")
+
 (defun url-do-terminal-emulator (type server port user)
   (switch-to-buffer
    (apply
@@ -58,6 +61,9 @@ url-do-terminal-emulator
 	  (t (error "Unknown terminal emulator required: %s" type)))
     nil
     (cond ((eq type 'rlogin)
+           (unless url-misc-rlogin-obsolete-warned-once
+             (lwarn 'url :error "Method `rlogin' is obsolete")
+             (setq url-misc-rlogin-obsolete-warned-once t))
 	   (if user (list server "-l" user) (list server)))
 	  ((eq type 'telnet)
 	   (if port (list server port) (list server)))
@@ -74,7 +80,7 @@ url-generic-emulator-loader
   nil)
 
 ;;;###autoload
-(defalias 'url-rlogin 'url-generic-emulator-loader)
+(define-obsolete-function-alias 'url-rlogin #'url-generic-emulator-loader "29.1")
 ;;;###autoload
 (defalias 'url-telnet 'url-generic-emulator-loader)
 ;;;###autoload
diff --git a/lisp/url/url-vars.el b/lisp/url/url-vars.el
index 859a5c75ed..4cdca05554 100644
--- a/lisp/url/url-vars.el
+++ b/lisp/url/url-vars.el
@@ -350,13 +350,11 @@ url-gateway-method
 
 Currently supported methods:
 `telnet': Run telnet in a subprocess to connect;
-`rlogin': Rlogin to another machine to connect;
 `socks': Connect through a socks server;
 `tls': Connect with TLS;
 `ssl': Connect with SSL (deprecated, use `tls' instead);
 `native': Connect directly."
   :type '(radio (const :tag "Telnet to gateway host" :value telnet)
-		(const :tag "Rlogin to gateway host" :value rlogin)
 		(const :tag "Use SOCKS proxy" :value socks)
 		(const :tag "Use SSL/TLS for all connections" :value tls)
 		(const :tag "Use SSL for all connections (obsolete)" :value ssl)
-- 
2.30.2