mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-26 11:47:31 +00:00
3914ddf8a7
UNIX systems, eg. MacOS X and Solaris. It uses Sun-compatible map format, has proper kernel support, and LDAP integration. There are still a few outstanding problems; they will be fixed shortly. Reviewed by: allanjude@, emaste@, kib@, wblock@ (earlier versions) Phabric: D523 MFC after: 2 weeks Relnotes: yes Sponsored by: The FreeBSD Foundation
39 lines
945 B
Bash
39 lines
945 B
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# Modify this to suit your needs. The "$1" is the map name, eg. "auto_master".
|
|
# To debug, simply run this script with map name as the only parameter. It's
|
|
# supposed to output map contents ("key location" pairs) to standard output.
|
|
SEARCHBASE="ou=$1,dc=example,dc=com"
|
|
ENTRY_ATTRIBUTE="cn"
|
|
VALUE_ATTRIBUTE="automountInformation"
|
|
|
|
/usr/local/bin/ldapsearch -LLL -x -o ldif-wrap=no -b "$SEARCHBASE" "$ENTRY_ATTRIBUTE" "$VALUE_ATTRIBUTE" | awk '
|
|
$1 == "'$ENTRY_ATTRIBUTE':" {
|
|
key = $2
|
|
}
|
|
|
|
$1 == "'$VALUE_ATTRIBUTE':" && key {
|
|
printf "%s%s", key, OFS
|
|
key = ""
|
|
for (i=2; i<NF; i++) {
|
|
printf "%s%s", $(i), OFS
|
|
}
|
|
printf "%s%s", $NF, ORS
|
|
}
|
|
|
|
# Double colon after attribute name means the value is in Base64.
|
|
$1 == "'$VALUE_ATTRIBUTE'::" && key {
|
|
printf "%s%s", key, OFS
|
|
key = ""
|
|
for (i=2; i<NF; i++) {
|
|
printf "%s%s", $(i), OFS
|
|
}
|
|
printf "%s", $NF | "b64decode -rp"
|
|
close("b64decode -rp")
|
|
printf "%s", ORS
|
|
}
|
|
'
|