Hi

In the hopes that some of these might be helpful (and I won't
have to merge them for future releases *g*) here the commented
patches I'm applying to the debian package. I think I posted
some of them already, I hope you don't mind if I just post them
again.




sorting was made locale-robust, showmount is located in sbin on
debian, using a PATH would be preferable IMHO


--- bak/samples/auto.net~       2004-09-03 22:11:51.000000000 +0200
+++ bak/samples/auto.net        2004-09-03 22:19:02.000000000 +0200
@@ -9,7 +9,7 @@
 
 # add "nosymlink" here if you want to suppress symlinking local filesystems
 # add "nonstrict" to make it OK for some filesystems to not mount
-opts="-fstype=nfs,hard,intr,nodev,nosuid"
+opts="-fstype=nfs,hard,intr,nodev,nosuid,nonstrict,rsize=8192,wsize=8192,async"
 
 # Showmount comes in a number of names and varieties.  "showmount" is
 # typically an older version which accepts the '--no-headers' flag
@@ -19,9 +19,9 @@
 #SHOWMOUNT="showmount -e $key | tail +2"
 
 # Newer distributions get this right
-SHOWMOUNT="/usr/sbin/showmount --no-headers -e $key"
+SHOWMOUNT="/sbin/showmount --no-headers -e $key"

-$SHOWMOUNT | sort +0 | \
+$SHOWMOUNT | LC_ALL=C sort +0 | \
        awk -v key="$key" -v opts="$opts" -- '
        BEGIN           { ORS=""; first=1 }
                        { if (first) { print opts; first=0 }; print " \\\n\t" $1, key 
":" $1 }



Document the +map syntax for file based auto.master (this is old
style analoguous to what can be done in passwd instead of using
nsswitch).

diff -ruN -x Makefile.in -x configure autofs-3.1.7.orig/man/autofs.8.in 
autofs-3.1.7/man/autofs.8.in
--- autofs-3.1.7.orig/man/autofs.8.in   Sat Nov  4 01:05:17 2000
+++ autofs-3.1.7/man/autofs.8.in        Thu Jan  4 23:00:21 2001
@@ -31,13 +31,16 @@
 process is started with the appropriate parameters. You can check the
 active mount points for the automounter with the
 .B @@INIT.D@@/autofs status
-command. After the
+command. If the
 .I auto.master
-configuration file is processed the
-.B autofs
-script will check for an NIS map with the same name. If such a map exists
-then that map will be processed in the same way as the auto.master map. The
-NIS map will be processed last.
+configuration file contains a line of the form
+.P
+.I +map
+.B [options]
+.P
+then the script will check for an NIS map with the same name.  If such a
+map exists then that map will be processed in the same way as the
+auto.master map, with any optional arguments.
 .P
 .B @@INIT.D@@/autofs reload
 will check the current auto.master map against running daemons. It will kill



Document -D options

 
diff -ruN -x Makefile.in -x configure autofs-4.0.0pre10.orig/man/automount.8 
autofs-4.0.0pre10/man/automount.8
--- autofs-4.0.0pre10.orig/man/automount.8      Tue Mar 27 23:08:23 2001
+++ autofs-4.0.0pre10/man/automount.8   Tue Oct 16 11:30:33 2001
@@ -22,6 +22,9 @@
 The filesystems are then autounmounted after a period of inactivity.
 .SH OPTIONS
 .TP
+.I "\-Dvariable=value"
+Replace \fIvariable\fP with \fIvalue\fP in map substitutions.
+.TP
 .I "\-p, \-\-pid-file"
 Write the pid of the daemon to the specified file.
 .TP



