autofs-5.0.3 - fix fd leak at multi-mount fail Fix file handle being left open following a multi-mount non-fatal mount fail. diff --git a/CHANGELOG b/CHANGELOG index 671d336..8609efb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -36,6 +36,7 @@ - check for mtab pointing to /proc/mounts. - dynamically allocate interface config buffer. - update kernel patches. +- fix fd leak at multi-mount non-fatal mount fail. 14/01/2008 autofs-5.0.3 ----------------------- diff --git a/daemon/direct.c b/daemon/direct.c index 13f572c..b94601a 100644 --- a/daemon/direct.c +++ b/daemon/direct.c @@ -1303,12 +1303,20 @@ static void *do_mount_direct(void *arg) pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state); if (status) { struct mapent *me; + struct statfs fs; + unsigned int close_fd = 0; + + if (statfs(mt.name, &fs) == -1 || + (fs.f_type == AUTOFS_SUPER_MAGIC && + !master_find_submount(ap, mt.name))) + close_fd = 1; cache_writelock(mt.mc); - me = cache_lookup_distinct(mt.mc, mt.name); - if (me) + if (!close_fd && (me = cache_lookup_distinct(mt.mc, mt.name))) me->ioctlfd = mt.ioctlfd; send_ready(ap->logopt, mt.ioctlfd, mt.wait_queue_token); cache_unlock(mt.mc); + if (close_fd) + close(mt.ioctlfd); info(ap->logopt, "mounted %s", mt.name); } else { send_fail(ap->logopt, mt.ioctlfd, mt.wait_queue_token);