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 746339 - GSocket kills process when fd is not a socket
GSocket kills process when fd is not a socket
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-03-17 12:05 UTC by Stef Walter
Modified: 2015-07-02 10:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gsocket: Don't g_error() if file-descriptor is not a socket (1.37 KB, patch)
2015-03-17 12:06 UTC, Stef Walter
accepted-commit_after_freeze Details | Review
gsocket: Don't g_error() if file-descriptor is not a socket (1.82 KB, patch)
2015-07-02 10:24 UTC, Stef Walter
none Details | Review

Description Stef Walter 2015-03-17 12:05:54 UTC
The gsocket.c code, particularly g_socket_details_from_fd() kills the current process if the given fd is not a valid socket.

This code seems out of date with current coding practices.

Nowadays it's common to receive file descriptors over environment variables from other processes like systemd. The unit files that control these file descriptors are configurable by sysadmins.

It is not (necessarily) a programmer error when g_socket_details_from_fd() is called with a file descriptor that is not a socket. It can also be a system and/or configuration error.

We saw this in cockpit-ws.
Comment 1 Stef Walter 2015-03-17 12:06:57 UTC
Created attachment 299581 [details] [review]
gsocket: Don't g_error() if file-descriptor is not a socket

This code was out of date with current coding practices.

Nowadays it's common to receive file descriptors over environment
variables from other processes like systemd. The unit files that
control these file descriptors are configurable by sysadmins.

It is not (necessarily) a programmer error when g_socket_details_from_fd()
is called with a file descriptor that is not a socket. It can also
be a system and/or configuration error.
Comment 3 Colin Walters 2015-03-17 16:07:11 UTC
Review of attachment 299581 [details] [review]:

Seems reasonable to me, but I would also update the documentation text with something like:

"Since GLib 2.46, it is no longer a fatal error to call this on a non-socket
 descriptor.  Instead, a GError will be set with code %G_IO_ERROR_FAILED".

You might also want to add a GIOError mapping ENOTSOCK -> G_IO_ERROR_NOT_SOCKET?
Comment 4 Dan Winship 2015-03-19 17:36:00 UTC
Comment on attachment 299581 [details] [review]
gsocket: Don't g_error() if file-descriptor is not a socket

agree with Colin on updating the docs, but I don't think we need a new error code
Comment 5 Stef Walter 2015-07-02 10:24:23 UTC
Created attachment 306593 [details] [review]
gsocket: Don't g_error() if file-descriptor is not a socket

This code was out of date with current coding practices.

Nowadays it's common to receive file descriptors over environment
variables from other processes like systemd. The unit files that
control these file descriptors are configurable by sysadmins.

It is not (necessarily) a programmer error when g_socket_details_from_fd()
is called with a file descriptor that is not a socket. It can also
be a system and/or configuration error.
Comment 6 Stef Walter 2015-07-02 10:28:45 UTC
Made changes suggested. Merged.