Ivan Warren wrote:
John Summerfield wrote:
In contrast, the tty command returns an actual device name when possible.
Talking about tty.. (labeit in a slightly different context for the word
'tty' !)
There is one big diff between a login & a 'su -' :
You don't gain ownership of /dev/tty on 'su -'.. This is some effect
when you're going from root to a less privileged user..
And it does affect *some* programs (like screen)..
I'm looking at CentOS5 on a PC. I'm running inside X (xorg). Oh, just in
case it matters, I'm running KDE. Who knows, it could be different in GNOME.
08:42 [sum...@bobtail ~]$ \ls -l $(tty)
crw------- 1 summer tty 136, 17 Mar 4 20:24 /dev/pts/17
20:24 [sum...@bobtail ~]$
so there is a problem there.
Inside screen, each session gets its own tty. The tty is as above except
group-writable. Directly logged into a console, it's owner rw, group w.
Connecting via ssh:
[r...@bobtail ~]# \ls -l $(tty)
crw--w---- 1 root tty 136, 22 Mar 4 20:30 /dev/pts/22
[r...@bobtail ~]#
HOWEVER, I logged in as root, used "su - summer" and it's all working,
until I do this:
20:33 [sum...@bobtail ~]$ id -Gn >$(tty)
-bash: /dev/pts/22: Permission denied
20:34 [sum...@bobtail ~]$
The reason is that the file handles are inherited, and while they remain
open the original permissions apply.
So the tty command tells you whether you have a terminal, but you need
to test whether you can read/write if before opening new handles.
sudo is setuid root, so _it_ is okay.
--
Cheers
John
-- spambait
[email protected] [email protected]
-- Advice
http://webfoot.com/advice/email.top.php
http://www.catb.org/~esr/faqs/smart-questions.html
http://support.microsoft.com/kb/555375
You cannot reply off-list:-)
----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390