import autofs-5.1.4-43.el8
This commit is contained in:
parent
babffc7442
commit
f67368e826
|
@ -0,0 +1,310 @@
|
||||||
|
autofs-5.1.6 - fix a regression with map instance lookup
|
||||||
|
|
||||||
|
From: Ian Kent <raven@themaw.net>
|
||||||
|
|
||||||
|
Commit b66deff4241d ("autofs-5.1.3 - fix possible map instance memory
|
||||||
|
leak") introduced a regression.
|
||||||
|
|
||||||
|
The change didn't fix the memory leak and also failed to fix the race
|
||||||
|
updating the map instance list that caused it.
|
||||||
|
|
||||||
|
To fix this get rid of the horible temporary map usage and update the
|
||||||
|
instance list in place. Doing this causes some additional allocations
|
||||||
|
and frees but is somewhat simpler overall and avoids the race.
|
||||||
|
|
||||||
|
Fixes: b66deff4241d ("autofs-5.1.3 - fix possible map instance memory leak")
|
||||||
|
Signed-off-by: Ian Kent <raven@themaw.net>
|
||||||
|
---
|
||||||
|
CHANGELOG | 1
|
||||||
|
daemon/lookup.c | 180 +++++++++++++++++++++++---------------------------------
|
||||||
|
2 files changed, 76 insertions(+), 105 deletions(-)
|
||||||
|
|
||||||
|
--- autofs-5.1.4.orig/CHANGELOG
|
||||||
|
+++ autofs-5.1.4/CHANGELOG
|
||||||
|
@@ -76,6 +76,7 @@ xx/xx/2018 autofs-5.1.5
|
||||||
|
- use local getmntent_r() in get_mnt_list().
|
||||||
|
- use local getmntent_r() in tree_make_mnt_list().
|
||||||
|
- fix missing initialization of autofs_point flags.
|
||||||
|
+- fix a regression with map instance lookup.
|
||||||
|
|
||||||
|
19/12/2017 autofs-5.1.4
|
||||||
|
- fix spec file url.
|
||||||
|
--- autofs-5.1.4.orig/daemon/lookup.c
|
||||||
|
+++ autofs-5.1.4/daemon/lookup.c
|
||||||
|
@@ -64,6 +64,10 @@ static char *find_map_path(struct autofs
|
||||||
|
char *search_path;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
+ /* Absolute path, just return a copy */
|
||||||
|
+ if (mname[0] == '/')
|
||||||
|
+ return strdup(mname);
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* This is different to the way it is in amd.
|
||||||
|
* autofs will always try to locate maps in AUTOFS_MAP_DIR
|
||||||
|
@@ -373,14 +377,27 @@ static int read_file_source_instance(str
|
||||||
|
char src_prog[] = "program";
|
||||||
|
struct stat st;
|
||||||
|
char *type, *format;
|
||||||
|
+ char *path;
|
||||||
|
+
|
||||||
|
+ if (map->argc < 1) {
|
||||||
|
+ error(ap->logopt, "invalid arguments for autofs_point");
|
||||||
|
+ return NSS_STATUS_UNKNOWN;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- if (stat(map->argv[0], &st) == -1) {
|
||||||
|
- warn(ap->logopt, "file map %s not found", map->argv[0]);
|
||||||
|
+ path = find_map_path(ap, map);
|
||||||
|
+ if (!path)
|
||||||
|
+ return NSS_STATUS_UNKNOWN;
|
||||||
|
+
|
||||||
|
+ if (stat(path, &st) == -1) {
|
||||||
|
+ warn(ap->logopt, "file map %s not found", path);
|
||||||
|
+ free(path);
|
||||||
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!S_ISREG(st.st_mode))
|
||||||
|
+ if (!S_ISREG(st.st_mode)) {
|
||||||
|
+ free(path);
|
||||||
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (st.st_mode & __S_IEXEC)
|
||||||
|
type = src_prog;
|
||||||
|
@@ -391,9 +408,23 @@ static int read_file_source_instance(str
|
||||||
|
|
||||||
|
instance = master_find_source_instance(map, type, format, 0, NULL);
|
||||||
|
if (!instance) {
|
||||||
|
- int argc = map->argc;
|
||||||
|
- const char **argv = map->argv;
|
||||||
|
+ const char **argv;
|
||||||
|
+ int argc;
|
||||||
|
+
|
||||||
|
+ argc = map->argc;
|
||||||
|
+ argv = copy_argv(map->argc, map->argv);
|
||||||
|
+ if (!argv) {
|
||||||
|
+ error(ap->logopt, "failed to copy args");
|
||||||
|
+ free(path);
|
||||||
|
+ return NSS_STATUS_UNKNOWN;
|
||||||
|
+ }
|
||||||
|
+ if (argv[0])
|
||||||
|
+ free((char *) argv[0]);
|
||||||
|
+ argv[0] = path;
|
||||||
|
+ path = NULL;
|
||||||
|
+
|
||||||
|
instance = master_add_source_instance(map, type, format, age, argc, argv);
|
||||||
|
+ free_argv(argc, argv);
|
||||||
|
if (!instance)
|
||||||
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
instance->recurse = map->recurse;
|
||||||
|
@@ -401,6 +432,9 @@ static int read_file_source_instance(str
|
||||||
|
}
|
||||||
|
instance->stale = map->stale;
|
||||||
|
|
||||||
|
+ if (path)
|
||||||
|
+ free(path);
|
||||||
|
+
|
||||||
|
return do_read_map(ap, instance, age);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -476,16 +510,11 @@ static int lookup_map_read_map(struct au
|
||||||
|
static enum nsswitch_status read_map_source(struct nss_source *this,
|
||||||
|
struct autofs_point *ap, struct map_source *map, time_t age)
|
||||||
|
{
|
||||||
|
- enum nsswitch_status result;
|
||||||
|
- struct map_source tmap;
|
||||||
|
- char *path;
|
||||||
|
-
|
||||||
|
if (strcasecmp(this->source, "files")) {
|
||||||
|
return read_source_instance(ap, map, this->source, age);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * autofs built-in map for nsswitch "files" is "file".
|
||||||
|
* This is a special case as we need to append the
|
||||||
|
* normal location to the map name.
|
||||||
|
* note: It's invalid to specify a relative path.
|
||||||
|
@@ -496,50 +525,7 @@ static enum nsswitch_status read_map_sou
|
||||||
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
- this->source[4] = '\0';
|
||||||
|
- tmap.flags = map->flags;
|
||||||
|
- tmap.type = this->source;
|
||||||
|
- tmap.format = map->format;
|
||||||
|
- tmap.name = map->name;
|
||||||
|
- tmap.lookup = map->lookup;
|
||||||
|
- tmap.mc = map->mc;
|
||||||
|
- tmap.instance = map->instance;
|
||||||
|
- tmap.exp_timeout = map->exp_timeout;
|
||||||
|
- tmap.recurse = map->recurse;
|
||||||
|
- tmap.depth = map->depth;
|
||||||
|
- tmap.stale = map->stale;
|
||||||
|
- tmap.argc = 0;
|
||||||
|
- tmap.argv = NULL;
|
||||||
|
-
|
||||||
|
- path = find_map_path(ap, map);
|
||||||
|
- if (!path)
|
||||||
|
- return NSS_STATUS_UNKNOWN;
|
||||||
|
-
|
||||||
|
- if (map->argc >= 1) {
|
||||||
|
- tmap.argc = map->argc;
|
||||||
|
- tmap.argv = copy_argv(map->argc, map->argv);
|
||||||
|
- if (!tmap.argv) {
|
||||||
|
- error(ap->logopt, "failed to copy args");
|
||||||
|
- free(path);
|
||||||
|
- return NSS_STATUS_UNKNOWN;
|
||||||
|
- }
|
||||||
|
- if (tmap.argv[0])
|
||||||
|
- free((char *) tmap.argv[0]);
|
||||||
|
- tmap.argv[0] = path;
|
||||||
|
- } else {
|
||||||
|
- error(ap->logopt, "invalid arguments for autofs_point");
|
||||||
|
- free(path);
|
||||||
|
- return NSS_STATUS_UNKNOWN;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- pthread_cleanup_push(argv_cleanup, &tmap);
|
||||||
|
- result = read_file_source_instance(ap, &tmap, age);
|
||||||
|
- pthread_cleanup_pop(1);
|
||||||
|
-
|
||||||
|
- if (!map->instance)
|
||||||
|
- map->instance = tmap.instance;
|
||||||
|
-
|
||||||
|
- return result;
|
||||||
|
+ return read_file_source_instance(ap, map, age);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lookup_nss_read_map(struct autofs_point *ap, struct map_source *source, time_t age)
|
||||||
|
@@ -925,17 +911,30 @@ static int lookup_name_file_source_insta
|
||||||
|
time_t age = monotonic_time(NULL);
|
||||||
|
struct stat st;
|
||||||
|
char *type, *format;
|
||||||
|
+ char *path;
|
||||||
|
|
||||||
|
if (*name == '/' && map->flags & MAP_FLAG_FORMAT_AMD)
|
||||||
|
return lookup_amd_instance(ap, map, name, name_len);
|
||||||
|
|
||||||
|
- if (stat(map->argv[0], &st) == -1) {
|
||||||
|
+ if (map->argc < 1) {
|
||||||
|
+ error(ap->logopt, "invalid arguments for autofs_point");
|
||||||
|
+ return NSS_STATUS_UNKNOWN;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ path = find_map_path(ap, map);
|
||||||
|
+ if (!path)
|
||||||
|
+ return NSS_STATUS_UNKNOWN;
|
||||||
|
+
|
||||||
|
+ if (stat(path, &st) == -1) {
|
||||||
|
debug(ap->logopt, "file map not found");
|
||||||
|
+ free(path);
|
||||||
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!S_ISREG(st.st_mode))
|
||||||
|
+ if (!S_ISREG(st.st_mode)) {
|
||||||
|
+ free(path);
|
||||||
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (st.st_mode & __S_IEXEC)
|
||||||
|
type = src_prog;
|
||||||
|
@@ -946,15 +945,32 @@ static int lookup_name_file_source_insta
|
||||||
|
|
||||||
|
instance = master_find_source_instance(map, type, format, 0, NULL);
|
||||||
|
if (!instance) {
|
||||||
|
- int argc = map->argc;
|
||||||
|
- const char **argv = map->argv;
|
||||||
|
+ const char **argv;
|
||||||
|
+ int argc;
|
||||||
|
+
|
||||||
|
+ argc = map->argc;
|
||||||
|
+ argv = copy_argv(map->argc, map->argv);
|
||||||
|
+ if (!argv) {
|
||||||
|
+ error(ap->logopt, "failed to copy args");
|
||||||
|
+ free(path);
|
||||||
|
+ return NSS_STATUS_UNKNOWN;
|
||||||
|
+ }
|
||||||
|
+ if (argv[0])
|
||||||
|
+ free((char *) argv[0]);
|
||||||
|
+ argv[0] = path;
|
||||||
|
+ path = NULL;
|
||||||
|
+
|
||||||
|
instance = master_add_source_instance(map, type, format, age, argc, argv);
|
||||||
|
+ free_argv(argc, argv);
|
||||||
|
if (!instance)
|
||||||
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
instance->recurse = map->recurse;
|
||||||
|
instance->depth = map->depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (path)
|
||||||
|
+ free(path);
|
||||||
|
+
|
||||||
|
return do_lookup_mount(ap, instance, name, name_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1030,10 +1046,6 @@ static enum nsswitch_status lookup_map_n
|
||||||
|
struct autofs_point *ap, struct map_source *map,
|
||||||
|
const char *name, int name_len)
|
||||||
|
{
|
||||||
|
- enum nsswitch_status result;
|
||||||
|
- struct map_source tmap;
|
||||||
|
- char *path;
|
||||||
|
-
|
||||||
|
if (strcasecmp(this->source, "files"))
|
||||||
|
return lookup_name_source_instance(ap, map,
|
||||||
|
this->source, name, name_len);
|
||||||
|
@@ -1050,49 +1062,7 @@ static enum nsswitch_status lookup_map_n
|
||||||
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
- this->source[4] = '\0';
|
||||||
|
- tmap.flags = map->flags;
|
||||||
|
- tmap.type = this->source;
|
||||||
|
- tmap.format = map->format;
|
||||||
|
- tmap.name = map->name;
|
||||||
|
- tmap.mc = map->mc;
|
||||||
|
- tmap.instance = map->instance;
|
||||||
|
- tmap.exp_timeout = map->exp_timeout;
|
||||||
|
- tmap.recurse = map->recurse;
|
||||||
|
- tmap.depth = map->depth;
|
||||||
|
- tmap.argc = 0;
|
||||||
|
- tmap.argv = NULL;
|
||||||
|
-
|
||||||
|
- path = find_map_path(ap, map);
|
||||||
|
- if (!path)
|
||||||
|
- return NSS_STATUS_UNKNOWN;
|
||||||
|
-
|
||||||
|
- if (map->argc >= 1) {
|
||||||
|
- tmap.argc = map->argc;
|
||||||
|
- tmap.argv = copy_argv(map->argc, map->argv);
|
||||||
|
- if (!tmap.argv) {
|
||||||
|
- error(ap->logopt, "failed to copy args");
|
||||||
|
- free(path);
|
||||||
|
- return NSS_STATUS_UNKNOWN;
|
||||||
|
- }
|
||||||
|
- if (tmap.argv[0])
|
||||||
|
- free((char *) tmap.argv[0]);
|
||||||
|
- tmap.argv[0] = path;
|
||||||
|
- } else {
|
||||||
|
- error(ap->logopt, "invalid arguments for autofs_point");
|
||||||
|
- free(path);
|
||||||
|
- return NSS_STATUS_UNKNOWN;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- result = lookup_name_file_source_instance(ap, &tmap, name, name_len);
|
||||||
|
-
|
||||||
|
- if (!map->instance)
|
||||||
|
- map->instance = tmap.instance;
|
||||||
|
-
|
||||||
|
- /* path is freed in free_argv */
|
||||||
|
- free_argv(tmap.argc, tmap.argv);
|
||||||
|
-
|
||||||
|
- return result;
|
||||||
|
+ return lookup_name_file_source_instance(ap, map, name, name_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct map_source *lookup_get_map_source(struct master_mapent *entry)
|
|
@ -0,0 +1,273 @@
|
||||||
|
autofs-5.1.6 - fix autofs mount options construction
|
||||||
|
|
||||||
|
From: Ian Kent <raven@themaw.net>
|
||||||
|
|
||||||
|
There's an off by one length error in the autofs mount options
|
||||||
|
construction.
|
||||||
|
|
||||||
|
Consolidate the options construction into make_options_string() and
|
||||||
|
use snprintf() to verify the options length calculation is correct.
|
||||||
|
|
||||||
|
Signed-off-by: Ian Kent <raven@themaw.net>
|
||||||
|
---
|
||||||
|
CHANGELOG | 1
|
||||||
|
daemon/direct.c | 46 ++-----------------------
|
||||||
|
daemon/indirect.c | 23 +-----------
|
||||||
|
include/mounts.h | 3 +
|
||||||
|
lib/mounts.c | 98 +++++++++++++++++++++++++++++++++++++++++++++---------
|
||||||
|
5 files changed, 92 insertions(+), 79 deletions(-)
|
||||||
|
|
||||||
|
--- autofs-5.1.4.orig/CHANGELOG
|
||||||
|
+++ autofs-5.1.4/CHANGELOG
|
||||||
|
@@ -80,6 +80,7 @@ xx/xx/2018 autofs-5.1.5
|
||||||
|
- fix trailing dollar sun entry expansion.
|
||||||
|
- initialize struct addrinfo for getaddrinfo() calls.
|
||||||
|
- fix quoted string length calc in expandsunent().
|
||||||
|
+- fix autofs mount options construction.
|
||||||
|
|
||||||
|
19/12/2017 autofs-5.1.4
|
||||||
|
- fix spec file url.
|
||||||
|
--- autofs-5.1.4.orig/daemon/direct.c
|
||||||
|
+++ autofs-5.1.4/daemon/direct.c
|
||||||
|
@@ -348,29 +348,10 @@ int do_mount_autofs_direct(struct autofs
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mp->options) {
|
||||||
|
- mp->options = make_options_string(ap->path, ap->kpipefd, str_direct);
|
||||||
|
+ mp->options = make_options_string(ap->path,
|
||||||
|
+ ap->kpipefd, str_direct, ap->flags);
|
||||||
|
if (!mp->options)
|
||||||
|
return 0;
|
||||||
|
-
|
||||||
|
- if ((ap->flags & MOUNT_FLAG_STRICTEXPIRE) &&
|
||||||
|
- ((get_kver_major() == 5 && get_kver_minor() > 3) ||
|
||||||
|
- (get_kver_major() > 5))) {
|
||||||
|
- char *tmp = realloc(mp->options, strlen(mp->options) + 12);
|
||||||
|
- if (tmp) {
|
||||||
|
- strcat(tmp, ",strictexpire");
|
||||||
|
- mp->options = tmp;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if ((ap->flags & MOUNT_FLAG_IGNORE) &&
|
||||||
|
- ((get_kver_major() == 5 && get_kver_minor() > 4) ||
|
||||||
|
- (get_kver_major() > 5))) {
|
||||||
|
- char *tmp = realloc(mp->options, strlen(mp->options) + 7);
|
||||||
|
- if (tmp) {
|
||||||
|
- strcat(tmp, ",ignore");
|
||||||
|
- mp->options = tmp;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In case the directory doesn't exist, try to mkdir it */
|
||||||
|
@@ -676,29 +657,10 @@ int mount_autofs_offset(struct autofs_po
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mp->options) {
|
||||||
|
- mp->options = make_options_string(ap->path, ap->kpipefd, str_offset);
|
||||||
|
+ mp->options = make_options_string(ap->path,
|
||||||
|
+ ap->kpipefd, str_offset, ap->flags);
|
||||||
|
if (!mp->options)
|
||||||
|
return MOUNT_OFFSET_OK;
|
||||||
|
-
|
||||||
|
- if ((ap->flags & MOUNT_FLAG_STRICTEXPIRE) &&
|
||||||
|
- ((get_kver_major() == 5 && get_kver_minor() > 3) ||
|
||||||
|
- (get_kver_major() > 5))) {
|
||||||
|
- char *tmp = realloc(mp->options, strlen(mp->options) + 12);
|
||||||
|
- if (tmp) {
|
||||||
|
- strcat(tmp, ",strictexpire");
|
||||||
|
- mp->options = tmp;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if ((ap->flags & MOUNT_FLAG_IGNORE) &&
|
||||||
|
- ((get_kver_major() == 5 && get_kver_minor() > 4) ||
|
||||||
|
- (get_kver_major() > 5))) {
|
||||||
|
- char *tmp = realloc(mp->options, strlen(mp->options) + 7);
|
||||||
|
- if (tmp) {
|
||||||
|
- strcat(tmp, ",ignore");
|
||||||
|
- mp->options = tmp;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(mountpoint, root);
|
||||||
|
--- autofs-5.1.4.orig/daemon/indirect.c
|
||||||
|
+++ autofs-5.1.4/daemon/indirect.c
|
||||||
|
@@ -78,32 +78,13 @@ static int do_mount_autofs_indirect(stru
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- options = make_options_string(ap->path, ap->kpipefd, str_indirect);
|
||||||
|
+ options = make_options_string(ap->path,
|
||||||
|
+ ap->kpipefd, str_indirect, ap->flags);
|
||||||
|
if (!options) {
|
||||||
|
error(ap->logopt, "options string error");
|
||||||
|
goto out_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if ((ap->flags & MOUNT_FLAG_STRICTEXPIRE) &&
|
||||||
|
- ((get_kver_major() == 5 && get_kver_minor() > 3) ||
|
||||||
|
- (get_kver_major() > 5))) {
|
||||||
|
- char *tmp = realloc(options, strlen(options) + 12);
|
||||||
|
- if (tmp) {
|
||||||
|
- strcat(tmp, ",strictexpire");
|
||||||
|
- options = tmp;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if ((ap->flags & MOUNT_FLAG_IGNORE) &&
|
||||||
|
- ((get_kver_major() == 5 && get_kver_minor() > 4) ||
|
||||||
|
- (get_kver_major() > 5))) {
|
||||||
|
- char *tmp = realloc(options, strlen(options) + 7);
|
||||||
|
- if (tmp) {
|
||||||
|
- strcat(tmp, ",ignore");
|
||||||
|
- options = tmp;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
/* In case the directory doesn't exist, try to mkdir it */
|
||||||
|
if (mkdir_path(root, mp_mode) < 0) {
|
||||||
|
if (errno != EEXIST && errno != EROFS) {
|
||||||
|
--- autofs-5.1.4.orig/include/mounts.h
|
||||||
|
+++ autofs-5.1.4/include/mounts.h
|
||||||
|
@@ -94,7 +94,8 @@ void free_amd_entry_list(struct list_hea
|
||||||
|
unsigned int query_kproto_ver(void);
|
||||||
|
unsigned int get_kver_major(void);
|
||||||
|
unsigned int get_kver_minor(void);
|
||||||
|
-char *make_options_string(char *path, int kernel_pipefd, const char *extra);
|
||||||
|
+char *make_options_string(char *path, int pipefd,
|
||||||
|
+ const char *type, unsigned int flags);
|
||||||
|
char *make_mnt_name_string(char *path);
|
||||||
|
int ext_mount_add(struct list_head *, const char *, unsigned int);
|
||||||
|
int ext_mount_remove(struct list_head *, const char *);
|
||||||
|
--- autofs-5.1.4.orig/lib/mounts.c
|
||||||
|
+++ autofs-5.1.4/lib/mounts.c
|
||||||
|
@@ -599,43 +599,111 @@ void free_amd_entry_list(struct list_hea
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int cacl_max_options_len(unsigned int flags)
|
||||||
|
+{
|
||||||
|
+ unsigned int kver_major = get_kver_major();
|
||||||
|
+ unsigned int kver_minor = get_kver_minor();
|
||||||
|
+ int max_len;
|
||||||
|
+
|
||||||
|
+ /* %d and %u are maximum lenght of 10 and mount type is maximum
|
||||||
|
+ * length of 9 (e. ",indirect").
|
||||||
|
+ * The base temaplate is "fd=%d,pgrp=%u,minproto=5,maxproto=%d"
|
||||||
|
+ * plus the length of mount type plus 1 for the NULL.
|
||||||
|
+ */
|
||||||
|
+ max_len = 79 + 1;
|
||||||
|
+
|
||||||
|
+ if (kver_major < 5 || (kver_major == 5 && kver_minor < 4))
|
||||||
|
+ goto out;
|
||||||
|
+
|
||||||
|
+ /* maybe add ",strictexpire" */
|
||||||
|
+ if (flags & MOUNT_FLAG_STRICTEXPIRE)
|
||||||
|
+ max_len += 13;
|
||||||
|
+
|
||||||
|
+ if (kver_major == 5 && kver_minor < 5)
|
||||||
|
+ goto out;
|
||||||
|
+
|
||||||
|
+ /* maybe add ",ignore" */
|
||||||
|
+ if (flags & MOUNT_FLAG_IGNORE)
|
||||||
|
+ max_len += 7;
|
||||||
|
+out:
|
||||||
|
+ return max_len;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Make common autofs mount options string
|
||||||
|
*/
|
||||||
|
-char *make_options_string(char *path, int pipefd, const char *extra)
|
||||||
|
+char *make_options_string(char *path, int pipefd,
|
||||||
|
+ const char *type, unsigned int flags)
|
||||||
|
{
|
||||||
|
+ unsigned int kver_major = get_kver_major();
|
||||||
|
+ unsigned int kver_minor = get_kver_minor();
|
||||||
|
char *options;
|
||||||
|
- int len;
|
||||||
|
+ int max_len, len, new;
|
||||||
|
|
||||||
|
- options = malloc(MAX_OPTIONS_LEN + 1);
|
||||||
|
+ max_len = cacl_max_options_len(flags);
|
||||||
|
+
|
||||||
|
+ options = malloc(max_len);
|
||||||
|
if (!options) {
|
||||||
|
logerr("can't malloc options string");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (extra)
|
||||||
|
- len = snprintf(options, MAX_OPTIONS_LEN,
|
||||||
|
+ if (type)
|
||||||
|
+ len = snprintf(options, max_len,
|
||||||
|
options_template_extra,
|
||||||
|
pipefd, (unsigned) getpgrp(),
|
||||||
|
- AUTOFS_MAX_PROTO_VERSION, extra);
|
||||||
|
+ AUTOFS_MAX_PROTO_VERSION, type);
|
||||||
|
else
|
||||||
|
- len = snprintf(options, MAX_OPTIONS_LEN, options_template,
|
||||||
|
+ len = snprintf(options, max_len, options_template,
|
||||||
|
pipefd, (unsigned) getpgrp(),
|
||||||
|
AUTOFS_MAX_PROTO_VERSION);
|
||||||
|
|
||||||
|
- if (len >= MAX_OPTIONS_LEN) {
|
||||||
|
- logerr("buffer to small for options - truncated");
|
||||||
|
- len = MAX_OPTIONS_LEN - 1;
|
||||||
|
+ if (len < 0)
|
||||||
|
+ goto error_out;
|
||||||
|
+
|
||||||
|
+ if (len >= max_len)
|
||||||
|
+ goto truncated;
|
||||||
|
+
|
||||||
|
+ if (kver_major < 5 || (kver_major == 5 && kver_minor < 4))
|
||||||
|
+ goto out;
|
||||||
|
+
|
||||||
|
+ /* maybe add ",strictexpire" */
|
||||||
|
+ if (flags & MOUNT_FLAG_STRICTEXPIRE) {
|
||||||
|
+ new = snprintf(options + len,
|
||||||
|
+ max_len, "%s", ",strictexpire");
|
||||||
|
+ if (new < 0)
|
||||||
|
+ goto error_out;
|
||||||
|
+ len += new;
|
||||||
|
+ if (len >= max_len)
|
||||||
|
+ goto truncated;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (len < 0) {
|
||||||
|
- logerr("failed to malloc autofs mount options for %s", path);
|
||||||
|
- free(options);
|
||||||
|
- return NULL;
|
||||||
|
+ if (kver_major == 5 && kver_minor < 5)
|
||||||
|
+ goto out;
|
||||||
|
+
|
||||||
|
+ /* maybe add ",ignore" */
|
||||||
|
+ if (flags & MOUNT_FLAG_IGNORE) {
|
||||||
|
+ new = snprintf(options + len,
|
||||||
|
+ max_len, "%s", ",ignore");
|
||||||
|
+ if (new < 0)
|
||||||
|
+ goto error_out;
|
||||||
|
+ len += new;
|
||||||
|
+ if (len >= max_len)
|
||||||
|
+ goto truncated;
|
||||||
|
}
|
||||||
|
+out:
|
||||||
|
options[len] = '\0';
|
||||||
|
-
|
||||||
|
return options;
|
||||||
|
+
|
||||||
|
+truncated:
|
||||||
|
+ logerr("buffer to small for options - truncated");
|
||||||
|
+ len = max_len -1;
|
||||||
|
+ goto out;
|
||||||
|
+
|
||||||
|
+error_out:
|
||||||
|
+ logerr("error constructing mount options string for %s", path);
|
||||||
|
+ free(options);
|
||||||
|
+ return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *make_mnt_name_string(char *path)
|
|
@ -0,0 +1,44 @@
|
||||||
|
autofs-5.1.6 - fix quoted string length calc in expandsunent()
|
||||||
|
|
||||||
|
From: Ian Kent <raven@themaw.net>
|
||||||
|
|
||||||
|
The expandsunent() function in modules/parse_sun.c fails to properly
|
||||||
|
handle the ending " in a quoted string causing the length calculation
|
||||||
|
to not account for the ending quote and also doesn't properly account
|
||||||
|
for the remainder of the string being expanded.
|
||||||
|
|
||||||
|
Also, when called again (after being called to get the length) the
|
||||||
|
allocated buffer is too small leading to out of bounds accesses.
|
||||||
|
|
||||||
|
Signed-off-by: Ian Kent <raven@themaw.net>
|
||||||
|
---
|
||||||
|
CHANGELOG | 1 +
|
||||||
|
modules/parse_sun.c | 6 ++++--
|
||||||
|
2 files changed, 5 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
--- autofs-5.1.4.orig/CHANGELOG
|
||||||
|
+++ autofs-5.1.4/CHANGELOG
|
||||||
|
@@ -79,6 +79,7 @@ xx/xx/2018 autofs-5.1.5
|
||||||
|
- fix a regression with map instance lookup.
|
||||||
|
- fix trailing dollar sun entry expansion.
|
||||||
|
- initialize struct addrinfo for getaddrinfo() calls.
|
||||||
|
+- fix quoted string length calc in expandsunent().
|
||||||
|
|
||||||
|
19/12/2017 autofs-5.1.4
|
||||||
|
- fix spec file url.
|
||||||
|
--- autofs-5.1.4.orig/modules/parse_sun.c
|
||||||
|
+++ autofs-5.1.4/modules/parse_sun.c
|
||||||
|
@@ -213,9 +213,11 @@ int expandsunent(const char *src, char *
|
||||||
|
*dst++ = *src;
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
- if (*src && dst) {
|
||||||
|
+ if (*src) {
|
||||||
|
len++;
|
||||||
|
- *dst++ = *src++;
|
||||||
|
+ if (dst)
|
||||||
|
+ *dst++ = *src;
|
||||||
|
+ src++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
autofs-5.1.6 - fix trailing dollar sun entry expansion
|
||||||
|
|
||||||
|
From: Ian Kent <raven@themaw.net>
|
||||||
|
|
||||||
|
In modules/parse_sun.c:expandsunent() if we see "$ " or "$<NULL>" in a
|
||||||
|
the entry it can't be a macro, and the value can't be quoted since '\'
|
||||||
|
and '"' cases are handled seperately in the swicth, so treat the
|
||||||
|
character as a valid entry character.
|
||||||
|
|
||||||
|
Signed-off-by: Ian Kent <raven@themaw.net>
|
||||||
|
---
|
||||||
|
CHANGELOG | 1 +
|
||||||
|
modules/parse_sun.c | 12 ++++++++++++
|
||||||
|
2 files changed, 13 insertions(+)
|
||||||
|
|
||||||
|
--- autofs-5.1.4.orig/CHANGELOG
|
||||||
|
+++ autofs-5.1.4/CHANGELOG
|
||||||
|
@@ -77,6 +77,7 @@ xx/xx/2018 autofs-5.1.5
|
||||||
|
- use local getmntent_r() in tree_make_mnt_list().
|
||||||
|
- fix missing initialization of autofs_point flags.
|
||||||
|
- fix a regression with map instance lookup.
|
||||||
|
+- fix trailing dollar sun entry expansion.
|
||||||
|
|
||||||
|
19/12/2017 autofs-5.1.4
|
||||||
|
- fix spec file url.
|
||||||
|
--- autofs-5.1.4.orig/modules/parse_sun.c
|
||||||
|
+++ autofs-5.1.4/modules/parse_sun.c
|
||||||
|
@@ -161,6 +161,18 @@ int expandsunent(const char *src, char *
|
||||||
|
}
|
||||||
|
src = p + 1;
|
||||||
|
} else {
|
||||||
|
+ /* If the '$' is folloed by a space or NULL it
|
||||||
|
+ * can't be a macro, and the value can't be
|
||||||
|
+ * quoted since '\' and '"' cases are handled
|
||||||
|
+ * in other cases, so treat the $ as a valid
|
||||||
|
+ * map entry character.
|
||||||
|
+ */
|
||||||
|
+ if (isblank(*src) || !*src) {
|
||||||
|
+ if (dst)
|
||||||
|
+ *dst++ = ch;
|
||||||
|
+ len++;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
p = src;
|
||||||
|
while (isalnum(*p) || *p == '_')
|
||||||
|
p++;
|
|
@ -0,0 +1,104 @@
|
||||||
|
autofs-5.1.6 - initialize struct addrinfo for getaddrinfo() calls
|
||||||
|
|
||||||
|
From: Ian Kent <raven@themaw.net>
|
||||||
|
|
||||||
|
The getaddrinfo() call may have become more fussy about initialization
|
||||||
|
of the passed in struct addrinfo that receives the results.
|
||||||
|
|
||||||
|
It's good practice to initialize it prior to the gataddrinfo() call just
|
||||||
|
in case.
|
||||||
|
|
||||||
|
Signed-off-by: Ian Kent <raven@themaw.net>
|
||||||
|
---
|
||||||
|
CHANGELOG | 1 +
|
||||||
|
lib/parse_subs.c | 1 +
|
||||||
|
lib/rpc_subs.c | 1 +
|
||||||
|
modules/dclist.c | 1 +
|
||||||
|
modules/parse_amd.c | 3 +++
|
||||||
|
modules/replicated.c | 2 ++
|
||||||
|
6 files changed, 9 insertions(+)
|
||||||
|
|
||||||
|
--- autofs-5.1.4.orig/CHANGELOG
|
||||||
|
+++ autofs-5.1.4/CHANGELOG
|
||||||
|
@@ -78,6 +78,7 @@ xx/xx/2018 autofs-5.1.5
|
||||||
|
- fix missing initialization of autofs_point flags.
|
||||||
|
- fix a regression with map instance lookup.
|
||||||
|
- fix trailing dollar sun entry expansion.
|
||||||
|
+- initialize struct addrinfo for getaddrinfo() calls.
|
||||||
|
|
||||||
|
19/12/2017 autofs-5.1.4
|
||||||
|
- fix spec file url.
|
||||||
|
--- autofs-5.1.4.orig/lib/parse_subs.c
|
||||||
|
+++ autofs-5.1.4/lib/parse_subs.c
|
||||||
|
@@ -475,6 +475,7 @@ unsigned int get_network_proximity(const
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME;
|
||||||
|
|
||||||
|
+ ni = NULL;
|
||||||
|
ret = getaddrinfo(name_or_num, NULL, &hints, &ni);
|
||||||
|
if (ret) {
|
||||||
|
logerr("hostname lookup for %s failed: %s",
|
||||||
|
--- autofs-5.1.4.orig/lib/rpc_subs.c
|
||||||
|
+++ autofs-5.1.4/lib/rpc_subs.c
|
||||||
|
@@ -691,6 +691,7 @@ static int create_client(struct conn_inf
|
||||||
|
else
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
|
+ ai = NULL;
|
||||||
|
ret = getaddrinfo(info->host, NULL, &hints, &ai);
|
||||||
|
if (ret) {
|
||||||
|
error(LOGOPT_ANY,
|
||||||
|
--- autofs-5.1.4.orig/modules/dclist.c
|
||||||
|
+++ autofs-5.1.4/modules/dclist.c
|
||||||
|
@@ -355,6 +355,7 @@ static char *getdnsdomainname(unsigned i
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
|
+ ni = NULL;
|
||||||
|
ret = getaddrinfo(name, NULL, &hints, &ni);
|
||||||
|
if (ret) {
|
||||||
|
error(logopt,
|
||||||
|
--- autofs-5.1.4.orig/modules/parse_amd.c
|
||||||
|
+++ autofs-5.1.4/modules/parse_amd.c
|
||||||
|
@@ -269,6 +269,7 @@ static int match_my_name(struct autofs_p
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
|
/* Get host canonical name */
|
||||||
|
+ cni = NULL;
|
||||||
|
ret = getaddrinfo(v->val, NULL, &hints, &cni);
|
||||||
|
if (ret) {
|
||||||
|
error(logopt, MODPREFIX
|
||||||
|
@@ -280,6 +281,7 @@ static int match_my_name(struct autofs_p
|
||||||
|
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG | AI_CANONNAME;
|
||||||
|
|
||||||
|
/* Resolve comparison name to its names and compare */
|
||||||
|
+ ni = NULL;
|
||||||
|
ret = getaddrinfo(exp_name, NULL, &hints, &ni);
|
||||||
|
if (ret) {
|
||||||
|
error(logopt, MODPREFIX
|
||||||
|
@@ -775,6 +777,7 @@ static char *normalize_hostname(unsigned
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
|
+ ni = NULL;
|
||||||
|
ret = getaddrinfo(host, NULL, &hints, &ni);
|
||||||
|
if (ret) {
|
||||||
|
error(logopt, MODPREFIX
|
||||||
|
--- autofs-5.1.4.orig/modules/replicated.c
|
||||||
|
+++ autofs-5.1.4/modules/replicated.c
|
||||||
|
@@ -985,6 +985,7 @@ static int add_host_addrs(struct host **
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
|
+ ni = NULL;
|
||||||
|
ret = getaddrinfo(name, NULL, &hints, &ni);
|
||||||
|
if (ret)
|
||||||
|
goto try_name;
|
||||||
|
@@ -1005,6 +1006,7 @@ try_name:
|
||||||
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
|
|
||||||
|
+ ni = NULL;
|
||||||
|
ret = getaddrinfo(name, NULL, &hints, &ni);
|
||||||
|
if (ret) {
|
||||||
|
error(LOGOPT_ANY,
|
|
@ -8,7 +8,7 @@
|
||||||
Summary: A tool for automatically mounting and unmounting filesystems
|
Summary: A tool for automatically mounting and unmounting filesystems
|
||||||
Name: autofs
|
Name: autofs
|
||||||
Version: 5.1.4
|
Version: 5.1.4
|
||||||
Release: 38%{?dist}
|
Release: 43%{?dist}
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: System Environment/Daemons
|
Group: System Environment/Daemons
|
||||||
|
@ -94,6 +94,12 @@ Patch81: autofs-5.1.5-use-local-getmntent_r-in-tree_get_mnt_list.patch
|
||||||
Patch82: autofs-5.1.5-fix-missing-initialization-of-autofs_point-flags.patch
|
Patch82: autofs-5.1.5-fix-missing-initialization-of-autofs_point-flags.patch
|
||||||
|
|
||||||
Patch83: autofs-5.1.6-update-ldap-READMEs-and-schema-definitions.patch
|
Patch83: autofs-5.1.6-update-ldap-READMEs-and-schema-definitions.patch
|
||||||
|
Patch84: autofs-5.1.6-fix-a-regression-with-map-instance-lookup.patch
|
||||||
|
|
||||||
|
Patch85: autofs-5.1.6-fix-trailing-dollar-sun-entry-expansion.patch
|
||||||
|
Patch86: autofs-5.1.6-initialize-struct-addrinfo-for-getaddrinfo-calls.patch
|
||||||
|
Patch87: autofs-5.1.6-fix-quoted-string-length-calc-in-expandsunent.patch
|
||||||
|
Patch88: autofs-5.1.6-fix-autofs-mount-options-construction.patch
|
||||||
|
|
||||||
%if %{with_systemd}
|
%if %{with_systemd}
|
||||||
BuildRequires: systemd-units
|
BuildRequires: systemd-units
|
||||||
|
@ -235,6 +241,12 @@ echo %{version}-%{release} > .version
|
||||||
%patch82 -p1
|
%patch82 -p1
|
||||||
|
|
||||||
%patch83 -p1
|
%patch83 -p1
|
||||||
|
%patch84 -p1
|
||||||
|
|
||||||
|
%patch85 -p1
|
||||||
|
%patch86 -p1
|
||||||
|
%patch87 -p1
|
||||||
|
%patch88 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
LDFLAGS=-Wl,-z,now
|
LDFLAGS=-Wl,-z,now
|
||||||
|
@ -330,6 +342,35 @@ fi
|
||||||
%dir /etc/auto.master.d
|
%dir /etc/auto.master.d
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jun 15 2020 Ian Kent <ikent@redhat.com> - 5.1.4-43
|
||||||
|
- bz1841456 - automount program crashes with "malloc(): invalid next size
|
||||||
|
(unsorted)
|
||||||
|
- fix autofs mount options construction.
|
||||||
|
-Related: rhbz#1841456
|
||||||
|
|
||||||
|
* Tue Jun 02 2020 Ian Kent <ikent@redhat.com> - 5.1.4-42
|
||||||
|
- bz1841456 - automount program crashes with "malloc(): invalid next size
|
||||||
|
(unsorted)
|
||||||
|
- initialize struct addrinfo for getaddrinfo() calls.
|
||||||
|
- fix quoted string length calc in expandsunent().
|
||||||
|
-Resolves: rhbz#1841456
|
||||||
|
|
||||||
|
* Mon May 18 2020 Ian Kent <ikent@redhat.com> - 5.1.4-41
|
||||||
|
- bz1835547 - [RHEL8]autofs cannot mount samba/cifs shares that end with a
|
||||||
|
dollar sign
|
||||||
|
- fix trailing dollar sun entry expansion.
|
||||||
|
- Resolves: rhbz#1835547
|
||||||
|
|
||||||
|
* Fri Feb 21 2020 Ian Kent <ikent@redhat.com> - 5.1.4-40
|
||||||
|
- fix incorrect changelog entry for bug 1802251.
|
||||||
|
- Related: rhbz#1802251
|
||||||
|
|
||||||
|
* Mon Feb 17 2020 Ian Kent <ikent@redhat.com> - 5.1.4-39
|
||||||
|
- bz1802251 - Autofs will only mount share once if sss is first ini
|
||||||
|
nsswitch.conf
|
||||||
|
- fix a regression with map instance lookup.
|
||||||
|
- Resolves: rhbz#1802251
|
||||||
|
|
||||||
* Mon Nov 25 2019 Ian Kent <ikent@redhat.com> - 5.1.4-38
|
* Mon Nov 25 2019 Ian Kent <ikent@redhat.com> - 5.1.4-38
|
||||||
- bz1660145 - autofs.schema doesn't work in RHEL8
|
- bz1660145 - autofs.schema doesn't work in RHEL8
|
||||||
- update spec file doc inclusions for schema definition update.
|
- update spec file doc inclusions for schema definition update.
|
||||||
|
|
Loading…
Reference in New Issue