|
Ian Kent |
1cd346 |
autofs-5.1.1 - Add a mode option for master map entries
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
From: Cyril B <cbay@excellency.fr>
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
Add a --mode map option to change the mode for the base location mount
|
|
Ian Kent |
1cd346 |
point. If this option is given, autofs will chmod the mount point right
|
|
Ian Kent |
1cd346 |
after mounting it (as the kernel autofs filesystem doesn't support a
|
|
Ian Kent |
1cd346 |
'mode' option).
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
Changing the mode of the base location mount point is normally not needed,
|
|
Ian Kent |
1cd346 |
but if one wants to do that, it's much better to do it inside autofs rather
|
|
Ian Kent |
1cd346 |
than outside to avoid race conditions and making sure the correct permissions
|
|
Ian Kent |
1cd346 |
are always set.
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
Signed-off-by: Cyril B <cbay@excellency.fr>
|
|
Ian Kent |
1cd346 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
1cd346 |
---
|
|
Ian Kent |
1cd346 |
CHANGELOG | 1 +
|
|
Ian Kent |
1cd346 |
daemon/direct.c | 4 ++++
|
|
Ian Kent |
1cd346 |
daemon/indirect.c | 4 ++++
|
|
Ian Kent |
1cd346 |
include/automount.h | 1 +
|
|
Ian Kent |
1cd346 |
lib/master.c | 1 +
|
|
Ian Kent |
1cd346 |
lib/master_parse.y | 9 ++++++++-
|
|
Ian Kent |
1cd346 |
lib/master_tok.l | 19 ++++++++++++++++++-
|
|
Ian Kent |
1cd346 |
man/auto.master.5.in | 5 +++++
|
|
Ian Kent |
1cd346 |
8 files changed, 42 insertions(+), 2 deletions(-)
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
Ian Kent |
1cd346 |
index 8d27e55..f954018 100644
|
|
Ian Kent |
1cd346 |
--- a/CHANGELOG
|
|
Ian Kent |
1cd346 |
+++ b/CHANGELOG
|
|
Ian Kent |
1cd346 |
@@ -22,6 +22,7 @@
|
|
Ian Kent |
1cd346 |
- add configuration option to use fqdn in mounts.
|
|
Ian Kent |
1cd346 |
- fix out of order call in program map lookup.
|
|
Ian Kent |
1cd346 |
- fix error handling of is_mounted().
|
|
Ian Kent |
1cd346 |
+- Add a mode option for master map entries.
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
21/04/2015 autofs-5.1.1
|
|
Ian Kent |
1cd346 |
=======================
|
|
Ian Kent |
1cd346 |
diff --git a/daemon/direct.c b/daemon/direct.c
|
|
Ian Kent |
1cd346 |
index 5569299..1962a58 100644
|
|
Ian Kent |
1cd346 |
--- a/daemon/direct.c
|
|
Ian Kent |
1cd346 |
+++ b/daemon/direct.c
|
|
Ian Kent |
1cd346 |
@@ -339,6 +339,7 @@ int do_mount_autofs_direct(struct autofs_point *ap,
|
|
Ian Kent |
1cd346 |
int status, ret, ioctlfd;
|
|
Ian Kent |
1cd346 |
const char *map_name;
|
|
Ian Kent |
1cd346 |
time_t runfreq;
|
|
Ian Kent |
1cd346 |
+ int err;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
if (timeout) {
|
|
Ian Kent |
1cd346 |
/* Calculate the expire run frequency */
|
|
Ian Kent |
1cd346 |
@@ -433,6 +434,9 @@ int do_mount_autofs_direct(struct autofs_point *ap,
|
|
Ian Kent |
1cd346 |
goto out_umount;
|
|
Ian Kent |
1cd346 |
}
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
+ if (ap->mode && (err = chmod(me->key, ap->mode)))
|
|
Ian Kent |
1cd346 |
+ warn(ap->logopt, "failed to change mode of %s", me->key);
|
|
Ian Kent |
1cd346 |
+
|
|
Ian Kent |
1cd346 |
ops->open(ap->logopt, &ioctlfd, st.st_dev, me->key);
|
|
Ian Kent |
1cd346 |
if (ioctlfd < 0) {
|
|
Ian Kent |
1cd346 |
crit(ap->logopt, "failed to create ioctl fd for %s", me->key);
|
|
Ian Kent |
1cd346 |
diff --git a/daemon/indirect.c b/daemon/indirect.c
|
|
Ian Kent |
1cd346 |
index a04a624..bfd181d 100644
|
|
Ian Kent |
1cd346 |
--- a/daemon/indirect.c
|
|
Ian Kent |
1cd346 |
+++ b/daemon/indirect.c
|
|
Ian Kent |
1cd346 |
@@ -95,6 +95,7 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
|
|
Ian Kent |
1cd346 |
struct stat st;
|
|
Ian Kent |
1cd346 |
struct mnt_list *mnts;
|
|
Ian Kent |
1cd346 |
int ret;
|
|
Ian Kent |
1cd346 |
+ int err;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
@@ -163,6 +164,9 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
|
|
Ian Kent |
1cd346 |
goto out_umount;
|
|
Ian Kent |
1cd346 |
}
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
+ if (ap->mode && (err = chmod(root, ap->mode)))
|
|
Ian Kent |
1cd346 |
+ warn(ap->logopt, "failed to change mode of %s", ap->path);
|
|
Ian Kent |
1cd346 |
+
|
|
Ian Kent |
1cd346 |
if (ops->open(ap->logopt, &ap->ioctlfd, st.st_dev, root)) {
|
|
Ian Kent |
1cd346 |
crit(ap->logopt,
|
|
Ian Kent |
1cd346 |
"failed to create ioctl fd for autofs path %s", ap->path);
|
|
Ian Kent |
1cd346 |
diff --git a/include/automount.h b/include/automount.h
|
|
Ian Kent |
1cd346 |
index 3ea2381..c56e265 100644
|
|
Ian Kent |
1cd346 |
--- a/include/automount.h
|
|
Ian Kent |
1cd346 |
+++ b/include/automount.h
|
|
Ian Kent |
1cd346 |
@@ -508,6 +508,7 @@ struct kernel_mod_version {
|
|
Ian Kent |
1cd346 |
struct autofs_point {
|
|
Ian Kent |
1cd346 |
pthread_t thid;
|
|
Ian Kent |
1cd346 |
char *path; /* Mount point name */
|
|
Ian Kent |
1cd346 |
+ mode_t mode; /* Mount point mode */
|
|
Ian Kent |
1cd346 |
char *pref; /* amd prefix */
|
|
Ian Kent |
1cd346 |
int pipefd; /* File descriptor for pipe */
|
|
Ian Kent |
1cd346 |
int kpipefd; /* Kernel end descriptor for pipe */
|
|
Ian Kent |
1cd346 |
diff --git a/lib/master.c b/lib/master.c
|
|
Ian Kent |
1cd346 |
index 6c38b1c..4588fa7 100644
|
|
Ian Kent |
1cd346 |
--- a/lib/master.c
|
|
Ian Kent |
1cd346 |
+++ b/lib/master.c
|
|
Ian Kent |
1cd346 |
@@ -129,6 +129,7 @@ int master_add_autofs_point(struct master_mapent *entry, unsigned logopt,
|
|
Ian Kent |
1cd346 |
free(ap);
|
|
Ian Kent |
1cd346 |
return 0;
|
|
Ian Kent |
1cd346 |
}
|
|
Ian Kent |
1cd346 |
+ ap->mode = 0;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
entry->ap = ap;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
diff --git a/lib/master_parse.y b/lib/master_parse.y
|
|
Ian Kent |
1cd346 |
index 9da78fc..0011429 100644
|
|
Ian Kent |
1cd346 |
--- a/lib/master_parse.y
|
|
Ian Kent |
1cd346 |
+++ b/lib/master_parse.y
|
|
Ian Kent |
1cd346 |
@@ -63,6 +63,7 @@ static unsigned ghost;
|
|
Ian Kent |
1cd346 |
extern unsigned global_selection_options;
|
|
Ian Kent |
1cd346 |
static unsigned random_selection;
|
|
Ian Kent |
1cd346 |
static unsigned use_weight;
|
|
Ian Kent |
1cd346 |
+static unsigned long mode;
|
|
Ian Kent |
1cd346 |
static char **tmp_argv;
|
|
Ian Kent |
1cd346 |
static int tmp_argc;
|
|
Ian Kent |
1cd346 |
static char **local_argv;
|
|
Ian Kent |
1cd346 |
@@ -101,7 +102,7 @@ static int master_fprintf(FILE *, char *, ...);
|
|
Ian Kent |
1cd346 |
%token COMMENT
|
|
Ian Kent |
1cd346 |
%token MAP
|
|
Ian Kent |
1cd346 |
%token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOBIND OPT_NOGHOST OPT_GHOST OPT_VERBOSE
|
|
Ian Kent |
1cd346 |
-%token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT OPT_SYMLINK
|
|
Ian Kent |
1cd346 |
+%token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT OPT_SYMLINK OPT_MODE
|
|
Ian Kent |
1cd346 |
%token COLON COMMA NL DDASH
|
|
Ian Kent |
1cd346 |
%type <strtype> map
|
|
Ian Kent |
1cd346 |
%type <strtype> options
|
|
Ian Kent |
1cd346 |
@@ -126,6 +127,7 @@ static int master_fprintf(FILE *, char *, ...);
|
|
Ian Kent |
1cd346 |
%token <strtype> MAPXFN
|
|
Ian Kent |
1cd346 |
%token <strtype> MAPNAME
|
|
Ian Kent |
1cd346 |
%token <longtype> NUMBER
|
|
Ian Kent |
1cd346 |
+%token <longtype> OCTALNUMBER
|
|
Ian Kent |
1cd346 |
%token <strtype> OPTION
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
%start file
|
|
Ian Kent |
1cd346 |
@@ -192,6 +194,7 @@ line:
|
|
Ian Kent |
1cd346 |
| PATH OPT_GHOST { master_notify($1); YYABORT; }
|
|
Ian Kent |
1cd346 |
| PATH OPT_NOGHOST { master_notify($1); YYABORT; }
|
|
Ian Kent |
1cd346 |
| PATH OPT_VERBOSE { master_notify($1); YYABORT; }
|
|
Ian Kent |
1cd346 |
+ | PATH OPT_MODE { master_notify($1); YYABORT; }
|
|
Ian Kent |
1cd346 |
| PATH { master_notify($1); YYABORT; }
|
|
Ian Kent |
1cd346 |
| QUOTE { master_notify($1); YYABORT; }
|
|
Ian Kent |
1cd346 |
| OPTION { master_notify($1); YYABORT; }
|
|
Ian Kent |
1cd346 |
@@ -576,6 +579,7 @@ daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; }
|
|
Ian Kent |
1cd346 |
| OPT_DEBUG { debug = 1; }
|
|
Ian Kent |
1cd346 |
| OPT_RANDOM { random_selection = 1; }
|
|
Ian Kent |
1cd346 |
| OPT_USE_WEIGHT { use_weight = 1; }
|
|
Ian Kent |
1cd346 |
+ | OPT_MODE OCTALNUMBER { mode = $2; }
|
|
Ian Kent |
1cd346 |
;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
mount_option: OPTION
|
|
Ian Kent |
1cd346 |
@@ -644,6 +648,7 @@ static void local_init_vars(void)
|
|
Ian Kent |
1cd346 |
ghost = defaults_get_browse_mode();
|
|
Ian Kent |
1cd346 |
random_selection = global_selection_options & MOUNT_FLAG_RANDOM_SELECT;
|
|
Ian Kent |
1cd346 |
use_weight = 0;
|
|
Ian Kent |
1cd346 |
+ mode = 0;
|
|
Ian Kent |
1cd346 |
tmp_argv = NULL;
|
|
Ian Kent |
1cd346 |
tmp_argc = 0;
|
|
Ian Kent |
1cd346 |
local_argv = NULL;
|
|
Ian Kent |
1cd346 |
@@ -847,6 +852,8 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
|
|
Ian Kent |
1cd346 |
entry->ap->flags |= MOUNT_FLAG_SYMLINK;
|
|
Ian Kent |
1cd346 |
if (negative_timeout)
|
|
Ian Kent |
1cd346 |
entry->ap->negative_timeout = negative_timeout;
|
|
Ian Kent |
1cd346 |
+ if (mode && mode < LONG_MAX)
|
|
Ian Kent |
1cd346 |
+ entry->ap->mode = mode;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
/*
|
|
Ian Kent |
1cd346 |
source = master_find_map_source(entry, type, format,
|
|
Ian Kent |
1cd346 |
diff --git a/lib/master_tok.l b/lib/master_tok.l
|
|
Ian Kent |
1cd346 |
index c692e14..b32918d 100644
|
|
Ian Kent |
1cd346 |
--- a/lib/master_tok.l
|
|
Ian Kent |
1cd346 |
+++ b/lib/master_tok.l
|
|
Ian Kent |
1cd346 |
@@ -84,7 +84,7 @@ unsigned int tlen;
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
%option nounput
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
-%x PATHSTR MAPSTR DNSTR OPTSTR
|
|
Ian Kent |
1cd346 |
+%x PATHSTR MAPSTR DNSTR OPTSTR OCTAL
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
WS [[:blank:]]+
|
|
Ian Kent |
1cd346 |
OPTWS [[:blank:]]*
|
|
Ian Kent |
1cd346 |
@@ -95,6 +95,7 @@ OPTIONSTR ([\-]?([[:alpha:]_]([[:alnum:]_\-])*(=(\"?([[:alnum:]_\-\:])+\"?))?)+)
|
|
Ian Kent |
1cd346 |
MACROSTR (-D{OPTWS}([[:alpha:]_]([[:alnum:]_\-\.])*)=([[:alnum:]_\-\.])+)
|
|
Ian Kent |
1cd346 |
SLASHIFYSTR (--(no-)?slashify-colons)
|
|
Ian Kent |
1cd346 |
NUMBER [0-9]+
|
|
Ian Kent |
1cd346 |
+OCTALNUMBER [0-7]+
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
DNSERVSTR1 ([[:alpha:]][[:alnum:]\-.]*(:[0-9]+)?:)
|
|
Ian Kent |
1cd346 |
DNSERVSTR2 (\[([[:xdigit:]]:.)+\](:[0-9]+)?:)
|
|
Ian Kent |
1cd346 |
@@ -125,6 +126,8 @@ MTYPE ((file|program|exec|sss|yp|nis|nisplus|ldap|ldaps|hesiod|userdir)(,(sun|h
|
|
Ian Kent |
1cd346 |
OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--timeout{OPTWS}|--timeout{OPTWS}={OPTWS})
|
|
Ian Kent |
1cd346 |
OPTNTOUT (-n{OPTWS}|-n{OPTWS}={OPTWS}|--negative-timeout{OPTWS}|--negative-timeout{OPTWS}={OPTWS})
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
+MODE (--mode{OPTWS}|--mode{OPTWS}={OPTWS})
|
|
Ian Kent |
1cd346 |
+
|
|
Ian Kent |
1cd346 |
%%
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
<INITIAL>{
|
|
Ian Kent |
1cd346 |
@@ -392,6 +395,11 @@ OPTNTOUT (-n{OPTWS}|-n{OPTWS}={OPTWS}|--negative-timeout{OPTWS}|--negative-timeo
|
|
Ian Kent |
1cd346 |
-w|--use-weight-only { return(OPT_USE_WEIGHT); }
|
|
Ian Kent |
1cd346 |
-r|--random-multimount-selection { return(OPT_RANDOM); }
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
+ {MODE}/{OCTALNUMBER} {
|
|
Ian Kent |
1cd346 |
+ BEGIN(OCTAL);
|
|
Ian Kent |
1cd346 |
+ return(OPT_MODE);
|
|
Ian Kent |
1cd346 |
+ }
|
|
Ian Kent |
1cd346 |
+
|
|
Ian Kent |
1cd346 |
{OPTWS}","{OPTWS} { return(COMMA); }
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
{OPTWS} {}
|
|
Ian Kent |
1cd346 |
@@ -423,6 +431,15 @@ OPTNTOUT (-n{OPTWS}|-n{OPTWS}={OPTWS}|--negative-timeout{OPTWS}|--negative-timeo
|
|
Ian Kent |
1cd346 |
<<EOF>> { BEGIN(INITIAL); }
|
|
Ian Kent |
1cd346 |
}
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
+<OCTAL>{
|
|
Ian Kent |
1cd346 |
+ {OCTALNUMBER} {
|
|
Ian Kent |
1cd346 |
+ master_lval.longtype = strtoul(master_text, NULL, 8);
|
|
Ian Kent |
1cd346 |
+ return(OCTALNUMBER);
|
|
Ian Kent |
1cd346 |
+ }
|
|
Ian Kent |
1cd346 |
+
|
|
Ian Kent |
1cd346 |
+ . { BEGIN(OPTSTR); yyless(0); }
|
|
Ian Kent |
1cd346 |
+}
|
|
Ian Kent |
1cd346 |
+
|
|
Ian Kent |
1cd346 |
%%
|
|
Ian Kent |
1cd346 |
|
|
Ian Kent |
1cd346 |
#include "automount.h"
|
|
Ian Kent |
1cd346 |
diff --git a/man/auto.master.5.in b/man/auto.master.5.in
|
|
Ian Kent |
1cd346 |
index 2e475dc..ba28494 100644
|
|
Ian Kent |
1cd346 |
--- a/man/auto.master.5.in
|
|
Ian Kent |
1cd346 |
+++ b/man/auto.master.5.in
|
|
Ian Kent |
1cd346 |
@@ -211,6 +211,11 @@ or in the configuration.
|
|
Ian Kent |
1cd346 |
Set the timeout for caching failed key lookups. This option can be
|
|
Ian Kent |
1cd346 |
used to override the global default given either on the command line
|
|
Ian Kent |
1cd346 |
or in the configuration.
|
|
Ian Kent |
1cd346 |
+.TP
|
|
Ian Kent |
1cd346 |
+.I "\-\-mode <octal_mode>"
|
|
Ian Kent |
1cd346 |
+Set the directory mode for the base location of the \fBautofs\fP mount point.
|
|
Ian Kent |
1cd346 |
+If this option is given, \fBautofs\fP will chmod that directory with this
|
|
Ian Kent |
1cd346 |
+mode.
|
|
Ian Kent |
1cd346 |
.SH BUILTIN MAP \-hosts
|
|
Ian Kent |
1cd346 |
If "\-hosts" is given as the map then accessing a key under the mount point
|
|
Ian Kent |
1cd346 |
which corresponds to a hostname will allow access to the exports of that
|