Skip to contentSkip to conversation

Bug#299298: autofs: set -e still too strong

DISCUSSION Steinar H. Gunderson 2 participants 2 messages Mar 13, 2005 – Mar 14, 2005 1 message not in the archive Kernel automounter

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · Tim Connors

If restarting autofs when a mountpoint is busy, or if the daemon has been killed manually, then the script never gets around to doing anything, failing midsentence, without printing an proper error message, because the start-stop-daemon isn't protected, despite the error code being explicitly checked thereafter:

30600,43> /etc/init.d/autofs restart
Stopping automounter:1-0-23:03:30, Sun Mar 13 root@bohr:/home/tconnors (bash)

I'll forward this upstream, but I think in general "set -e" makes a lot more sense than just silently go on if anything unexpected would fail. To me, it looks like the init script should simply check the return value of start-stop-daemon; I don't think just removing "set -e" is the magic bullet.

(Rest of the mail kept for Ian and the others on the autofs mailing list :-) )

Quoted 42 lines

Since it makes sense to run restart when the daemon could possibly be not there (since restart is the automatic thing to do upon an upgrade), and since it makes sense to restart the daemon when a mountpoint is busy (new processes will get the new mountpoint with new mount flags, old processes will continue to use the stale mount point), then I think the proper thing to do is to print the message, and then just continue as before.

Is `set -e' really the right thing to do? I think a wise man (possibly Dijkstra) once said "don't check for errors you don't explicitly know how to handle". Since we already check for all conceivable errors, then does an extra `set -e' help anything? It only seems to cause us to not issue correct errors when we really do fail -- see also bug 295480.

Relevant trace follows:

30599,42> bash -x /etc/init.d/autofs restart
+ FLAGS='defaults 21'
+ DAEMON=/usr/sbin/automount
...
+ debian restart
+ set -e
+ case "$1" in
+ debian stop
+ set -e
+ case "$1" in
+ echo -n 'Stopping automounter:'
Stopping automounter:+ umount_loopback
++ LC_ALL=C
++ awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts
+ loops=
++ LC_ALL=C
++ awk '!/^#/ && $1 ~ /^automount/ {print $2}' /proc/mounts
+ automounts=/var/autofs/net
++ LC_ALL=C
++ awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts
+ loopmnts=
+ any=0
++ ls /var/run/autofs/_var_autofs_net.pid
+ for file in 'ls /var/run/autofs/*.pid 2>/dev/null'
+ '[' -e /var/run/autofs/_var_autofs_net.pid ']'

Quoted 8 lines

+ any=1
++ head -n 1 /var/run/autofs/_var_autofs_net.pid
+ pid=31598
++ ps -wwo cmd= 31598
++ sed -e 's,.* --pid-file=/var/run/autofs/\([^ ]*\)\.pid.*,\1,; s,_,/,g'
+ mnt=
+ start-stop-daemon --stop --quiet --retry USR2/20 --pidfile /var/run/autofs/_var_autofs_net.pid --exec /usr/sbin/automount 1-0-23:01:24, Sun Mar 13 root@bohr:/home/tconnors (bash)

/* Steinar */

Signature · 1 line
Homepage: http://www.sesse.net/
maintainer
#2 lore raw
Quoted 7 lines · Steinar H. Gunderson
Quoted 6 lines · Tim Connors

If restarting autofs when a mountpoint is busy, or if the daemon has been killed manually, then the script never gets around to doing anything, failing midsentence, without printing an proper error message, because the start-stop-daemon isn't protected, despite the error code being explicitly checked thereafter:

Quoted 7 lines
Quoted 2 lines

30600,43> /etc/init.d/autofs restart
Stopping automounter:1-0-23:03:30, Sun Mar 13 root@bohr:/home/tconnors (bash)

I'll forward this upstream, but I think in general "set -e" makes a lot more sense than just silently go on if anything unexpected would fail. To me, it looks like the init script should simply check the return value of start-stop-daemon; I don't think just removing "set -e" is the magic bullet.

Personally I'd prefer not to use the set -e.
It is included because the Debian patch sets included it.

At first glance it appears this is may be a case where we need to explicitly turn this of to get the required behaviour.

Quoted 63 lines

(Rest of the mail kept for Ian and the others on the autofs mailing list :-) )

Quoted 42 lines

Since it makes sense to run restart when the daemon could possibly be not there (since restart is the automatic thing to do upon an upgrade), and since it makes sense to restart the daemon when a mountpoint is busy (new processes will get the new mountpoint with new mount flags, old processes will continue to use the stale mount point), then I think the proper thing to do is to print the message, and then just continue as before.

Is `set -e' really the right thing to do? I think a wise man (possibly Dijkstra) once said "don't check for errors you don't explicitly know how to handle". Since we already check for all conceivable errors, then does an extra `set -e' help anything? It only seems to cause us to not issue correct errors when we really do fail -- see also bug 295480.

Relevant trace follows:

30599,42> bash -x /etc/init.d/autofs restart
+ FLAGS='defaults 21'
+ DAEMON=/usr/sbin/automount
...
+ debian restart
+ set -e
+ case "$1" in
+ debian stop
+ set -e
+ case "$1" in
+ echo -n 'Stopping automounter:'
Stopping automounter:+ umount_loopback
++ LC_ALL=C
++ awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts
+ loops=
++ LC_ALL=C
++ awk '!/^#/ && $1 ~ /^automount/ {print $2}' /proc/mounts
+ automounts=/var/autofs/net
++ LC_ALL=C
++ awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $1}' /proc/mounts
+ loopmnts=
+ any=0
++ ls /var/run/autofs/_var_autofs_net.pid
+ for file in 'ls /var/run/autofs/*.pid 2>/dev/null'
+ '[' -e /var/run/autofs/_var_autofs_net.pid ']'

Quoted 8 lines

+ any=1
++ head -n 1 /var/run/autofs/_var_autofs_net.pid
+ pid=31598
++ ps -wwo cmd= 31598
++ sed -e 's,.* --pid-file=/var/run/autofs/\([^ ]*\)\.pid.*,\1,; s,_,/,g'
+ mnt=
+ start-stop-daemon --stop --quiet --retry USR2/20 --pidfile /var/run/autofs/_var_autofs_net.pid --exec /usr/sbin/automount 1-0-23:01:24, Sun Mar 13 root@bohr:/home/tconnors (bash)

/* Steinar */

Signature · 6 lines
Homepage: http://www.sesse.net/

_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs