LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   autofs started too early in rc.M? (http://www.linuxquestions.org/questions/slackware-14/autofs-started-too-early-in-rc-m-4175458270/)

chantk 04-16-2013 02:28 AM

autofs started too early in rc.M?
 
I took the auto.smb from CentOS 6.2 and modified it slightly to cater for my Win 7 env at work. Same script, works on CentOS by visiting /smb/<host>/<share>. On Slackware 14, it doesn't work UNTIL autofs is restarted manually after bootup. And from then on, it just works like a charm.

I think the issue lies in autofs being started too early in rc.M? Has anyone seen this problem before?

Another thing is, the script can't handle default shares well, e.g. C$. Anyone's got a solution on this?


Code:

#!/bin/bash

# This file must be executable to work! chmod 755!

key="$1"
credfile="${HOME}/.auto.smb.$USER"

[ "x$GROUP" == "x" ] || grpopt=",gid=$GROUP"
opts="-fstype=cifs,nosuid,file_mode=0664,dir_mode=0775,uid=$USER,sec=ntlm"$grpopt

for P in /bin /sbin /usr/bin /usr/sbin
do
        if [ -x $P/smbclient ]
        then
                SMBCLIENT=$P/smbclient
                break
        fi
done

[ -x $SMBCLIENT ] || exit 1

if [ -e "$credfile" ]; then
        opts=$opts",credentials=$credfile"
        smbclientopts="-d 2 -A "$credfile
else
        smbclientopts="-N"
fi

$SMBCLIENT $smbclientopts -gL $key 2>/dev/null \
        | awk -v key="$key" -v opts="$opts" -F'|' -- '
        BEGIN  { ORS=""; first=1 }
        /Disk/  {
                  if (first)
                        print opts; first=0
                  dir = $2
                  loc = $2
                  # Enclose mount dir and location in quotes
                  # Double quote "$" in location as it is special
                  gsub(/\$$/, "\\$", loc);
                  gsub(/\&/,"\\\\&",loc)
                  print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
                }
        END    { if (!first) print "\n"; else exit 1 }
        '


Mark Pettit 04-16-2013 07:57 AM

It starts before wicd or networkmanager. But even so, I thought it only mounted drives or points when needed. So, until you have someone or something actively trying to access a file on an autofs moount, it really should make no difference. Having said that though, it will be trivial to cut+paste the code and move it lower down and see how it goes. That's the great thing about Slackware - you can fiddle. Please report back on your findings. If you're right, I guess it will be moved down "officially".

chantk 04-19-2013 06:59 AM

I've moved the autofs section all the way down to right before rc.local. Still no avail. I'll keep poking around and report my progress.

Richard Cranium 04-19-2013 02:03 PM

What is in your /etc/auto.master file?

chantk 04-19-2013 04:10 PM

A /smb line like /misc.

Code:

/misc  /etc/auto.misc
/smb    /etc/auto.smb
/net    -hosts
+auto.master

/etc/auto.smb is executable.

I also did the following. (forgot where I read it). I can confirm it's necessary. In case you want to replicate it.
Code:

chmod 4755 /sbin/mount.cifs
cp /usr/doc/samba-3.6.8/examples/scripts/mount/mount.smbfs /bin
chmod +x /bin/mount.smbfs


Richard Cranium 04-19-2013 11:10 PM

Hmm. I kinda wonder if it's really necessary to make /sbin/mount.cifs suid, but that has no bearing that I can tell about your reported problem.

How about editing /etc/default/autofs and changing the LOGGING value to "verbose" or "debug" to see what's going on?

chantk 04-24-2013 12:04 PM

Richard, you're right. I removed the suid bit on /sbin/mount.cifs and it still works. So suid is totally unnecessary.

Here's the syslog with LOGGING="-v -d" in /etc/default/autofs immediately after bootup.

Code:

Apr 24 23:54:02 darkstar automount[2060]: lookup_nss_read_master: reading master files auto.master
Apr 24 23:54:02 darkstar automount[2060]: parse_init: parse(sun): init gathered global options: (null)
Apr 24 23:54:02 darkstar automount[2060]: lookup_read_master: lookup(file): read entry /misc
Apr 24 23:54:02 darkstar automount[2060]: lookup_read_master: lookup(file): read entry /smb
Apr 24 23:54:02 darkstar automount[2060]: lookup_read_master: lookup(file): read entry /net
Apr 24 23:54:02 darkstar automount[2060]: lookup_read_master: lookup(file): read entry +auto.master
Apr 24 23:54:02 darkstar automount[2060]: lookup_nss_read_master: reading master files auto.master
Apr 24 23:54:02 darkstar automount[2060]: parse_init: parse(sun): init gathered global options: (null)
Apr 24 23:54:02 darkstar automount[2060]: lookup(file): failed to read included master map auto.master
Apr 24 23:54:02 darkstar automount[2060]: master_do_mount: mounting /misc
Apr 24 23:54:02 darkstar automount[2060]: automount_path_to_fifo: fifo name /var/run/autofs.fifo-misc
Apr 24 23:54:02 darkstar automount[2060]: lookup_nss_read_map: reading map file /etc/auto.misc
Apr 24 23:54:02 darkstar automount[2060]: parse_init: parse(sun): init gathered global options: (null)
Apr 24 23:54:02 darkstar automount[2060]: st_ready: st_ready(): state = 0 path /misc
Apr 24 23:54:02 darkstar automount[2060]: master_do_mount: mounting /smb
Apr 24 23:54:02 darkstar automount[2060]: automount_path_to_fifo: fifo name /var/run/autofs.fifo-smb
Apr 24 23:54:02 darkstar automount[2060]: lookup_nss_read_map: reading map file /etc/auto.smb
Apr 24 23:54:02 darkstar automount[2060]: parse_init: parse(sun): init gathered global options: (null)
Apr 24 23:54:02 darkstar automount[2060]: st_ready: st_ready(): state = 0 path /smb
Apr 24 23:54:02 darkstar automount[2060]: master_do_mount: mounting /net
Apr 24 23:54:02 darkstar automount[2060]: automount_path_to_fifo: fifo name /var/run/autofs.fifo-net
Apr 24 23:54:02 darkstar automount[2060]: lookup_nss_read_map: reading map hosts (null)
Apr 24 23:54:02 darkstar automount[2060]: parse_init: parse(sun): init gathered global options: (null)
Apr 24 23:54:02 darkstar automount[2060]: st_ready: st_ready(): state = 0 path /net
Apr 24 23:55:47 darkstar automount[2060]: handle_packet: type = 3
Apr 24 23:55:47 darkstar automount[2060]: handle_packet_missing_indirect: token 1, name nma-bk01, request pid 2184
Apr 24 23:55:47 darkstar automount[2060]: lookup_mount: lookup(program): looking up nma-bk01
Apr 24 23:55:48 darkstar automount[2060]: dev_ioctl_send_fail: token = 1
Apr 24 23:56:01 darkstar automount[2060]: st_expire: state 1 path /misc
Apr 24 23:56:01 darkstar automount[2060]: expire_proc: exp_proc = 3045063488 path /misc
Apr 24 23:56:01 darkstar automount[2060]: expire_cleanup: got thid 3045063488 path /misc stat 0
Apr 24 23:56:01 darkstar automount[2060]: expire_cleanup: sigchld: exp 3045063488 finished, switching from 2 to 1
Apr 24 23:56:01 darkstar automount[2060]: st_ready: st_ready(): state = 2 path /misc


And it spit out these when I do "ls -l /smb/nma-bk01" the first time.

Code:

Apr 25 00:00:02 darkstar automount[2060]: st_expire: state 1 path /smb
Apr 25 00:00:02 darkstar automount[2060]: expire_proc: exp_proc = 3045063488 path /smb
Apr 25 00:00:02 darkstar automount[2060]: expire_cleanup: got thid 3045063488 path /smb stat 0
Apr 25 00:00:02 darkstar automount[2060]: expire_cleanup: sigchld: exp 3045063488 finished, switching from 2 to 1
Apr 25 00:00:02 darkstar automount[2060]: st_ready: st_ready(): state = 2 path /smb
Apr 25 00:00:49 darkstar automount[2060]: handle_packet: type = 3
Apr 25 00:00:49 darkstar automount[2060]: handle_packet_missing_indirect: token 6, name nma-bk01, request pid 2234
Apr 25 00:00:49 darkstar automount[2060]: lookup_mount: lookup(program): looking up nma-bk01
Apr 25 00:00:49 darkstar automount[2060]: dev_ioctl_send_fail: token = 6
Apr 25 00:01:01 darkstar automount[2060]: st_expire: state 1 path /misc
Apr 25 00:01:01 darkstar automount[2060]: expire_proc: exp_proc = 3045063488 path /misc
Apr 25 00:01:01 darkstar automount[2060]: expire_cleanup: got thid 3045063488 path /misc stat 0
Apr 25 00:01:01 darkstar automount[2060]: expire_cleanup: sigchld: exp 3045063488 finished, switching from 2 to 1
Apr 25 00:01:01 darkstar automount[2060]: st_ready: st_ready(): state = 2 path /misc


Richard Cranium 04-24-2013 11:22 PM

You might have to look in /var/log/debug too, although the stuff you posted certainly seems verbose enough. :)

What is the output of...
Code:

ls -lart /var/run
...?

chantk 04-26-2013 10:45 AM

Nothing special about /var/run

Code:

chantk@darkstar:~> ls -la /var/run
---------- 1 root root    5 Apr 24 23:54 /var/run/autofs-running
prw------- 1 root root    0 Apr 24 23:54 /var/run/autofs.fifo-misc
prw------- 1 root root    0 Apr 24 23:54 /var/run/autofs.fifo-net
prw------- 1 root root    0 Apr 24 23:54 /var/run/autofs.fifo-smb

/var/run/autofs:
total 0
chantk@darkstar:~>



All times are GMT -5. The time now is 06:03 PM.