* emacsclient and sudo
@ 2021-02-24 17:48 Luca Ferrari
2021-02-24 18:01 ` 2QdxY4RzWzUUiLuE
2021-03-08 15:32 ` Luca Ferrari
0 siblings, 2 replies; 4+ messages in thread
From: Luca Ferrari @ 2021-02-24 17:48 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
when I start my emacsclient I can see all the colors I've setup for
fonts and faces. However, when I start it thru sudo (e..g, to quickly
edit a file with privileges instead of using tramp) all my settings
seem to be gone.
So far, I'm starting it normally (without sudo) and use tramp to edit
a file with sudo, but sometimes my fingers are faster than my brain
and I type "sudo emacs ...".
I suspect sudo is doing something to prevent emacs to start with my
settings, even if my home environment is kept.
Anyone else dealing with this?
Thanks,
Luca
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: emacsclient and sudo
2021-02-24 17:48 emacsclient and sudo Luca Ferrari
@ 2021-02-24 18:01 ` 2QdxY4RzWzUUiLuE
2021-03-08 15:32 ` Luca Ferrari
1 sibling, 0 replies; 4+ messages in thread
From: 2QdxY4RzWzUUiLuE @ 2021-02-24 18:01 UTC (permalink / raw)
To: help-gnu-emacs
On 2021-02-24 at 18:48:54 +0100,
Regarding "emacsclient and sudo,"
Luca Ferrari <fluca1978@gmail.com> wrote:
> Hi all,
> when I start my emacsclient I can see all the colors I've setup for
> fonts and faces. However, when I start it thru sudo (e..g, to quickly
> edit a file with privileges instead of using tramp) all my settings
> seem to be gone.
> So far, I'm starting it normally (without sudo) and use tramp to edit
> a file with sudo, but sometimes my fingers are faster than my brain
> and I type "sudo emacs ...".
> I suspect sudo is doing something to prevent emacs to start with my
> settings, even if my home environment is kept.
>
> Anyone else dealing with this?
No, but that's because I don't use sudo with emacsclient. ;-)
Sudo has a whole bunch of configuration (command line arguments,
environment variables, policies) regarding the HOME environment variable
and the effiective user id, and I'd bet that one of those is actually
being set to root's and then emacs doesn't find your settings. Check
sudo's the man page and your local sudo policies.
In the long run, please retrain your fingers. Unnecessarily running
programs as root is an accident waiting to happen.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: emacsclient and sudo
2021-02-24 17:48 emacsclient and sudo Luca Ferrari
2021-02-24 18:01 ` 2QdxY4RzWzUUiLuE
@ 2021-03-08 15:32 ` Luca Ferrari
2021-03-09 6:04 ` Jean Louis
1 sibling, 1 reply; 4+ messages in thread
From: Luca Ferrari @ 2021-03-08 15:32 UTC (permalink / raw)
To: help-gnu-emacs
On Wed, Feb 24, 2021 at 6:48 PM Luca Ferrari <fluca1978@gmail.com> wrote:
>
> So far, I'm starting it normally (without sudo) and use tramp to edit
> a file with sudo, but sometimes my fingers are faster than my brain
> and I type "sudo emacs ...".
Another solution I found is to export SUDO_EDITOR variable set to
emacsclient and then use `sudo -e` to edit a file. While this works
with regard to emacsclient, it does prevent emacs to load my .emacs
configuration file.
% export SUDO_EDITOR="emacsclient -t -a ''"
% sudo -e /etc/fstab
I would like to be able to use my customizations, any idea?
Thanks,
Luca
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: emacsclient and sudo
2021-03-08 15:32 ` Luca Ferrari
@ 2021-03-09 6:04 ` Jean Louis
0 siblings, 0 replies; 4+ messages in thread
From: Jean Louis @ 2021-03-09 6:04 UTC (permalink / raw)
To: Luca Ferrari; +Cc: help-gnu-emacs
* Luca Ferrari <fluca1978@gmail.com> [2021-03-08 18:36]:
> On Wed, Feb 24, 2021 at 6:48 PM Luca Ferrari <fluca1978@gmail.com> wrote:
> >
> > So far, I'm starting it normally (without sudo) and use tramp to edit
> > a file with sudo, but sometimes my fingers are faster than my brain
> > and I type "sudo emacs ...".
>
> Another solution I found is to export SUDO_EDITOR variable set to
> emacsclient and then use `sudo -e` to edit a file. While this works
> with regard to emacsclient, it does prevent emacs to load my .emacs
> configuration file.
>
> % export SUDO_EDITOR="emacsclient -t -a ''"
> % sudo -e /etc/fstab
>
> I would like to be able to use my customizations, any idea?
I just think that sudo will use $HOME as /root so one way could be to
provide HOME as your own one.
maybe like this:
export SUDO_EDITOR="env HOME=/home/myusername EDITOR"
but if you are using emacsclient that implies you wish to have server
running, so in that case server has to be started. As I have started
server as me, as user, this works just fine:
export SUDO_EDITOR="emacsclient -t -a ''"
on my side.
And this works as well good:
export SUDO_EDITOR="emacs -nw"
But if I would be user joe who wish to user HOME configuration of user
john, then I would be doing something like:
export SUDO_EDITOR="env HOME=/home/john emacs -nw"
provided that configuration is readable.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-09 6:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-24 17:48 emacsclient and sudo Luca Ferrari
2021-02-24 18:01 ` 2QdxY4RzWzUUiLuE
2021-03-08 15:32 ` Luca Ferrari
2021-03-09 6:04 ` Jean Louis
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.