1 autofs-5.0.4 - use CLOEXEC flag for setmntent
3 From: Ian Kent <raven@themaw.net>
5 Update use of CLOEXEC functionality to cover setmntent(3)
10 include/automount.h | 20 ++++++++++++++++++++
11 lib/mounts.c | 8 ++++----
12 3 files changed, 25 insertions(+), 4 deletions(-)
15 diff --git a/CHANGELOG b/CHANGELOG
16 index af77b55..eb4a189 100644
20 - make hash table scale to thousands of entries (Paul Wankadia,
21 Valerie Aurora Henson).
22 - clear the quoted flag after each character from program map input.
23 +- use CLOEXEC flag for setmntent also.
25 4/11/2008 autofs-5.0.4
26 -----------------------
27 diff --git a/include/automount.h b/include/automount.h
28 index 005d209..46cb6c6 100644
29 --- a/include/automount.h
30 +++ b/include/automount.h
31 @@ -581,5 +581,25 @@ static inline FILE *open_fopen_r(const char *path)
35 +static inline FILE *open_setmntent_r(const char *table)
39 +#if defined(O_CLOEXEC) && defined(SOCK_CLOEXEC)
40 + if (cloexec_works != -1) {
41 + tab = setmntent(table, "re");
43 + check_cloexec(fileno(tab));
48 + tab = fopen(table, "r");
51 + check_cloexec(fileno(tab));
57 diff --git a/lib/mounts.c b/lib/mounts.c
58 index ce4691b..b98e1a4 100644
61 @@ -218,7 +218,7 @@ struct mnt_list *get_mnt_list(const char *table, const char *path, int include)
62 if (!path || !pathlen || pathlen > PATH_MAX)
65 - tab = setmntent(table, "r");
66 + tab = open_setmntent_r(table);
68 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
69 logerr("setmntent: %s", estr);
70 @@ -415,7 +415,7 @@ static int table_is_mounted(const char *table, const char *path, unsigned int ty
71 if (!path || !pathlen || pathlen >= PATH_MAX)
74 - tab = setmntent(table, "r");
75 + tab = open_setmntent_r(table);
77 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
78 logerr("setmntent: %s", estr);
79 @@ -489,7 +489,7 @@ int has_fstab_option(const char *opt)
83 - tab = setmntent(_PATH_MNTTAB, "r");
84 + tab = open_setmntent_r(_PATH_MNTTAB);
86 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
87 logerr("setmntent: %s", estr);
88 @@ -668,7 +668,7 @@ struct mnt_list *tree_make_mnt_tree(const char *table, const char *path)
92 - tab = setmntent(table, "r");
93 + tab = open_setmntent_r(table);
95 char *estr = strerror_r(errno, buf, PATH_MAX - 1);
96 logerr("setmntent: %s", estr);