2003-01-30 Havoc Pennington <hp@pobox.com>
+ * dbus/dbus-auth.c: rework to use only REJECTED, no
+ MECHANISMS
+
+ * doc/dbus-sasl-profile.txt: drop MECHANISMS and just
+ use REJECTED, suggested by Mark McLoughlin
+
+2003-01-30 Havoc Pennington <hp@pobox.com>
+
* dbus/dbus-server.c (dbus_server_listen): @todo about how we need
a better way to report errors here. e.g. "unix address lacks
path" or something. also "no such file" when the path doesn't
/* -*- mode: C; c-file-style: "gnu" -*- */
/* dbus-auth.c Authentication
*
- * Copyright (C) 2002 Red Hat Inc.
+ * Copyright (C) 2002, 2003 Red Hat Inc.
*
* Licensed under the Academic Free License version 1.2
*
static dbus_bool_t process_error_server (DBusAuth *auth,
const DBusString *command,
const DBusString *args);
-static dbus_bool_t process_mechanisms (DBusAuth *auth,
- const DBusString *command,
- const DBusString *args);
static dbus_bool_t process_rejected (DBusAuth *auth,
const DBusString *command,
const DBusString *args);
static dbus_bool_t client_try_next_mechanism (DBusAuth *auth);
-
+static dbus_bool_t send_rejected (DBusAuth *auth);
static DBusAuthCommandHandler
server_handlers[] = {
{ "DATA", process_data_server },
{ "ERROR", process_error_server },
{ NULL, NULL }
-};
+};
static DBusAuthCommandHandler
client_handlers[] = {
- { "MECHANISMS", process_mechanisms },
{ "REJECTED", process_rejected },
{ "OK", process_ok },
{ "DATA", process_data_client },
}
static dbus_bool_t
-do_rejection (DBusAuth *auth)
-{
- if (_dbus_string_append (&auth->outgoing,
- "REJECTED\r\n"))
- {
- shutdown_mech (auth);
- _dbus_verbose ("rejected client auth\n");
- return TRUE;
- }
- else
- return FALSE;
-}
-
-static dbus_bool_t
handle_server_data_external_mech (DBusAuth *auth,
const DBusString *data)
{
if (auth->credentials.uid < 0)
{
_dbus_verbose ("no credentials, mechanism EXTERNAL can't authenticate\n");
- return do_rejection (auth);
+ return send_rejected (auth);
}
if (_dbus_string_get_length (data) > 0)
if (_dbus_string_get_length (&auth->identity) > 0)
{
/* Tried to send two auth identities, wtf */
- return do_rejection (auth);
+ return send_rejected (auth);
}
else
{
{
if (!_dbus_credentials_from_uid_string (&auth->identity,
&desired_identity))
- return do_rejection (auth);
+ return send_rejected (auth);
}
if (desired_identity.uid < 0)
{
_dbus_verbose ("desired UID %d is no good\n", desired_identity.uid);
- return do_rejection (auth);
+ return send_rejected (auth);
}
if (_dbus_credentials_match (&auth->credentials,
}
else
{
- return do_rejection (auth);
+ return send_rejected (auth);
}
}
}
static dbus_bool_t
-send_mechanisms (DBusAuth *auth)
+send_rejected (DBusAuth *auth)
{
DBusString command;
int i;
return FALSE;
if (!_dbus_string_append (&command,
- "MECHANISMS"))
+ "REJECTED"))
goto nomem;
i = 0;
else if (_dbus_string_get_length (args) == 0)
{
/* No args to the auth, send mechanisms */
- if (!send_mechanisms (auth))
+ if (!send_rejected (auth))
return FALSE;
return TRUE;
else
{
/* Unsupported mechanism */
- if (!send_mechanisms (auth))
+ if (!send_rejected (auth))
return FALSE;
}
}
static dbus_bool_t
-process_mechanisms (DBusAuth *auth,
- const DBusString *command,
- const DBusString *args)
+record_mechanisms (DBusAuth *auth,
+ const DBusString *command,
+ const DBusString *args)
{
int next;
int len;
if (!auth->already_got_mechanisms)
{
- /* Ask for mechanisms */
- if (!_dbus_string_append (&auth->outgoing,
- "AUTH\r\n"))
+ if (!record_mechanisms (auth, command, args))
return FALSE;
}
- else if (DBUS_AUTH_CLIENT (auth)->mechs_to_try != NULL)
+
+ if (DBUS_AUTH_CLIENT (auth)->mechs_to_try != NULL)
{
client_try_next_mechanism (auth);
}
From server to client are as follows:
- MECHANISMS <space-separated list of mechanism names>
-
- REJECTED
+ REJECTED <space-separated list of mechanism names>
OK
ERROR
-
Special credentials-passing nul byte
===
AUTH Command
===
- If an AUTH command has no arguments, it is a request to list
- available mechanisms. The server SHOULD respond with a MECHANISMS
- command listing the mechanisms it understands.
+ If an AUTH command has no arguments, it is a request to list
+ available mechanisms. The server SHOULD respond with a REJECTED
+ command listing the mechanisms it understands.
If an AUTH command specifies a mechanism, and the server supports
said mechanism, the server SHOULD begin exchanging SASL
challenge-response data with the client using DATA commands.
If the server does not support the mechanism given in the AUTH
- command, it SHOULD send a MECHANISMS command listing the mechanisms
- it does support. A MECHANISMS command implies that any
- authentication in progress was rejected, as if REJECTED were also
- sent. A server MAY send a REJECTED command instead of a MECHANISMS
- command, though this is unhelpful.
+ command, it SHOULD send a REJECTED command listing the mechanisms
+ it does support.
If the [initial-response] argument is provided, it is intended for
use with mechanisms that have no initial challenge (or an empty
initial challenge), as if it were the argument to an initial DATA
command. If the selected mechanism has an initial challenge, the
- server should reject authentication (send MECHANISMS or REJECTED).
+ server should reject authentication by sending REJECTED.
If authentication succeeds after exchanging DATA commands,
an OK command should be sent to the client.
CANCEL Command
===
- At any time up to sending the BEGIN command, the client may
- send a CANCEL command. On receiving the CANCEL command, the
- server MUST send a REJECTED or MECHANISMS command and abort the
- current authentication exchange.
+ At any time up to sending the BEGIN command, the client may send a
+ CANCEL command. On receiving the CANCEL command, the server MUST
+ send a REJECTED command and abort the current authentication
+ exchange.
DATA Command
===
command from the client MUST be the first octet of the
authenticated/encrypted stream of D-BUS messages.
-MECHANISMS Command
-===
-
- The MECHANISMS command has a space-separated list of
- available auth mechanisms as arguments. The MECHANISMS command
- implies REJECTED if an authentication exchange is in progress;
- the current exchange MUST be considered rejected.
-
REJECTED Command
===
The client would normally try another mechanism, or try providing
different responses to challenges.
+ Optionally, the REJECTED command has a space-separated list of
+ available auth mechanisms as arguments. If a server ever provides
+ a list of supported mechanisms, it MUST provide the same list
+ each time it sends a REJECTED message. Clients are free to
+ ignore all lists received after the first.
+
OK Command
===
===
C: AUTH
- S: MECHANISMS KERBEROS_V4 SKEY
+ S: REJECTED KERBEROS_V4 SKEY
C: AUTH SKEY bW9yZ2Fu
S: DATA OTUgUWE1ODMwOA==
C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
===
C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
- S: MECHANISMS KERBEROS_V4 SKEY
+ S: REJECTED KERBEROS_V4 SKEY
C: AUTH SKEY bW9yZ2Fu
S: DATA OTUgUWE1ODMwOA==
C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
===
C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
- S: MECHANISMS KERBEROS_V4 SKEY
+ S: REJECTED KERBEROS_V4 SKEY
C: AUTH SKEY bW9yZ2Fu
S: DATA OTUgUWE1ODMwOA==
C: DATA Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA==
===
C: AUTH MAGIC_COOKIE BsAY3g4gBNo=
- S: MECHANISMS KERBEROS_V4 SKEY
+ S: REJECTED KERBEROS_V4 SKEY
C: AUTH SKEY bW9yZ2Fu
S: DATA OTUgUWE1ODMwOA==
C: CANCEL