Re: screen with su and dosemu

Phil!Gregory <[email protected]> Thu, 18 Mar 2004 20:04:07 -0500
Newsgroups gmane.comp.gnu.screen
Message-ID <[email protected]>
* <[email protected]> <[email protected]> [2004-03-18 22:15 +0100]:
> su - [specific application user] -c "screen dosemu"
> 
> But i have the following error.
> "Cannot open your terminal '/dev/pts/0' - please check."

screen requires read and write access to the terminal (or pseudoterminal)
that you are using.  Most of the time, only the owner of the terminal can
do that, though.

  $ tty
  /dev/pts/7
  $ ls -l /dev/pts/7
  crw--w----    1 phil     tty      136,   7 2004-03-18 19:47 /dev/pts/7

Since su changes the user that screen runs as, it no longer has enough
access to your terminal.

There are a couple of things that you can do to deal with this.  The
simplest is just to change the permissions on your terminal before running
screen as a different user:

  $ chmod 777 `tty`
  $ su - <user> -c "screen dosemu"
  [do stuff, detach]

This approach will require that you change your terminal permissions every
time you want to reattach to the screen session.

A somewhat better solution is to use screen's multiuser capabilities.
This may get a little complicated, but some of this information should be
useful even if you don't go multiuser.

First off, if this is in your system startup scripts, you need to start
screen detached.  Otherwise, you have to be at the machine's console to
detach the screen session as soon as it starts.  (If you're not, it may
even hold up the boot process.)  The '-d -m' option combination to screen
will create a new session in detached mode, so your startup script would
contain

  su - <dosemu user> -c "screen -d -m dosemu"

This will start screen, but it will be running as the dosemu user, so
ordinarily you'd still have to play with tty permissions when you wanted
to reconnect ... unless you enable multiuser support.  Add these lines to
the .screenrc in the dosemu user's home directory:

  multiuser on
  addacl <your username>

Then you, as your regular user can just use the command

  screen -r <dosemu user>/

to reattach to the dosemu screen session.

-- 
...computer contrarian of the first order... / http://aperiodic.net/phil/
PGP: 026A27F2  print: D200 5BDB FC4B B24A 9248  9F7A 4322 2D22 026A 27F2
--- --
Many an ancient lord's last words had been, "You can't kill me because I've
got magic aaargh."
                       -- _Interesting Times_, Terry Pratchett
---- --- --


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Upgrade to 128-bit SSL Security!
http://us.click.yahoo.com/LPJzrA/yjVHAA/TtwFAA/NhFolB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/gnu-screen/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/