rpms/autofs/FC-6 autofs-5.0.1-rc2-add-export-syntax-checks.patch, NONE, 1.1 autofs-5.0.1-rc2-admit-slashify-colons.patch, NONE, 1.1 autofs-5.0.1-rc2-afs-buffer-overflow-check.patch, NONE, 1.1 autofs-5.0.1-rc2-allow-underscore-in-hostname.patch, NONE, 1.1 autofs-5.0.1-rc2-change-mount-device-to-map-name.patch, NONE, 1.1 autofs-5.0.1-rc2-hosts-check-exports-update.patch, NONE, 1.1 autofs-5.0.1-rc2-replace-tempnam.patch, NONE, 1.1 autofs-5.0.1-rc2-set-socket-close-on-exec.patch, NONE, 1.1
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Thu Dec 14 05:01:05 UTC 2006
Author: ikent
Update of /cvs/dist/rpms/autofs/FC-6
In directory cvs.devel.redhat.com:/tmp/cvs-serv11684
Added Files:
autofs-5.0.1-rc2-add-export-syntax-checks.patch
autofs-5.0.1-rc2-admit-slashify-colons.patch
autofs-5.0.1-rc2-afs-buffer-overflow-check.patch
autofs-5.0.1-rc2-allow-underscore-in-hostname.patch
autofs-5.0.1-rc2-change-mount-device-to-map-name.patch
autofs-5.0.1-rc2-hosts-check-exports-update.patch
autofs-5.0.1-rc2-replace-tempnam.patch
autofs-5.0.1-rc2-set-socket-close-on-exec.patch
Log Message:
- add patches for previous commit.
autofs-5.0.1-rc2-add-export-syntax-checks.patch:
CHANGELOG | 1
lib/rpc_subs.c | 76 ++++++++++++++++++++++++++++++++++-----------------------
2 files changed, 47 insertions(+), 30 deletions(-)
--- NEW FILE autofs-5.0.1-rc2-add-export-syntax-checks.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 1d12402..989b7cb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -45,6 +45,7 @@
check for "port=" parameter.
- correct semantics of "-null" map handling.
- remove ability to use multiple indirect mount entries in master map.
+- expand export access checks to include missing syntax options.
1/9/2006 autofs-5.0.1 rc2
-------------------------
diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
index 342d33a..4982457 100644
--- a/lib/rpc_subs.c
+++ b/lib/rpc_subs.c
@@ -44,6 +44,8 @@ #endif
#define MAX_ERR_BUF 512
+static char *ypdomain = NULL;
+
/*
* Create a UDP RPC client
*/
@@ -910,51 +912,62 @@ static int pattern_match(const char *s,
static int string_match(const char *myname, const char *pattern)
{
- struct hostent he;
- struct hostent *phe = &he;
- struct hostent *result;
- char buf[HOST_ENT_BUF_SIZE];
- int ret, ghn_errno;
+ struct addrinfo hints, *ni;
+ int ret;
- memset(buf, 0, HOST_ENT_BUF_SIZE);
- memset(&he, 0, sizeof(struct hostent));
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = 0;
+ hints.ai_socktype = 0;
- ret = gethostbyname_r(myname, phe,
- buf, HOST_ENT_BUF_SIZE, &result, &ghn_errno);
- if (ret || !result)
+ ret = getaddrinfo(myname, NULL, &hints, &ni);
+ if (ret) {
+ error(LOGOPT_ANY, "name lookup failed: %s", gai_strerror(ret));
return 0;
+ }
if (strchr(pattern, '*') || strchr(pattern, '?')) {
ret = pattern_match(myname, pattern);
if (!ret)
- ret = pattern_match(phe->h_name, pattern);
+ ret = pattern_match(ni->ai_canonname, pattern);
} else {
- if (strchr(pattern, '.'))
- ret = !memcmp(phe->h_name, pattern, strlen(pattern));
- else
- ret = !memcmp(myname, pattern, strlen(pattern));
+ /* Match simple nane or FQDN */
+ ret = !memcmp(myname, pattern, strlen(pattern));
+ if (!ret)
+ ret = !memcmp(ni->ai_canonname, pattern, strlen(pattern));
+
+ /* Name could still be a netgroup (Solaris) */
+ if (!ret && ypdomain) {
+ ret = innetgr(pattern, myname, NULL, ypdomain);
+ if (!ret)
+ ret = innetgr(pattern,
+ ni->ai_canonname, NULL, ypdomain);
+ }
+
}
+ freeaddrinfo(ni);
return ret;
}
static int host_match(char *pattern)
{
- static char *ypdomain = NULL;
- static char myname[MAXHOSTNAMELEN + 1] = "\0";
+ unsigned int negate = (*pattern == '-');
+ const char *m_pattern = (negate ? pattern + 1 : pattern);
+ char myname[MAXHOSTNAMELEN + 1] = "\0";
struct in_addr tmp;
int ret = 0;
- if (!*myname)
- if (gethostname(myname, MAXHOSTNAMELEN))
- return 0;
+ if (gethostname(myname, MAXHOSTNAMELEN))
+ return 0;
- if (*pattern == '@') {
- if (!ypdomain)
- if (yp_get_default_domain(&ypdomain))
- return 0;
- ret = innetgr(pattern + 1, myname, (char *) 0, ypdomain);
- } else if (inet_aton(pattern, &tmp) || strchr(pattern, '/')) {
- size_t len = strlen(pattern) + 1;
+ if (yp_get_default_domain(&ypdomain))
+ ypdomain = NULL;
+
+ if (*m_pattern == '@') {
+ if (ypdomain)
+ ret = innetgr(m_pattern + 1, myname, NULL, ypdomain);
+ } else if (inet_aton(m_pattern, &tmp) || strchr(m_pattern, '/')) {
+ size_t len = strlen(m_pattern) + 1;
char *addr, *mask;
addr = alloca(len);
@@ -962,18 +975,21 @@ static int host_match(char *pattern)
return 0;
memset(addr, 0, len);
- memcpy(addr, pattern, len - 1);
+ memcpy(addr, m_pattern, len - 1);
mask = strchr(addr, '/');
if (mask) {
*mask++ = '\0';
ret = masked_match(addr, mask);
} else
ret = masked_match(addr, "32");
- } else if (!strcmp(pattern, "gss/krb5")) {
+ } else if (!strcmp(m_pattern, "gss/krb5")) {
/* Leave this to the GSS layer */
ret = 1;
} else
- ret = string_match(myname, pattern);
+ ret = string_match(myname, m_pattern);
+
+ if (negate)
+ ret = !ret;
return ret;
}
autofs-5.0.1-rc2-admit-slashify-colons.patch:
CHANGELOG | 1 +
lib/master_tok.l | 6 ++++++
2 files changed, 7 insertions(+)
--- NEW FILE autofs-5.0.1-rc2-admit-slashify-colons.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index e42bf42..c41dc39 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -49,6 +49,7 @@
- make "-hosts" module try to be sensitive to exports list changes.
- change mount "device" from "automount" to the map name.
- check for buffer overflow in mount_afs.c.
+- update master map tokenizer to admit "slasify-colons" option (Capelle Bonoit).
1/9/2006 autofs-5.0.1 rc2
-------------------------
diff --git a/lib/master_tok.l b/lib/master_tok.l
index dc76c5c..84239c1 100644
--- a/lib/master_tok.l
+++ b/lib/master_tok.l
@@ -92,6 +92,7 @@ CONT \\\n{OPTWS}
OPTIONSTR ([\-]?([[:alpha:]_]([[:alnum:]_\-])*(=([[:alnum:]_\-])+)*)+)
MACROSTR (-D{OPTWS}([[:alpha:]_]([[:alnum:]_\-])*)=([[:alnum:]_\-])+)
+SLASHIFYSTR (--(no-)?slashify-colons)
NUMBER [0-9]+
DNSERVSTR1 ([[:alpha:]][[:alnum:]\-.]*(:[0-9]+)?:)
@@ -307,6 +308,11 @@ OPTTOUT (-t{OPTWS}|-t{OPTWS}={OPTWS}|--
{OPTWS} {}
+ {SLASHIFYSTR} {
+ strcpy(master_lval.strtype, master_text);
+ return(OPTION);
+ }
+
{MACROSTR} {
strcpy(master_lval.strtype, master_text);
return(OPTION);
autofs-5.0.1-rc2-afs-buffer-overflow-check.patch:
CHANGELOG | 1 +
modules/mount_afs.c | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
--- NEW FILE autofs-5.0.1-rc2-afs-buffer-overflow-check.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 4b5a14b..e42bf42 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -48,6 +48,7 @@
- expand export access checks to include missing syntax options.
- make "-hosts" module try to be sensitive to exports list changes.
- change mount "device" from "automount" to the map name.
+- check for buffer overflow in mount_afs.c.
1/9/2006 autofs-5.0.1 rc2
-------------------------
diff --git a/modules/mount_afs.c b/modules/mount_afs.c
index 252302e..3b4261a 100644
--- a/modules/mount_afs.c
+++ b/modules/mount_afs.c
@@ -30,11 +30,18 @@ int mount_init(void **context)
int mount_mount(struct autofs_point *ap, const char *root, const char *name, int name_len,
const char *what, const char *fstype, const char *options, void *context)
{
- char dest[PATH_MAX * 2];
-
- strcpy(dest, root); /* Convert the name to a mount point. */
- strncat(dest, "/", sizeof(dest));
- strncat(dest, name, sizeof(dest));
+ /* PATH_MAX is allegedly longest path allowed */
+ char dest[PATH_MAX + 1];
+ size_t r_len = strlen(root);
+ size_t d_len = r_len + name_len + 2;
+
+ if (d_len > PATH_MAX)
+ return 1;
+
+ /* Convert the name to a mount point. */
+ strcpy(dest, root);
+ strcat(dest, "/");
+ strcat(dest, name);
/* remove trailing slash (http://bugs.debian.org/141775) */
if (dest[strlen(dest)-1] == '/')
autofs-5.0.1-rc2-allow-underscore-in-hostname.patch:
CHANGELOG | 1 +
modules/parse_sun.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
--- NEW FILE autofs-5.0.1-rc2-allow-underscore-in-hostname.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index c41dc39..49620d5 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -50,6 +50,7 @@
- change mount "device" from "automount" to the map name.
- check for buffer overflow in mount_afs.c.
- update master map tokenizer to admit "slasify-colons" option (Capelle Bonoit).
+- update location validation to accept "_" (Fabio Olive Leite).
1/9/2006 autofs-5.0.1 rc2
-------------------------
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
index 6f10a4f..c849ff3 100644
--- a/modules/parse_sun.c
+++ b/modules/parse_sun.c
@@ -691,7 +691,7 @@ static int validate_location(char *loc)
if (check_colon(ptr)) {
while (*ptr && *ptr != ':') {
if (!(isalnum(*ptr) ||
- *ptr == '-' || *ptr == '.' ||
+ *ptr == '-' || *ptr == '.' || *ptr == '_' ||
*ptr == ',' || *ptr == '(' || *ptr == ')'))
return 0;
ptr++;
autofs-5.0.1-rc2-change-mount-device-to-map-name.patch:
CHANGELOG | 1 +
b/daemon/direct.c | 10 ++++++++--
daemon/indirect.c | 13 ++++++++++++-
include/automount.h | 1 +
lib/cache.c | 2 ++
5 files changed, 24 insertions(+), 3 deletions(-)
--- NEW FILE autofs-5.0.1-rc2-change-mount-device-to-map-name.patch ---
unchanged:
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -47,6 +47,7 @@
- remove ability to use multiple indirect mount entries in master map.
- expand export access checks to include missing syntax options.
- make "-hosts" module try to be sensitive to exports list changes.
+- change mount "device" from "automount" to the map name.
1/9/2006 autofs-5.0.1 rc2
-------------------------
diff -u b/daemon/direct.c b/daemon/direct.c
--- b/daemon/direct.c
+++ b/daemon/direct.c
@@ -357,6 +357,7 @@
struct stat st;
int status, ret, ioctlfd, cl_flags;
struct list_head list;
+ const char *map_name;
INIT_LIST_HEAD(&list);
@@ -448,7 +449,9 @@
me->dir_created = 1;
}
- ret = mount("automount", me->key, "autofs", MS_MGC_VAL, mp->options);
+ map_name = me->mc->map->argv[0];
+
+ ret = mount(map_name, me->key, "autofs", MS_MGC_VAL, mp->options);
if (ret) {
crit(ap->logopt, "failed to mount autofs path %s", me->key);
goto out_err;
@@ -695,6 +698,7 @@
time_t timeout = ap->exp_timeout;
struct stat st;
int ioctlfd, cl_flags, status, ret;
+ const char *map_name;
if (is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
if (ap->state != ST_READMAP)
@@ -772,7 +776,9 @@
"calling mount -t autofs " SLOPPY " -o %s automount %s",
mp->options, me->key);
- ret = mount("automount", me->key, "autofs", MS_MGC_VAL, mp->options);
+ map_name = me->mc->map->argv[0];
+
+ ret = mount(map_name, me->key, "autofs", MS_MGC_VAL, mp->options);
if (ret) {
crit(ap->logopt, "failed to mount autofs path %s", me->key);
goto out_err;
unchanged:
--- a/daemon/indirect.c
+++ b/daemon/indirect.c
@@ -147,6 +147,7 @@ static int do_mount_autofs_indirect(stru
{
time_t timeout = ap->exp_timeout;
char *options = NULL;
+ const char *type, *map_name = NULL;
struct stat st;
struct mnt_list *mnts;
int cl_flags, ret;
@@ -183,7 +184,17 @@ static int do_mount_autofs_indirect(stru
ap->dir_created = 1;
}
- ret = mount("automount", ap->path, "autofs", MS_MGC_VAL, options);
+ type = ap->entry->maps->type;
+ if (type && !strcmp(ap->entry->maps->type, "hosts")) {
+ char *tmp = alloca(7);
+ if (tmp) {
+ strcpy(tmp, "-hosts");
+ map_name = (const char *) tmp;
+ }
+ } else
+ map_name = ap->entry->maps->argv[0];
+
+ ret = mount(map_name, ap->path, "autofs", MS_MGC_VAL, options);
if (ret) {
crit(ap->logopt, "failed to mount autofs path %s", ap->path);
goto out_rmdir;
unchanged:
--- a/include/automount.h
+++ b/include/automount.h
@@ -131,6 +131,7 @@ struct mapent_cache {
unsigned int size;
pthread_mutex_t ino_index_mutex;
struct list_head *ino_index;
+ struct map_source *map;
struct mapent **hash;
};
unchanged:
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -207,6 +207,8 @@ struct mapent_cache *cache_init(struct m
INIT_LIST_HEAD(&mc->ino_index[i]);
}
+ mc->map = map;
+
cache_unlock(mc);
return mc;
autofs-5.0.1-rc2-hosts-check-exports-update.patch:
CHANGELOG | 1 +
modules/lookup_hosts.c | 31 ++++++++++++++++---------------
2 files changed, 17 insertions(+), 15 deletions(-)
--- NEW FILE autofs-5.0.1-rc2-hosts-check-exports-update.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 989b7cb..f8583b8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -46,6 +46,7 @@
- correct semantics of "-null" map handling.
- remove ability to use multiple indirect mount entries in master map.
- expand export access checks to include missing syntax options.
+- make "-hosts" module try to be sensitive to exports list changes.
1/9/2006 autofs-5.0.1 rc2
-------------------------
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
index 08ef278..1a16b96 100644
--- a/modules/lookup_hosts.c
+++ b/modules/lookup_hosts.c
@@ -123,7 +123,6 @@ int lookup_mount(struct autofs_point *ap
int mapent_len;
time_t now = time(NULL);
exports exp;
- int status = NSS_STATUS_UNKNOWN;
int ret;
source = ap->entry->current;
@@ -135,6 +134,7 @@ int lookup_mount(struct autofs_point *ap
cache_readlock(mc);
me = cache_lookup_distinct(mc, name);
if (!me) {
+ cache_unlock(mc);
/*
* We haven't read the list of hosts into the
* cache so go straight to the lookup.
@@ -146,12 +146,11 @@ int lookup_mount(struct autofs_point *ap
* so it's NOTFOUND otherwise this could be a
* lookup for a new host.
*/
- if (strchr(name, '/'))
- status = NSS_STATUS_NOTFOUND;
+ if (*name != '/' && strchr(name, '/'))
+ return NSS_STATUS_NOTFOUND;
goto done;
}
- pthread_cleanup_push(cache_lock_cleanup, mc);
if (*name == '/')
msg(MODPREFIX
"can't find path in hosts map %s", name);
@@ -159,8 +158,9 @@ int lookup_mount(struct autofs_point *ap
msg(MODPREFIX
"can't find path in hosts map %s/%s",
ap->path, name);
- pthread_cleanup_pop(0);
- status = NSS_STATUS_NOTFOUND;
+
+ debug(ap->logopt,
+ MODPREFIX "lookup failed - update exports list");
goto done;
}
/*
@@ -175,12 +175,8 @@ int lookup_mount(struct autofs_point *ap
pthread_cleanup_pop(0);
mapent[mapent_len] = '\0';
}
-done:
cache_unlock(mc);
- if (status != NSS_STATUS_UNKNOWN)
- return status;
-
if (mapent) {
master_source_current_wait(ap->entry);
ap->entry->current = source;
@@ -190,14 +186,14 @@ done:
ret = ctxt->parse->parse_mount(ap, name, name_len,
mapent, ctxt->parse->context);
- if (ret)
- return NSS_STATUS_TRYAGAIN;
+ if (!ret)
+ return NSS_STATUS_SUCCESS;
- return NSS_STATUS_SUCCESS;
+ debug(ap->logopt, MODPREFIX "mount failed - update exports list");
}
-
+done:
/*
- * Otherwise we need to get the exports list and add then
+ * Otherwise we need to get the exports list and add update
* the cache.
*/
debug(ap->logopt, MODPREFIX "fetchng export list for %s", name);
@@ -207,6 +203,7 @@ done:
/* Check exports for obvious ones we don't have access to */
exp = rpc_exports_prune(exp);
+ mapent = NULL;
while (exp) {
if (mapent) {
int len = strlen(mapent) + 1;
@@ -256,9 +253,13 @@ done:
cache_update(mc, name, mapent, now);
cache_unlock(mc);
+ debug(LOGOPT_ANY, "source wait");
+
master_source_current_wait(ap->entry);
ap->entry->current = source;
+ debug(LOGOPT_ANY, "do parse_mount");
+
ret = ctxt->parse->parse_mount(ap, name, name_len,
mapent, ctxt->parse->context);
free(mapent);
autofs-5.0.1-rc2-replace-tempnam.patch:
lib/mounts.c | 33 +++++++++++++++++----------------
modules/mount_bind.c | 41 +++++++++++++++++------------------------
2 files changed, 34 insertions(+), 40 deletions(-)
--- NEW FILE autofs-5.0.1-rc2-replace-tempnam.patch ---
diff --git a/lib/mounts.c b/lib/mounts.c
index c2a8f04..050ec8c 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -38,16 +38,17 @@ static const char kver_options_template[
unsigned int query_kproto_ver(void)
{
- char options[MAX_OPTIONS_LEN + 1], *tmp;
+ char dir[] = "/tmp/autoXXXXXX", *t_dir;
+ char options[MAX_OPTIONS_LEN + 1];
pid_t pgrp = getpgrp();
int pipefd[2], ioctlfd, len;
- tmp = tempnam(NULL, "auto");
- if (mkdir(tmp, 0700) == -1)
+ t_dir = mkdtemp(dir);
+ if (!t_dir)
return 0;
if (pipe(pipefd) == -1) {
- rmdir(tmp);
+ rmdir(t_dir);
return 0;
}
@@ -56,24 +57,24 @@ unsigned int query_kproto_ver(void)
if (len < 0) {
close(pipefd[0]);
close(pipefd[1]);
- rmdir(tmp);
+ rmdir(t_dir);
return 0;
}
- if (mount("automount", tmp, "autofs", MS_MGC_VAL, options)) {
+ if (mount("automount", t_dir, "autofs", MS_MGC_VAL, options)) {
close(pipefd[0]);
close(pipefd[1]);
- rmdir(tmp);
+ rmdir(t_dir);
return 0;
}
close(pipefd[1]);
- ioctlfd = open(tmp, O_RDONLY);
+ ioctlfd = open(t_dir, O_RDONLY);
if (ioctlfd == -1) {
- umount(tmp);
+ umount(t_dir);
close(pipefd[0]);
- rmdir(tmp);
+ rmdir(t_dir);
return 0;
}
@@ -82,25 +83,25 @@ unsigned int query_kproto_ver(void)
/* If this ioctl() doesn't work, it is kernel version 2 */
if (ioctl(ioctlfd, AUTOFS_IOC_PROTOVER, &kver.major) == -1) {
close(ioctlfd);
- umount(tmp);
+ umount(t_dir);
close(pipefd[0]);
- rmdir(tmp);
+ rmdir(t_dir);
return 0;
}
/* If this ioctl() doesn't work, version is 4 or less */
if (ioctl(ioctlfd, AUTOFS_IOC_PROTOSUBVER, &kver.minor) == -1) {
close(ioctlfd);
- umount(tmp);
+ umount(t_dir);
close(pipefd[0]);
- rmdir(tmp);
+ rmdir(t_dir);
return 0;
}
close(ioctlfd);
- umount(tmp);
+ umount(t_dir);
close(pipefd[0]);
- rmdir(tmp);
+ rmdir(t_dir);
return 1;
}
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
index 1cdb1c6..e76e5ee 100644
--- a/modules/mount_bind.c
+++ b/modules/mount_bind.c
@@ -34,46 +34,39 @@ static int bind_works = 0;
int mount_init(void **context)
{
- char *tmp1 = tempnam(NULL, "auto");
- char *tmp2 = tempnam(NULL, "auto");
+ char tmp1[] = "/tmp/autoXXXXXX", *t1_dir;
+ char tmp2[] = "/tmp/autoXXXXXX", *t2_dir;
int err;
struct stat st1, st2;
- if (tmp1 == NULL || tmp2 == NULL) {
- if (tmp1)
- free(tmp1);
- if (tmp2)
- free(tmp2);
+ t1_dir = mkdtemp(tmp1);
+ t2_dir = mkdtemp(tmp2);
+ if (t1_dir == NULL || t2_dir == NULL) {
+ if (t1_dir)
+ rmdir(t1_dir);
+ if (t2_dir)
+ rmdir(t2_dir);
return 0;
}
- if (mkdir(tmp1, 0700) == -1)
- goto out2;
-
- if (mkdir(tmp2, 0700) == -1)
- goto out1;
-
- if (lstat(tmp1, &st1) == -1)
+ if (lstat(t1_dir, &st1) == -1)
goto out;
- err = spawn_mount(log_debug, "-n", "--bind", tmp1, tmp2, NULL);
+ err = spawn_mount(log_debug, "-n", "--bind", t1_dir, t2_dir, NULL);
if (err == 0 &&
- lstat(tmp2, &st2) == 0 &&
+ lstat(t2_dir, &st2) == 0 &&
st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino) {
bind_works = 1;
}
debug(LOGOPT_NONE, MODPREFIX "bind_works = %d", bind_works);
- spawn_umount(log_debug, "-n", tmp2, NULL);
+ spawn_umount(log_debug, "-n", t2_dir, NULL);
+
+out:
+ rmdir(t2_dir);
+ rmdir(t2_dir);
- out:
- rmdir(tmp2);
- out1:
- free(tmp2);
- rmdir(tmp1);
- out2:
- free(tmp1);
return 0;
}
autofs-5.0.1-rc2-set-socket-close-on-exec.patch:
CHANGELOG | 1 +
lib/rpc_subs.c | 22 +++++++++++++++++++---
modules/replicated.c | 9 ++++++++-
3 files changed, 28 insertions(+), 4 deletions(-)
--- NEW FILE autofs-5.0.1-rc2-set-socket-close-on-exec.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 49620d5..bf5195d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -51,6 +51,7 @@
- check for buffer overflow in mount_afs.c.
- update master map tokenizer to admit "slasify-colons" option (Capelle Bonoit).
- update location validation to accept "_" (Fabio Olive Leite).
+- set close-on-exec flag on open sockets.
1/9/2006 autofs-5.0.1 rc2
-------------------------
diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
index 4982457..b4e9c91 100644
--- a/lib/rpc_subs.c
+++ b/lib/rpc_subs.c
@@ -51,7 +51,7 @@ static char *ypdomain = NULL;
*/
static CLIENT *create_udp_client(struct conn_info *info)
{
- int fd, ret, ghn_errno;
+ int fd, cl_flags, ret, ghn_errno;
CLIENT *client;
struct sockaddr_in laddr, raddr;
struct hostent hp;
@@ -105,6 +105,12 @@ got_addr:
fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0)
return NULL;
+
+ if ((cl_flags = fcntl(fd, F_GETFD, 0)) != -1) {
+ cl_flags |= FD_CLOEXEC;
+ fcntl(fd, F_SETFD, cl_flags);
+ }
+
laddr.sin_family = AF_INET;
laddr.sin_port = 0;
laddr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -255,7 +261,7 @@ done:
*/
static CLIENT *create_tcp_client(struct conn_info *info)
{
- int fd, ghn_errno;
+ int fd, cl_flags, ghn_errno;
CLIENT *client;
struct sockaddr_in addr;
struct hostent hp;
@@ -304,6 +310,11 @@ got_addr:
if (fd < 0)
return NULL;
+ if ((cl_flags = fcntl(fd, F_GETFD, 0)) != -1) {
+ cl_flags |= FD_CLOEXEC;
+ fcntl(fd, F_SETFD, cl_flags);
+ }
+
ret = connect_nb(fd, &addr, &info->timeout);
if (ret < 0)
goto out_close;
@@ -749,7 +760,7 @@ static int masked_match(const char *addr
struct sockaddr_in6 saddr6;
struct ifconf ifc;
struct ifreq *ifr;
- int sock, ret, i, is_ipv4, is_ipv6;
+ int sock, cl_flags, ret, i, is_ipv4, is_ipv6;
unsigned int msize;
sock = socket(AF_INET, SOCK_DGRAM, 0);
@@ -759,6 +770,11 @@ static int masked_match(const char *addr
return 0;
}
+ if ((cl_flags = fcntl(sock, F_GETFD, 0)) != -1) {
+ cl_flags |= FD_CLOEXEC;
+ fcntl(sock, F_SETFD, cl_flags);
+ }
+
ifc.ifc_len = sizeof(buf);
ifc.ifc_req = (struct ifreq *) buf;
ret = ioctl(sock, SIOCGIFCONF, &ifc);
diff --git a/modules/replicated.c b/modules/replicated.c
index 5aaaba1..46ea36b 100644
--- a/modules/replicated.c
+++ b/modules/replicated.c
@@ -52,6 +52,8 @@ #include <arpa/inet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netdb.h>
+#include <unistd.h>
+#include <fcntl.h>
#include "rpc_subs.h"
#include "replicated.h"
@@ -79,7 +81,7 @@ static unsigned int get_proximity(const
char tmp[20], buf[MAX_ERR_BUF], *ptr;
struct ifconf ifc;
struct ifreq *ifr, nmptr;
- int sock, ret, i;
+ int sock, cl_flags, ret, i;
uint32_t mask, ha, ia;
memcpy(tmp, host_addr, addr_len);
@@ -94,6 +96,11 @@ static unsigned int get_proximity(const
return PROXIMITY_ERROR;
}
+ if ((cl_flags = fcntl(sock, F_GETFD, 0)) != -1) {
+ cl_flags |= FD_CLOEXEC;
+ fcntl(sock, F_SETFD, cl_flags);
+ }
+
ifc.ifc_len = sizeof(buf);
ifc.ifc_req = (struct ifreq *) buf;
ret = ioctl(sock, SIOCGIFCONF, &ifc);
More information about the fedora-cvs-commits
mailing list