After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 333186 - esd should close file descriptors it doesn't need
esd should close file descriptors it doesn't need
Status: RESOLVED FIXED
Product: esound
Classification: Deprecated
Component: general
0.2.x
Other Linux
: Normal normal
: ---
Assigned To: Esound Maintainers
Esound Maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-02 20:55 UTC by Dan Winship
Modified: 2006-08-07 23:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Winship 2006-03-02 20:55:32 UTC
It's good behavior in a daemon to close all open file descriptors, in case
the parent didn't intend to hand some of them over.

In particular, https://bugzilla.novell.com/show_bug.cgi?id=154072 shows a
problem when esd gets started by gnomesu; clicking "Cancel" won't work,
because it closes a pipe and waits for the backend process to notice that
and exit, but the backend process doesn't see the pipe get closed, because
gnomesu's end of the pipe accidentally got handed off to esd, so it remains
open even though gnomesu closed its copy of it.

--- esd.c
+++ esd.c
@@ -816,6 +816,12 @@
        }
     }

+    /* close any file descriptors that shouldn't be open */
+    for (i = getdtablesize () - 1; i > STDERR_FILENO; i--) {
+       if (i != esd_spawnfd)
+           close (i);
+    }
+
     /* open the listening socket */
   listen_socket = open_listen_socket(hostname, esd_port );
   if ( listen_socket < 0 ) {
Comment 1 David Schleef 2006-08-07 23:20:42 UTC
Yup, this needs to be fixed.  I fixed it slightly differently, though.