[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: which display is active and which user is logged in? (kdm?)



On Wednesday 02 April 2003 23:45, Oswald Buddenhagen wrote:
> On Wed, Apr 02, 2003 at 08:29:16PM +0000, David Pye wrote:
> > However, I'm not sure how you 
> > can find out which one is currently being displayed.
> > 
> oh, right, i forgot that part. fgconsole. but this works only as root,
> so you need to define a sudo rule if a regular user should be able to
> execute it. alternatively you can make it suid root, but somehow i doubt
> that this is a good idea.

Great one peace more of the puzzle.  Here fgconsole works also for normal user:

ach@lost(0) ~ $ fgconsole
7
ach@lost(2) ~ $ whoami
ach

fgconsole return error code 2. Strange but it does the same for root.

Looks like Xserver does not change the tty<n>:
(vt7,8 are kdm managed displays,  vt12 is used by X -query ...):

ach@lost(0) ~ $ l -L /dev/tty{[1-9],1{0,1,2}}
crw-------    1 root     root       4,   1 Mar 31 10:51 /dev/tty1
crw-rw-rw-    1 root     tty        4,  10 Jan  1  1970 /dev/tty10
crw-rw-rw-    1 root     tty        4,  11 Jan  1  1970 /dev/tty11
crw-rw-rw-    1 root     root       4,  12 Jan  1  1970 /dev/tty12
crw-------    1 root     root       4,   2 Mar 17 17:20 /dev/tty2
crw-------    1 root     root       4,   3 Mar 17 17:20 /dev/tty3
crw-------    1 root     root       4,   4 Mar 17 17:20 /dev/tty4
crw-------    1 root     root       4,   5 Mar 17 17:20 /dev/tty5
crw-------    1 root     root       4,   6 Mar 17 17:20 /dev/tty6
crw-rw-rw-    1 root     root       4,   7 Jan  1  1970 /dev/tty7
crw-rw-rw-    1 root     root       4,   8 Jan  1  1970 /dev/tty8
crw-rw-rw-    1 root     root       4,   9 Jan  1  1970 /dev/tty9

It this a (security) bug?  I've tried
	echo some garbage > /dev/tty8
but :1 (on vt8) is still working.


Back on topic ;)  Missing is now  vt# -> display#.  I hacked this little
script.  Anyone care to test?  Works here(tm).  (Better methods that
work with {k,g,w,x}dm etc welcome.)

#!/bin/bash
vtnum=`fgconsole`
match=`grep -l " using VT number $vtnum$" /var/log/XFree86.*.log`
if [ "$match" ]; then
        display="${match#/var/log/XFree86.}"
        display="${display%.log}"
        user="`who | grep " :$display " | awk '{print $1}'`"
        echo display=:$display
        echo user=$user
	# groups $user | grep -q camera && exec su - $user  "DISPLAY="$display" exec digikam 
	exit 0
else
	exit 1
fi

Thx for all the help,
Achim
> 
> greetings
> 
> 
> -- 
> Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
> --
> Chaos, panic, and disorder - my work here is done.
-- 
  To me vi is Anti-Virus software:  Signature not copied ;)



Reply to: