[FFE] autofs5-ldap doesn't work immediately after bootup

Bug #533029 reported by Andrew Pollock
34
This bug affects 6 people
Affects Status Importance Assigned to Milestone
autofs5 (Ubuntu)
Fix Released
High
Chuck Short
Lucid
Fix Released
High
Chuck Short

Bug Description

Binary package hint: autofs5

If you log into a system that using automounted home directories and autofs5-ldap, you don't get your home directory mounted. If you wait a little while, or reload autofs, the home directory becomes automountable.

I think the problem is that autofs is starting via the legacy init scripts before the network is started by Upstart.

Tags: glucid

Related branches

Revision history for this message
Andrew Pollock (apollock) wrote :

This is the upstart job that I've hacked together, but either it's incorrect, or Upstart is misbehaving, because it's not working terribly well.

description "automounter"
author "Andrew Pollock <email address hidden>"

start on (net-device-up IFACE!=lo)
stop on runlevel [!2345]

expect daemon
respawn

pre-start script
 . /etc/default/autofs

 # Make sure the (right) kernel module is loaded
 if ! grep -q autofs /proc/filesystems; then
  if !modprobe autofs4 >/dev/null 2>&1; then
   echo "Error: failed to load autofs4 module"
   exit 1
  fi
 elif [ -f /proc/modules ] && grep -q ^autofs[^4] /proc/modules; then
  # wrong autofs filesystem module loaded
  echo
  echo "Error: autofs kernel module is loaded, autofs4 required"
  exit 1
 fi

 # Check misc device
 if [ -n "$USE_MISC_DEVICE" -a "$USE_MISC_DEVICE" = "yes" ]; then
  sleep 1
  if [ -e "/proc/misc" ]; then
   MINOR=$(awk '/autofs/ { print $1 }' /proc/misc)
   if [ -n "$MINOR" -a ! -c "/dev/autofs" ]; then
    mknod -m 0600 /dev/autofs c 10 $MINOR
   fi
  fi
  if [ -x /sbin/restorecon -a -c /dev/autofs ]; then
   /sbin/restorecon /dev/autofs
  fi
 else
  if [ -c /dev/autofs ]; then
   rm /dev/autofs
  fi
 fi
end script

exec /usr/sbin/automount

Revision history for this message
Andrew Pollock (apollock) wrote :

Sounds like I was experiencing bug #406397

Here's the Upstart job I'm currently using, which seems to be working insofar as it starts autofs. It hasn't solved the problem I was trying to solve though.

description "automounter"
author "Andrew Pollock <email address hidden>"

start on (net-device-up IFACE!=lo)
stop on runlevel [!2345]

expect fork
respawn

pre-start script
 . /etc/default/autofs

 # Make sure the (right) kernel module is loaded
 if ! grep -q autofs /proc/filesystems; then
  if ! modprobe autofs4 >/dev/null 2>&1; then
   echo "Error: failed to load autofs4 module"
   exit 1
  fi
 elif [ -f /proc/modules ] && grep -q ^autofs[^4] /proc/modules; then
  # wrong autofs filesystem module loaded
  echo
  echo "Error: autofs kernel module is loaded, autofs4 required"
  exit 1
 fi

 # Check misc device
 if [ -n "$USE_MISC_DEVICE" -a "$USE_MISC_DEVICE" = "yes" ]; then
  sleep 1
  if [ -e "/proc/misc" ]; then
   MINOR=$(awk '/autofs/ { print $1 }' /proc/misc)
   if [ -n "$MINOR" -a ! -c "/dev/autofs" ]; then
    mknod -m 0600 /dev/autofs c 10 $MINOR
   fi
  fi
  if [ -x /sbin/restorecon -a -c /dev/autofs ]; then
   /sbin/restorecon /dev/autofs
  fi
 else
  if [ -c /dev/autofs ]; then
   rm /dev/autofs
  fi
 fi
end script

exec /usr/sbin/automount

Revision history for this message
Andrew Pollock (apollock) wrote :

With further testing, I think just using an upstart job instead of a legacy init script does solve the problem I was having.

summary: - autofs5-ldap needs an upstart job
+ autofs5-ldap doesn't work immediately after bootup
description: updated
Revision history for this message
Cédric Dufour (cdufour-keyword-ubuntu-086000) wrote : Re: autofs5-ldap doesn't work immediately after bootup

I had the same problem and incompletely hacked a solution as in https://bugs.launchpad.net/ubuntu/+source/autofs/+bug/511245/comments/5. Maybe it can help.

Revision history for this message
Chuck Short (zulcss) wrote :

Thanks for the examples I have added them for the next upload. We will need an FFE exception for them as well.

Regards
chuck

Changed in autofs5 (Ubuntu):
importance: Undecided → High
status: New → Triaged
Thierry Carrez (ttx)
Changed in autofs5 (Ubuntu Lucid):
assignee: nobody → Chuck Short (zulcss)
Revision history for this message
Chuck Short (zulcss) wrote :

I would like to ask for a FFE for autofs. I have provided an upstart job for autofs5 that should fix this issue. I have supplied the following:

- a debdiff
- a buildlog
- example of it running

Regards
chuck

summary: - autofs5-ldap doesn't work immediately after bootup
+ [FFE] autofs5-ldap doesn't work immediately after bootup
Revision history for this message
Chuck Short (zulcss) wrote :
Revision history for this message
Chuck Short (zulcss) wrote :
Revision history for this message
Chuck Short (zulcss) wrote :
Revision history for this message
Steve Langasek (vorlon) wrote :

The setup work needs to be put in a pre-start script, not in the 'script'; otherwise upstart will be confused because it's told to 'expect fork', and there are several forked processes in this script and upstart has no way to know which is the correct one.

Revision history for this message
Chuck Short (zulcss) wrote :

Updated debdiff

Revision history for this message
Steve Langasek (vorlon) wrote :

+pre-script

Wrong; this is "pre-start script".

+ echo "Error: failed to load autofs4 module."
+ return 1

+ # wrong autofs filesystem module loaded
+ echo
+ echo "Error: autofs kernel module is loaded, autofs4 required"
+ return 1

Instead of 'return 1', these should be 'stop; exit 1' - otherwise, the 'respawn' will cause upstart to repeatedly try to launch the daemon even though it's guaranteed to fail.

+ exec /usr/sbin/automount $OPTIONS

I guess this $OPTIONS variable is meant to be taken from /etc/default/autofs, but there's nothing in the job that makes this variable to the 'exec' - sourcing it in the pre-start script only makes it available to the pre-start script.

Either the unused $OPTIONS should be dropped, or this should be rewritten as:

script
       if [ -f /etc/default/autofs ]; then
               . /etc/default/autofs
       fi
       exec /usr/sbin/automount $OPTIONS
end script

Revision history for this message
Chuck Short (zulcss) wrote :

Updated debdiff

Revision history for this message
Cédric Dufour (cdufour-keyword-ubuntu-086000) wrote :

Please don't drop the $OPTIONS (. /etc/default/autofs). These may really be handy!
Besides - sorry for being slightly off-topic, but - the supplied /etc/default/autofs file mentions options and variables (e.g. BROWSE_MODE, APPEND_OPTIONS, etc.) that *seem* to be used nowhere in /etc/init.d or /etc/init scripts (nor mentioned in the man pages). Am I missing something? If not, it is really confusing...

Revision history for this message
Steve Langasek (vorlon) wrote :

latest debdiff looks correct; approved.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package autofs5 - 5.0.4-3.1ubuntu5

---------------
autofs5 (5.0.4-3.1ubuntu5) lucid; urgency=low

  FFE LP: #533029

  * Replace init script with Upstart job:
    - debian/rules, debian/autofs5.autofs.upstart: Add upstart job.
 -- Chuck Short <email address hidden> Mon, 12 Apr 2010 08:56:32 -0400

Changed in autofs5 (Ubuntu Lucid):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.