Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 7

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

autofs-5.0.1 - add nobind option

From: Lars R. Damerow <lars@pixar.com>

If we want to prevent the use of bind mounting for local mounts
the option "nosymlink" has to be used or we need to specify the
"port=<port number>" optionn the mount location.

To resolve this the "nobind" option is added.
The man page documentation for the "nosymlink" option is replaced
with the documentation for this option but the handling of the
"nosymlink" option has been retained for backward compatibity.
---

 CHANGELOG              |    1 +
 daemon/automount.c     |    3 +++
 include/automount.h    |    3 +++
 include/master.h       |    2 +-
 lib/master.c           |    8 ++++++--
 lib/master_parse.y     |    8 ++++++--
 lib/master_tok.l       |    1 +
 man/auto.master.5.in   |   12 ++++++------
 modules/mount_autofs.c |    8 ++++++--
 modules/mount_nfs.c    |    9 ++++++---
 10 files changed, 39 insertions(+), 16 deletions(-)


--- autofs-5.0.1.orig/CHANGELOG
+++ autofs-5.0.1/CHANGELOG
@@ -53,6 +53,7 @@
 - update location validation to accept "_" (Fabio Olive Leite).
 - set close-on-exec flag on open sockets.
 - fix nonstrict multi-mount handling.
+- add nobind option.
 
 1/9/2006 autofs-5.0.1 rc2
 -------------------------
--- autofs-5.0.1.orig/daemon/automount.c
+++ autofs-5.0.1/daemon/automount.c
@@ -1514,6 +1514,9 @@ void *handle_mounts(void *arg)
 
 	free(root);
 
+	if (ap->flags & MOUNT_FLAG_NOBIND)
+		info(ap->logopt, "bind mounts disabled");
+
 	if (ap->flags & MOUNT_FLAG_GHOST && ap->type != LKP_DIRECT)
 		info(ap->logopt, "ghosting enabled");
 
