Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 278884 - net-fs/autofs automatically try a credential file for a given host
Summary: net-fs/autofs automatically try a credential file for a given host
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Network Filesystems
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-24 00:13 UTC by niv
Modified: 2011-09-13 18:03 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description niv 2009-07-24 00:13:53 UTC
I couldnt use autofs to automount a windows xp share, then I found that I had to change the auto.smb to use my user and password according to this script below:

as Ashar Voultoiz suggest in http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg138136.html :

Hello there !

I have discovered autofs recently and it looks amazing to manage samba share.
So I have uncommented auto.smb in the auto.master file and tried lsing
/smb/myserver/ . Failure!

My file server is a Microsoft Windows 2000 system that require a username
and password to connect to.

I have patched the auto.smb file (see below) so it look for an optional
credential file that looks like /etc/auto.smb.<hostname> . I have a few
hosts so its easy for me. If the file doesnt exist, it just use the
old system.

Here is the full file (sorry I got no proper patch cause I forgot to backup
the original file).

--------------------8<-------------------------------------------------------
#!/bin/bash

# $Id: auto.smb,v 1.3 2005/04/05 13:02:09 raven Exp $

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

key="$1"
credfile="/etc/auto.smb.$key"
mountopts="-fstype=smbfs"
smbclientopts=""

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
        mountopts=$mountopts",credentials=$credfile"
        smbclientopts="-A "$credfile
else
        smbclientopts="-N"
fi

$SMBCLIENT $smbclientopts -gL $key 2>/dev/null| awk -v key="$key" -v 
opts="$mountopts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
        /Disk/  { if (first) { print opts; first=0 }; print " \\\n\t /" $2, 
"://" key "/" $2 }
        END     { if (!first) print "\n"; else exit 1 }
        '
--------------------8<-------------------------------------------------------


Then i created /etc/auto.smb.<hostname> which contain:

username = Someuser
password = Somepassword

Then a ll /smb/<hostname> gave me the files :p

So I ask to change auto.smb
Comment 1 Dustin Polke 2010-06-22 14:36:43 UTC
Could you please tell which version of autofs you are using with this script?
Please include emerge --info as well for completeness.

I have already problems to use it to connect to shares without password protection, so I'd like to have a starting point to get this working.
Then I can think about adding a reworked script to autofs.
Thanks.
Comment 2 Pacho Ramos gentoo-dev 2011-09-13 18:03:51 UTC
(In reply to comment #1)
> Could you please tell which version of autofs you are using with this script?
> Please include emerge --info as well for completeness.
> 
> I have already problems to use it to connect to shares without password
> protection, so I'd like to have a starting point to get this working.
> Then I can think about adding a reworked script to autofs.
> Thanks.

Please post needed info if still valid