[Lxc-users] upstart /etc/init/screen-cleanup.conf

Trent W. Buck trentbuck at gmail.com
Wed Jan 26 04:20:13 UTC 2011


A race condition in my containers means that occasionally
/var/run/screen/ isn't present when startup finishes and I SSH in.
This results in an error when normal users try to run screen.

I believe the race is against my lxc integration job:

    root at imago:~# cat /etc/init/lxc.conf
    description "LXC vs. Upstart workarounds"
    start on startup
    task
    console output
    script
     # As lxc 0.7's halt/reboot detection hack needs /var/run to NOT be a
     # tmpfs, we need to manually clean it -- esp. the ifstate file that
     # tells falsely tells ifupdown "lo is up".
     #
     # To debug, add -printf "Deleting stale file %p\n" before -delete.
     find /var/run/ -xdev -not -path /var/run/ -delete
     initctl emit -n stopped JOB=udevtrigger
     initctl emit -n started JOB=udev
     # This one is needed for broken ifupdown NMU 0.6.8ubuntu29.1
     initctl emit -n net-device-up IFACE=lo LOGICAL=lo ADDRFAM=inet
     METHOD=loopback
    end script

The screen-cleanup job is

    root at imago:~# grep -v ^$ /etc/init/screen-cleanup.conf
    # screen
    description "GNU Screen Cleanup"
    author "Dustin Kirkland <kirkland at canonical.com>"
    start on filesystem
    task
    script
      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
    end script

Obviously the *right* solution is to use a tmpfs for /var/run, as
non-containerized Ubuntu does.  Since this breaks lxc-start's
reboot/halt (via utmp) detection, I'm looking for the next best
workaround.

I think this is probably to disable /etc/init/mountall.conf and spoof
its events at the end of /etc/init/lxc.conf.  mountall.conf is currently
a noop -- I don't allow containers to perform mounts -- but I left it
enabled because it generates a whole bunch of events and I haven't
gotten around to working out exactly what they are yet.





More information about the lxc-users mailing list