all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: "Bruno Félix Rezende Ribeiro" <oitofelix@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: tramp-auto-auth.el --- TRAMP automatic authentication library
Date: Thu, 29 Aug 2019 13:04:28 +0200	[thread overview]
Message-ID: <87ftlkp70j.fsf@gmx.de> (raw)
In-Reply-To: <87o9086ea0.fsf@oitofelix.com> ("Bruno Félix Rezende Ribeiro"'s message of "Wed, 28 Aug 2019 20:50:15 -0300")

Bruno Félix Rezende Ribeiro <oitofelix@gnu.org> writes:

> Hello Michael and other GNU Emacs developers,

Hi Bruno,

>> Frankly, I'm not enthusiastic adding cleartext passwords into
>> Tramp. This has all the security flaws you know, and is good for
>> problems. At least in core Tramp it shouldn't be propagated.
>
> Please, find attached the implementation of tramp-auto-auth.el using
> exclusively the auth-source library.

Thanks for this! It looks better now to my eyes.

> I did as you suggested except that I didn’t add a new keyword nor made
> any change to auth-source.el.
>
> Quoting from the commentary section:
>
>    When a TRAMP prompt is encountered, ‘tramp-auto-auth-mode’ queries
>    the alist ‘tramp-auto-auth-alist’ for the auth-source spec value
>    whose regexp key matches the correspondent TRAMP path.  This spec
>    is then used to query the auth-source library for a presumably
>    phony entry exclusively dedicated to the whole class of TRAMP
>    paths matching that regexp.

Thinking about this, I believe we could use such a mechanism at broader
level. You manage just one Tramp resource (passwords). WIBNI you could
cluster remote hosts also for other resources? For example, in order to
say "users for a given host share the same password if they access via
'ssh' or 'sftp' or 'scp'". Or if you say "the connection property [1]
\"remote-shell\" of a given list of hosts shall be \"/bin/bash\"". Or if
you say "the connection-local variable [2] `tramp-remote-path' for a
given list of hosts shall contain \"/appli/pub/bin\"".

[1] (info "(tramp) Predefined connection information")
[2] (info "(tramp) Remote programs")

Then you could declare just clusters. I would start with a cluster name
(a string), and a list of regular expressions which identify the remote
hosts. Using your example, one would declare

(add-to-list 'tramp-clusters '("Funny-Machines" "root@10\\.0\\." "..."))

For every resource, be it a password, a connection property, or a
connection-local variable, Tramp would always check whether there is a
setting of that resource for the host in question, and if not, whether
there is a setting in a cluster the host belongs to.

This broader approach wouldn't be implemented by an own package via
advising Tramp functions, but in Tramp itself. For the beginning, one
could start with managing passwords this way.

> Is this feature in this form suitable for inclusion in the TRAMP
> standard distribution?

Does this proposal makes sense to you? Would you like to work on this?

Just some comments on your code

> ;; Copyright (C) 2019 Bruno Félix Rezende Ribeiro <oitofelix@gnu.org>

This would be FSF copyrighted, if included in Emacs/Tramp.

> ;; Author: Bruno Félix Rezende Ribeiro <oitofelix@gnu.org>
> ;; Maintainer: Bruno Félix Rezende Ribeiro <oitofelix@gnu.org>

If there is an author, you don't need a maintainer.

> ;; Package-Version: 20190827.1316
> ;; Package-Requires: (tramp)

These entries are needed only in case it would be an ELPA package.

> ;; After this, just put the respective sacred secret in an
> ;; authentication source supported by auth-source library.  For
> ;; instance:
> ;;
> ;; ---- ~/.authinfo.gpg ---------------------------------------------
> ;; machine Funny-Machines login root password "$r00tP#sWD!" port ssh
> ;; ------------------------------------------------------------------

IIRC, neither "login" nor "port" keys are mandatory in auth-source. So
you could live just with "machine" and "password".

> ;; In case you are feeling lazy or the secret is not so secret (nor so
> ;; sacred) -- or for any reason you need to do it all from Lisp --
> ;; it’s enough to:
> ;;
> ;; (auth-source-remember '(:host "Funny-Machines" :user "root" :port "ssh")
> ;; 		         '((:secret "$r00tP#sWD!")))

I wouldn't write this into a Tramp doc. Refer to the "auth" Info pages.

> (defcustom tramp-auto-auth-alist

A defcustom should have a :version key. In case it will be added to
Tramp, :version "27.1" (the first Emacs version this user option has
appeared) would be OK.

>   :require 'tramp-auto-auth)

Why is this needed?

> ;;;###autoload

Please use ";;;###tramp-autoload". The user option makes only sense
after Tramp has been loaded.

> 	(advice-add #'tramp-action-password :around

Code, which is part of core Emacs, shall not advice other
functions. Advicing is intended for user-written Lisp.

Please ensure also, that you do not exceed the 80 chars/line limit, for
better readability.

Best regards, Michael.



  reply	other threads:[~2019-08-29 11:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23  2:08 tramp-auto-auth.el --- TRAMP automatic authentication library Bruno Félix Rezende Ribeiro
2019-08-27 10:12 ` Michael Albinus
2019-08-28 23:50   ` Bruno Félix Rezende Ribeiro
2019-08-29 11:04     ` Michael Albinus [this message]
2019-08-31 23:29       ` Bruno Félix Rezende Ribeiro
2019-09-01  9:59         ` Michael Albinus
2019-09-01 12:53       ` Stefan Monnier
2019-09-01 15:35         ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ftlkp70j.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=emacs-devel@gnu.org \
    --cc=oitofelix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.