GNU bug report logs - #68074
eshell sudo/doas does not work for aliases

Previous Next

Package: emacs;

Reported by: Alfonso Sanchez-Beato <alfonsosanchezbeato <at> yahoo.es>

Date: Thu, 28 Dec 2023 04:14:02 UTC

Severity: normal

Tags: patch

Done: Jim Porter <jporterbugs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#68074: closed (eshell sudo/doas does not work for aliases)
Date: Sat, 27 Jan 2024 20:26:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 27 Jan 2024 12:24:46 -0800
with message-id <e8c9cdd3-ba88-4334-869f-5f2b79fd1ca2 <at> gmail.com>
and subject line Re: bug#68074: eshell sudo/doas does not work for aliases
has caused the debbugs.gnu.org bug report #68074,
regarding eshell sudo/doas does not work for aliases
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
68074: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68074
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Alfonso Sanchez-Beato <alfonsosanchezbeato <at> yahoo.es>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: eshell sudo/doas does not work for aliases
Date: Wed, 27 Dec 2023 21:12:26 +0000 (UTC)
[Message part 3 (text/plain, inline)]
sudo/doas does not give the expected permissions when using an eshell alias:

When no alias has been defined:

~ $ which cp
eshell/cp is a native-compiled Lisp function in ‘em-unix.el’.
~ $ touch test
~ $ cp test /boot/efi/
Opening output file: Permission denied, /boot/efi/test
~ $ sudo cp test /boot/efi/
~ $ echo $?
0

But after defining the alias:

~ $ alias cp '*cp $*'
~ $ which cp
cp is an alias, defined as "*cp $*"
~ $ sudo cp test /boot/efi/
/usr/bin/cp: cannot stat '/boot/efi/test': Permission denied

I have attached a patch with a possible fix.
[0001-lisp-eshell-em-alias.el-eshell-maybe-replace-by-alia.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Jim Porter <jporterbugs <at> gmail.com>
To: Alfonso Sanchez-Beato <alfonsosanchezbeato <at> yahoo.es>,
 Stefan Kangas <stefankangas <at> gmail.com>
Cc: 68074-done <at> debbugs.gnu.org
Subject: Re: bug#68074: eshell sudo/doas does not work for aliases
Date: Sat, 27 Jan 2024 12:24:46 -0800
On 1/27/2024 12:46 AM, Alfonso Sanchez-Beato via Bug reports for GNU 
Emacs, the Swiss army knife of text editors wrote:
> 
>   En sábado, 27 de enero de 2024, 01:19:32 GMT, Jim Porter <jporterbugs <at> gmail.com> escribió:
>> ... actually, this is a more-complete patch. I'm not 100% sure about
>> this part though:
>>
>>    ',(car args)
>>
>> That (usually) creates something like (quote "command"), but it's safer

I thought about this some more and the extraneous quoting is fine in my 
opinion. Eshell already does that quite a bit in 'eshell-do-eval', so 
what's one more case?

> This last patch works nicely, thanks a lot! It works also in cases where my patch was not, like:
> 
> $ eshell/sudo VAR=val <alias> ...

Wait, that works?! (After trying it out locally, so it does!)

Looking at the code, I see why now: 'eshell-named-command' calls 
'eshell-prepare-command-hook', and that hook is where we handle local 
variables. However, I truly didn't expect that; I thought the local 
variable handling occurred in an earlier phase. The more you know...

Anyway, since this works even better than I'd expected, I've now merged 
my patch to the master branch as 3c680968e49. Closing this bug now.


This bug report was last modified 1 year and 115 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.