autofs/etc/auto.smb aktualisiert

This commit is contained in:
Peter Reichart 2024-06-25 23:35:17 +00:00
parent 3445086dc5
commit 48a75ea45f

View File

@ -27,38 +27,39 @@ get_krb5_cache() {
uid=${UID} uid=${UID}
for x in $(ls -d /run/user/$uid/krb5cc_* 2>/dev/null); do for x in $(ls -d /run/user/$uid/krb5cc_* 2>/dev/null); do
if [ -d "$x" ] && klist -s DIR:"$x"; then if [ -d "$x" ] && klist -s DIR:"$x"; then
cache=DIR:$x cache=DIR:$x
return return
fi fi
done done
if [ -f /tmp/krb5cc_$uid ] && klist -s /tmp/krb5cc_$uid; then if [ -f /tmp/krb5cc_$uid ] && klist -s /tmp/krb5cc_$uid; then
cache=/tmp/krb5cc_$uid cache=/tmp/krb5cc_$uid
return return
fi fi
} }
key="$1" key="$1"
opts="-fstype=cifs" opts="-fstype=cifs,file_mode=0777,dir_mode=0777,nounix,gid=tape,uid=bacula,forcegid,forceuid"
for P in /bin /sbin /usr/bin /usr/sbin for P in /bin /sbin /usr/bin /usr/sbin
do do
if [ -x $P/smbclient ] if [ -x $P/smbclient ]
then then
SMBCLIENT=$P/smbclient SMBCLIENT=$P/smbclient
break break
fi fi
done done
[ -x $SMBCLIENT ] || exit 1 [ -x $SMBCLIENT ] || exit 1
creds=/etc/creds/$key creds=/etc/creds/$key
if [ -f "$creds" ]; then if [ -f "$creds" ]; then
opts="$opts"',uid=$UID,gid=$GID,credentials='"$creds" opts="$opts"',credentials='"$creds"
smbopts="-A $creds" smbopts="-A $creds"
else else
get_krb5_cache get_krb5_cache
if [ -n "$cache" ]; then if [ -n "$cache" ]; then
opts="$opts"',multiuser,cruid=$UID,sec=krb5i' opts="$opts"',multiuser,cruid=$uid,sec=krb5i'
smbopts="-k" smbopts="-k"
export KRB5CCNAME=$cache export KRB5CCNAME=$cache
else else
@ -68,15 +69,15 @@ else
fi fi
$SMBCLIENT $smbopts -gL "$key" 2>/dev/null| awk -v "key=$key" -v "opts=$opts" -F '|' -- ' $SMBCLIENT $smbopts -gL "$key" 2>/dev/null| awk -v "key=$key" -v "opts=$opts" -F '|' -- '
BEGIN { ORS=""; first=1 } BEGIN { ORS=""; first=1 }
/Disk/ { /Disk/ {
if (first) if (first)
print opts; first=0 print opts; first=0
dir = $2 dir = $2
loc = $2 loc = $2
# Enclose mount dir and location in quotes # Enclose mount dir and location in quotes
print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\"" print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
} }
END { if (!first) print "\n"; else exit 1 } END { if (!first) print "\n"; else exit 1 }
' '