check nsswitch.conf for submounts
Subsystems (2)
PATCH 1/1 check nsswitch.conf for submounts
This patch addresses the problem if a user has the following in one of their automount maps:
# auto.misc test -fstype=autofs auto.m2
Before it would automatically assume that auto.m2 was a yp/nis map. The patch now checks if the file exists in /etc/ (and if it's a file or program map) or if it exists in yp (according to the order in nsswitch.conf).
In the future we may want to include functionality in the lookup_xxx.so modules so we can more easily detect if a certain map exists.
Thanks,
Chris
include/automount.h +8 -0
@@ -282,6 +282,14 @@ int is_mounted(const char *table, constint has_fstab_option (const char *path,const char *opt);int allow_owner_mount (const char *); +/* nsswitch parsing */ +#define MAPTYPE_FILE 1 +#define MAPTYPE_PROGRAM 2 + +char *get_nsswitch_map (const char *); +int isfilemap (const char *); +int isypmap (const char *); +/* log notification */ extern int do_verbose;extern int do_debug;
lib/Makefile +2 -2
@@ -9,10 +9,10 @@ include ../Makefile.rules RPCGEN = /usr/bin/rpcgen RANLIB = /usr/bin/ranlib -SRCS = cache.c listmount.c cat_path.c rpc_subs.c mounts.c lock.c +SRCS = cache.c listmount.c cat_path.c rpc_subs.c mounts.c lock.c nsswitch.c RPCS = mount.h mount_clnt.c mount_xdr.c OBJS = cache.o mount_clnt.o mount_xdr.o listmount.o \ - cat_path.o rpc_subs.o mounts.o lock.o + cat_path.o rpc_subs.o mounts.o lock.o nsswitch.o LIB = autofs.a
lib/Makefile.rej +0 -22
@@ -1,22 +0,0 @@ -*************** -*** 9,17 **** - RPCGEN = /usr/bin/rpcgen - RANLIB = /usr/bin/ranlib - -- SRCS = cache.c listmount.c cat_path.c rpc_subs.c - RPCS = mount.h mount_clnt.c mount_xdr.c -- OBJS = cache.o mount_clnt.o mount_xdr.o listmount.o cat_path.o rpc_subs.o - - LIB = autofs.a - ---- 9,18 ---- - RPCGEN = /usr/bin/rpcgen - RANLIB = /usr/bin/ranlib - -+ SRCS = cache.c listmount.c cat_path.c rpc_subs.c nsswitch.c - RPCS = mount.h mount_clnt.c mount_xdr.c -+ OBJS = cache.o mount_clnt.o mount_xdr.o listmount.o cat_path.o rpc_subs.o \ -+ nsswitch.o - - LIB = autofs.a -
lib/nsswitch.c +154 -0
154 lines not on this page · raw message
modules/Makefile +4 -0
@@ -86,3 +86,7 @@ lookup_ldap.so: lookup_ldap.c $(CC) $(SOLDFLAGS) $(CFLAGS) $(LDAP_FLAGS) -o lookup_ldap.so \ lookup_ldap.c $(AUTOFS_LIB) $(LIBLDAP) $(STRIP) lookup_ldap.so + +parse_sun.so: parse_sun.c + $(CC) $(SOLDFLAGS) $(CFLAGS) -o parse_sun.so parse_sun.c $(AUTOFS_LIB) $(LIBNSL) + $(STRIP) parse_sun.so
modules/parse_sun.c +13 -5
@@ -566,6 +566,8 @@ static int sun_mount(const char *root, cint rv;char *mountpoint;char *what; +char *nsswitch_map; +int newmaplen =0 ;if (*options =='\0' ) options =NULL ;
@@ -646,11 +648,17 @@ static int sun_mount(const char *root, cmemcpy (what, loc, loclen); what[loclen] ='\0' ; -if (!strcmp (fstype,"autofs" ) &&strchr (loc,':' ) ==NULL ) { - what =alloca (loclen +3 +1 );/* 1 for '0', 3 for yp: */ -memcpy (what,"yp:" ,3 ); -memcpy (what +3 , loc, loclen); - what[loclen +3 ] ='\0' ; +/* +* If we have an autofs map that doesn't contain a ':' then we need +* to detect what type of map it is. +*/ +if (!strcmp (fstype,"autofs" ) &&strchr (loc,':' ) ==NULL && + ((nsswitch_map =get_nsswitch_map (loc)) !=NULL )) { + newmaplen =strlen (nsswitch_map); + what =alloca (newmaplen +1 ); +memcpy (what, nsswitch_map, newmaplen); + what[newmaplen] ='\0' ; +free (nsswitch_map); }else { what =alloca (loclen +1 );memcpy (what, loc, loclen);
_______________________________________________
autofs mailing list
[email protected]
http://linux.kernel.org/mailman/listinfo/autofs
[email protected]
maintainerOn Wed, 23 Feb 2005, Chris Feist wrote:
Thanks Chris.
This is a really useful bit of code.
Appart from addressing the default map problem, it is one of the pieces of code needed to move logic out of the init script.
Howerver, we can't assume that maps are stored in "/etc". This really should be a configure logical.
Quoted 12 lines
This patch addresses the problem if a user has the following in one of their automount maps:
# auto.misc test -fstype=autofs auto.m2Before it would automatically assume that auto.m2 was a yp/nis map. The patch now checks if the file exists in
/etc/(and if it's a file or program map) or if it exists in yp (according to the order in nsswitch.conf).In the future we may want to include functionality in the lookup_xxx.so modules so we can more easily detect if a certain map exists.
Thanks,
Chris
==> Regarding Re: [autofs] [PATCH] check nsswitch.conf for submounts; [email protected] adds:
raven> On Wed, 23 Feb 2005, Chris Feist wrote: Thanks Chris.
raven> This is a really useful bit of code. Appart from addressing the raven> default map problem, it is one of the pieces of code needed to move raven> logic out of the init script.
raven> Howerver, we can't assume that maps are stored in "/etc". This raven> really should be a configure logical.
And why not? Is this not precisely what the Sun automounter does?
-Jeff
Quoted 8 lines
Quoted 8 lines
This patch addresses the problem if a user has the following in one of their automount maps: # auto.misc test -fstype=autofs auto.m2
Before it would automatically assume that auto.m2 was a yp/nis map. The patch now checks if the file exists in
/etc/(and if it's a file or program map) or if it exists in yp (according to the order in nsswitch.conf).
Quoted 6 lines
Quoted 6 lines
In the future we may want to include functionality in the lookup_xxx.so modules so we can more easily detect if a certain map exists.
Thanks, Chris
raven> _______________________________________________ autofs mailing list raven> [email protected]
raven> http://linux.kernel.org/mailman/listinfo/autofs
[email protected]
maintainerQuoted 4 lines · Jeff Moyer
==> Regarding Re: [autofs] [PATCH] check nsswitch.conf for submounts; [email protected] adds:
raven> On Wed, 23 Feb 2005, Chris Feist wrote: Thanks Chris.
Quoted 8 lines
raven> This is a really useful bit of code. Appart from addressing the raven> default map problem, it is one of the pieces of code needed to move raven> logic out of the init script.
raven> Howerver, we can't assume that maps are stored in "/etc". This raven> really should be a configure logical.
And why not? Is this not precisely what the Sun automounter does?
Yes but not all distributions store their maps in /etc.
I don't want to make it hard for myself and others that may need this in time to come.
Gentoo stores maps in /etc/autofs for example.
Quoted 22 lines
-Jeff
Quoted 8 lines
Quoted 8 lines
This patch addresses the problem if a user has the following in one of their automount maps: # auto.misc test -fstype=autofs auto.m2
Before it would automatically assume that auto.m2 was a yp/nis map. The patch now checks if the file exists in
/etc/(and if it's a file or program map) or if it exists in yp (according to the order in nsswitch.conf).Quoted 6 lines
Quoted 6 lines
In the future we may want to include functionality in the lookup_xxx.so modules so we can more easily detect if a certain map exists.
Thanks, Chris
raven> _______________________________________________ autofs mailing list raven> [email protected]
raven> http://linux.kernel.org/mailman/listinfo/autofs
Quoted 5 lines · [email protected] wrote:
This is a really useful bit of code.
Appart from addressing the default map problem, it is one of the pieces of code needed to move logic out of the init script.Howerver, we can't assume that maps are stored in "/etc". This really should be a configure logical.
We do use _PATH_NSSWITCH_CONF for the location of the nsswitch.conf file which is defined in netdb.h. So if that file was someplace else I would expect that the changes would need to be made in netdb.h (for glibc, etc.)
Thanks,
Chris
[email protected]
maintainerQuoted 8 lines · Chris Feist
Quoted 5 lines · [email protected] wrote:
This is a really useful bit of code.
Appart from addressing the default map problem, it is one of the pieces of code needed to move logic out of the init script.Howerver, we can't assume that maps are stored in "/etc". This really should be a configure logical.
We do use
_PATH_NSSWITCH_CONFfor the location of the nsswitch.conf file which is defined innetdb.h. So if that file was someplace else I would expect that the changes would need to be made innetdb.h(for glibc, etc.)
It's the autofs maps location I'd like to have configurable.
Ian