X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgunixconnection.c;h=b5da60a4edeb082469e5adc99d0a0a9e606f3a25;hb=7fd6f07d498063470903a886b4805a13bd333908;hp=8a0968e44bc5387b7745e42315f8f0314be2b511;hpb=b377e69685c99150cf7661e1aa77d60934e00521;p=platform%2Fupstream%2Fglib.git diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c index 8a0968e..b5da60a 100644 --- a/gio/gunixconnection.c +++ b/gio/gunixconnection.c @@ -13,10 +13,19 @@ */ #include "config.h" + #include "gunixconnection.h" +#include "gnetworking.h" +#include "gsocket.h" +#include "gsocketcontrolmessage.h" #include "gunixcredentialsmessage.h" +#include "gunixfdmessage.h" #include "glibintl.h" +#include +#include +#include + /** * SECTION:gunixconnection * @title: GUnixConnection @@ -30,23 +39,13 @@ * It contains functions to do some of the UNIX socket specific * functionality like passing file descriptors. * - * Note that <gio/gunixconnection.h> belongs to - * the UNIX-specific GIO interfaces, thus you have to use the - * gio-unix-2.0.pc pkg-config file when using it. + * Note that `` belongs to the UNIX-specific + * GIO interfaces, thus you have to use the `gio-unix-2.0.pc` + * pkg-config file when using it. * * Since: 2.22 */ -#include -#include -#include -#include - -#include -#include -#include - - G_DEFINE_TYPE_WITH_CODE (GUnixConnection, g_unix_connection, G_TYPE_SOCKET_CONNECTION, g_socket_connection_factory_register_type (g_define_type_id, @@ -157,7 +156,10 @@ g_unix_connection_receive_fd (GUnixConnection *connection, gint i; g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - _("Expecting 1 control message, got %d"), nscm); + ngettext("Expecting 1 control message, got %d", + "Expecting 1 control message, got %d", + nscm), + nscm); for (i = 0; i < nscm; i++) g_object_unref (scms[i]); @@ -188,7 +190,10 @@ g_unix_connection_receive_fd (GUnixConnection *connection, gint i; g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - _("Expecting one fd, but got %d\n"), nfd); + ngettext("Expecting one fd, but got %d\n", + "Expecting one fd, but got %d\n", + nfd), + nfd); for (i = 0; i < nfd; i++) close (fds[i]); @@ -476,16 +481,14 @@ g_unix_connection_receive_credentials (GUnixConnection *connection, #ifdef __linux__ { gint opt_val; - socklen_t opt_len; turn_off_so_passcreds = FALSE; opt_val = 0; - opt_len = sizeof (gint); - if (getsockopt (g_socket_get_fd (socket), - SOL_SOCKET, - SO_PASSCRED, - &opt_val, - &opt_len) != 0) + if (!g_socket_get_option (socket, + SOL_SOCKET, + SO_PASSCRED, + &opt_val, + NULL)) { g_set_error (error, G_IO_ERROR, @@ -494,24 +497,13 @@ g_unix_connection_receive_credentials (GUnixConnection *connection, strerror (errno)); goto out; } - if (opt_len != sizeof (gint)) - { - g_set_error (error, - G_IO_ERROR, - G_IO_ERROR_FAILED, - _("Unexpected option length while checking if SO_PASSCRED is enabled for socket. " - "Expected %d bytes, got %d"), - (gint) sizeof (gint), (gint) opt_len); - goto out; - } if (opt_val == 0) { - opt_val = 1; - if (setsockopt (g_socket_get_fd (socket), - SOL_SOCKET, - SO_PASSCRED, - &opt_val, - sizeof opt_val) != 0) + if (!g_socket_set_option (socket, + SOL_SOCKET, + SO_PASSCRED, + TRUE, + NULL)) { g_set_error (error, G_IO_ERROR, @@ -559,7 +551,9 @@ g_unix_connection_receive_credentials (GUnixConnection *connection, g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - _("Expecting 1 control message, got %d"), + ngettext("Expecting 1 control message, got %d", + "Expecting 1 control message, got %d", + nscm), nscm); goto out; } @@ -598,13 +592,11 @@ g_unix_connection_receive_credentials (GUnixConnection *connection, #ifdef __linux__ if (turn_off_so_passcreds) { - gint opt_val; - opt_val = 0; - if (setsockopt (g_socket_get_fd (socket), - SOL_SOCKET, - SO_PASSCRED, - &opt_val, - sizeof opt_val) != 0) + if (!g_socket_set_option (socket, + SOL_SOCKET, + SO_PASSCRED, + FALSE, + NULL)) { g_set_error (error, G_IO_ERROR,