Remove the credentials argument from g_unix_connect_send_credentials()

Instead, make it always send the current credentials.
This commit is contained in:
Matthias Clasen 2010-05-13 14:25:29 -04:00
parent 33952347ff
commit 9e90b381f5
3 changed files with 8 additions and 12 deletions

View File

@ -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";

View File

@ -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;
}

View File

@ -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);