Compare commits

...

No commits in common. "c8" and "c8-beta" have entirely different histories.
c8 ... c8-beta

15 changed files with 296 additions and 1824 deletions

View File

@ -1,347 +0,0 @@
autofs-5.1.6 - fix ldap sasl reconnect problem
From: Ian Kent <raven@themaw.net>
When performing an ldap sasl connection a two step initialisation
was being done in an attempt to partially reuse existing connection
setup.
But if a network connectivity problem occurs the connection can end
up only half initialized and recovery after connectivity is restored
fails.
So get rid of the two step initialization, as it's benefit was at best
questionable, so that connection attempts either succeed or completely
fail. This leaves the connection completely uninitialized if there's a
network conectivity problem, ready for a new connection attempt.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1
include/lookup_ldap.h | 1
modules/cyrus-sasl.c | 131 +++++++++++++++++++++++++-------------------------
3 files changed, 68 insertions(+), 65 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -162,6 +162,7 @@
- refactor umount_amd_ext_mount().
- add flags argument to amd do_program_mount().
- fix deadlock in master_notify_submount().
+- fix ldap sasl reconnect problem.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/include/lookup_ldap.h
+++ autofs-5.1.4/include/lookup_ldap.h
@@ -87,7 +87,6 @@ struct lookup_context {
char *secret;
char *client_princ;
char *client_cc;
- int kinit_done;
int kinit_successful;
#ifdef WITH_SASL
/* Kerberos */
--- autofs-5.1.4.orig/modules/cyrus-sasl.c
+++ autofs-5.1.4/modules/cyrus-sasl.c
@@ -396,9 +396,9 @@ do_sasl_bind(unsigned logopt, LDAP *ld,
* cache, add the TGT to that cache, and set the environment variable so
* that the sasl/krb5 libraries can find our credentials.
*
- * Returns 0 upon success. ctxt->kinit_done and ctxt->kinit_successful
- * are set for cleanup purposes. The krb5 context and ccache entries in
- * the lookup_context are also filled in.
+ * Returns 0 upon success. ctxt->kinit_successful is set for cleanup
+ * purposes. The krb5 context and ccache entries in the lookup_context
+ * are also filled in.
*
* Upon failure, -1 is returned.
*/
@@ -412,9 +412,16 @@ sasl_do_kinit(unsigned logopt, struct lo
const char *realm_name;
int status, realm_length;
- if (ctxt->kinit_done)
+ status = pthread_mutex_lock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
+
+ if (ctxt->kinit_successful) {
+ status = pthread_mutex_unlock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
return 0;
- ctxt->kinit_done = 1;
+ }
debug(logopt,
"initializing kerberos ticket: client principal %s",
@@ -423,15 +430,14 @@ sasl_do_kinit(unsigned logopt, struct lo
ret = krb5_init_context(&ctxt->krb5ctxt);
if (ret) {
error(logopt, "krb5_init_context failed with %d", ret);
- return -1;
+ goto out_unlock;
}
ret = krb5_cc_resolve(ctxt->krb5ctxt, krb5ccval, &ctxt->krb5_ccache);
if (ret) {
error(logopt, "krb5_cc_resolve failed with error %d",
ret);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ goto out_free_context;
}
if (ctxt->client_princ) {
@@ -515,19 +521,11 @@ sasl_do_kinit(unsigned logopt, struct lo
goto out_cleanup_unparse;
}
- status = pthread_mutex_lock(&krb5cc_mutex);
- if (status)
- fatal(status);
-
if (krb5cc_in_use++ == 0)
/* tell the cache what the default principal is */
ret = krb5_cc_initialize(ctxt->krb5ctxt,
ctxt->krb5_ccache, krb5_client_princ);
- status = pthread_mutex_unlock(&krb5cc_mutex);
- if (status)
- fatal(status);
-
if (ret) {
error(logopt,
"krb5_cc_initialize failed with error %d", ret);
@@ -550,6 +548,10 @@ sasl_do_kinit(unsigned logopt, struct lo
}
ctxt->kinit_successful = 1;
+ status = pthread_mutex_unlock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
+
debug(logopt, "Kerberos authentication was successful!");
krb5_free_unparsed_name(ctxt->krb5ctxt, tgs_name);
@@ -569,10 +571,6 @@ out_cleanup_tgs_princ:
out_cleanup_client_princ:
krb5_free_principal(ctxt->krb5ctxt, krb5_client_princ);
out_cleanup_cc:
- status = pthread_mutex_lock(&krb5cc_mutex);
- if (status)
- fatal(status);
-
if (krb5cc_in_use)
ret = krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
else
@@ -580,22 +578,21 @@ out_cleanup_cc:
if (ret)
warn(logopt,
"krb5_cc_destroy failed with non-fatal error %d", ret);
-
+out_free_context:
+ krb5_free_context(ctxt->krb5ctxt);
+out_unlock:
status = pthread_mutex_unlock(&krb5cc_mutex);
if (status)
fatal(status);
-
- krb5_free_context(ctxt->krb5ctxt);
-
return -1;
}
/*
* Check a client given external credential cache.
*
- * Returns 0 upon success. ctxt->kinit_done and ctxt->kinit_successful
- * are set for cleanup purposes. The krb5 context and ccache entries in
- * the lookup_context are also filled in.
+ * Returns 0 upon success. ctxt->kinit_successful is set for cleanup
+ * purposes. The krb5 context and ccache entries in the lookup_context
+ * are also filled in.
*
* Upon failure, -1 is returned.
*/
@@ -606,10 +603,18 @@ sasl_do_kinit_ext_cc(unsigned logopt, st
krb5_principal krb5_client_princ;
krb5_error_code ret;
char *cc_princ, *client_princ;
+ int status;
+
+ status = pthread_mutex_lock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
- if (ctxt->kinit_done)
+ if (ctxt->kinit_successful) {
+ status = pthread_mutex_unlock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
return 0;
- ctxt->kinit_done = 1;
+ }
debug(logopt,
"using external credential cache for auth: client principal %s",
@@ -618,33 +623,26 @@ sasl_do_kinit_ext_cc(unsigned logopt, st
ret = krb5_init_context(&ctxt->krb5ctxt);
if (ret) {
error(logopt, "krb5_init_context failed with %d", ret);
- return -1;
+ goto out_unlock;
}
ret = krb5_cc_resolve(ctxt->krb5ctxt, ctxt->client_cc, &ctxt->krb5_ccache);
if (ret) {
error(logopt, "krb5_cc_resolve failed with error %d",
ret);
- krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ goto out_cleanup_cc;
}
ret = krb5_cc_get_principal(ctxt->krb5ctxt, ctxt->krb5_ccache, &def_princ);
if (ret) {
error(logopt, "krb5_cc_get_principal failed with error %d", ret);
- krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ goto out_cleanup_cc;
}
ret = krb5_unparse_name(ctxt->krb5ctxt, def_princ, &cc_princ);
if (ret) {
error(logopt, "krb5_unparse_name failed with error %d", ret);
- krb5_free_principal(ctxt->krb5ctxt, def_princ);
- krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ goto out_cleanup_def_princ;
}
debug(logopt, "external credential cache default principal %s", cc_princ);
@@ -667,10 +665,8 @@ sasl_do_kinit_ext_cc(unsigned logopt, st
error(logopt,
"krb5_sname_to_principal failed for "
"%s with error %d", default_client, ret);
- krb5_free_principal(ctxt->krb5ctxt, def_princ);
- krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ krb5_free_unparsed_name(ctxt->krb5ctxt, cc_princ);
+ goto out_cleanup_def_princ;
}
@@ -681,10 +677,8 @@ sasl_do_kinit_ext_cc(unsigned logopt, st
"krb5_unparse_name failed with error %d",
ret);
krb5_free_principal(ctxt->krb5ctxt, krb5_client_princ);
- krb5_free_principal(ctxt->krb5ctxt, def_princ);
- krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ krb5_free_unparsed_name(ctxt->krb5ctxt, cc_princ);
+ goto out_cleanup_def_princ;
}
debug(logopt,
@@ -711,10 +705,7 @@ sasl_do_kinit_ext_cc(unsigned logopt, st
if (!ctxt->client_princ)
krb5_free_unparsed_name(ctxt->krb5ctxt, client_princ);
krb5_free_unparsed_name(ctxt->krb5ctxt, cc_princ);
- krb5_free_principal(ctxt->krb5ctxt, def_princ);
- krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ goto out_cleanup_def_princ;
}
if (!ctxt->client_princ)
@@ -725,15 +716,24 @@ sasl_do_kinit_ext_cc(unsigned logopt, st
/* Set the environment variable to point to the external cred cache */
if (setenv(krb5ccenv, ctxt->client_cc, 1) != 0) {
error(logopt, "setenv failed with %d", errno);
- krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
- krb5_free_context(ctxt->krb5ctxt);
- return -1;
+ goto out_cleanup_cc;
}
ctxt->kinit_successful = 1;
debug(logopt, "Kerberos authentication was successful!");
return 0;
+
+out_cleanup_def_princ:
+ krb5_free_principal(ctxt->krb5ctxt, def_princ);
+out_cleanup_cc:
+ krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
+ krb5_free_context(ctxt->krb5ctxt);
+out_unlock:
+ status = pthread_mutex_unlock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
+ return -1;
}
/*
@@ -975,11 +975,19 @@ void autofs_sasl_dispose(struct ldap_con
{
int status, ret;
+ status = pthread_mutex_lock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
+
if (ctxt->sasl_mech && !strncmp(ctxt->sasl_mech, "EXTERNAL", 8)) {
if (conn && conn->ldap) {
ldap_unbind_s(conn->ldap);
conn->ldap = NULL;
+ ctxt->kinit_successful = 0;
}
+ status = pthread_mutex_unlock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
return;
}
@@ -989,10 +997,6 @@ void autofs_sasl_dispose(struct ldap_con
}
if (ctxt->kinit_successful) {
- status = pthread_mutex_lock(&krb5cc_mutex);
- if (status)
- fatal(status);
-
if (--krb5cc_in_use || ctxt->client_cc)
ret = krb5_cc_close(ctxt->krb5ctxt, ctxt->krb5_ccache);
else
@@ -1001,19 +1005,18 @@ void autofs_sasl_dispose(struct ldap_con
logmsg("krb5_cc_destroy failed with non-fatal error %d",
ret);
- status = pthread_mutex_unlock(&krb5cc_mutex);
- if (status)
- fatal(status);
-
krb5_free_context(ctxt->krb5ctxt);
if (unsetenv(krb5ccenv) != 0)
logerr("unsetenv failed with error %d", errno);
ctxt->krb5ctxt = NULL;
ctxt->krb5_ccache = NULL;
- ctxt->kinit_done = 0;
ctxt->kinit_successful = 0;
}
+
+ status = pthread_mutex_unlock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
}
static void *sasl_mutex_new(void)

View File

@ -1,132 +0,0 @@
autofs-5.1.8 - always recreate credential cache
From: Ian Collier <imc@cs.ox.ac.uk>
In recent Kerberos revisions when a TGT expires autofs will fail to
renew the ticket.
Expired creds are being pulled out of the cache and in that case the patched
version clears the cache to remove the expired creds.
If the cache is already in use, try to pull out a cred and then if that
was successful and the cred is expired, clear the cache.
So this fixes the behaviour I was seeing, since that was happening because
expired creds were being pulled out of the cache and in that case the patched
version clears the cache to remove the expired creds.
What sort of race conditions might happen here?
- If the function is called very late during the validity of a ticket, it
might expire after the decision not to clear the cache. In that case,
the behaviour is the same as the unpatched version, but this is highly
unlikely because do_kinit is not supposed to happen while there is a
valid ticket.
- If two or more threads decide to call do_kinit at about the same time:
it's protected by a mutex, so one of the calls will happen first; this
call will clear the cache and add a new ticket. When the others kick
in, the cache won't be cleared because it's only cleared if we can
find an expired ticket in the cache and any such ticket was removed
when the first do_kinit happened.
- If one thread does do_kinit while another thread is trying to do a lookup:
if the current ticket is expired then the lookup would have failed anyway;
if it's not expired then we won't clear the cache.
- If there is both an expired and a valid ticket in the cache:
this only happens if two or more do_kinits clashed and stored tickets
with different expiration times, and if the current time is between those
times. The current bug happens because krb5 cache retrieval is returning
the earliest (i.e. expired) ticket. When that's the case then do_kinit
will clear the cache because when it tests the cache it will pull the
expired cred - and it needs to do this because otherwise all lookups are
failing (that's the bug). In a case where krb5 cache retrieval returns
the valid ticket, it doesn't matter that the cache is not cleared because
any subsequent lookups will use that valid ticket.
Signed-off-by: Ian Collier <imc@cs.ox.ac.uk>
---
CHANGELOG | 1
modules/cyrus-sasl.c | 53 +++++++++++++++++++++++++++++++++++++++------------
2 files changed, 42 insertions(+), 12 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -163,6 +163,7 @@
- add flags argument to amd do_program_mount().
- fix deadlock in master_notify_submount().
- fix ldap sasl reconnect problem.
+- always recreate credential cache.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/cyrus-sasl.c
+++ autofs-5.1.4/modules/cyrus-sasl.c
@@ -509,6 +509,46 @@ sasl_do_kinit(unsigned logopt, struct lo
debug(logopt, "Using tgs name %s", tgs_name);
memset(&my_creds, 0, sizeof(my_creds));
+
+ if (krb5cc_in_use++ == 0) {
+ /* tell the cache what the default principal is */
+ ret = krb5_cc_initialize(ctxt->krb5ctxt,
+ ctxt->krb5_ccache, krb5_client_princ);
+
+ if (ret) {
+ --krb5cc_in_use;
+ error(logopt,
+ "krb5_cc_initialize failed with error %d", ret);
+ goto out_cleanup_unparse;
+ }
+ }
+ else {
+ krb5_creds match_creds, out_creds;
+ time_t now = monotonic_time(NULL);
+
+ /* even if the cache is in use, we will clear it if it
+ * contains an expired credential for our principal,
+ * because Kerberos doesn't always work well with caches
+ * that contain both expired and valid credentials
+ */
+ memset(&match_creds, 0, sizeof match_creds);
+ match_creds.client = krb5_client_princ;
+ match_creds.server = tgs_princ;
+ ret = krb5_cc_retrieve_cred(ctxt->krb5ctxt, ctxt->krb5_ccache,
+ 0, &match_creds, &out_creds);
+ if (ret == 0 && (time_t) out_creds.times.endtime < now) {
+ debug(logopt,
+ "calling krb5_cc_initialize to clear expired tickets");
+ ret = krb5_cc_initialize(ctxt->krb5ctxt,
+ ctxt->krb5_ccache, krb5_client_princ);
+ if (ret)
+ warn(logopt,
+ "krb5_cc_initialize failed with error %d "
+ "while trying to clear existing cache",
+ ret);
+ }
+ }
+
ret = krb5_get_init_creds_keytab(ctxt->krb5ctxt, &my_creds,
krb5_client_princ,
NULL /*keytab*/,
@@ -521,18 +561,7 @@ sasl_do_kinit(unsigned logopt, struct lo
goto out_cleanup_unparse;
}
- if (krb5cc_in_use++ == 0)
- /* tell the cache what the default principal is */
- ret = krb5_cc_initialize(ctxt->krb5ctxt,
- ctxt->krb5_ccache, krb5_client_princ);
-
- if (ret) {
- error(logopt,
- "krb5_cc_initialize failed with error %d", ret);
- goto out_cleanup_creds;
- }
-
- /* and store credentials for that principal */
+ /* and store credentials for our principal */
ret = krb5_cc_store_cred(ctxt->krb5ctxt, ctxt->krb5_ccache, &my_creds);
if (ret) {
error(logopt,

View File

@ -1,37 +0,0 @@
autofs-5.1.8 - fix missing unlock in sasl_do_kinit_ext_cc()
From: James Dingwall <james-autofs@dingwall.me.uk>
There is a missing mutex unlock in function sasl_do_kinit_ext_cc(),
fix it.
Signed-off-by: James Dingwall <james-autofs@dingwall.me.uk>
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/cyrus-sasl.c | 4 ++++
2 files changed, 5 insertions(+)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -165,6 +165,7 @@
- fix ldap sasl reconnect problem.
- always recreate credential cache.
- fix always recreate credential cache.
+- fix missing unlock in sasl_do_kinit_ext_cc().
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/cyrus-sasl.c
+++ autofs-5.1.4/modules/cyrus-sasl.c
@@ -751,6 +751,10 @@ sasl_do_kinit_ext_cc(unsigned logopt, st
debug(logopt, "Kerberos authentication was successful!");
+ status = pthread_mutex_unlock(&krb5cc_mutex);
+ if (status)
+ fatal(status);
+
return 0;
out_cleanup_def_princ:

View File

@ -1,60 +0,0 @@
autofs-5.1.9 - add flags argument to amd do_program_mount()
From: Ian Kent <raven@themaw.net>
Most of the amd mount functions take a flags argument that allows them
to alter their function based on configuration.
For example the amd option autofs_use_lofs will use bind mounts instead
of symlinks in some cases which might be preferred.
The program mount function was not being passed this parameter but the
design of all the amd mount functions is quite similar and adding the
flag works as expected..
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_amd.c | 7 ++++---
2 files changed, 5 insertions(+), 3 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -160,6 +160,7 @@
- don't free ext mount if mounted.
- refactor amd function do_program_mount().
- refactor umount_amd_ext_mount().
+- add flags argument to amd do_program_mount().
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/parse_amd.c
+++ autofs-5.1.4/modules/parse_amd.c
@@ -1405,7 +1405,8 @@ out:
}
static int do_program_mount(struct autofs_point *ap,
- struct amd_entry *entry, const char *name)
+ struct amd_entry *entry, const char *name,
+ unsigned int flags)
{
int rv = 1;
@@ -1479,7 +1480,7 @@ static int do_program_mount(struct autof
goto out;
}
done:
- rv = do_link_mount(ap, name, entry, 0);
+ rv = do_link_mount(ap, name, entry, flags);
if (rv) {
if (!umount_amd_ext_mount(ap, entry->fs, 1)) {
debug(ap->logopt, MODPREFIX
@@ -1708,7 +1709,7 @@ static int amd_mount(struct autofs_point
case AMD_MOUNT_TYPE_PROGRAM:
if (!validate_program_options(ap->logopt, entry))
return 1;
- ret = do_program_mount(ap, entry, name);
+ ret = do_program_mount(ap, entry, name, flags);
break;
default:

View File

@ -1,53 +0,0 @@
autofs-5.1.9 - don't free ext mount if mounted
From: Ian Kent <raven@themaw.net>
If an external mount is in use when a umount is attempted don't free
it just let the reference count go to zero.
This will leave the mount in place and it won't get umounted. But if
another automount uses it it's reference count will become no zero
allowing for it to be umounted as normal if it isn't in use during
automount expire.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
lib/mounts.c | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -157,6 +157,7 @@
- fix submount shutdown race.
- fix amd external mount error handling.
- fix amd external mount mount handling.
+- don't free ext mount if mounted.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/lib/mounts.c
+++ autofs-5.1.4/lib/mounts.c
@@ -906,10 +906,10 @@ int ext_mount_remove(const char *path)
if (!em)
goto done;
- em->ref--;
if (em->ref)
- goto done;
- else {
+ em->ref--;
+
+ if (!em->ref && !is_mounted(path, MNTS_REAL)) {
hlist_del_init(&em->mount);
free(em->mp);
if (em->umount)
@@ -931,7 +931,7 @@ int ext_mount_inuse(const char *path)
em = ext_mount_lookup(path);
if (!em)
goto done;
- ret = em->ref;
+ ret = 1;
done:
ext_mount_hash_mutex_unlock();
return ret;

View File

@ -1,36 +0,0 @@
autofs-5.1.9 - fix always recreate credential cache
From: Ian Kent <raven@themaw.net>
When I aplied the original patch from Ian Collier for this I changed
the credential end time comparison to be against the time returned from
monotomic_time(). But this isn't the same as the calander time returned
from time() which Ian used in his original patch.
Signed-off-by: Ian Kent < raven@themaw.net>
---
CHANGELOG | 1 +
modules/cyrus-sasl.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -164,6 +164,7 @@
- fix deadlock in master_notify_submount().
- fix ldap sasl reconnect problem.
- always recreate credential cache.
+- fix always recreate credential cache.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/cyrus-sasl.c
+++ autofs-5.1.4/modules/cyrus-sasl.c
@@ -524,7 +524,7 @@ sasl_do_kinit(unsigned logopt, struct lo
}
else {
krb5_creds match_creds, out_creds;
- time_t now = monotonic_time(NULL);
+ time_t now = time(NULL);
/* even if the cache is in use, we will clear it if it
* contains an expired credential for our principal,

View File

@ -1,55 +0,0 @@
autofs-5.1.9 - fix amd external mount error handling
From: Ian Kent <raven@themaw.net>
An amd program mount might have defined its own umount program to be used
for external mounts.
In mount failure cases where the mount needs to be umounted be sure to
use the custom umount if there is one.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_amd.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -155,6 +155,7 @@
- fix get parent multi-mount check in try_remount().
- fix deadlock in remount.
- fix submount shutdown race.
+- fix amd external mount error handling.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/parse_amd.c
+++ autofs-5.1.4/modules/parse_amd.c
@@ -1183,7 +1183,7 @@ static int do_generic_mount(struct autof
}
/* If we have an external mount add it to the list */
if (umount && !ext_mount_add(entry->fs, entry->umount)) {
- umount_ent(ap, entry->fs);
+ umount_amd_ext_mount(ap, entry->fs);
error(ap->logopt, MODPREFIX
"error: could not add external mount %s",
entry->fs);
@@ -1233,7 +1233,7 @@ static int do_nfs_mount(struct autofs_po
}
/* We might be using an external mount */
if (umount && !ext_mount_add(entry->fs, entry->umount)) {
- umount_ent(ap, entry->fs);
+ umount_amd_ext_mount(ap, entry->fs);
error(ap->logopt, MODPREFIX
"error: could not add external mount %s", entry->fs);
ret = 1;
@@ -1462,7 +1462,7 @@ static int do_program_mount(struct autof
"%s: mounted %s", entry->type, entry->fs);
goto do_free;
}
- umount_ent(ap, entry->fs);
+ umount_amd_ext_mount(ap, entry->fs);
}
if (!ext_mount_inuse(entry->fs))

View File

@ -1,71 +0,0 @@
autofs-5.1.9 - fix amd external mount mount handling
From: Ian Kent <raven@themaw.net>
Amd external mounts exist outside of the autofs file system and need
extra effort to try and keep track of them so they are mounted and
umounted when they should be.
Cleanup cases where an external mount is already mounted.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/parse_amd.c | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -156,6 +156,7 @@
- fix deadlock in remount.
- fix submount shutdown race.
- fix amd external mount error handling.
+- fix amd external mount mount handling.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/parse_amd.c
+++ autofs-5.1.4/modules/parse_amd.c
@@ -1182,8 +1182,9 @@ static int do_generic_mount(struct autof
umount = 1;
}
/* If we have an external mount add it to the list */
- if (umount && !ext_mount_add(entry->fs, entry->umount)) {
- umount_amd_ext_mount(ap, entry->fs);
+ if (!ext_mount_add(entry->fs, entry->umount)) {
+ if (umount)
+ umount_amd_ext_mount(ap, entry->fs);
error(ap->logopt, MODPREFIX
"error: could not add external mount %s",
entry->fs);
@@ -1232,8 +1233,9 @@ static int do_nfs_mount(struct autofs_po
umount = 1;
}
/* We might be using an external mount */
- if (umount && !ext_mount_add(entry->fs, entry->umount)) {
- umount_amd_ext_mount(ap, entry->fs);
+ if (!ext_mount_add(entry->fs, entry->umount)) {
+ if (umount)
+ umount_amd_ext_mount(ap, entry->fs);
error(ap->logopt, MODPREFIX
"error: could not add external mount %s", entry->fs);
ret = 1;
@@ -1435,12 +1437,13 @@ static int do_program_mount(struct autof
* before executing the mount command and removing it at
* umount.
*/
- if (ext_mount_inuse(entry->fs)) {
+ if (is_mounted(entry->fs, MNTS_REAL)) {
+ if (!ext_mount_add(entry->fs, entry->umount)) {
+ error(ap->logopt, MODPREFIX
+ "error: could not add external mount %s", entry->fs);
+ goto out;
+ }
rv = 0;
- /* An external mount with path entry->fs exists
- * so ext_mount_add() won't fail.
- */
- ext_mount_add(entry->fs, entry->umount);
} else {
rv = mkdir_path(entry->fs, mp_mode);
if (rv && errno != EEXIST) {

View File

@ -1,66 +0,0 @@
autofs-5.1.9 - fix deadlock in master_notify_submount()
From: Ian Kent <raven@themaw.net>
A deadlock between mnts_remove_submount() and master_notify_submount()
can occur because master_notify_submount() holds the state mutex over
a call to mnts_find_submount() which then needs to take mnts_hash_mutex.
But mnts_remove_submount() takes mnts_hash_mutex and then needs to take
the state mutex to clear the ->ap field so deadlock cann occur.
But it isn't necessary for master_notify_submount() to take the state
mutex before calling mnts_find_submount() because if the submount is'
found a reference is taken on the entry so it won't go away while it's
being used. All that's needed is to ensure that the ->ap field doesn't
get set to NULL by mnts_remove_submount() while it's being used to check
if the submount has shutdown.
Fixes: 81ac572466e3 ("autofs-5.1.9 - fix submount shutdown race")
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/master.c | 7 +++----
2 files changed, 4 insertions(+), 4 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -161,6 +161,7 @@
- refactor amd function do_program_mount().
- refactor umount_amd_ext_mount().
- add flags argument to amd do_program_mount().
+- fix deadlock in master_notify_submount().
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/daemon/master.c
+++ autofs-5.1.4/daemon/master.c
@@ -1237,26 +1237,25 @@ int master_notify_submount(struct autofs
* ST_SHUTDOWN_FORCE we need to wait until it goes away
* or changes to state ST_SHUTDOWN or ST_READY.
*/
- st_mutex_lock();
while ((sbmnt = mnts_find_submount(path))) {
struct timespec t = { 0, 300000000 };
struct timespec r;
+ st_mutex_lock();
if (!sbmnt->ap ||
(sbmnt->ap->state != ST_SHUTDOWN_PENDING &&
sbmnt->ap->state != ST_SHUTDOWN_FORCE)) {
ret = 0;
+ st_mutex_unlock();
mnts_put_mount(sbmnt);
break;
}
+ st_mutex_unlock();
mnts_put_mount(sbmnt);
- st_mutex_unlock();
while (nanosleep(&t, &r) == -1 && errno == EINTR)
memcpy(&t, &r, sizeof(struct timespec));
- st_mutex_lock();
}
- st_mutex_unlock();
done:
mnts_put_mount(this);
}

View File

@ -1,66 +0,0 @@
autofs-5.1.9 - fix lock ordering deadlock in expire_cleanup()
From: Ian Kent <raven@themaw.net>
Commit 81ac572466e3 ("autofs-5.1.9 - fix submount shutdown race")
introduced a lock ordering deadlock between the state mutex and the
mounts hash list mutex when fixing a submount shutdown race. It's enough
to just move the conditional alarm set function call outside of the
state mutex critical section to fix it.
Fixes: 81ac572466e3 ("autofs-5.1.9 - fix submount shutdown race")
Signed-off-by: Ian Kent <raven@themaw.net>
---
daemon/state.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--- autofs-5.1.4.orig/daemon/state.c
+++ autofs-5.1.4/daemon/state.c
@@ -86,8 +86,9 @@ void expire_cleanup(void *arg)
pthread_t thid = pthread_self();
struct expire_args *ec;
struct autofs_point *ap;
- int success;
enum states next = ST_INVAL;
+ unsigned int need_alarm = 0;
+ int success;
ec = (struct expire_args *) arg;
ap = ec->ap;
@@ -123,7 +124,7 @@ void expire_cleanup(void *arg)
}
if (ap->state == ST_EXPIRE)
- conditional_alarm_add(ap, ap->exp_runfreq);
+ need_alarm = 1;
/* FALLTHROUGH */
@@ -140,7 +141,7 @@ void expire_cleanup(void *arg)
rv = ops->askumount(ap->logopt, ap->ioctlfd, &idle);
if (!rv && !idle && !ap->shutdown) {
next = ST_READY;
- conditional_alarm_add(ap, ap->exp_runfreq);
+ need_alarm = 1;
break;
}
@@ -153,7 +154,7 @@ void expire_cleanup(void *arg)
/* Failed shutdown returns to ready */
warn(ap->logopt, "filesystem %s still busy", ap->path);
- conditional_alarm_add(ap, ap->exp_runfreq);
+ need_alarm = 1;
next = ST_READY;
break;
#endif
@@ -180,6 +181,9 @@ void expire_cleanup(void *arg)
st_mutex_unlock();
+ if (need_alarm)
+ conditional_alarm_add(ap, ap->exp_runfreq);
+
return;
}

View File

@ -1,89 +0,0 @@
autofs-5.1.9 - fix submount shutdown race
From: Ian Kent <raven@themaw.net>
In function master_notify_submount() an expire notification is sent to
existing submounts. automount waits for the task to complete then, if
the submount is exiting, waits for the submount to reach a completion
state.
But the submount can go away during these checks resulting in the
autofs mount point structure field of the mount list structure to be
set to NULL which can then lead to a crash.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
daemon/master.c | 23 +++++++++++++----------
lib/mounts.c | 2 ++
3 files changed, 16 insertions(+), 10 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -154,6 +154,7 @@
- fix multi-mount check.
- fix get parent multi-mount check in try_remount().
- fix deadlock in remount.
+- fix submount shutdown race.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/daemon/master.c
+++ autofs-5.1.4/daemon/master.c
@@ -1213,22 +1213,24 @@ int master_notify_submount(struct autofs
this = mnts_find_submount(path);
if (this) {
+ struct autofs_point *found;
+
/* We have found a submount to expire */
st_mutex_lock();
-
- if (this->ap->state == ST_SHUTDOWN) {
+ found = this->ap;
+ if (!found || found->state == ST_SHUTDOWN) {
this = NULL;
st_mutex_unlock();
goto done;
}
-
- this->ap->shutdown = ap->shutdown;
-
- __st_add_task(this->ap, state);
-
+ found->shutdown = ap->shutdown;
+ __st_add_task(found, state);
st_mutex_unlock();
- st_wait_task(this->ap, state, 0);
+ /* This is ok because found isn't dereferenced during
+ * the wait checks.
+ */
+ st_wait_task(found, state, 0);
/*
* If our submount gets to state ST_SHUTDOWN_PENDING or
@@ -1240,8 +1242,9 @@ int master_notify_submount(struct autofs
struct timespec t = { 0, 300000000 };
struct timespec r;
- if (sbmnt->ap->state != ST_SHUTDOWN_PENDING &&
- sbmnt->ap->state != ST_SHUTDOWN_FORCE) {
+ if (!sbmnt->ap ||
+ (sbmnt->ap->state != ST_SHUTDOWN_PENDING &&
+ sbmnt->ap->state != ST_SHUTDOWN_FORCE)) {
ret = 0;
mnts_put_mount(sbmnt);
break;
--- autofs-5.1.4.orig/lib/mounts.c
+++ autofs-5.1.4/lib/mounts.c
@@ -1153,7 +1153,9 @@ void mnts_remove_submount(const char *mp
this = mnts_lookup(mp);
if (this && this->flags & MNTS_AUTOFS) {
this->flags &= ~MNTS_AUTOFS;
+ st_mutex_lock();
this->ap = NULL;
+ st_mutex_unlock();
list_del_init(&this->submount);
__mnts_put_mount(this);
}

View File

@ -1,49 +0,0 @@
autofs-5.1.9 - handle sss special case getautomntbyname() error
From: Ian Kent <raven@themaw.net>
The sss key lookup (via getautomntbyname()) returns EHOSTDOWN when the
entry is invalid, such as when the location is empty. But setatomntent()
has already been called successfully so we know the host is up and the
map exists hence this probably should be EINVAL.
In both these cases the better return is NSS_STATUS_UNAVAIL.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1 +
modules/lookup_sss.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -166,6 +166,7 @@
- always recreate credential cache.
- fix always recreate credential cache.
- fix missing unlock in sasl_do_kinit_ext_cc().
+- handle sss special case getautomntbyname() error.
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/lookup_sss.c
+++ autofs-5.1.4/modules/lookup_sss.c
@@ -658,8 +658,8 @@ static int getautomntbyname(unsigned int
err = NSS_STATUS_NOTFOUND;
goto free;
}
- if (ret != EHOSTDOWN)
- goto error;
+ if (ret == EINVAL || ret == EHOSTDOWN)
+ goto free;
}
ret = getautomntbyname_wait(logopt, ctxt,
@@ -670,7 +670,7 @@ static int getautomntbyname(unsigned int
if (ret == ETIMEDOUT)
goto error;
/* sss proto version 0 and sss timeout not set */
- if (ret == EINVAL)
+ if (ret == EINVAL || ret == EHOSTDOWN)
goto free;
if (ret == ENOENT) {
err = NSS_STATUS_NOTFOUND;

View File

@ -1,138 +0,0 @@
autofs-5.1.9 - refactor amd function do_program_mount()
From: Ian Kent <raven@themaw.net>
The amd mounts function do_program_mount() is particularly untidy.
Refactor it to make it a little simpler and to take advantage of the
coming refactoring of the funtion umount_amd_ext_mount().
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1
modules/parse_amd.c | 74 ++++++++++++++++++++++++----------------------------
2 files changed, 36 insertions(+), 39 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -158,6 +158,7 @@
- fix amd external mount error handling.
- fix amd external mount mount handling.
- don't free ext mount if mounted.
+- refactor amd function do_program_mount().
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/modules/parse_amd.c
+++ autofs-5.1.4/modules/parse_amd.c
@@ -1407,26 +1407,8 @@ out:
static int do_program_mount(struct autofs_point *ap,
struct amd_entry *entry, const char *name)
{
- char *prog, *str;
- char **argv;
- int argc = -1;
int rv = 1;
- str = strdup(entry->mount);
- if (!str)
- goto out;
-
- prog = NULL;
- argv = NULL;
-
- argc = construct_argv(str, &prog, &argv);
- if (argc == -1) {
- error(ap->logopt, MODPREFIX
- "%s: error creating mount arguments", entry->type);
- free(str);
- goto out;
- }
-
/* The am-utils documentation doesn't actually say that the
* mount (and umount, if given) command need to use ${fs} as
* the mount point in the command.
@@ -1445,6 +1427,25 @@ static int do_program_mount(struct autof
}
rv = 0;
} else {
+ char *prog, *str;
+ char **argv;
+ int argc = -1;
+
+ str = strdup(entry->mount);
+ if (!str)
+ goto out;
+
+ prog = NULL;
+ argv = NULL;
+
+ argc = construct_argv(str, &prog, &argv);
+ if (argc == -1) {
+ error(ap->logopt, MODPREFIX
+ "%s: error creating mount arguments", entry->type);
+ free(str);
+ goto out;
+ }
+
rv = mkdir_path(entry->fs, mp_mode);
if (rv && errno != EEXIST) {
char buf[MAX_ERR_BUF];
@@ -1454,7 +1455,9 @@ static int do_program_mount(struct autof
error(ap->logopt,
MODPREFIX "%s: mkdir_path %s failed: %s",
entry->type, entry->fs, estr);
- goto do_free;
+ free_argv(argc, (const char **) argv);
+ free(str);
+ goto out;
}
rv = spawnv(ap->logopt, prog, (const char * const *) argv);
@@ -1463,33 +1466,26 @@ static int do_program_mount(struct autof
rv = 0;
debug(ap->logopt, MODPREFIX
"%s: mounted %s", entry->type, entry->fs);
- goto do_free;
+ free_argv(argc, (const char **) argv);
+ free(str);
+ goto done;
}
umount_amd_ext_mount(ap, entry->fs);
}
-
- if (!ext_mount_inuse(entry->fs))
- rmdir_path(ap, entry->fs, ap->dev);
error(ap->logopt, MODPREFIX
"%s: failed to mount using %s", entry->type, entry->mount);
- }
-do_free:
- free_argv(argc, (const char **) argv);
- free(str);
-
- if (rv)
+ free_argv(argc, (const char **) argv);
+ free(str);
goto out;
-
+ }
+done:
rv = do_link_mount(ap, name, entry, 0);
- if (!rv)
- goto out;
-
- if (umount_amd_ext_mount(ap, entry->fs)) {
- if (!ext_mount_inuse(entry->fs))
- rmdir_path(ap, entry->fs, ap->dev);
- debug(ap->logopt, MODPREFIX
- "%s: failed to umount external mount at %s",
- entry->type, entry->fs);
+ if (rv) {
+ if (umount_amd_ext_mount(ap, entry->fs)) {
+ debug(ap->logopt, MODPREFIX
+ "%s: failed to cleanup external mount at %s",
+ entry->type, entry->fs);
+ }
}
out:
return rv;

View File

@ -1,242 +0,0 @@
autofs-5.1.9 - refactor amd function umount_amd_ext_mount()
From: Ian Kent <raven@themaw.net>
The amd mounts function umount_amd_ext_mount() needs some improvement.
Make sure the function returns true for success and false for failure
and add a parameter to control if the expternal mount reference should
be decremented on successful umount.
If the reference count of the external mount is greater than 1 there's
some other mount using (symlink pointing to) it so don't try to umount
it just return success.
Also check for the case where the mount is already mounted.
Signed-off-by: Ian Kent <raven@themaw.net>
---
CHANGELOG | 1
daemon/automount.c | 4 +-
include/mounts.h | 2 -
lib/mounts.c | 80 ++++++++++++++++++++++++++++++----------------------
modules/parse_amd.c | 10 +++---
5 files changed, 56 insertions(+), 41 deletions(-)
--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -159,6 +159,7 @@
- fix amd external mount mount handling.
- don't free ext mount if mounted.
- refactor amd function do_program_mount().
+- refactor umount_amd_ext_mount().
xx/xx/2018 autofs-5.1.5
- fix flag file permission.
--- autofs-5.1.4.orig/daemon/automount.c
+++ autofs-5.1.4/daemon/automount.c
@@ -619,7 +619,7 @@ static int umount_subtree_mounts(struct
/* Check for an external mount and umount if possible */
mnt = mnts_find_amdmount(path);
if (mnt) {
- umount_amd_ext_mount(ap, mnt->ext_mp);
+ umount_amd_ext_mount(ap, mnt->ext_mp, 1);
mnts_remove_amdmount(path);
mnts_put_mount(mnt);
}
@@ -684,7 +684,7 @@ int umount_multi(struct autofs_point *ap
/* Check for an external mount and attempt umount if needed */
mnt = mnts_find_amdmount(path);
if (mnt) {
- umount_amd_ext_mount(ap, mnt->ext_mp);
+ umount_amd_ext_mount(ap, mnt->ext_mp, 1);
mnts_remove_amdmount(path);
mnts_put_mount(mnt);
}
--- autofs-5.1.4.orig/include/mounts.h
+++ autofs-5.1.4/include/mounts.h
@@ -199,7 +199,7 @@ int try_remount(struct autofs_point *, s
void set_indirect_mount_tree_catatonic(struct autofs_point *);
void set_direct_mount_tree_catatonic(struct autofs_point *, struct mapent *);
int umount_ent(struct autofs_point *, const char *);
-int umount_amd_ext_mount(struct autofs_point *, const char *);
+int umount_amd_ext_mount(struct autofs_point *, const char *, int remove);
int clean_stale_multi_triggers(struct autofs_point *, struct mapent *, char *, const char *);
#endif
--- autofs-5.1.4.orig/lib/mounts.c
+++ autofs-5.1.4/lib/mounts.c
@@ -3097,37 +3097,62 @@ int umount_ent(struct autofs_point *ap,
return mounted;
}
-int umount_amd_ext_mount(struct autofs_point *ap, const char *path)
+int umount_amd_ext_mount(struct autofs_point *ap, const char *path, int remove)
{
struct ext_mount *em;
char *umount = NULL;
- char *mp;
+ char *mp = NULL;
int rv = 1;
+ int ret;
pthread_mutex_lock(&ext_mount_hash_mutex);
-
em = ext_mount_lookup(path);
if (!em) {
pthread_mutex_unlock(&ext_mount_hash_mutex);
+ rv = 0;
goto out;
}
mp = strdup(em->mp);
if (!mp) {
pthread_mutex_unlock(&ext_mount_hash_mutex);
+ rv = 0;
goto out;
}
if (em->umount) {
umount = strdup(em->umount);
if (!umount) {
pthread_mutex_unlock(&ext_mount_hash_mutex);
- free(mp);
+ rv = 0;
goto out;
}
}
-
+ /* Don't try and umount if there's more than one
+ * user of the external mount.
+ */
+ if (em->ref > 1) {
+ pthread_mutex_unlock(&ext_mount_hash_mutex);
+ if (!remove)
+ error(ap->logopt,
+ "reference count mismatch, called with remove false");
+ else
+ ext_mount_remove(mp);
+ goto out;
+ }
+ /* This shouldn't happen ... */
+ if (!is_mounted(mp, MNTS_REAL)) {
+ pthread_mutex_unlock(&ext_mount_hash_mutex);
+ error(ap->logopt, "failed to umount program mount at %s", mp);
+ if (remove)
+ ext_mount_remove(mp);
+ goto out;
+ }
pthread_mutex_unlock(&ext_mount_hash_mutex);
- if (umount) {
+ if (!umount) {
+ ret = umount_ent(ap, mp);
+ if (ret)
+ rv = 0;
+ } else {
char *prog;
char **argv;
int argc = -1;
@@ -3136,41 +3161,30 @@ int umount_amd_ext_mount(struct autofs_p
argv = NULL;
argc = construct_argv(umount, &prog, &argv);
- if (argc == -1)
- goto done;
-
- if (!ext_mount_remove(mp)) {
- rv =0;
- goto out_free;
- }
-
- rv = spawnv(ap->logopt, prog, (const char * const *) argv);
- if (rv == -1 || (WIFEXITED(rv) && WEXITSTATUS(rv)))
+ if (argc == -1) {
error(ap->logopt,
- "failed to umount program mount at %s", mp);
- else {
+ "failed to allocate args for umount of %s", mp);
rv = 0;
- debug(ap->logopt, "umounted program mount at %s", mp);
- rmdir_path(ap, mp, ap->dev);
+ goto out;
}
-out_free:
+ ret = spawnv(ap->logopt, prog, (const char * const *) argv);
+ rv = WIFEXITED(ret) && !WEXITSTATUS(ret);
free_argv(argc, (const char **) argv);
-
- goto done;
}
- if (ext_mount_remove(mp)) {
- rv = umount_ent(ap, mp);
- if (rv)
- error(ap->logopt,
- "failed to umount external mount %s", mp);
- else
- debug(ap->logopt, "umounted external mount %s", mp);
+ if (is_mounted(mp, MNTS_REAL))
+ error(ap->logopt,
+ "failed to umount external mount %s", mp);
+ else {
+ info(ap->logopt, "umounted external mount %s", mp);
+ rmdir_path(ap, mp, ap->dev);
}
-done:
+ if (remove)
+ ext_mount_remove(mp);
+out:
if (umount)
free(umount);
- free(mp);
-out:
+ if (mp)
+ free(mp);
return rv;
}
--- autofs-5.1.4.orig/modules/parse_amd.c
+++ autofs-5.1.4/modules/parse_amd.c
@@ -1133,7 +1133,7 @@ symlink:
if (entry->sublink) {
/* failed to complete sublink mount */
- umount_amd_ext_mount(ap, entry->fs);
+ umount_amd_ext_mount(ap, entry->fs, 1);
}
out:
return ret;
@@ -1184,7 +1184,7 @@ static int do_generic_mount(struct autof
/* If we have an external mount add it to the list */
if (!ext_mount_add(entry->fs, entry->umount)) {
if (umount)
- umount_amd_ext_mount(ap, entry->fs);
+ umount_amd_ext_mount(ap, entry->fs, 0);
error(ap->logopt, MODPREFIX
"error: could not add external mount %s",
entry->fs);
@@ -1235,7 +1235,7 @@ static int do_nfs_mount(struct autofs_po
/* We might be using an external mount */
if (!ext_mount_add(entry->fs, entry->umount)) {
if (umount)
- umount_amd_ext_mount(ap, entry->fs);
+ umount_amd_ext_mount(ap, entry->fs, 0);
error(ap->logopt, MODPREFIX
"error: could not add external mount %s", entry->fs);
ret = 1;
@@ -1470,7 +1470,7 @@ static int do_program_mount(struct autof
free(str);
goto done;
}
- umount_amd_ext_mount(ap, entry->fs);
+ umount_amd_ext_mount(ap, entry->fs, 0);
}
error(ap->logopt, MODPREFIX
"%s: failed to mount using %s", entry->type, entry->mount);
@@ -1481,7 +1481,7 @@ static int do_program_mount(struct autof
done:
rv = do_link_mount(ap, name, entry, 0);
if (rv) {
- if (umount_amd_ext_mount(ap, entry->fs)) {
+ if (!umount_amd_ext_mount(ap, entry->fs, 1)) {
debug(ap->logopt, MODPREFIX
"%s: failed to cleanup external mount at %s",
entry->type, entry->fs);

View File

@ -8,7 +8,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.1.4
Release: 114%{?dist}.6
Release: 113%{?dist}
Epoch: 1
License: GPLv2+
Group: System Environment/Daemons
@ -332,30 +332,6 @@ Patch328: autofs-5.1.8-fix-multi-mount-check.patch
Patch329: autofs-5.1.9-fix-get-parent-multi-mount-check-in-try_remount.patch
Patch330: autofs-5.1.9-fix-deadlock-in-remount.patch
Patch331: autofs-5.1.9-fix-submount-shutdown-race.patch
Patch332: autofs-5.1.9-fix-amd-external-mount-error-handling.patch
Patch333: autofs-5.1.9-fix-amd-external-mount-mount-handling.patch
Patch334: autofs-5.1.9-dont-free-ext-mount-if-mounted.patch
Patch335: autofs-5.1.9-refactor-amd-function-do_program_mount.patch
Patch336: autofs-5.1.9-refactor-amd-function-umount_amd_ext_mount.patch
Patch337: autofs-5.1.9-add-flags-argument-to-amd-do_program_mount.patch
Patch338: autofs-5.1.9-fix-deadlock-in-master_notify_submount.patch
Patch339: autofs-5.1.9-fix-lock-ordering-deadlock-in-expire_cleanup.patch
# JIRA: RHEL-90238
Patch340: autofs-5.1.6-fix-ldap-sasl-reconnect-problem.patch
Patch341: autofs-5.1.8-always-recreate-credential-cache.patch
Patch342: autofs-5.1.9-fix-always-recreate-credential-cache.patch
# JIRA: RHEL-111930
Patch343: autofs-5.1.8-fix-missing-unlock-in-sasl_do_kinit_ext_cc.patch
# JIRA: RHEL-127179
Patch344: autofs-5.1.9-handle-sss-special-case-getautomntbyname-error.patch
%if %{with_systemd}
BuildRequires: systemd-units
BuildRequires: systemd-devel
@ -415,339 +391,318 @@ echo %{version}-%{release} > .version
%define unitdir %{?_unitdir:/usr/lib/systemd/system}
%define systemd_configure_arg --with-systemd
%endif
%patch -P 1 -p1
%patch -P 2 -p1
%patch -P 3 -p1
%patch -P 4 -p1
%patch -P 5 -p1
%patch -P 6 -p1
%patch -P 7 -p1
%patch -P 8 -p1
%patch -P 9 -p1
%patch -P 10 -p1
%patch -P 11 -p1
%patch -P 12 -p1
%patch -P 13 -p1
%patch -P 14 -p1
%patch -P 15 -p1
%patch -P 16 -p1
%patch -P 17 -p1
%patch -P 18 -p1
%patch -P 19 -p1
%patch -P 20 -p1
%patch -P 21 -p1
%patch -P 22 -p1
%patch -P 23 -p1
%patch -P 24 -p1
%patch -P 25 -p1
%patch -P 26 -p1
%patch -P 27 -p1
%patch -P 28 -p1
%patch -P 29 -p1
%patch -P 30 -p1
%patch -P 31 -p1
%patch -P 32 -p1
%patch -P 33 -p1
%patch -P 34 -p1
%patch -P 35 -p1
%patch -P 36 -p1
%patch -P 37 -p1
%patch -P 38 -p1
%patch -P 39 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch35 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch -P 40 -p1
%patch -P 41 -p1
%patch -P 42 -p1
%patch -P 43 -p1
%patch -P 44 -p1
%patch -P 45 -p1
%patch -P 46 -p1
%patch -P 47 -p1
%patch -P 48 -p1
%patch -P 49 -p1
%patch -P 50 -p1
%patch -P 51 -p1
%patch -P 52 -p1
%patch -P 53 -p1
%patch -P 54 -p1
%patch40 -p1
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%patch51 -p1
%patch52 -p1
%patch53 -p1
%patch54 -p1
%patch -P 60 -p1
%patch -P 61 -p1
%patch -P 62 -p1
%patch -P 63 -p1
%patch -P 64 -p1
%patch -P 65 -p1
%patch -P 66 -p1
%patch -P 67 -p1
%patch -P 68 -p1
%patch -P 69 -p1
%patch -P 70 -p1
%patch -P 71 -p1
%patch -P 72 -p1
%patch -P 73 -p1
%patch -P 74 -p1
%patch -P 75 -p1
%patch -P 76 -p1
%patch -P 77 -p1
%patch -P 78 -p1
%patch -P 79 -p1
%patch -P 80 -p1
%patch -P 81 -p1
%patch -P 82 -p1
%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%patch72 -p1
%patch73 -p1
%patch74 -p1
%patch75 -p1
%patch76 -p1
%patch77 -p1
%patch78 -p1
%patch79 -p1
%patch80 -p1
%patch81 -p1
%patch82 -p1
%patch -P 83 -p1
%patch -P 84 -p1
%patch83 -p1
%patch84 -p1
%patch -P 85 -p1
%patch -P 86 -p1
%patch -P 87 -p1
%patch -P 88 -p1
%patch85 -p1
%patch86 -p1
%patch87 -p1
%patch88 -p1
%patch -P 89 -p1
%patch -P 90 -p1
%patch89 -p1
%patch90 -p1
%patch -P 91 -p1
%patch -P 92 -p1
%patch -P 93 -p1
%patch -P 94 -p1
%patch -P 95 -p1
%patch -P 96 -p1
%patch -P 97 -p1
%patch -P 98 -p1
%patch91 -p1
%patch92 -p1
%patch93 -p1
%patch94 -p1
%patch95 -p1
%patch96 -p1
%patch97 -p1
%patch98 -p1
%patch -P 100 -p1
%patch -P 101 -p1
%patch -P 102 -p1
%patch -P 103 -p1
%patch -P 104 -p1
%patch -P 105 -p1
%patch -P 106 -p1
%patch -P 107 -p1
%patch -P 108 -p1
%patch -P 109 -p1
%patch -P 110 -p1
%patch -P 111 -p1
%patch -P 112 -p1
%patch -P 113 -p1
%patch -P 114 -p1
%patch -P 115 -p1
%patch -P 116 -p1
%patch -P 117 -p1
%patch -P 118 -p1
%patch -P 119 -p1
%patch100 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch107 -p1
%patch108 -p1
%patch109 -p1
%patch110 -p1
%patch111 -p1
%patch112 -p1
%patch113 -p1
%patch114 -p1
%patch115 -p1
%patch116 -p1
%patch117 -p1
%patch118 -p1
%patch119 -p1
%patch -P 120 -p1
%patch -P 121 -p1
%patch -P 122 -p1
%patch -P 123 -p1
%patch -P 124 -p1
%patch -P 125 -p1
%patch -P 126 -p1
%patch -P 127 -p1
%patch -P 128 -p1
%patch -P 129 -p1
%patch -P 130 -p1
%patch -P 131 -p1
%patch -P 132 -p1
%patch -P 133 -p1
%patch -P 134 -p1
%patch -P 135 -p1
%patch -P 136 -p1
%patch -P 137 -p1
%patch -P 138 -p1
%patch -P 139 -p1
%patch -P 140 -p1
%patch -P 141 -p1
%patch -P 142 -p1
%patch -P 143 -p1
%patch -P 144 -p1
%patch -P 145 -p1
%patch -P 146 -p1
%patch -P 147 -p1
%patch -P 148 -p1
%patch -P 149 -p1
%patch -P 150 -p1
%patch -P 151 -p1
%patch -P 152 -p1
%patch -P 153 -p1
%patch -P 154 -p1
%patch -P 155 -p1
%patch -P 156 -p1
%patch -P 157 -p1
%patch -P 158 -p1
%patch -P 159 -p1
%patch -P 160 -p1
%patch -P 161 -p1
%patch -P 162 -p1
%patch -P 163 -p1
%patch -P 164 -p1
%patch -P 165 -p1
%patch -P 166 -p1
%patch -P 167 -p1
%patch -P 168 -p1
%patch -P 169 -p1
%patch -P 170 -p1
%patch -P 171 -p1
%patch -P 172 -p1
%patch -P 173 -p1
%patch -P 174 -p1
%patch -P 175 -p1
%patch -P 176 -p1
%patch -P 177 -p1
%patch -P 178 -p1
%patch -P 179 -p1
%patch -P 180 -p1
%patch -P 181 -p1
%patch -P 182 -p1
%patch -P 183 -p1
%patch -P 184 -p1
%patch -P 185 -p1
%patch -P 186 -p1
%patch -P 187 -p1
%patch -P 188 -p1
%patch -P 189 -p1
%patch -P 190 -p1
%patch -P 191 -p1
%patch -P 192 -p1
%patch -P 193 -p1
%patch -P 194 -p1
%patch -P 195 -p1
%patch -P 196 -p1
%patch -P 197 -p1
%patch -P 198 -p1
%patch -P 199 -p1
%patch -P 200 -p1
%patch -P 201 -p1
%patch -P 202 -p1
%patch -P 203 -p1
%patch -P 204 -p1
%patch -P 205 -p1
%patch -P 206 -p1
%patch -P 207 -p1
%patch -P 208 -p1
%patch -P 209 -p1
%patch -P 210 -p1
%patch -P 211 -p1
%patch120 -p1
%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1
%patch125 -p1
%patch126 -p1
%patch127 -p1
%patch128 -p1
%patch129 -p1
%patch130 -p1
%patch131 -p1
%patch132 -p1
%patch133 -p1
%patch134 -p1
%patch135 -p1
%patch136 -p1
%patch137 -p1
%patch138 -p1
%patch139 -p1
%patch140 -p1
%patch141 -p1
%patch142 -p1
%patch143 -p1
%patch144 -p1
%patch145 -p1
%patch146 -p1
%patch147 -p1
%patch148 -p1
%patch149 -p1
%patch150 -p1
%patch151 -p1
%patch152 -p1
%patch153 -p1
%patch154 -p1
%patch155 -p1
%patch156 -p1
%patch157 -p1
%patch158 -p1
%patch159 -p1
%patch160 -p1
%patch161 -p1
%patch162 -p1
%patch163 -p1
%patch164 -p1
%patch165 -p1
%patch166 -p1
%patch167 -p1
%patch168 -p1
%patch169 -p1
%patch170 -p1
%patch171 -p1
%patch172 -p1
%patch173 -p1
%patch174 -p1
%patch175 -p1
%patch176 -p1
%patch177 -p1
%patch178 -p1
%patch179 -p1
%patch180 -p1
%patch181 -p1
%patch182 -p1
%patch183 -p1
%patch184 -p1
%patch185 -p1
%patch186 -p1
%patch187 -p1
%patch188 -p1
%patch189 -p1
%patch190 -p1
%patch191 -p1
%patch192 -p1
%patch193 -p1
%patch194 -p1
%patch195 -p1
%patch196 -p1
%patch197 -p1
%patch198 -p1
%patch199 -p1
%patch200 -p1
%patch201 -p1
%patch202 -p1
%patch203 -p1
%patch204 -p1
%patch205 -p1
%patch206 -p1
%patch207 -p1
%patch208 -p1
%patch209 -p1
%patch210 -p1
%patch211 -p1
%patch -P 212 -p1
%patch -P 213 -p1
%patch -P 214 -p1
%patch -P 215 -p1
%patch -P 216 -p1
%patch -P 217 -p1
%patch -P 218 -p1
%patch212 -p1
%patch213 -p1
%patch214 -p1
%patch215 -p1
%patch216 -p1
%patch217 -p1
%patch218 -p1
%patch -P 219 -p1
%patch -P 220 -p1
%patch -P 221 -p1
%patch219 -p1
%patch220 -p1
%patch221 -p1
%patch -P 222 -p1
%patch -P 223 -p1
%patch222 -p1
%patch223 -p1
%patch -P 224 -p1
%patch -P 225 -p1
%patch -P 226 -p1
%patch -P 227 -p1
%patch -P 228 -p1
%patch224 -p1
%patch225 -p1
%patch226 -p1
%patch227 -p1
%patch228 -p1
%patch -P 229 -p1
%patch -P 230 -p1
%patch -P 231 -p1
%patch -P 232 -p1
%patch -P 233 -p1
%patch -P 234 -p1
%patch -P 235 -p1
%patch -P 236 -p1
%patch -P 237 -p1
%patch -P 238 -p1
%patch -P 239 -p1
%patch -P 240 -p1
%patch -P 241 -p1
%patch -P 242 -p1
%patch -P 243 -p1
%patch -P 244 -p1
%patch -P 245 -p1
%patch -P 246 -p1
%patch -P 247 -p1
%patch -P 248 -p1
%patch -P 249 -p1
%patch -P 250 -p1
%patch -P 251 -p1
%patch -P 252 -p1
%patch -P 253 -p1
%patch -P 254 -p1
%patch229 -p1
%patch230 -p1
%patch231 -p1
%patch232 -p1
%patch233 -p1
%patch234 -p1
%patch235 -p1
%patch236 -p1
%patch237 -p1
%patch238 -p1
%patch239 -p1
%patch240 -p1
%patch241 -p1
%patch242 -p1
%patch243 -p1
%patch244 -p1
%patch245 -p1
%patch246 -p1
%patch247 -p1
%patch248 -p1
%patch249 -p1
%patch250 -p1
%patch251 -p1
%patch252 -p1
%patch253 -p1
%patch254 -p1
%patch -P 260 -p1
%patch -P 261 -p1
%patch -P 262 -p1
%patch -P 263 -p1
%patch -P 264 -p1
%patch -P 265 -p1
%patch -P 266 -p1
%patch -P 267 -p1
%patch -P 268 -p1
%patch -P 269 -p1
%patch -P 270 -p1
%patch -P 271 -p1
%patch -P 272 -p1
%patch -P 273 -p1
%patch -P 274 -p1
%patch -P 275 -p1
%patch260 -p1
%patch261 -p1
%patch262 -p1
%patch263 -p1
%patch264 -p1
%patch265 -p1
%patch266 -p1
%patch267 -p1
%patch268 -p1
%patch269 -p1
%patch270 -p1
%patch271 -p1
%patch272 -p1
%patch273 -p1
%patch274 -p1
%patch275 -p1
%patch -P 300 -p1
%patch -P 301 -p1
%patch -P 302 -p1
%patch -P 303 -p1
%patch -P 304 -p1
%patch -P 305 -p1
%patch -P 306 -p1
%patch -P 307 -p1
%patch -P 308 -p1
%patch -P 309 -p1
%patch -P 310 -p1
%patch -P 311 -p1
%patch -P 312 -p1
%patch -P 313 -p1
%patch -P 314 -p1
%patch -P 315 -p1
%patch -P 316 -p1
%patch -P 317 -p1
%patch -P 318 -p1
%patch -P 319 -p1
%patch -P 320 -p1
%patch -P 321 -p1
%patch -P 322 -p1
%patch -P 323 -p1
%patch -P 324 -p1
%patch -P 325 -p1
%patch -P 326 -p1
%patch300 -p1
%patch301 -p1
%patch302 -p1
%patch303 -p1
%patch304 -p1
%patch305 -p1
%patch306 -p1
%patch307 -p1
%patch308 -p1
%patch309 -p1
%patch310 -p1
%patch311 -p1
%patch312 -p1
%patch313 -p1
%patch314 -p1
%patch315 -p1
%patch316 -p1
%patch317 -p1
%patch318 -p1
%patch319 -p1
%patch320 -p1
%patch321 -p1
%patch322 -p1
%patch323 -p1
%patch324 -p1
%patch325 -p1
%patch326 -p1
%patch -P 327 -p1
%patch -P 328 -p1
%patch327 -p1
%patch328 -p1
%patch -P 329 -p1
%patch -P 330 -p1
%patch -P 331 -p1
%patch -P 332 -p1
%patch -P 333 -p1
%patch -P 334 -p1
%patch -P 335 -p1
%patch -P 336 -p1
%patch -P 337 -p1
%patch -P 338 -p1
%patch -P 339 -p1
%patch -P 340 -p1
%patch -P 341 -p1
%patch -P 342 -p1
%patch -P 343 -p1
%patch -P 344 -p1
%patch329 -p1
%patch330 -p1
%build
LDFLAGS=-Wl,-z,now
@ -843,48 +798,6 @@ fi
%dir /etc/auto.master.d
%changelog
* Tue Nov 25 2025 Ian Kent <ikent@redhat.com> - 5.1.4-114.el8_10.6
- RHEL-127179 - sssd autofs fails to get correct EHOSTDOWN if requested
incorrect mount after upgrade to sssd-2.9.1-4.el8_9.5.x86_64
[rhel-8.10.z]
- handle sss special case getautomntbyname() error.
- Resolves: RHEL-127179
* Mon Sep 01 2025 Ian Kent <ikent@redhat.com> - 5.1.4-114.el8_10.5
- RHEL-111930 - automount blocked when attempting to lookup ldap maps
- fix missing unlock in sasl_do_kinit_ext_cc().
- Resolves: RHEL-111930
* Mon Jun 09 2025 Ian Kent <ikent@redhat.com> - 5.1.4-114.el8_10.4
- RHEL-90238 - autofs fails to mount shares when using kerberised LDAP (RHEL 8)
- fix ldap sasl reconnect problem.
- always recreate credential cache.
- fix always recreate credential cache.
- Resolves: RHEL-90238
* Mon Apr 07 2025 Ian Kent <ikent@redhat.com> - 5.1.4-114.el8_10.3
- RHEL-84118 - autofs hang - autofs-5.1.4-114.el8_10.2
- fix lock ordering deadlock in expire_cleanup().
- change spec file %patchN to %patch -P N as required by rpm(8).
- Resolves: RHEL-84118
* Wed Jan 15 2025 Ian Kent <ikent@redhat.com> - 5.1.4-114.el8_10.2
- RHEL-72524 - autofs: deadlock between mnts_lookup_mount and mnts_remove_mount
- fix deadlock in master_notify_submount().
-Resolves: RHEL-72524
* Fri Nov 08 2024 Ian Kent <ikent@redhat.com> - 5.1.4-114
- RHEL-61670 - sporadic autofs daemon segfaults
- fix submount shutdown race.
- RHEL-52402 - Sporadic mount failures with amd program maps on RHEL8
- fix amd external mount error handling.
- fix amd external mount mount handling.
- don't free ext mount if mounted.
- refactor amd function do_program_mount().
- refactor umount_amd_ext_mount().
- add flags argument to amd do_program_mount().
- Resolves: RHEL-61670 RHEL-52402
* Mon Dec 18 2023 Ian Kent <ikent@redhat.com> - 5.1.4-113
- RHEL-18035 - SIGSEGV using hierarchical map entries on reload with
autofs-5.1.4-109