[glib/gdbus-merge] Remove the credentials argument from g_unix_connect_send_credentials()



commit 9e90b381f58c4a06f49e622a07ee0b56fb52b3f1
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 13 14:25:29 2010 -0400

    Remove the credentials argument from g_unix_connect_send_credentials()
    
    Instead, make it always send the current credentials.

 gio/gdbusauth.c       |    3 +--
 gio/gunixconnection.c |   16 +++++++---------
 gio/gunixconnection.h |    1 -
 3 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
index 3f7ccce..f774eee 100644
--- a/gio/gdbusauth.c
+++ b/gio/gdbusauth.c
@@ -612,7 +612,6 @@ _g_dbus_auth_run_client (GDBusAuth     *auth,
     {
       credentials = g_credentials_new ();
       if (!g_unix_connection_send_credentials (G_UNIX_CONNECTION (auth->priv->stream),
-                                               credentials,
                                                cancellable,
                                                error))
         goto out;
@@ -641,7 +640,7 @@ _g_dbus_auth_run_client (GDBusAuth     *auth,
       debug_print ("CLIENT: didn't send any credentials");
     }
 
-  /* TODO: to reduce rountrips, try to pick an auth mechanism to start with */
+  /* TODO: to reduce roundtrips, try to pick an auth mechanism to start with */
 
   /* Get list of supported authentication mechanisms */
   s = "AUTH\r\n";
diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c
index 8b618cb..1d48ff5 100644
--- a/gio/gunixconnection.c
+++ b/gio/gunixconnection.c
@@ -299,34 +299,30 @@ gboolean                g_unix_connection_create_pair                   (GUnixCo
 /**
  * g_unix_connection_send_credentials:
  * @connection: A #GUnixConnection.
- * @credentials: A #GCredentials to send.
  * @cancellable: A #GCancellable or %NULL.
  * @error: Return location for error or %NULL.
  *
- * Passes the credentials stored in @credentials to the recieving side
+ * Passes the credentials of the current user the receiving side
  * of the connection. The recieving end has to call
  * g_unix_connection_receive_credentials() (or similar) to accept the
  * credentials.
  *
- * The credentials which the sender specifies are checked by the
- * kernel.  A process with effective user ID 0 is allowed to specify
- * values that do not match its own. This means that the credentials
- * can be used to authenticate other connections.
- *
  * As well as sending the credentials this also writes a single NUL
  * byte to the stream, as this is required for credentials passing to
  * work on some implementations.
  *
+ * Note that this function only works on Linux, currently.
+ *
  * Returns: %TRUE on success, %FALSE if @error is set.
  *
  * Since: 2.26
  */
 gboolean
 g_unix_connection_send_credentials (GUnixConnection      *connection,
-                                    GCredentials         *credentials,
                                     GCancellable         *cancellable,
                                     GError              **error)
 {
+  GCredentials *credentials;
   GSocketControlMessage *scm;
   GSocket *socket;
   gboolean ret;
@@ -334,11 +330,12 @@ g_unix_connection_send_credentials (GUnixConnection      *connection,
   guchar nul_byte[1] = {'\0'};
 
   g_return_val_if_fail (G_IS_UNIX_CONNECTION (connection), FALSE);
-  g_return_val_if_fail (G_IS_CREDENTIALS (credentials), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
   ret = FALSE;
 
+  credentials = g_credentials_new ();
+
   vector.buffer = &nul_byte;
   vector.size = 1;
   scm = g_unix_credentials_message_new_with_credentials (credentials);
@@ -362,6 +359,7 @@ g_unix_connection_send_credentials (GUnixConnection      *connection,
  out:
   g_object_unref (socket);
   g_object_unref (scm);
+  g_object_unref (credentials);
   return ret;
 }
 
diff --git a/gio/gunixconnection.h b/gio/gunixconnection.h
index 9c691ea..c38b0c9 100644
--- a/gio/gunixconnection.h
+++ b/gio/gunixconnection.h
@@ -72,7 +72,6 @@ gint                    g_unix_connection_receive_fd                    (GUnixCo
                                                                          GError              **error);
 
 gboolean                g_unix_connection_send_credentials              (GUnixConnection      *connection,
-                                                                         GCredentials         *credentials,
                                                                          GCancellable         *cancellable,
                                                                          GError              **error);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]