Skip to contentSkip to conversation

dir map-type patch v2

PATCH New Masatake YAMATO 1 participant 1 message Mar 28, 2011 Kernel automounter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dir map-type patch v2

This is the second post of "dir map-type" patch.

Changes since last post:

- Don't use auto. as prefix for included map. Use .autofs suffix instead. Suggested by Steve Linn.

- Use scandir instead of using opendir/readdir/closedir.

What is dir map-type?

`dir' map-type is for including files under a directory into master map.
`file' map-type can be used for including a file with + notation like:

       +/etc/auto.mine

in auto.master. However, for specifying a new file to be included you have to edit auto.master file. Editing is also needed when you want to remove the included file. When you have to do this with your shell script you may have to use sed or awk.

dir' map-type permits you adding new master map entries with cp command and removing the entries with rm command. dir' map-type is inspired from /etc/httpd/conf.d and /etc/modprobe.d.

`dir' map-type can be used for included files under a directory (e.g. /etc/auto.master.d) with + notation like:

      +dir:/etc/auto.master.d

in auto.master. With this notation /etc/auto.master.d/*.autofs files are included except a file which name is started with ".". With the name of the file you can control whether a file under the directory is included or not: the file which name ends with ".autofs" is included.

---
 autofs.spec          |    5 +
 daemon/lookup.c      |    3 +-
 man/auto.master.5.in |   10 ++-
 modules/Makefile     |    6 +-
 modules/lookup_dir.c |  219 ++++++++++++++++++++++++++++++++++++++++++++++++++
 samples/auto.master  |    4 +
 6 files changed, 242 insertions(+), 5 deletions(-)
 create mode 100644 modules/lookup_dir.c
autofs.spec +5 -0
index a72a0c8..e54871f 100644
@@ -67,6 +67,7 @@ mkdir -p -m755 $RPM_BUILD_ROOT%{_sbindir}
 mkdir -p -m755 $RPM_BUILD_ROOT%{_libdir}/autofs
 mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/{man5,man8}
 mkdir -p -m755 $RPM_BUILD_ROOT/etc/sysconfig
+mkdir -p -m755 $RPM_BUILD_ROOT/etc/auto.master.d
 
 make install mandir=%{_mandir} initdir=/etc/rc.d/init.d INSTALLROOT=$RPM_BUILD_ROOT
 make -C redhat
@@ -104,8 +105,12 @@ fi
 %dir %{_libdir}/autofs
 %{_libdir}/autofs/*
 %{_mandir}/*/*
+%dir /etc/auto.master.d
 
 %changelog
+* Fri Jan 14 2011 Masatake YAMATO <[email protected]>
+- Added /etc/auto.master.d
+
 * Thu Sep 3 2009 Ian Kent <[email protected]>
 - Update package to version 5.0.5.
 
daemon/lookup.c +2 -1
index 36e60c9..a118bfa 100644
@@ -176,7 +176,8 @@ int lookup_nss_read_master(struct master *master, time_t age)
 			    !strncmp(name, "nis:", 4) ||
 			    !strncmp(name, "nisplus:", 8) ||
 			    !strncmp(name, "ldap:", 5) ||
-			    !strncmp(name, "ldaps:", 6)) {
+			    !strncmp(name, "ldaps:", 6) ||
+			    !strncmp(name, "dir:", 4)) {
 				strncpy(source, name, tmp - name);
 
 				/*
man/auto.master.5.in +9 -1
index 380b706..80747c5 100644
@@ -107,6 +107,14 @@ appropriate certificate must be configured in the LDAP client.
 .B multi
 This map type allows the specification of multiple maps separated
 by "--". These maps are searched in order to resolve key lookups.
+.TP
+.B dir
+This map type can be used at 
+.BR + 
+master map including notation. The contents of files under given directory are included
+to the master map. The name of file to be included must be ended with ".autofs". A file
+will be ignored if its name is not ended with the suffix. In addition a dot file, a file
+which name is started with "." is also ignored.
 .RE
 .TP
 \fBformat\fP
@@ -118,7 +126,7 @@ left unspecified, it defaults to \fBsun\fP for all map types except
 .TP
 \fBmap\fP
 Name of the map to use.  This is an absolute UNIX pathname
-for maps of types \fBfile\fP or \fBprogram\fP, and the name of a database
+for maps of types \fBfile\fP, \fBdir\fP, or \fBprogram\fP, and the name of a database
 in the case for maps of type \fByp\fP, \fBnisplus\fP, or \fBhesiod\fP or
 the \fBdn\fP of an LDAP entry for maps of type \fBldap\fP.
 .TP
modules/Makefile +3 -3
index 9ad3915..96768b1 100644
@@ -5,14 +5,14 @@
 -include ../Makefile.conf
 include ../Makefile.rules
 
-SRCS :=	lookup_yp.c  lookup_file.c  lookup_program.c  lookup_userhome.c \
-	lookup_multi.c lookup_hosts.c \
+SRCS :=	lookup_yp.c  lookup_file.c lookup_program.c  lookup_userhome.c \
+	lookup_multi.c lookup_hosts.c lookup_dir.c \
 	parse_sun.c    \
 	mount_generic.c  mount_nfs.c  mount_afs.c  mount_autofs.c \
 	mount_changer.c  mount_bind.c
 
 MODS :=	lookup_yp.so lookup_file.so lookup_program.so lookup_userhome.so \
-	lookup_multi.so lookup_hosts.so \
+	lookup_multi.so lookup_hosts.so lookup_dir.so \
 	parse_sun.so \
 	mount_generic.so mount_nfs.so mount_afs.so mount_autofs.so \
 	mount_changer.so mount_bind.so
modules/lookup_dir.c new file +219 -0

219 lines not on this page · raw message

samples/auto.master +4 -0
index 9fe5609..72f086c 100644
@@ -12,6 +12,10 @@
 #
 /net	-hosts
 #
+# Include /etc/auto.master.d/*.autofs
+#
++dir:/etc/auto.master.d
+#
 # Include central master map if it can be found using
 # nsswitch sources.
 #
Signature · 1 line
1.7.4