Page MenuHomeFreeBSD

D16492.id46301.diff
No OneTemporary

D16492.id46301.diff

Index: head/etc/Makefile
===================================================================
--- head/etc/Makefile
+++ head/etc/Makefile
@@ -190,9 +190,6 @@
echo "./var/db/services.db type=file mode=0644 uname=root gname=wheel"; \
) | ${METALOG.add}
.endif
-.if ${MK_AUTOFS} != "no"
- ${_+_}cd ${.CURDIR}/autofs; ${MAKE} install
-.endif
.if ${MK_BLUETOOTH} != "no"
${_+_}cd ${.CURDIR}/bluetooth; ${MAKE} install
.endif
Index: head/etc/auto_master
===================================================================
--- head/etc/auto_master
+++ head/etc/auto_master
@@ -1,9 +0,0 @@
-# $FreeBSD$
-#
-# Automounter master map, see auto_master(5) for details.
-#
-/net -hosts -nobrowse,nosuid,intr
-# When using the -media special map, make sure to edit devd.conf(5)
-# to move the call to "automount -c" out of the comments section.
-#/media -media -nosuid,noatime
-#/- -noauto
Index: head/etc/autofs/Makefile
===================================================================
--- head/etc/autofs/Makefile
+++ head/etc/autofs/Makefile
@@ -1,15 +0,0 @@
-# $FreeBSD$
-
-FILES= include_ldap \
- include_nis \
- include_nis_nullfs \
- special_hosts \
- special_media \
- special_noauto \
- special_null
-
-NO_OBJ=
-FILESDIR= /etc/autofs
-FILESMODE= 755
-
-.include <bsd.prog.mk>
Index: head/etc/autofs/include_ldap
===================================================================
--- head/etc/autofs/include_ldap
+++ head/etc/autofs/include_ldap
@@ -1,55 +0,0 @@
-#!/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':" {
- for (i = 2; i <= NF; i++) {
- value[i] = $(i)
- }
- nvalues = NF
- b64 = 0
-}
-
-# Double colon after attribute name means the value is in Base64.
-$1 == "'$VALUE_ATTRIBUTE'::" {
- for (i = 2; i <= NF; i++) {
- value[i] = $(i)
- }
- nvalues = NF
- b64 = 1
-}
-
-# Empty line - end of record.
-NF == 0 && key != "" && nvalues > 0 {
- printf "%s%s", key, OFS
- for (i = 2; i < nvalues; i++) {
- printf "%s%s", value[i], OFS
- }
- if (b64 == 1) {
- printf "%s", value[nvalues] | "b64decode -rp"
- close("b64decode -rp")
- printf "%s", ORS
- } else {
- printf "%s%s", value[nvalues], ORS
- }
-}
-
-NF == 0 {
- key = ""
- nvalues = 0
- delete value
-}
-'
Index: head/etc/autofs/include_nis
===================================================================
--- head/etc/autofs/include_nis
+++ head/etc/autofs/include_nis
@@ -1,14 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-if [ -n "$2" ]; then
- ypmatch $2 $1
- exit 0
-fi
-
-if [ -n "$1" ]; then
- ypcat -k $1
- exit 0
-fi
Index: head/etc/autofs/include_nis_nullfs
===================================================================
--- head/etc/autofs/include_nis_nullfs
+++ head/etc/autofs/include_nis_nullfs
@@ -1,180 +0,0 @@
-#!/usr/bin/awk -f
-#-
-# Copyright (c) 2017 G. Paul Ziemba
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-# $FreeBSD$
-#
-
-#
-# /etc/autofs/include_nis_nullfs
-#
-# automountd Directory Services script for NIS
-#
-# SYNOPSIS
-# include_nis_nullfs <mapname>
-#
-# include_nis_nullfs <mapname> <key>
-#
-# DESCRIPTION
-#
-# This script provides a Directory Services map for automountd
-# based on NIS. Please see auto_master(5) for general information.
-#
-# The first form, with one argument, emits the entire named NIS map.
-# The second form, with two arguments, emits the map entry for the
-# key given in the second argument.
-#
-# This script attempts to determine the names and IP addresses
-# of the local host. Map entries matching the local host are
-# rewritten to specify nullfs mounts (instead of the default
-# NFS) to reduce access overhead in the kernel.
-#
-# If a map entry contains multiple location fields, it is not changed.
-#
-
-
-# Populate list of names and IP addrs thet mean "this host"
-# into myhostnames array
-BEGIN {
- #
- # Set self hostnames
- #
-
- "hostname -s" | getline;
- myhostnames[$0] = 1;
-
- "hostname -f" | getline;
- myhostnames[$0] = 1;
-
- myhostnames["localhost"] = 1
-
- "hostname -f" | getline;
- localdomain=$0
- myhostnames["localhost."localdomain] = 1
-
- while ("ifconfig" | getline) {
- if ($1 == "inet") {
- myhostnames[$2] = 1;
- }
- }
-
- # debug
-# print "--- hostname list start ----"
-# for (i in myhostnames) {
-# print i
-# }
-# print "--- hostname list end ----"
-
- if (ARGC == 2) {
- # mapname only
- while ("ypcat -k " ARGV[1] | getline) {
- proc_mapline(1)
- }
- }
- if (ARGC == 3) {
- # mapname and keyname
- while ("ypmatch " ARGV[2] " " ARGV[1] | getline) {
- proc_mapline(0)
- }
- }
- exit 0
-}
-
-function is_self(hostname)
-{
- if (myhostnames[hostname]) {
- return 1
- }
- return 0
-}
-
-#
-# Lines are of the form [key] [-opts] location1 [... locationN]
-#
-# indicate index of key field with first positional parameter
-# 1 means keyfield is the first field
-# 0 means keyfield is not present
-#
-function proc_mapline(keyfield)
-{
- optionsfield = 0
- locationfield = 0
- locationcount = 0
-
- for (i=keyfield+1; i <= NF; ++i) {
- if (!optionsfield) {
- if ($i ~ /^-/) {
- # the first options field found on the line
- optionsfield = i;
- continue
- }
- }
- # Assumption: location contains colon (":")
- if (optionsfield && ($i ~ /:/) && ($i !~ /^-/)) {
- ++locationcount
- if (!locationfield) {
- # the first location field found on the line
- locationfield = i
- }
- }
- }
-
- #
- # If location not found, do not modify.
- #
- # If there is more than one location, do not modify. Rationale:
- # Options are applied to all locations. We ca not have "nullfs"
- # for only some locations and "nfs" for others for a given
- # map key (i.e., a line). The usual reason for multiple
- # locations is for redundancy using replicated volumes on
- # multiple hosts, so multiple hosts imply fstype=nfs (the
- # FreeBSD default for automounter maps).
- #
- # Hypothetically there could be a map entry with multiple
- # locations all with host parts matching "me". In that case,
- # it would be safe to rewrite the locations and specify
- # nullfs, but the code does not handle this case.
- #
- if (locationcount == 1) {
- #
- # We have a line with exactly one location field
- #
- # Assumption: location has no more than one colon (":")
- #
- n=split($locationfield,location,":")
- if (is_self(location[1])) {
- $locationfield = ":" location[2]
- if (optionsfield) {
- # append to existing options
- $optionsfield = $optionsfield ",fstype=nullfs"
- } else {
- # sneak in ahead of location
- $locationfield = "-fstype=nullfs " $locationfield
- }
- }
- }
-
- print
-}
Index: head/etc/autofs/special_hosts
===================================================================
--- head/etc/autofs/special_hosts
+++ head/etc/autofs/special_hosts
@@ -1,17 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-if [ $# -eq 0 ]; then
- out=`getent hosts`
- [ $? -eq 0 ] || exit 1
- echo "$out" | awk '{ print $2 }' | sort -u
- exit 0
-fi
-
-out=`showmount -E "$1"`
-[ $? -eq 0 ] || exit 1
-echo "$out" | awk -v host="$1" \
- '{ printf "\"%s\"\t\"%s:%s\" ", $0, host, $0 } END { printf "\n" }'
-
Index: head/etc/autofs/special_media
===================================================================
--- head/etc/autofs/special_media
+++ head/etc/autofs/special_media
@@ -1,136 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-# Print newline-separated list of devices available for mounting.
-# If there is a filesystem label - use it, otherwise use device name.
-print_available() {
- local _fstype _fstype_and_label _label _p
-
- for _p in ${providers}; do
- _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
- if [ $? -ne 0 ]; then
- # Ignore devices for which we were unable
- # to determine filesystem type.
- continue
- fi
-
- _fstype="${_fstype_and_label%% *}"
- if [ "${_fstype}" != "${_fstype_and_label}" ]; then
- _label="${_fstype_and_label#* }"
- # Replace plus signs and slashes with minuses;
- # leading plus signs have special meaning in maps,
- # and multi-component keys are just not supported.
- _label="$(echo ${_label} | sed 's,[+/],-,g')"
- echo "${_label}"
- continue
- fi
-
- echo "${_p}"
- done
-}
-
-# Print a single map entry.
-print_map_entry() {
- local _fstype _p
-
- _fstype="$1"
- _p="$2"
-
- case "${_fstype}" in
- "exfat")
- if [ -f "/usr/local/sbin/mount.exfat" ]; then
- echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid :/dev/${_p}"
- else
- /usr/bin/logger -p info -t "special_media[$$]" \
- "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first"
- exit 1
- fi
- ;;
- "ntfs")
- if [ -f "/usr/local/bin/ntfs-3g" ]; then
- echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid :/dev/${_p}"
- else
- /usr/bin/logger -p info -t "special_media[$$]" \
- "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first"
- exit 1
- fi
- ;;
- "ext2fs" | "msdosfs")
- echo "-fstype=${_fstype},nosuid,async :/dev/${_p}"
- ;;
- *)
- echo "-fstype=${_fstype},nosuid :/dev/${_p}"
- ;;
- esac
-}
-
-# Determine map entry contents for the given key and print out the entry.
-print_one() {
- local _fstype _fstype_and_label _label _key _p
-
- _key="$1"
-
- _fstype="$(fstyp "/dev/${_key}" 2> /dev/null)"
- if [ $? -eq 0 ]; then
- print_map_entry "${_fstype}" "${_key}"
- return
- fi
-
- for _p in ${providers}; do
- _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
- if [ $? -ne 0 ]; then
- # Ignore devices for which we were unable
- # to determine filesystem type.
- continue
- fi
-
- _fstype="${_fstype_and_label%% *}"
- if [ "${_fstype}" = "${_fstype_and_label}" ]; then
- # No label, try another device.
- continue
- fi
-
- _label="${_fstype_and_label#* }"
- # Replace plus signs and slashes with minuses;
- # leading plus signs have special meaning in maps,
- # and multi-component keys are just not supported.
- _label="$(echo ${_label} | sed 's,[+/],-,g')"
- if [ "${_label}" != "${_key}" ]; then
- # Labels don't match, try another device.
- continue
- fi
-
- print_map_entry "${_fstype}" "${_p}"
- done
-
- # No matching device - don't print anything, autofs will handle it.
-}
-
-# Obtain a list of (geom-provider-name, access-count) pairs, turning this:
-#
-# z0xfffff80005085d00 [shape=hexagon,label="ada0\nr2w2e3\nerr#0\nsector=512\nstripe=0"];
-#
-# Into this:
-#
-# ada0 r2w2e3
-#
-# XXX: It would be easier to use kern.geom.conftxt instead, but it lacks
-# access counts.
-pairs=$(sysctl kern.geom.confdot | sed -n 's/^.*hexagon,label="\([^\]*\)\\n\([^\]*\).*/\1 \2/p')
-
-# Obtain a list of GEOM providers that are not already open - not mounted,
-# and without other GEOM class, such as gpart, attached. In other words,
-# grep for "r0w0e0". Skip providers with names containing slashes; we're
-# not interested in geom_label(4) creations.
-providers=$(echo "$pairs" | awk '$2 == "r0w0e0" && $1 !~ /\// { print $1 }')
-
-if [ $# -eq 0 ]; then
- print_available
- exit 0
-fi
-
-print_one "$1"
-exit 0
-
Index: head/etc/autofs/special_noauto
===================================================================
--- head/etc/autofs/special_noauto
+++ head/etc/autofs/special_noauto
@@ -1,29 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-print_available() {
- sed 's/#.*//' /etc/fstab | awk '$4 ~ /noauto/ { print $2 }'
-}
-
-print_one() {
- local _mntpoint
-
- _mntpoint="${1%/}"
-
- sed 's/#.*//' /etc/fstab | awk '
- $2 == "'"${_mntpoint}"'" && $4 ~ /noauto/ {
- if ($1 ~ /:/) { dev=$1 } else { dev=":"$1 }
- print "-fstype=" $3 "," $4, dev
- }'
-}
-
-if [ $# -eq 0 ]; then
- print_available
- exit 0
-fi
-
-print_one "$1"
-exit 0
-
Index: head/etc/autofs/special_null
===================================================================
--- head/etc/autofs/special_null
+++ head/etc/autofs/special_null
@@ -1,4 +0,0 @@
-#!/usr/bin/true
-#
-# $FreeBSD$
-#
Index: head/usr.sbin/autofs/Makefile
===================================================================
--- head/usr.sbin/autofs/Makefile
+++ head/usr.sbin/autofs/Makefile
@@ -1,5 +1,6 @@
# $FreeBSD$
+CONFS= auto_master
PACKAGE=autofs
PROG= automountd
SRCS= automount.c
@@ -29,5 +30,7 @@
LINKS+= ${BINDIR}/automountd ${BINDIR}/autounmountd
.PATH: ${MOUNT}
+
+SUBDIR= autofs
.include <bsd.prog.mk>
Index: head/usr.sbin/autofs/auto_master
===================================================================
--- head/usr.sbin/autofs/auto_master
+++ head/usr.sbin/autofs/auto_master
@@ -0,0 +1,9 @@
+# $FreeBSD$
+#
+# Automounter master map, see auto_master(5) for details.
+#
+/net -hosts -nobrowse,nosuid,intr
+# When using the -media special map, make sure to edit devd.conf(5)
+# to move the call to "automount -c" out of the comments section.
+#/media -media -nosuid,noatime
+#/- -noauto
Index: head/usr.sbin/autofs/autofs/Makefile
===================================================================
--- head/usr.sbin/autofs/autofs/Makefile
+++ head/usr.sbin/autofs/autofs/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+CONFS= include_ldap \
+ include_nis \
+ include_nis_nullfs \
+ special_hosts \
+ special_media \
+ special_noauto \
+ special_null
+
+NO_OBJ=
+CONFDIR= /etc/autofs
+CONFMODE= 755
+
+.include <bsd.prog.mk>
Index: head/usr.sbin/autofs/autofs/include_ldap
===================================================================
--- head/usr.sbin/autofs/autofs/include_ldap
+++ head/usr.sbin/autofs/autofs/include_ldap
@@ -0,0 +1,55 @@
+#!/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':" {
+ for (i = 2; i <= NF; i++) {
+ value[i] = $(i)
+ }
+ nvalues = NF
+ b64 = 0
+}
+
+# Double colon after attribute name means the value is in Base64.
+$1 == "'$VALUE_ATTRIBUTE'::" {
+ for (i = 2; i <= NF; i++) {
+ value[i] = $(i)
+ }
+ nvalues = NF
+ b64 = 1
+}
+
+# Empty line - end of record.
+NF == 0 && key != "" && nvalues > 0 {
+ printf "%s%s", key, OFS
+ for (i = 2; i < nvalues; i++) {
+ printf "%s%s", value[i], OFS
+ }
+ if (b64 == 1) {
+ printf "%s", value[nvalues] | "b64decode -rp"
+ close("b64decode -rp")
+ printf "%s", ORS
+ } else {
+ printf "%s%s", value[nvalues], ORS
+ }
+}
+
+NF == 0 {
+ key = ""
+ nvalues = 0
+ delete value
+}
+'
Index: head/usr.sbin/autofs/autofs/include_nis
===================================================================
--- head/usr.sbin/autofs/autofs/include_nis
+++ head/usr.sbin/autofs/autofs/include_nis
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+if [ -n "$2" ]; then
+ ypmatch $2 $1
+ exit 0
+fi
+
+if [ -n "$1" ]; then
+ ypcat -k $1
+ exit 0
+fi
Index: head/usr.sbin/autofs/autofs/include_nis_nullfs
===================================================================
--- head/usr.sbin/autofs/autofs/include_nis_nullfs
+++ head/usr.sbin/autofs/autofs/include_nis_nullfs
@@ -0,0 +1,180 @@
+#!/usr/bin/awk -f
+#-
+# Copyright (c) 2017 G. Paul Ziemba
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+#
+# /etc/autofs/include_nis_nullfs
+#
+# automountd Directory Services script for NIS
+#
+# SYNOPSIS
+# include_nis_nullfs <mapname>
+#
+# include_nis_nullfs <mapname> <key>
+#
+# DESCRIPTION
+#
+# This script provides a Directory Services map for automountd
+# based on NIS. Please see auto_master(5) for general information.
+#
+# The first form, with one argument, emits the entire named NIS map.
+# The second form, with two arguments, emits the map entry for the
+# key given in the second argument.
+#
+# This script attempts to determine the names and IP addresses
+# of the local host. Map entries matching the local host are
+# rewritten to specify nullfs mounts (instead of the default
+# NFS) to reduce access overhead in the kernel.
+#
+# If a map entry contains multiple location fields, it is not changed.
+#
+
+
+# Populate list of names and IP addrs thet mean "this host"
+# into myhostnames array
+BEGIN {
+ #
+ # Set self hostnames
+ #
+
+ "hostname -s" | getline;
+ myhostnames[$0] = 1;
+
+ "hostname -f" | getline;
+ myhostnames[$0] = 1;
+
+ myhostnames["localhost"] = 1
+
+ "hostname -f" | getline;
+ localdomain=$0
+ myhostnames["localhost."localdomain] = 1
+
+ while ("ifconfig" | getline) {
+ if ($1 == "inet") {
+ myhostnames[$2] = 1;
+ }
+ }
+
+ # debug
+# print "--- hostname list start ----"
+# for (i in myhostnames) {
+# print i
+# }
+# print "--- hostname list end ----"
+
+ if (ARGC == 2) {
+ # mapname only
+ while ("ypcat -k " ARGV[1] | getline) {
+ proc_mapline(1)
+ }
+ }
+ if (ARGC == 3) {
+ # mapname and keyname
+ while ("ypmatch " ARGV[2] " " ARGV[1] | getline) {
+ proc_mapline(0)
+ }
+ }
+ exit 0
+}
+
+function is_self(hostname)
+{
+ if (myhostnames[hostname]) {
+ return 1
+ }
+ return 0
+}
+
+#
+# Lines are of the form [key] [-opts] location1 [... locationN]
+#
+# indicate index of key field with first positional parameter
+# 1 means keyfield is the first field
+# 0 means keyfield is not present
+#
+function proc_mapline(keyfield)
+{
+ optionsfield = 0
+ locationfield = 0
+ locationcount = 0
+
+ for (i=keyfield+1; i <= NF; ++i) {
+ if (!optionsfield) {
+ if ($i ~ /^-/) {
+ # the first options field found on the line
+ optionsfield = i;
+ continue
+ }
+ }
+ # Assumption: location contains colon (":")
+ if (optionsfield && ($i ~ /:/) && ($i !~ /^-/)) {
+ ++locationcount
+ if (!locationfield) {
+ # the first location field found on the line
+ locationfield = i
+ }
+ }
+ }
+
+ #
+ # If location not found, do not modify.
+ #
+ # If there is more than one location, do not modify. Rationale:
+ # Options are applied to all locations. We ca not have "nullfs"
+ # for only some locations and "nfs" for others for a given
+ # map key (i.e., a line). The usual reason for multiple
+ # locations is for redundancy using replicated volumes on
+ # multiple hosts, so multiple hosts imply fstype=nfs (the
+ # FreeBSD default for automounter maps).
+ #
+ # Hypothetically there could be a map entry with multiple
+ # locations all with host parts matching "me". In that case,
+ # it would be safe to rewrite the locations and specify
+ # nullfs, but the code does not handle this case.
+ #
+ if (locationcount == 1) {
+ #
+ # We have a line with exactly one location field
+ #
+ # Assumption: location has no more than one colon (":")
+ #
+ n=split($locationfield,location,":")
+ if (is_self(location[1])) {
+ $locationfield = ":" location[2]
+ if (optionsfield) {
+ # append to existing options
+ $optionsfield = $optionsfield ",fstype=nullfs"
+ } else {
+ # sneak in ahead of location
+ $locationfield = "-fstype=nullfs " $locationfield
+ }
+ }
+ }
+
+ print
+}
Index: head/usr.sbin/autofs/autofs/special_hosts
===================================================================
--- head/usr.sbin/autofs/autofs/special_hosts
+++ head/usr.sbin/autofs/autofs/special_hosts
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+if [ $# -eq 0 ]; then
+ out=`getent hosts`
+ [ $? -eq 0 ] || exit 1
+ echo "$out" | awk '{ print $2 }' | sort -u
+ exit 0
+fi
+
+out=`showmount -E "$1"`
+[ $? -eq 0 ] || exit 1
+echo "$out" | awk -v host="$1" \
+ '{ printf "\"%s\"\t\"%s:%s\" ", $0, host, $0 } END { printf "\n" }'
+
Index: head/usr.sbin/autofs/autofs/special_media
===================================================================
--- head/usr.sbin/autofs/autofs/special_media
+++ head/usr.sbin/autofs/autofs/special_media
@@ -0,0 +1,136 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# Print newline-separated list of devices available for mounting.
+# If there is a filesystem label - use it, otherwise use device name.
+print_available() {
+ local _fstype _fstype_and_label _label _p
+
+ for _p in ${providers}; do
+ _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
+ if [ $? -ne 0 ]; then
+ # Ignore devices for which we were unable
+ # to determine filesystem type.
+ continue
+ fi
+
+ _fstype="${_fstype_and_label%% *}"
+ if [ "${_fstype}" != "${_fstype_and_label}" ]; then
+ _label="${_fstype_and_label#* }"
+ # Replace plus signs and slashes with minuses;
+ # leading plus signs have special meaning in maps,
+ # and multi-component keys are just not supported.
+ _label="$(echo ${_label} | sed 's,[+/],-,g')"
+ echo "${_label}"
+ continue
+ fi
+
+ echo "${_p}"
+ done
+}
+
+# Print a single map entry.
+print_map_entry() {
+ local _fstype _p
+
+ _fstype="$1"
+ _p="$2"
+
+ case "${_fstype}" in
+ "exfat")
+ if [ -f "/usr/local/sbin/mount.exfat" ]; then
+ echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid :/dev/${_p}"
+ else
+ /usr/bin/logger -p info -t "special_media[$$]" \
+ "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first"
+ exit 1
+ fi
+ ;;
+ "ntfs")
+ if [ -f "/usr/local/bin/ntfs-3g" ]; then
+ echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},nosuid :/dev/${_p}"
+ else
+ /usr/bin/logger -p info -t "special_media[$$]" \
+ "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first"
+ exit 1
+ fi
+ ;;
+ "ext2fs" | "msdosfs")
+ echo "-fstype=${_fstype},nosuid,async :/dev/${_p}"
+ ;;
+ *)
+ echo "-fstype=${_fstype},nosuid :/dev/${_p}"
+ ;;
+ esac
+}
+
+# Determine map entry contents for the given key and print out the entry.
+print_one() {
+ local _fstype _fstype_and_label _label _key _p
+
+ _key="$1"
+
+ _fstype="$(fstyp "/dev/${_key}" 2> /dev/null)"
+ if [ $? -eq 0 ]; then
+ print_map_entry "${_fstype}" "${_key}"
+ return
+ fi
+
+ for _p in ${providers}; do
+ _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
+ if [ $? -ne 0 ]; then
+ # Ignore devices for which we were unable
+ # to determine filesystem type.
+ continue
+ fi
+
+ _fstype="${_fstype_and_label%% *}"
+ if [ "${_fstype}" = "${_fstype_and_label}" ]; then
+ # No label, try another device.
+ continue
+ fi
+
+ _label="${_fstype_and_label#* }"
+ # Replace plus signs and slashes with minuses;
+ # leading plus signs have special meaning in maps,
+ # and multi-component keys are just not supported.
+ _label="$(echo ${_label} | sed 's,[+/],-,g')"
+ if [ "${_label}" != "${_key}" ]; then
+ # Labels don't match, try another device.
+ continue
+ fi
+
+ print_map_entry "${_fstype}" "${_p}"
+ done
+
+ # No matching device - don't print anything, autofs will handle it.
+}
+
+# Obtain a list of (geom-provider-name, access-count) pairs, turning this:
+#
+# z0xfffff80005085d00 [shape=hexagon,label="ada0\nr2w2e3\nerr#0\nsector=512\nstripe=0"];
+#
+# Into this:
+#
+# ada0 r2w2e3
+#
+# XXX: It would be easier to use kern.geom.conftxt instead, but it lacks
+# access counts.
+pairs=$(sysctl kern.geom.confdot | sed -n 's/^.*hexagon,label="\([^\]*\)\\n\([^\]*\).*/\1 \2/p')
+
+# Obtain a list of GEOM providers that are not already open - not mounted,
+# and without other GEOM class, such as gpart, attached. In other words,
+# grep for "r0w0e0". Skip providers with names containing slashes; we're
+# not interested in geom_label(4) creations.
+providers=$(echo "$pairs" | awk '$2 == "r0w0e0" && $1 !~ /\// { print $1 }')
+
+if [ $# -eq 0 ]; then
+ print_available
+ exit 0
+fi
+
+print_one "$1"
+exit 0
+
Index: head/usr.sbin/autofs/autofs/special_noauto
===================================================================
--- head/usr.sbin/autofs/autofs/special_noauto
+++ head/usr.sbin/autofs/autofs/special_noauto
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+print_available() {
+ sed 's/#.*//' /etc/fstab | awk '$4 ~ /noauto/ { print $2 }'
+}
+
+print_one() {
+ local _mntpoint
+
+ _mntpoint="${1%/}"
+
+ sed 's/#.*//' /etc/fstab | awk '
+ $2 == "'"${_mntpoint}"'" && $4 ~ /noauto/ {
+ if ($1 ~ /:/) { dev=$1 } else { dev=":"$1 }
+ print "-fstype=" $3 "," $4, dev
+ }'
+}
+
+if [ $# -eq 0 ]; then
+ print_available
+ exit 0
+fi
+
+print_one "$1"
+exit 0
+
Index: head/usr.sbin/autofs/autofs/special_null
===================================================================
--- head/usr.sbin/autofs/autofs/special_null
+++ head/usr.sbin/autofs/autofs/special_null
@@ -0,0 +1,4 @@
+#!/usr/bin/true
+#
+# $FreeBSD$
+#

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 10, 11:19 PM (17 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31253009
Default Alt Text
D16492.id46301.diff (27 KB)

Event Timeline