LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 09-15-2007, 12:06 PM   #1
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Question bash# "chvt N" as non-root says 'Operation not permitted'


Hiya folks

OK, the basic details first: I have a video card with THREE connectors (DVI, VGA, S-VIDEO), but it will only run any TWO displays at a time.
My main X configuration uses two monitors (DVI & VGA), but I wanted an alternate X configuration I could switch to easily, with output to DVI + SVIDEO, so I could watch movies on the television sometimes.
Rather than do a lot of messing around with multiple xorg.confs, logging-out/in again, or unplugging things, I made two 'ServerLayouts' in my xorg.conf;

Now, by clicking a desktop-link to a one line script like so:

#!/bin/bash
startx -- :1 -layout "television"


A second X session starts using the "television" ServerLayout and displays video on my main monitor, plus the TV. The second monitor turns off. I switch back using CTRL-ALT-F7.
This is cool, and works from my user desktop, but here's the issue(s):

A) Regardless of whether I use a :1 or :2 or :6 or :<any-number> in the command above, the new session starts on CTRL-ALT-F2 (which is technically TTY2 I guess). What do I have to do to get the new session to start on CTRL-ALT-F6 for example? I'd prefer using F7 & F6 than F7 & F2. Just makes better sense to me.

B) More importantly, I have learned that if I want a similarly clickable (bash) method of switching back to CTRL-ALT-F7 (my default X session) it seems I need to use the chvt N command. However, as a regular user, chvt 7 returns a 'Operation Not Permitted' error. As root, it works fine, but I'm not running as root.
The binary chvt is rwx r-x r-x so I should be able to execute it.

I'm sure there is a VERY simple item I am overlooking, but keep coming back to such things as inittab, init, .bashrc, .bash_profile, and similar files, but it doesn't look like the answer lies in one of these files.
Google mostly gives me the same bash and X tutorials paraphrased 100 different ways, but all they focus on are CTRL-ALT-Fn (not a mouse click) and chvt N (works in the tutorials, but not for me).

Guidance is appreciated
Thanks.
 
Old 09-15-2007, 12:40 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by GrapefruiTgirl View Post
A) Regardless of whether I use a :1 or :2 or :6 or :<any-number> in the command above, the new session starts on CTRL-ALT-F2 (which is technically TTY2 I guess). What do I have to do to get the new session to start on CTRL-ALT-F6 for example? I'd prefer using F7 & F6 than F7 & F2. Just makes better sense to me.
The :1 :2 or :6 has nothing to do with which terminal X starts on. It only serves to id the X server so clients may write to its local domain sockets. By default X will start in the first unused tty (i.e., the same as if you ran the command openvt as root).
Quote:
Originally Posted by GrapefruiTgirl View Post
B) More importantly, I have learned that if I want a similarly clickable (bash) method of switching back to CTRL-ALT-F7 (my default X session) it seems I need to use the chvt N command. However, as a regular user, chvt 7 returns a 'Operation Not Permitted' error. As root, it works fine, but I'm not running as root.
The binary chvt is rwx r-x r-x so I should be able to execute it.
chvt, much like the X binary, must be run as root since it does some permission-requiring ioctls on device nodes. Imagine if any (unprivileged) remote user could play with the root terminal! Fortunately, the solution is simple: use sudo with NOPASSWD for that particular command.
 
Old 09-15-2007, 12:55 PM   #3
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Interesting; thank you Osor for the quick and concise reply.

So, kinda funny how I can start an X on another terminal, but then can't use chvn just the same to switch back to my default session.. Well, perhaps I will have to settle on using the CTRL-ALT-F7 method, or right click desktop and switch to my other logon. No big deal. (Note: I don't use SUDO for anything.)

As to the first issue, I was indeed aware that the "DEFAULT" is to open the new session on the first available console, BUT, is there no way to specify an alternate?

Thanks again
 
Old 09-15-2007, 02:16 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by osor View Post
must be run as root since it does some permission-requiring ioctls on device nodes.
On second thought, it might work for an ordinary user if that user has write permission on the tty to which you are changing (i.e., /dev/tty7 permissions are 0666). This can be made to occur with clever udev rules. See if you can get that to work.
Quote:
Originally Posted by GrapefruiTgirl View Post
As to the first issue, I was indeed aware that the "DEFAULT" is to open the new session on the first available console, BUT, is there no way to specify an alternate?
I am not aware of any way to specify an alternate terminal. Well, you could open up tty[2-6] (with openvt) prior to running X, then close them after X has launched (with deallocvt).
 
Old 09-16-2007, 04:44 PM   #5
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Thumbs up Solved - chvt an unnecessary luxury; X session #2 starts on TTY6

Well, here's the situation currently:

I can use the chvt command to change to whatever console I want, ONLY IF I set the SUID bit on chvt.
Despite that I feel chvt is a relatively benign binary, and this is a fairly well hardened desktop system with no (known) remote access or other users, I'd just as soon NOT use SUID for anything not really necessary. This issue isn't that big a deal. I can get by by either logging out of my second X session after the movie, or hitting CTRL-ALT-Fn to switch.

However, I did figure out a way to get my second X session to start up on TTY6 , by changing the following section of my inittab file like so:
Code:
# Standard console login getties in multiuser mode:
c1:1235:respawn:/sbin/agetty 38400 tty1 linux
c2:12345:respawn:/sbin/agetty 38400 tty2 linux
c3:12345:respawn:/sbin/agetty 38400 tty3 linux
c4:12345:respawn:/sbin/agetty 38400 tty4 linux
c5:12345:respawn:/sbin/agetty 38400 tty5 linux
c6:1235:respawn:/sbin/agetty 38400 tty6 linux
This way, the system still boots up on TTY1, and X starts up on TTY7, as usual, but I've made TTY[2..5] into login gettys in run-level 4, so I can actually use them. As such, this leaves TTY6 unused, and so my second X session opens there.

Thanks for the input Osor; I think I will be content with this setup.

P.S. - I also had tried earlier to make sure I had RW permissions to the TTYs. All VC/TTYs are in the group TTY, to which I added my user account, and the permissions of the TTYs were RW-RW---- so should be sufficient, but still, chvt wouldn't let me switch to one.

Last edited by GrapefruiTgirl; 09-17-2007 at 07:35 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"creating symbolic link" "operation not permitted" wheni Linux - Newbie 3 05-08-2011 01:36 AM
"capset: Operation not permitted" error when I run valgrind. rsravi74 Linux - Newbie 1 09-02-2007 05:30 PM
hdparm -d1 /dev/hda gives me "HDIO_SET_DMA failed: Operation not permitted" elluva Linux - Hardware 7 07-21-2007 03:49 AM
"Operation not permitted" error logging in to Ubuntu Dapper Drake paulBottomley Linux - Newbie 7 08-10-2006 11:13 AM
"ioctl: Operation not permitted" (beep media playe) unholy Linux - Software 1 12-18-2004 06:14 PM


All times are GMT -5. The time now is 05:19 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration