9
6
When I'm logged in as user "paul" on a virtual terminal (/dev/tty2 for example) and I type in "chvt 4" I get switched over to the virtual terminal for /dev/tty4 just fine.
When, as user "paul" I type "chvt 7" I get switched over to the X window system. Just fine.
HOWEVER... Within an xterm, if as user "paul" I type "chvt 2" I get the following error: "Couldn't get a file descriptor referring to the console"
The chvt command only works from within an xterm when I run it as "root", in which case, it's then happy to switch me over to a virtual terminal.
This seems very broken to me. Does anyone know why this is as it is?
I could be off on this but i thought the portion of DISPLAY to the left of the : identified the host? So, 0 aka 0.0.0.0 aka localhost, or 127.0.0.1 and possibly some others would indicate localhost, meaning it's a local display. I added NOPASSWD to sudoers and an alias or two so I can switch back and forth now seamlessly, but it's a hack. Still perplexed re: why it wouldn't be possible to fix this. – pbr – 2012-04-18T03:02:07.357
Wow... outstanding details as to why this is the way it is. Thank you, ~quack!
<p> Still it seems wrong to me that this doesn't work when DISPLAY is 0:0 or 0:N i.e. in the case where the X client is running locally. <p> With X over a network DISPLAY would be 1:0...N, 2:0..N, etc. and yes from a security perspective any X clients not on 0:0..N should fail. <p> It's just a shame that these programs fail when run from local clients without sudo. – pbr – 2009-11-24T01:29:58.550
it's just "hostname:x.y", and since "y" is usually "0" we can shorten it to "hostname:x". there's no local/remote difference -- the :N doesn't tell X anything about whether it's a remote or local display. for example, right now my server runs Xvnc on myserver:0. if i wanted, i could configure it to run on myserver:2 instead -- that doesn't necessarily mean there's an x-server on myserver:0 and myserver:1 as well. so X can't tell whether you're local or remote just from the :N display number. – quack quixote – 2009-11-24T04:26:47.590