dnschneid / crouton

Chromium OS Universal Chroot Environment
https://goo.gl/fd3zc?si=1
BSD 3-Clause "New" or "Revised" License
8.57k stars 1.24k forks source link

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

Closed gsf closed 11 years ago

gsf commented 11 years ago

I think this is a result of 8013ab1773ad59d821662502d9b3bf8b747e06f5, 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 commented 11 years ago

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 commented 11 years ago

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 :heart: crouton! I've been taking some notes on my setup at https://gist.github.com/5377654.

dnschneid commented 11 years ago

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 commented 11 years ago

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.