You are not logged in.

#1 2013-04-19 09:43:40

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 617

[SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

Solution on the bottom of this post

I was curious why root inherits my user's $PROMPT, even when I use sudo -i to switch to root. Note: I do not set my root's prompt explicitly (nor do I have any other environment variables set for root).

$USER@rechenschieber i ~ % echo $PROMPT
%K{blue}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f
$USER@rechenschieber i ~ % sudo -i
[sudo] password for $USER: 
root@rechenschieber i ~ # echo $PROMPT
%K{red}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f

I went out to #archlinux, which as often, provided much hillarity but wasn't that useful, and so I finally resorted to reading man 5 sudoers:
I consulted the su, sudo and sudoers man pages, and did a quick Googling, before I went out to #archlinux, which as often, provided much hillarity but wasn't that useful, and so I finally resorted to reading man 5 sudoers again and asking here:

$ man 5 sudoers
[snip]
As a special case, if sudo's -i option (initial login) is specified, sudoers will initialize the environment regardless of the value of env_reset.
     The DISPLAY, PATH and TERM variables remain unchanged; HOME, MAIL, SHELL, USER, and LOGNAME are set based on the target user.  On AIX (and Linux sys‐
     tems without PAM), the contents of /etc/environment are also included.  All other environment variables are removed.
[snip]

Let me highlight the important part:
All other environment variables are removed.

This leads me to these two possible conclusion:

  1. man 5 sudoers is lying to my face

  2. Archlinux uses a non-vanilla definition of sudoers (or sudo -i, whatever fits better)

Please do enlighten me!


EDIT/Solution: Turns out, there is a third possible conclusion:

  • set /root/.zshrc, forget about it, and claim you have never set it

Last edited by Stalafin (2013-04-19 14:12:29)

Offline

#2 2013-04-19 09:46:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

You chose an inflamatory title, then insult the community you are asking for help from, and describe how you eventually resorted to actually reading the manual ... but not very well it would seem.

What kind of response do you expect?  Stop trolling.

To enlighten you: you seem to have concluded that archlinux is broken and the community sucks.  Don't expect anyone here to change your mind: use a different distro.

Last edited by Trilby (2013-04-19 09:48:44)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2013-04-19 09:49:59

HalosGhost
Forum Moderator
From: Twin Cities, MN
Registered: 2012-06-22
Posts: 2,089
Website

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

P.S., "resorting" to reading the man-page after asking for help from this community is exactly what the community explicitly wants to avoid. Reading should always come before asking.

All the best,

-HG

P.P.S., "!twofishes"

Last edited by HalosGhost (2013-04-19 11:35:07)

Offline

#4 2013-04-19 11:26:52

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 617

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

Ok, despite what my first post might suggest: I did read the sudo and sudoers man pages before asking #archlinux. After consulting Google, I did go to #archlinux, where it was suggested that I did not read the man pages properly. However, nobody could suggest why I experience the above behaviour.

And considering that I am using this distribution a lot longer than the both of you combined: the quality of #archlinux is really bad, depending on the time of the day. If you don't have gtmanfred, jelly1 or earnestly (and a couple of others) around, you can expect to have people who a) do not read your questions properly, b) imply that you have not done your research, and most importantly, c), have no idea what you are talking about.


So thank you for enlightening me, Trilby. I love when people call names (trolling) and do just that.


EDIT: And I have edited the first post just for you.

Last edited by Stalafin (2013-04-19 11:27:15)

Offline

#5 2013-04-19 11:52:56

gridcol
Member
From: Karlsruhe, Germany
Registered: 2012-03-27
Posts: 32

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

Just because I don't get it:

$USER@rechenschieber i ~ % echo $PROMPT
%K{blue}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f
$USER@rechenschieber i ~ % sudo -i
[sudo] password for $USER:
root@rechenschieber i ~ # echo $PROMPT
%K{red}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f

This is not the same $PROMPT. So you **do** set it somewhere for root, don't you?
Maybe it's just silly me, then feel free to ignore my post.

Offline

#6 2013-04-19 11:56:20

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 617

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

gridcol wrote:

Just because I don't get it:

$USER@rechenschieber i ~ % echo $PROMPT
%K{blue}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f
$USER@rechenschieber i ~ % sudo -i
[sudo] password for $USER:
root@rechenschieber i ~ # echo $PROMPT
%K{red}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f

This is not the same $PROMPT. So you **do** set it somewhere for root, don't you?
Maybe it's just silly me, then feel free to ignore my post.

Yeah, it's not exactly the same (I should have been more clear about that), but the definition comes solely from my user's .zshrc:

if $isroot; then
  PROMPT='%K{red}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f'
else
  PROMPT='%K{blue}%n@%m%k %F{magenta}${vimode}%f %B%F{cyan}%~%b%f ${vcs_info_msg_0_}%B%F{white}%# %b%f'
fi

So that tells me that something is actually sourcing that file! But I do not have this file anywhere except for in my user's $HOME

Offline

#7 2013-04-19 12:12:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,449
Website

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

Stalafin wrote:

And considering that I am using this distribution a lot longer than the both of you combined

Great way to motivate people to help: be a dick.

So you only want help from people who are not on #archlinux, who have been members of this forum for more than 6 years.  That primarily leaves mods and admins - but not to worry, I reported this thread to them upon the first post, so they've certainly seen it.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2013-04-19 12:13:24

gridcol
Member
From: Karlsruhe, Germany
Registered: 2012-03-27
Posts: 32

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

Maybe you copied the file/setting somewhere and forgot about it?
I would try to replace the PROMPT in the users .zshrc and see if this affects the output after sudo -i. If it also changes, we have to go on searching, but maybe .... smile

Offline

#9 2013-04-19 13:45:06

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

Stalafin wrote:

Please do enlighten me!

Gladly. Take a look at what you quoted,

$ man 5 sudoers
[snip]
As a special case, if sudo's -i option (initial login) is specified, sudoers will initialize the environment regardless of the value of env_reset.
     The DISPLAY, PATH and TERM variables remain unchanged; HOME, MAIL, SHELL, USER, and LOGNAME are set based on the target user.  On AIX (and Linux sys‐
     tems without PAM), the contents of /etc/environment are also included.  All other environment variables are removed.
[snip]

The relevant part is HOME, MAIL, SHELL, USER, and LOGNAME are set based on the target user. Verify if sudo passes your user's HOME envar to root. If yes, that is how your prompt is being propagated.

Please also read the Forum Etiquette, specifically the following sections,


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#10 2013-04-19 13:51:45

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

To everyone else, if you think someone is trolling or being a nuisance, please do no troll back. Report it and let us moderators handle the situation. Thanks.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#11 2013-04-19 14:08:32

Stalafin
Member
From: Berlin, Germany
Registered: 2007-10-26
Posts: 617

Re: [SOLVED] man 5 sudoers lying to my face - or Archlinux' fault?

gridcol wrote:

Maybe you copied the file/setting somewhere and forgot about it?
I would try to replace the PROMPT in the users .zshrc and see if this affects the output after sudo -i. If it also changes, we have to go on searching, but maybe .... smile

That was the way to go. Turns out, I did set /root/.zshrc. Mea culpa.

The HOME env_var is not propagated to root.

fsck wrote:

To everyone else, if you think someone is trolling or being a nuisance, please do no troll back. Report it and let us moderators handle the situation. Thanks.

I realize that my first post was formulated in a way that was edging on the offensive, which was not my intention. Let's just say, I felt like writing it in a more humorous way. Clearly, that failed.

However, in order to reply the way 2 posters above me did, you really have to insinuate and insist on me having bad intentions (take, as an example, me supposedly insulting the community, not to speak of twisting what I actually wrote). Keeping in mind how rather relaxed the conduct on other community channels is, I am rather surprised you thought it's needed to call me out on trolling.

Offline

Board footer

Powered by FluxBB