remove trailing slash (http://bugs.debian.org/141775) in AFS
mounts

 
--- bak/modules/mount_afs.c.orig        2004-01-29 17:01:22.000000000 +0100
+++ bak/modules/mount_afs.c     2004-09-03 23:03:04.000000000 +0200
@@ -39,6 +39,10 @@
        strncat(dest, "/", sizeof(dest));
        strncat(dest, name, sizeof(dest));
 
+       /* remove trailing slash (http://bugs.debian.org/141775) */
+       if (dest[strlen(dest)-1] == '/')
+           dest[strlen(dest)-1] = '\0';
+
        debug(MODPREFIX "mounting AFS %s -> %s", dest, what);
 
        return symlink(what, dest);     /* Try it.  If it fails, return the error. */



Crude support for hesiod priorities.


--- autofs-4.1.3/modules/lookup_hesiod.c.orig   2004-09-03 23:18:31.000000000 +0200
+++ autofs-4.1.3/modules/lookup_hesiod.c        2004-09-03 23:18:35.000000000 +0200
@@ -9,6 +9,7 @@
 
 #include <sys/types.h>
 #include <ctype.h>
+#include <limits.h>
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
@@ -70,6 +71,8 @@ int lookup_mount(const char *root, const
        char **hes_result;
        struct lookup_context *ctxt = (struct lookup_context *) context;
        int rv;
+       char **record, *best_record = NULL, *p;
+       int priority, lowest_priority = INT_MAX;        
 
        debug(MODPREFIX "looking up root=\"%s\", name=\"%s\"", root, name);
 
@@ -78,14 +81,30 @@ int lookup_mount(const char *root, const
 
        hes_result = hes_resolve(name, "filsys");
 
-       if (!hes_result) {
+       if (!hes_result || !hes_result[0]) {
                warn(MODPREFIX "entry \"%s\" not found in map\n", name);
                return 1;
        }
 
-       debug(MODPREFIX "lookup for \"%s\" gave \"%s\"", name, hes_result[0]);
+       /* autofs doesn't support falling back to alternate records, so just
+          find the record with the lowest priority and hope it works.
+          -- Aaron Ucko <[EMAIL PROTECTED]> 2002-03-11 */
+       for (record = hes_result; *record; ++record) {
+           p = strrchr(*record, ' ');
+           if ( p && isdigit(p[1]) ) {
+               priority = atoi(p+1);
+           } else {
+               priority = INT_MAX - 1;
+           }
+           if (priority < lowest_priority) {
+               lowest_priority = priority;
+               best_record = *record;
+           }
+       }
 
-       rv = ctxt->parser->parse_mount(root, name, name_len, hes_result[0],
+       debug(MODPREFIX "lookup for \"%s\" gave \"%s\"", name, best_record);
+
+       rv = ctxt->parser->parse_mount(root, name, name_len, best_record,
                                       ctxt->parser->context);
        free(hes_result);
        return rv;



Fix calls to mount without options.


--- autofs-4.1.3/modules/mount_changer.c.orig   2004-05-10 14:44:30.000000000 +0200
+++ autofs-4.1.3/modules/mount_changer.c        2004-09-03 23:49:18.000000000 +0200
@@ -94,7 +94,7 @@
        }
 
        wait_for_lock();
-       if (options) {
+       if (options && options[0]) {
                debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
                    fstype, options, what, fullpath);
 
--- autofs-4.1.3/modules/mount_ext2.c.orig      2004-05-10 14:44:30.000000000 +0200
+++ autofs-4.1.3/modules/mount_ext2.c   2004-09-03 23:49:47.000000000 +0200
@@ -73,7 +73,7 @@
                return 0;
        }
 
-       if (options) {
+       if (options && options[0]) {
                for (p = options; (p1 = strchr(p, ',')); p = p1)
                        if (!strncmp(p, "ro", p1 - p) && ++p1 - p == sizeof("ro"))
                                ro = 1;
--- autofs-4.1.3/modules/mount_generic.c.orig   2004-05-10 14:44:30.000000000 +0200
+++ autofs-4.1.3/modules/mount_generic.c        2004-09-03 23:50:19.000000000 +0200
@@ -72,7 +72,7 @@
        }
 
        wait_for_lock();
-       if (options) {
+       if (options && options[0]) {
                debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
                      fstype, options, what, fullpath);



Program mounts repeated last character of map output.


diff -ruN autofs-4.1.3.orig/modules/lookup_program.c 
autofs-4.1.3/modules/lookup_program.c
--- autofs-4.1.3.orig/modules/lookup_program.c  2004-01-29 17:01:22.000000000 +0100
+++ autofs-4.1.3/modules/lookup_program.c       2004-09-03 23:58:42.000000000 +0200
@@ -159,6 +159,7 @@
                        if (read(pipefd[0], &ch, 1) < 1) {
                                FD_CLR(pipefd[0], &ourfds);
                                files_left--;
+                               state = st_done;
                        }
 
                        if (!quoted && ch == '\\') {



Make should fail if a child of it fails.


diff -ruN autofs-4.1.3.orig/Makefile autofs-4.1.3/Makefile
--- autofs-4.1.3.orig/Makefile  2003-09-29 10:22:35.000000000 +0200
+++ autofs-4.1.3/Makefile       2004-09-04 20:23:42.000000000 +0200
@@ -13,26 +13,26 @@
 all:   daemon samples
 
 daemon:
-       for i in $(SUBDIRS); do $(MAKE) -C $$i all; done 
+       set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i all; done 
 
 kernel:
-       if [ -d kernel ]; then $(MAKE) -C kernel all; fi
+       set -e; if [ -d kernel ]; then $(MAKE) -C kernel all; fi
 
 samples:
-       if [ -d samples ]; then $(MAKE) -C samples all; fi
+       set -e; if [ -d samples ]; then $(MAKE) -C samples all; fi
 
 clean:
        for i in $(SUBDIRS) samples kernel; do \
                if [ -d $$i ]; then $(MAKE) -C $$i clean; fi; done      
 
 install:
-       for i in $(SUBDIRS); do $(MAKE) -C $$i install; done    
+       set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install; done    
 
 install_kernel:
-       if [ -d kernel ]; then $(MAKE) -C kernel install; fi
+       set -e; if [ -d kernel ]; then $(MAKE) -C kernel install; fi
 
 install_samples:
-       if [ -d samples ]; then $(MAKE) -C samples install; fi
+       set -e; if [ -d samples ]; then $(MAKE) -C samples install; fi
 
 mrproper distclean: clean
        find . -noleaf \( -name '*~' -o -name '#*' -o -name '*.orig' -o -name '*.rej' 
-o -name '*.old' \) -print0 | xargs -0 rm -f




This is a bit large now.
- load /etc/default/autofs on debian, allow it to override
  localoptions and daemonoptions (ie source it after setting
  them to default values). TIMEOUT is supported for
  compatibility with debian stable (it doesn't hurt to do it, so
  it's done).
- getschemes(): fall back on files if no automount entry is
  found in nsswitch.conf (backwards compatibility too).
- getmounts(): reorder handling of short-form map specifiers,
  check for file maps in /etc/ if no path specified, allow
  !program syntax. (backwards compatibility).
- make stop, restart and reload actions work again as they
  should. CRITICAL

As I proposed in other mail, I'd be interested in reducing
rc.autofs to a script library with the generic stuff and leaving
the actual init scripts to distributions and individuals. I will
come up with something when the release is over and I got time.


diff -u autofs-4.1.3/samples/rc.autofs.in autofs-4.1.3/samples/rc.autofs.in
--- autofs-4.1.3/samples/rc.autofs.in   2004-09-27 19:34:47.000000000 +0200
+++ autofs-4.1.3/samples/rc.autofs.in   2004-09-27 20:15:01.000000000 +0200
@@ -76,11 +76,27 @@
 daemonoptions=''
 
 #
+# load settings for above variables
+#
+if [ "$system" = "debian" ]; then
+    TIMEOUT=300
+
+    [ -f /etc/default/autofs ] && . /etc/default/autofs
+
+    daemonoptions="$daemonoptions --timeout=$TIMEOUT"
+fi
+
+#
 # Check for all maps that are to be loaded
 #
 function getschemes()
 {
-    grep ^automount: /etc/nsswitch.conf | sed -e 's/^.*://' -e 's/\[.*\]/ /g'
+    if grep -q '^automount: ' /etc/nsswitch.conf; then
+        grep ^automount: /etc/nsswitch.conf | \
+                sed -e 's/^.*://' -e 's/\[.*\]/ /g'
+    else
+        echo files
+    fi
 }
 function catnismap()
 {
@@ -196,19 +212,25 @@
                maptype=`echo $map | cut -f1 -d:`
                # Handle degenerate map specifiers
                if [ "$maptype" = "$map" ] ; then
-                   if [ -x "$map" ]; then
-                       maptype=program
-                   elif [ -x "/etc/$map" ]; then
-                       maptype=program
-                       map=`echo /etc/$map | sed 's^//^/^g'`
-                   elif [ -f "$map" ]; then
-                       maptype=file
-                   elif [ "$map" = "hesiod" -o "$map" = "userhome" ] ; then
+                   if [ "$map" = "hesiod" -o "$map" = "userhome" ] ; then
                        maptype=$map
                        map=
                    elif [ "$map" = "multi" ] ; then
                        maptype=$map
                        map=
+                   elif echo "$map" | grep -q '^!'; then
+                       map=`echo "$map"| sed -e 's/^!//g'`
+                   elif [ -x "$map" ]; then
+                       maptype=program
+                   elif [ -x "/etc/$map" ]; then
+                       maptype=program
+                       map=`echo "/etc/$map" | sed 's^//^/^g'`
+                   elif [ -f "$map" ]; then
+                       maptype=file
+                   elif [ -f "/etc/$map" ]; then
+                       # compatibility with behaviour of autofs 3.* debian init
+                       maptype=file
+                       map=`echo "/etc/$map" | sed 's^//^/^g'`
                    else
                        maptype=yp
                        # If the master map says the maps have '_' why change it?
@@ -250,6 +272,20 @@
        )
 }
 
+function get_command_from_pid()
+{
+    ps ax | grep "[0-9]:[0-9][0-9] $DAEMON " | (
+        while read pid tt stat time command; do
+            if [ "$pid" = "$1" ] ; then
+                echo `echo "$command" | sed 's/--pid-file.*\.pid/ /'`
+                return 0
+            fi
+        done
+    )
+
+    return 0
+}
+
 # return true if at least one pid is alive
 function alive()
 {
@@ -443,44 +479,88 @@
        echo -n 'Starting automounter:'
        getmounts | while read cmd rest
        do
-               mnt=`echo $rest | sed 's/^.* \(\/[^ ]*\) [A-Za-z].*$/\1/'`
-               echo -n " $mnt"
-               pidfile=/var/run/autofs`echo $mnt | sed 's/\//./'`.pid
-               start-stop-daemon --start --pidfile $pidfile --quiet \
-                       --exec $DAEMON $daemonoptions -- $rest
+                mnt=`echo $rest | sed 's/^.* \(\/[^ ]*\) [A-Za-z].*$/\1/'`
+                pidfile=/var/run/autofs/`echo $mnt | sed 's,/,_,g'`.pid
+                echo -n " $mnt"
+                if [ ! -d /var/run/autofs ]; then
+                        mkdir /var/run/autofs
+                fi
+                start-stop-daemon --start --pidfile $pidfile --quiet \
+                    --exec $DAEMON -- --pid-file=$pidfile $rest
        done
        echo "."
        ;;
     stop)
-       echo 'Stopping automounter.'
-       start-stop-daemon --stop --quiet --signal USR2 --exec $DAEMON
+       echo 'Stopping automounter: '
+        any=0
+        for file in /var/run/autofs/*.pid
+        do
+            if [ -e "$file" ]
+            then
+                any=1
+               pid=`head -1 $file`
+               set +e
+                start-stop-daemon --stop --quiet --retry USR2/5 \
+                       --pidfile $file --exec $DAEMON
+               case $? in
+               0)
+                   echo -n -e "\n  Stopped $pid"
+                   rm -f $file
+                   ;;
+               1)
+                   echo -n -e "\n No process for $pid"
+                   rm -f $file
+                   ;;
+                2)
+                   echo -n -e "\n  Couldn't stop $pid"
+                   ;;
+               *)
+                   echo -n -e "\n Strange start-stop-daemon exit status: $?"
+                   ;;
+                esac
+            fi
+        done
+        if [ $any -eq 1 ]; then
+                echo
+        fi
+        echo "done."
        ;;
-    reload|restart)
+    reload)
        echo "Reloading automounter: checking for changes ... "
-       TMP=/var/run/autofs.tmp
+       TMP=`mktemp -t autofs.XXXXXX`
        getmounts >$TMP
-       for i in /var/run/autofs.*.pid
+       for i in /var/run/autofs/*.pid
        do
                pid=`head -n 1 $i 2>/dev/null`
                [ "$pid" = "" ] && continue
-               command=`tail +2 $i`
-               if ! grep -q "^$command" $TMP
+               command=`ps -wwo 'cmd=' $pid| sed -e 's,.* 
--pid-file=/var/run/autofs/\([^ ]*\)\.pid.*,\1,; s,_,/,g'`
+               if ! grep -q " $command " $TMP
                then
-                       echo "Stopping automounter: $command"
+                       echo "Stopping automounter: $pid"
                        kill -USR2 $pid 2> /dev/null
                else
-                       echo "Reloading automounter map: $command"
+                       echo "Reloading automounter map: $pid"
                        kill -HUP $pid 2> /dev/null
                fi
        done
        rm -f $TMP
        $thisscript start
        ;;
+    force-reload|restart)
+       $0 stop
+       $0 start
+       ;;
     status)
        status
        ;;
+    getmounts)
+       getmounts
+       ;;
+    active)
+       active
+       ;;
     *)
-       echo "Usage: $initdir/autofs {start|stop|restart|reload|status}" >&2
+       echo "Usage: $initdir/autofs 
{start|stop|restart|reload|status|getmounts|active}" >&2
        exit 1
        ;;
 esac




Fix handling of --timeout: map options form master maps override
$daemonoptions.


--- autofs-4.1.3.orig/samples/rc.autofs.in      2004-09-27 18:17:32.000000000 +0200
+++ autofs-4.1.3/samples/rc.autofs.in   2004-09-27 18:39:27.000000000 +0200
@@ -187,14 +187,11 @@
                # those particular options out.
                : echo DAEMONOPTIONS OPTIONS $daemonoptions $options
                startupoptions=
-               if echo "$daemonoptions" | grep -q -- '-t' ; then
-                   startupoptions="--timeout=$(echo $daemonoptions $options | \
-                     sed 's/.*--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\).*$/\2/g')"
-               fi
-               # Override timeout in $daemonoptions with map $options
-               if echo "$options" | grep -q -- '-t' ; then
-                   startupoptions="--timeout=$(echo $daemonoptions $options | \
-                     sed 's/.*--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\).*$/\2/g')"
+               if echo "$options $daemonoptions" | grep -q -- '-t' ; then
+                   # the first timout value in "$options $daemonoptions" is
+                   # the one that is taken.
+                   startupoptions="--timeout=$(echo $options $daemonoptions | \
+                     sed 's/^.?*--*t\(imeout\)*[ \t=]*\([0-9][0-9]*\).*$/\2/')"
                fi
                if echo "$daemonoptions $options" | grep -q -- '-g' ; then
                    startupoptions="$startupoptions --ghost"



Fix reference to this mailinglist in manpage.


diff -ruN autofs-4.1.3.orig/man/automount.8 autofs-4.1.3/man/automount.8
--- autofs-4.1.3.orig/man/automount.8   2004-09-27 21:57:04.000000000 +0200
+++ autofs-4.1.3/man/automount.8        2004-09-27 21:47:26.000000000 +0200
@@ -146,7 +146,7 @@
 The documentation leaves a lot to be desired.
 
 Please report other bugs along with a detailed description to
-<[EMAIL PROTECTED]>.  To join this mailing list, send a message
-with the line "subscribe autofs" to <[EMAIL PROTECTED]>.
+<[EMAIL PROTECTED]>. For instructions on how to join the list
+and for archives visit http://linux.kernel.org/mailman/listinfo/autofs
 .SH AUTHOR
 H. Peter Anvin <[EMAIL PROTECTED]>


HTH, 2ri
-- 
Secure email, spread GPG, clearsign all mail. http://www.gnupg.org
.
Nearly all men can stand adversity, but if you want to test a man's 
character, give him power.
 -- Abraham Lincoln

Attachment: signature.asc
Description: Digital signature

_______________________________________________
autofs mailing list
[EMAIL PROTECTED]
http://linux.kernel.org/mailman/listinfo/autofs

Reply via email to