views:

399

answers:

4

I want to use GNU screen in such a way that the user doesn't know it's there. It's to help ensure that a text based management application that I'm writing can only be used by a single user at a time. To guard against against users locking everyone else out by running the application and going, leaving it running when going on holiday, I want to be able to detach their session and allow another user to attach to it.

So my questions is:

  • Can I set the escape key in .screenrc to null, so that the user can't access any of screen's functionality themselves?
+2  A: 

It looks like the following in .screenrc does the trick:

escape ''

This does not set the escape character to ', but disables the escape mechanism entirely.

Greg Hewgill
I successfully managed to get into screen's command mode (or whatever) by typing Ctrl-Shift-@ (which outputs 0x00 to the terminal) using your example.
strager
Hmm, I tried that keystroke too but was unable to make that work. That's why I said I wouldn't count on it. :)
Greg Hewgill
Your update works (or, at least, I can't find the sequence which enables it). Another step to making screen transparent is to set the TERM to something other than "screen".
strager
I suggest moving your update (the correct answer) to the top of your post, or removing the rest of the content.
strager
Good idea, thanks. Interested parties who read the above comments can go look at the revision history. :)
Greg Hewgill
A: 

Maybe just set the escape character in .screenrc to an obscure character from the ASCII table which cannot by typed on a keyboard. I think the character 176 would be an example (or try any other one outside the normal range):

escape ^°°

Just put it in your .screenrc file, and your users won't be able to access any screen functionality:

perl -e 'print "escape ^", chr(176), chr(176), "\n"' >> .screenrc
How about 0x7F (delete character)?
strager
You can still type any arbitrary ASCII character, using Alt+nnn or copy and paste. Including chr(0x7F).
Greg Hewgill
@Hewgill, You can use Alt+nnn on an average terminal?
strager
@Hewgill, first, they won't even know that there is such a character. Second, even if they know the character, can you do Alt+nnn together with Ctrl?
@strager: The question didn't say anything about an "average terminal". I had interpreted the question to mean that people would be accessing the application from their normal PC workstations, through something like Putty or other terminal emulator.
Greg Hewgill
@dehmann: There's no need to use Ctrl, since the Alt+nnn method generates ASCII characters based on the number typed. Control characters can be generated by typing Alt+1 through Alt+31 (Alt+0 doesn't seem to generate a null, at least on my XP workstation).
Greg Hewgill
A: 

Preventing the user from using the functionality of Screen is bad form (unless you have a shared login which runs your application).

Instead, make your application deal with the use case you've shown by autologout, warning new connecting users and giving them the option to boot the other user, handling multiple users, etc.

Adam Hawes
A: 

instead of using screen, consider using detachtty/attachtty

Vardhan Varma