autofs-5.0.5 - add nobind option From: Lars R. Damerow 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=" 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(-) diff --git a/CHANGELOG b/CHANGELOG index 8db51fc..f39c055 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -77,6 +77,7 @@ - fix map source check in file lookup. - fix simple bind without SASL support. - fix sasl bind host name selection. +- add nobind option. 03/09/2009 autofs-5.0.5 ----------------------- diff --git a/daemon/automount.c b/daemon/automount.c index 6b4e0d0..376e965 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -1534,6 +1534,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"); diff --git a/include/automount.h b/include/automount.h index 5002747..8816c15 100644 --- a/include/automount.h +++ b/include/automount.h @@ -446,6 +446,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 */ diff --git a/include/master.h b/include/master.h index 1c1a7d5..b443abb 100644 --- a/include/master.h +++ b/include/master.h @@ -78,7 +78,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 **); diff --git a/lib/master.c b/lib/master.c index 01a004b..153a38b 100644 --- a/lib/master.c +++ b/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 master_mapent *entry, if (ghost) ap->flags = MOUNT_FLAG_GHOST; + if (nobind) + ap->flags |= MOUNT_FLAG_NOBIND; + if (ap->path[1] == '-') ap->type = LKP_DIRECT; else diff --git a/lib/master_parse.y b/lib/master_parse.y index 845cbed..d56d044 100644 --- a/lib/master_parse.y +++ b/lib/master_parse.y @@ -57,6 +57,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; @@ -98,7 +99,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 map @@ -185,6 +186,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; } @@ -555,6 +557,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; } @@ -624,6 +627,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; @@ -786,7 +790,7 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne } 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) diff --git a/lib/master_tok.l b/lib/master_tok.l index c7fbe37..77e9a26 100644 --- a/lib/master_tok.l +++ b/lib/master_tok.l @@ -359,6 +359,7 @@ OPTNTOUT (-n{OPTWS}|-n{OPTWS}={OPTWS}|--negative-timeout{OPTWS}|--negative-timeo return(NUMBER); } + -?nobind { return(OPT_NOBIND); } -?nobrowse { return(OPT_NOGHOST); } -g|--ghost|-?browse { return(OPT_GHOST); } -v|--verbose { return(OPT_VERBOSE); } diff --git a/man/auto.master.5.in b/man/auto.master.5.in index 380b706..de692d2 100644 --- a/man/auto.master.5.in +++ b/man/auto.master.5.in @@ -139,13 +139,13 @@ multiple file systems should be mounted (`multimounts'). If this option 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 diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c index ec75111..d0f7a50 100644 --- a/modules/mount_autofs.c +++ b/modules/mount_autofs.c @@ -48,7 +48,9 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, char realpath[PATH_MAX]; char mountpoint[PATH_MAX]; 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; struct map_type_info *info; @@ -114,6 +116,8 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, 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) { @@ -145,7 +149,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, 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"); diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c index 474804a..7b97f66 100644 --- a/modules/mount_nfs.c +++ b/modules/mount_nfs.c @@ -65,6 +65,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int 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 */ @@ -115,6 +116,8 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int 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) { @@ -130,9 +133,9 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int } } - 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); } mount_default_proto = defaults_get_mount_nfs_default_proto();