summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-auth-script.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-05 02:01:34 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-05 02:01:34 +0000
commit7e050c88719553d0c74e3dc68caf7bc50ae99590 (patch)
treef7a9abccae6591849e58e71d45dded9aa76512ec /dbus/dbus-auth-script.c
parent6bea42d2b84121152e4e5c719d23ed22901a972a (diff)
2003-03-04 Havoc Pennington <hp@pobox.com>
* test/data/auth/*: adapt to changes * dbus/dbus-auth-script.c (_dbus_auth_script_run): add USERID_BASE64 and change USERNAME_BASE64 to put in username not userid * dbus/dbus-keyring.c (_dbus_keyring_validate_context): prevent more stuff from being in a context name, to make the protocol simpler to deal with * dbus/dbus-errors.c (dbus_error_has_name): new function (dbus_error_is_set): new function * dbus/dbus-auth.c: replace DBUS_STUPID_TEST_MECH auth with DBUS_COOKIE_SHA1, implement DBUS_COOKIE_SHA1 * dbus/dbus-connection.c (dbus_connection_flush): also read messages during a flush operation * dbus/Makefile.am: remove dbus-md5 since it isn't currently used.
Diffstat (limited to 'dbus/dbus-auth-script.c')
-rw-r--r--dbus/dbus-auth-script.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c
index 4dccfe9f..732b4515 100644
--- a/dbus/dbus-auth-script.c
+++ b/dbus/dbus-auth-script.c
@@ -191,9 +191,12 @@ _dbus_auth_script_run (const DBusString *filename)
DBusAuth *auth;
DBusString from_auth;
DBusAuthState state;
+ DBusString context;
retval = FALSE;
auth = NULL;
+
+ _dbus_string_init_const (&context, "org_freedesktop_test");
if (!_dbus_string_init (&file, _DBUS_INT_MAX))
return FALSE;
@@ -299,6 +302,7 @@ _dbus_auth_script_run (const DBusString *filename)
_dbus_credentials_from_current_process (&creds);
_dbus_auth_set_credentials (auth, &creds);
+ _dbus_auth_set_context (auth, &context);
}
else if (auth == NULL)
{
@@ -359,24 +363,60 @@ _dbus_auth_script_run (const DBusString *filename)
goto out;
}
- /* Replace USERNAME_BASE64 with our username in base64 */
+ /* Replace USERID_BASE64 with our username in base64 */
{
int where;
if (_dbus_string_find (&to_send, 0,
- "USERNAME_BASE64", &where))
+ "USERID_BASE64", &where))
{
DBusString username;
if (!_dbus_string_init (&username, _DBUS_INT_MAX))
{
- _dbus_warn ("no memory for username\n");
+ _dbus_warn ("no memory for userid\n");
_dbus_string_free (&to_send);
goto out;
}
if (!_dbus_string_append_our_uid (&username))
{
+ _dbus_warn ("no memory for userid\n");
+ _dbus_string_free (&username);
+ _dbus_string_free (&to_send);
+ goto out;
+ }
+
+ _dbus_string_delete (&to_send, where, strlen ("USERID_BASE64"));
+
+ if (!_dbus_string_base64_encode (&username, 0,
+ &to_send, where))
+ {
+ _dbus_warn ("no memory to subst USERID_BASE64\n");
+ _dbus_string_free (&username);
+ _dbus_string_free (&to_send);
+ goto out;
+ }
+
+ _dbus_string_free (&username);
+ }
+ else if (_dbus_string_find (&to_send, 0,
+ "USERNAME_BASE64", &where))
+ {
+ DBusString username;
+ const DBusString *u;
+
+ if (!_dbus_string_init (&username, _DBUS_INT_MAX))
+ {
+ _dbus_warn ("no memory for username\n");
+ _dbus_string_free (&to_send);
+ goto out;
+ }
+
+ if (!_dbus_user_info_from_current_process (&u, NULL, NULL) ||
+ !_dbus_string_copy (u, 0, &username,
+ _dbus_string_get_length (&username)))
+ {
_dbus_warn ("no memory for username\n");
_dbus_string_free (&username);
_dbus_string_free (&to_send);