Re: prompt w/ uid 0 for cshrc

2012-11-23 Thread Tim Kientzle

On Nov 19, 2012, at 8:46 AM, jb wrote:

 Eitan Adler lists at eitanadler.com writes:
 
 
 On 18 November 2012 18:44, Mateusz Guzik mjguzik at gmail.com wrote:
 Just take user name from id -nu.
 
 While that does provide the $user value I want, id is in /usr/bin/
 which may not be mounted.
 
 /rescue/id

Bad idea:
  * /rescue tools are not part of the standard world
  * /rescue tools are sometimes not installed
  * Quite a few people have customized the rescue tools to adding or omitting 
things suitable for their particular installation.
  * /rescue tools are not guaranteed to be functionally identical to the 
non-rescue versions.

Better to invoke 'id' in a way that produces
reasonable results if 'id' is unavailable.

For example:
/bin/sh -c 'id -nu 2/dev/null' || echo '?'

prints '?' if the id command fails or is unavailable.

Tim

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: prompt w/ uid 0 for cshrc

2012-11-19 Thread Eitan Adler
On 18 November 2012 18:44, Mateusz Guzik mjgu...@gmail.com wrote:
 Just take user name from id -nu.

While that does provide the $user value I want, id is in /usr/bin/
which may not be mounted.
Is there a builtin which provides similar functionality?



-- 
Eitan Adler
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: prompt w/ uid 0 for cshrc

2012-11-19 Thread jb
Eitan Adler lists at eitanadler.com writes:

 
 On 18 November 2012 18:44, Mateusz Guzik mjguzik at gmail.com wrote:
  Just take user name from id -nu.
 
 While that does provide the $user value I want, id is in /usr/bin/
 which may not be mounted.

/rescue/id
jb




___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: prompt w/ uid 0 for cshrc

2012-11-19 Thread Mateusz Guzik
On Mon, Nov 19, 2012 at 10:45:35AM -0500, Eitan Adler wrote:
 On 18 November 2012 18:44, Mateusz Guzik mjgu...@gmail.com wrote:
  Just take user name from id -nu.
 
 While that does provide the $user value I want, id is in /usr/bin/
 which may not be mounted.
 Is there a builtin which provides similar functionality?
 

Valid point, but should not happen a lot when unprivileged accounts are
involved, so I suggest the following (pseudo-sh-code):

if [ -x /usr/bin/id ]; then
up=$(id -nu);
else if [ $uid = 0 ]; then
up=root;
else
up=($uid)
fi

-- 
Mateusz Guzik mjguzik gmail.com
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: prompt w/ uid 0 for cshrc

2012-11-19 Thread Eitan Adler
On 18 November 2012 18:32, Eitan Adler li...@eitanadler.com wrote:
 Hey,

 at the moment the current default csh prompt looks like

 user@hostname:directory% command

 This leads to an unexpected[*] result when using su (without -).

 In particular the user part is *not* changed to root (or toor or
 any other superuser indication) although the promptchar is changed to
 #.
 This causes some confusion for new users and even some experienced ones.

 I worked around this issue by including the following

 if ($uid == 0) then
 set user = root
 endif

 which I'm not certain is a good idea.

 I would like to replace this with logic like

 if $uid = 0 AND $user != toor AND $user != root
   set user = +$user
 endif

 does anyone think this is a bad idea? can anyone propose a better
 idea? Is the status quo okay?
...

I was pointed in the right direction. I should use %N instead of %n.



-- 
Eitan Adler
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


prompt w/ uid 0 for cshrc

2012-11-18 Thread Eitan Adler
Hey,

at the moment the current default csh prompt looks like

user@hostname:directory% command

This leads to an unexpected[*] result when using su (without -).

In particular the user part is *not* changed to root (or toor or
any other superuser indication) although the promptchar is changed to
#.
This causes some confusion for new users and even some experienced ones.

I worked around this issue by including the following

if ($uid == 0) then
set user = root
endif

which I'm not certain is a good idea.

I would like to replace this with logic like

if $uid = 0 AND $user != toor AND $user != root
  set user = +$user
endif

does anyone think this is a bad idea? can anyone propose a better
idea? Is the status quo okay?

I don't trust user education for this problem. I've seen way too many
people get confused to leave the default without some extra indicator.

[*] Okay, so this is expected if you understand the difference between
su and su - but the defaults are not aimed at people that
understand this difference.


-- 
Eitan Adler
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: prompt w/ uid 0 for cshrc

2012-11-18 Thread Mateusz Guzik
On Sun, Nov 18, 2012 at 06:32:20PM -0500, Eitan Adler wrote:
 Hey,
 
 at the moment the current default csh prompt looks like
 
 user@hostname:directory% command
 
 This leads to an unexpected[*] result when using su (without -).
 
 In particular the user part is *not* changed to root (or toor or
 any other superuser indication) although the promptchar is changed to
 #.
 This causes some confusion for new users and even some experienced ones.
 
 I worked around this issue by including the following
 
 if ($uid == 0) then
 set user = root
 endif
 
 which I'm not certain is a good idea.
 
 I would like to replace this with logic like
 
 if $uid = 0 AND $user != toor AND $user != root
   set user = +$user
 endif
 
 does anyone think this is a bad idea? can anyone propose a better
 idea? Is the status quo okay?
 

Just take user name from id -nu.

-- 
Mateusz Guzik mjguzik gmail.com
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org