Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU Screen won't work on re-entry #115

Closed
gsf opened this issue Apr 13, 2013 · 4 comments
Closed

GNU Screen won't work on re-entry #115

gsf opened this issue Apr 13, 2013 · 4 comments
Labels

Comments

@gsf
Copy link

gsf commented Apr 13, 2013

I think this is a result of 8013ab1, but I'm not sure how best to solve it.

chronos@localhost ~/Downloads$ sudo enter-chroot
gsf@localhost:~$ sudo apt-get install screen
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  byobu
The following NEW packages will be installed:
  screen
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/574 kB of archives.
After this operation, 775 kB of additional disk space will be used.
Selecting previously unselected package screen.
(Reading database ... 10257 files and directories currently installed.)
Unpacking screen (from .../screen_4.0.3-14ubuntu8_armhf.deb) ...
Processing triggers for ureadahead ...
Setting up screen (4.0.3-14ubuntu8) ...
gsf@localhost:~$ screen
[Screen runs as expected]
...
[screen is terminating]
gsf@localhost:~$ logout
Unmounting /usr/local/chroots/precise...
chronos@localhost ~/Downloads$ sudo enter-chroot
gsf@localhost:~$ screen
Cannot make directory '/var/run/screen': Permission denied
gsf@localhost:~$ ll /var/run/
total 4
drwxr-xr-x  3 root root   80 Apr 13 03:58 ./
drwxr-xr-x 21 root root 4096 Apr 13 03:21 ../
drwxrwxrwt  2 root root   40 Apr 13 03:58 lock/
lrwxrwxrwx  1 root root    8 Apr 13 03:58 shm -> /dev/shm/
gsf@localhost:~$ sudo apt-get install --reinstall screen
[sudo] password for gsf: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/574 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 10309 files and directories currently installed.)
Preparing to replace screen 4.0.3-14ubuntu8 (using .../screen_4.0.3-14ubuntu8_armhf.deb) ...
Unpacking replacement screen ...
Processing triggers for ureadahead ...
Setting up screen (4.0.3-14ubuntu8) ...
gsf@localhost:~$ ll /var/run/
total 4
drwxr-xr-x  4 root root  100 Apr 13 04:00 ./
drwxr-xr-x 21 root root 4096 Apr 13 03:21 ../
drwxrwxrwt  2 root root   40 Apr 13 03:58 lock/
drwxrwxr-x  2 root utmp   40 Apr 13 04:00 screen/
lrwxrwxrwx  1 root root    8 Apr 13 03:58 shm -> /dev/shm/
gsf@localhost:~$ screen
[Screen runs as expected]
@dnschneid
Copy link
Owner

Turns out screen depends on an init script to add its /var/run/screen directory:

SCREENDIR=/var/run/screen
if [ -L $SCREENDIR ] || [ ! -d $SCREENDIR ]; then
    rm -f $SCREENDIR
    mkdir $SCREENDIR
    chown root:utmp $SCREENDIR
fi
find $SCREENDIR -type p -delete
# If the local admin has used dpkg-statoverride to install the screen
# binary with different set[ug]id bits, change the permissions of
# $SCREENDIR accordingly
BINARYPERM=`stat -c%a /usr/bin/screen`
if [ "$BINARYPERM" -ge 4000 ]; then
    chmod 0755 $SCREENDIR
elif [ "$BINARYPERM" -ge 2000 ]; then
    chmod 0775 $SCREENDIR
else
    chmod 0777 $SCREENDIR
fi

You can add the exact same thing to /etc/rc.local, and crouton will run it when you first enter the chroot. Not much crouton can do by default for you, since it will not parse and run init scripts automatically.

@gsf
Copy link
Author

gsf commented Apr 13, 2013

Thanks! I had figured out something similar.

Due to https://bugs.launchpad.net/ubuntu/+source/screen/+bug/574773 I thought I could add /etc/init.d/screen-cleanup to /etc/rc.local in the chroot, but it's an upstart script, so it's right out. I instead went stupid simple and added these lines:

mkdir /var/run/screen
chmod 775 /var/run/screen
chgrp utmp /var/run/screen

I could one-line those or move them into a script later on, but that works for now.

I ❤️ crouton! I've been taking some notes on my setup at https://gist.github.com/5377654.

@dnschneid
Copy link
Owner

Thanks for sharing! I'm guessing you're using ssh just to get the newer hterm? Try the crosh window extension; it uses the ssh app's hterm to launch a shell in a new window.

@gsf
Copy link
Author

gsf commented Apr 13, 2013

Nice! I am using ssh just for a window, and that extension definitely simplifies things. One thing hterm still has over the crosh window, though, is a title bar that plays nicely with screen:

Screenshot 2013-04-13 at 6 26 45 AM

The crosh window will still come in handy, I'm sure. Anyway, I really can't thank you enough for turning my chromebook into a fantastic development machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants