A method for using BSD automounter with LDAP
From BNL Physics Computing
This topic describes how the BSD automounter is used in the Physics Department S.C. LDAP server.
Contents |
Overview
To provide uniform access to home directories, the BSD automounter (Debian package am-utils) with a custom exec mount map is used. Along with that, a custom LDAP schema is used.
Installation of the BSD Auto Mounter (am-utils)
Install:
apt-get install am-utils
Configuration
For configuration do not use NIS, do use the "net" map and do not use the "home" map. The /etc/default/am-utils file should contain:
AM_UTILS_USE_NIS='false' AM_UTILS_NIS_MASTER_MAP='amd.master' AM_UTILS_NIS_MASTER_MAP_KEY_STYLE='onekey' AM_UTILS_NIS_KEY='default' AM_UTILS_NIS_CUSTOM='echo "/amd-is-misconfigured /usr/share/am-utils/amd.net"' AM_UTILS_MAP_NET='true' AM_UTILS_MAP_HOME='false' AM_UTILS_MAP_OTHERS= AM_UTILS_CLUSTERNAME=
(plus comments).
At the end of the default /etc/am-utils/amd.conf file, add this additional map:
[/home] map_type = exec map_name = /etc/am-utils/amd.home.sh
The referenced script is responsible for accessing the LDAP server and looking up what the correct home directory is for the given username. It determines this from the users remotehome and localhome directory. It assumes that the remotehome value is of the form:
/xxx/homeserver.phy.bnl.gov/path/to/remote/home/username
It then pulls out the hostname and checks it against the local host name. If it matches then it returns the localhome value, o.w. it returns remotehome. The xxx is "net" if using the AMD net map or may be "sfs" if using the Self-certifying File System.
Home map script
The /etc/am-utils/amd.home.sh script is here:
#!/bin/sh
#
# $Id: amd.home.sh,v 1.1 2006-01-31 16:14:18 bviren Exp $
#
# This file is under Cfengine control
#
log () {
echo "$@" >> /tmp/amd.log 2>&1
}
get_defaults () {
echo "opts:=rw,intr;type:=link"
}
get_home () {
user=$1 ; shift
remotepath=$(ldapsearch -x uid=$user | grep remotehome: | cut -f 2 -d ' ')
remotehost=$(echo $remotepath | cut -d / -f 3)
log "remotehost = $remotehost"
localpath=$(ldapsearch -x uid=$user | grep localhome: | cut -f 2 -d ' ')
path=""
if [ "$remotehost" = "$(hostname -f)" ] ; then
path=$localpath
else
path=$remotepath
fi
if [ -n "$path" ] ; then
echo "fs=$path"
fi
}
ret=""
case "$1" in
"/defaults" )
ret=$(get_defaults)
;;
* )
ret=$(get_home $1)
;;
esac
log `date`
log "inputs= $@"
log "return= $ret"
echo $ret
