Subject: Re: bug#60722: 30.0.50; [PATCH] Using Tramp to sudo in Eshell doesn't change prompt sigil

From: Michael Albinus <[email-masked]>
Date: Wed, 11 Jan 2023 10:33:41 +0100

Jim Porter <[email-masked]> writes:

Hi Jim,

> Attached is a patch to do this. It adds a new function,
> 'user-uid-for-file', which is aware of file name handlers. Then, Tramp
> adds the appropriate handler. Now, Eshell can use that function and we
> get the prompt sigil we expect.

I haven't tested, but in general it looks good. There are some minor
changes I'm missing, for example documentation of the new function in
the Lisp Reference Manual "(elisp) User Identification", and a new test
case in tramp-tests.el, but this can wait.

More serious are the following comments:

> +    ;; `user-uid-for-file' performed by default handler.

We shouldn't do this. user-uid-for-file would return the *local* uid,
which is wrong. So please, for all handlers apply

> +    (user-uid-for-file . tramp-handle-user-uid-for-file)

Except in tramp-archive.el, where ignore as handler seems to be appropriate.

> +(defun user-uid-for-file (filename)
> +  "Return the effective uid for FILENAME.
> +For local files, this is equivalent to `user-uid' (which see),
> +but for remote files, this returns the effective uid for that
> +remote connection."

Please add, that it returns -1 in case the remote uid could not be
determined.

Best regards, Michael.