--- autofs-5.0.1.orig/include/automount.h
+++ autofs-5.0.1/include/automount.h
@@ -444,6 +444,9 @@ struct kernel_mod_version {
 /* Use server weight only for selection */
 #define MOUNT_FLAG_USE_WEIGHT_ONLY	0x0010
 
+/* Don't use bind mounts even when system supports them */
+#define MOUNT_FLAG_NOBIND		0x0020
+
 struct autofs_point {
 	pthread_t thid;
 	char *path;			/* Mount point name */
--- autofs-5.0.1.orig/include/master.h
+++ autofs-5.0.1/include/master.h
@@ -77,7 +77,7 @@ void master_mutex_unlock(void);
 void master_mutex_lock_cleanup(void *);
 void master_set_default_timeout(void);
 void master_set_default_ghost_mode(void);
-int master_add_autofs_point(struct master_mapent *, time_t, unsigned, unsigned, int);
+int master_add_autofs_point(struct master_mapent *, time_t, unsigned, unsigned, unsigned, int);
 void master_free_autofs_point(struct autofs_point *);
 struct map_source *
 master_add_map_source(struct master_mapent *, char *, char *, time_t, int, const char **);
--- autofs-5.0.1.orig/lib/master.c
+++ autofs-5.0.1/lib/master.c
@@ -65,8 +65,9 @@ void master_mutex_lock_cleanup(void *arg
 	return;
 }
 
-int master_add_autofs_point(struct master_mapent *entry,
-		time_t timeout, unsigned logopt, unsigned ghost, int submount) 
+int master_add_autofs_point(struct master_mapent *entry, time_t timeout,
+			    unsigned logopt, unsigned nobind, unsigned ghost,
+			    int submount)
 {
 	struct autofs_point *ap;
 	int status;
@@ -104,6 +105,9 @@ int master_add_autofs_point(struct maste
 	if (ghost)
 		ap->flags = MOUNT_FLAG_GHOST;
 
+	if (nobind)
+		ap->flags |= MOUNT_FLAG_NOBIND;
+
 	if (ap->path[1] == '-')
 		ap->type = LKP_DIRECT;
 	else
--- autofs-5.0.1.orig/lib/master_parse.y
+++ autofs-5.0.1/lib/master_parse.y
@@ -59,6 +59,7 @@ static char *type;
 static char *format;
 static long timeout;
 static long negative_timeout;
+static unsigned nobind;
 static unsigned ghost;
 extern unsigned global_selection_options;
 static unsigned random_selection;
@@ -100,7 +101,7 @@ static int master_fprintf(FILE *, char *
 
 %token COMMENT
 %token MAP
-%token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOGHOST OPT_GHOST OPT_VERBOSE
+%token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOBIND OPT_NOGHOST OPT_GHOST OPT_VERBOSE
 %token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT
 %token COLON COMMA NL DDASH
 %type <strtype> map
@@ -187,6 +188,7 @@ line:
 	| PATH OPT_USE_WEIGHT { master_notify($1); YYABORT; }
 	| PATH OPT_DEBUG { master_notify($1); YYABORT; }
 	| PATH OPT_TIMEOUT { master_notify($1); YYABORT; }
+	| PATH OPT_NOBIND { master_notify($1); YYABORT; }
 	| PATH OPT_GHOST { master_notify($1); YYABORT; }
 	| PATH OPT_NOGHOST { master_notify($1); YYABORT; }
 	| PATH OPT_VERBOSE { master_notify($1); YYABORT; }
@@ -557,6 +559,7 @@ option: daemon_option
 
 daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; }
 	| OPT_NTIMEOUT NUMBER { negative_timeout = $2; }
+	| OPT_NOBIND	{ nobind = 1; }
 	| OPT_NOGHOST	{ ghost = 0; }
 	| OPT_GHOST	{ ghost = 1; }
 	| OPT_VERBOSE	{ verbose = 1; }
@@ -626,6 +629,7 @@ static void local_init_vars(void)
 	debug = 0;
 	timeout = -1;
 	negative_timeout = 0;
+	nobind = 0;
 	ghost = defaults_get_browse_mode();
 	random_selection = global_selection_options & MOUNT_FLAG_RANDOM_SELECT;
 	use_weight = 0;
@@ -788,7 +792,7 @@ int master_parse_entry(const char *buffe
 	}
 
 	if (!entry->ap) {
-		ret = master_add_autofs_point(entry, timeout, logopt, ghost, 0);
+		ret = master_add_autofs_point(entry, timeout, logopt, nobind, ghost, 0);
 		if (!ret) {
 			error(m_logopt, "failed to add autofs_point");
 			if (new)
--- autofs-5.0.1.orig/lib/master_tok.l
+++ autofs-5.0.1/lib/master_tok.l
@@ -357,6 +357,7 @@ OPTNTOUT	(-n{OPTWS}|-n{OPTWS}={OPTWS}|--
 		return(NUMBER);
 	}
 
+	-?nobind		{ return(OPT_NOBIND); }
 	-?nobrowse		{ return(OPT_NOGHOST); }
 	-g|--ghost|-?browse	{ return(OPT_GHOST); }
 	-v|--verbose		{ return(OPT_VERBOSE); }
--- autofs-5.0.1.orig/man/auto.master.5.in
+++ autofs-5.0.1/man/auto.master.5.in
@@ -140,13 +140,13 @@ multiple file systems should be mounted 
 is given, no file system is mounted at all if at least one file system
 can't be mounted.
 .TP
-.I "nosymlink"
+.I "nobind"
 This is an autofs specific option that is a pseudo mount option and
-so is given without a leading dash. Historically this option was used
-to prevent symlinking of local NFS mounts. Nowadays it can be used to
-prevent bind mounting of local NFS filesystems as well. If you need to
-prevent bind mounting for only specific entrys in a map then this
-can be done by adding the "port=" mount option to the given entries.
+so is given without a leading dash. It may be used either in the master
+map entry (so it effects all the map entries) or with individual map
+entries to prevent bind mounting of local NFS filesystems. Bind mounting
+of NFS file systems can also be prevented for specific map entrys by
+adding the "port=" mount option to the entries.
 .TP
 .I "\-r, \-\-random-multimount-selection"
 Enables the use of ramdom selection when choosing a host from a
--- autofs-5.0.1.orig/modules/mount_autofs.c
+++ autofs-5.0.1/modules/mount_autofs.c
@@ -50,7 +50,9 @@ int mount_mount(struct autofs_point *ap,
 	pthread_t thid;
 	char *realpath, *mountpoint;
 	const char **argv;
-	int argc, status, ghost = ap->flags & MOUNT_FLAG_GHOST;
+	int argc, status;
+	int nobind = ap->flags & MOUNT_FLAG_NOBIND;
+	int ghost = ap->flags & MOUNT_FLAG_GHOST;
 	time_t timeout = ap->exp_timeout;
 	unsigned logopt = ap->logopt;
 	char *type, *format, *tmp, *tmp2;
@@ -122,6 +124,8 @@ int mount_mount(struct autofs_point *ap,
 
 			if (strncmp(cp, "nobrowse", 8) == 0)
 				ghost = 0;
+			else if (strncmp(cp, "nobind", 6) == 0)
+				nobind = 1;
 			else if (strncmp(cp, "browse", 6) == 0)
 				ghost = 1;
 			else if (strncmp(cp, "timeout=", 8) == 0) {
@@ -153,7 +157,7 @@ int mount_mount(struct autofs_point *ap,
 		return 1;
 	}
 
-	ret = master_add_autofs_point(entry, timeout, logopt, ghost, 1);
+	ret = master_add_autofs_point(entry, timeout, logopt, nobind, ghost, 1);
 	if (!ret) {
 		error(ap->logopt,
 		      MODPREFIX "failed to add autofs_point to entry");
--- autofs-5.0.1.orig/modules/mount_nfs.c
+++ autofs-5.0.1/modules/mount_nfs.c
@@ -66,6 +66,7 @@ int mount_mount(struct autofs_point *ap,
 	char *nfsoptions = NULL;
 	unsigned int flags = ap->flags &
 			(MOUNT_FLAG_RANDOM_SELECT | MOUNT_FLAG_USE_WEIGHT_ONLY);
+	int nobind = ap->flags & MOUNT_FLAG_NOBIND;
 	int len, status, err, existed = 1;
 	int nosymlink = 0;
 	int ro = 0;            /* Set if mount bind should be read-only */
@@ -116,6 +117,8 @@ int mount_mount(struct autofs_point *ap,
 
 			if (strncmp("nosymlink", cp, end - cp + 1) == 0) {
 				nosymlink = 1;
+			} else if (strncmp("nobind", cp, end - cp + 1) == 0) {
+				nobind = 1;
 			} else if (strncmp("no-use-weight-only", cp, end - cp + 1) == 0) {
 				flags &= ~MOUNT_FLAG_USE_WEIGHT_ONLY;
 			} else if (strncmp("use-weight-only", cp, end - cp + 1) == 0) {
@@ -131,9 +134,9 @@ int mount_mount(struct autofs_point *ap,
 			}
 		}
 
-		debug(ap->logopt, 
-		      MODPREFIX "nfs options=\"%s\", nosymlink=%d, ro=%d",
-		      nfsoptions, nosymlink, ro);
+		debug(ap->logopt, MODPREFIX
+		      "nfs options=\"%s\", nobind=%d, nosymlink=%d, ro=%d",
+		      nfsoptions, nobind, nosymlink, ro);
 	}
 
 	if (strcmp(fstype, "nfs4") == 0)