diff options
Diffstat (limited to 'dbus/dbus-auth-script.c')
-rw-r--r-- | dbus/dbus-auth-script.c | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 6285e3ba..8bf7e78a 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -1,10 +1,10 @@ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-auth-script.c Test DBusAuth using a special script file (internal to D-Bus implementation) - * + * * Copyright (C) 2003 Red Hat, Inc. * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -63,7 +63,7 @@ append_quoted_string (DBusString *dest, if (in_backslash) { unsigned char a; - + if (b == 'r') a = '\r'; else if (b == 'n') @@ -78,7 +78,7 @@ append_quoted_string (DBusString *dest, if (!_dbus_string_append_byte (dest, a)) return FALSE; - + in_backslash = FALSE; } else if (b == '\\') @@ -107,7 +107,7 @@ append_quoted_string (DBusString *dest, return FALSE; } } - + ++i; } @@ -131,7 +131,7 @@ same_first_word (const DBusString *a, static DBusAuthState auth_state_from_string (const DBusString *str) -{ +{ if (_dbus_string_starts_with_c_str (str, "WAITING_FOR_INPUT")) return DBUS_AUTH_STATE_WAITING_FOR_INPUT; else if (_dbus_string_starts_with_c_str (str, "WAITING_FOR_MEMORY")) @@ -253,13 +253,13 @@ _dbus_auth_script_run (const DBusString *filename) DBusAuthState state; DBusString context; DBusString guid; - + retval = FALSE; auth = NULL; _dbus_string_init_const (&guid, "5fa01f4202cd837709a3274ca0df9d00"); _dbus_string_init_const (&context, "org_freedesktop_test"); - + if (!_dbus_string_init (&file)) return FALSE; @@ -276,7 +276,7 @@ _dbus_auth_script_run (const DBusString *filename) return FALSE; } - if (!_dbus_file_get_contents (&file, filename, &error)) { + if (!_dbus_file_get_contents (&file, filename, NULL, &error)) { _dbus_warn ("Getting contents of %s failed: %s\n", _dbus_string_get_const_data (filename), error.message); dbus_error_free (&error); @@ -288,11 +288,11 @@ _dbus_auth_script_run (const DBusString *filename) next_iteration: while (_dbus_string_pop_line (&file, &line)) - { + { line_no += 1; /* _dbus_warn ("%s\n", _dbus_string_get_const_data (&line)); */ - + _dbus_string_delete_leading_blanks (&line); if (auth != NULL) @@ -311,7 +311,7 @@ _dbus_auth_script_run (const DBusString *filename) } } } - + if (_dbus_string_get_length (&line) == 0) { /* empty line */ @@ -359,7 +359,7 @@ _dbus_auth_script_run (const DBusString *filename) "CLIENT")) { DBusCredentials *creds; - + if (auth != NULL) { _dbus_warn ("already created a DBusAuth (CLIENT or SERVER given twice)\n"); @@ -385,7 +385,7 @@ _dbus_auth_script_run (const DBusString *filename) auth = NULL; goto out; } - + if (!_dbus_auth_set_credentials (auth, creds)) { _dbus_warn ("no memory for setting credentials\n"); @@ -394,14 +394,14 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_credentials_unref (creds); goto out; } - + _dbus_credentials_unref (creds); } else if (_dbus_string_starts_with_c_str (&line, "SERVER")) { DBusCredentials *creds; - + if (auth != NULL) { _dbus_warn ("already created a DBusAuth (CLIENT or SERVER given twice)\n"); @@ -427,7 +427,7 @@ _dbus_auth_script_run (const DBusString *filename) auth = NULL; goto out; } - + if (!_dbus_auth_set_credentials (auth, creds)) { _dbus_warn ("no memory for setting credentials\n"); @@ -436,7 +436,7 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_credentials_unref (creds); goto out; } - + _dbus_credentials_unref (creds); _dbus_auth_set_context (auth, &context); @@ -476,7 +476,7 @@ _dbus_auth_script_run (const DBusString *filename) "SEND")) { DBusString to_send; - + _dbus_string_delete_first_word (&line); if (!_dbus_string_init (&to_send)) @@ -494,7 +494,7 @@ _dbus_auth_script_run (const DBusString *filename) } _dbus_verbose ("Sending '%s'\n", _dbus_string_get_const_data (&to_send)); - + if (!_dbus_string_append (&to_send, "\r\n")) { _dbus_warn ("failed to append \r\n from line %d\n", @@ -506,7 +506,7 @@ _dbus_auth_script_run (const DBusString *filename) /* Replace USERID_HEX with our username in hex */ { int where; - + if (_dbus_string_find (&to_send, 0, "USERID_HEX", &where)) { @@ -528,7 +528,7 @@ _dbus_auth_script_run (const DBusString *filename) } _dbus_string_delete (&to_send, where, strlen ("USERID_HEX")); - + if (!_dbus_string_hex_encode (&username, 0, &to_send, where)) { @@ -544,7 +544,7 @@ _dbus_auth_script_run (const DBusString *filename) "USERNAME_HEX", &where)) { DBusString username; - + if (!_dbus_string_init (&username)) { _dbus_warn ("no memory for username\n"); @@ -561,7 +561,7 @@ _dbus_auth_script_run (const DBusString *filename) } _dbus_string_delete (&to_send, where, strlen ("USERNAME_HEX")); - + if (!_dbus_string_hex_encode (&username, 0, &to_send, where)) { @@ -590,14 +590,14 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_auth_return_buffer (auth, buffer, _dbus_string_get_length (&to_send)); } - + _dbus_string_free (&to_send); } else if (_dbus_string_starts_with_c_str (&line, "EXPECT_STATE")) { DBusAuthState expected; - + _dbus_string_delete_first_word (&line); expected = auth_state_from_string (&line); @@ -620,7 +620,7 @@ _dbus_auth_script_run (const DBusString *filename) "EXPECT_COMMAND")) { DBusString received; - + _dbus_string_delete_first_word (&line); if (!_dbus_string_init (&received)) @@ -646,7 +646,7 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_string_free (&received); goto out; } - + _dbus_string_free (&received); } else if (_dbus_string_starts_with_c_str (&line, @@ -654,7 +654,7 @@ _dbus_auth_script_run (const DBusString *filename) { DBusString expected; const DBusString *unused; - + _dbus_string_delete_first_word (&line); if (!_dbus_string_init (&expected)) @@ -672,7 +672,7 @@ _dbus_auth_script_run (const DBusString *filename) } _dbus_auth_get_unused_bytes (auth, &unused); - + if (_dbus_string_equal (&expected, unused)) { _dbus_auth_delete_unused_bytes (auth); @@ -691,7 +691,7 @@ _dbus_auth_script_run (const DBusString *filename) "EXPECT_HAVE_NO_CREDENTIALS")) { DBusCredentials *authorized_identity; - + authorized_identity = _dbus_auth_get_identity (auth); if (!_dbus_credentials_are_anonymous (authorized_identity)) { @@ -703,7 +703,7 @@ _dbus_auth_script_run (const DBusString *filename) "EXPECT_HAVE_SOME_CREDENTIALS")) { DBusCredentials *authorized_identity; - + authorized_identity = _dbus_auth_get_identity (auth); if (_dbus_credentials_are_anonymous (authorized_identity)) { @@ -715,7 +715,7 @@ _dbus_auth_script_run (const DBusString *filename) "EXPECT")) { DBusString expected; - + _dbus_string_delete_first_word (&line); if (!_dbus_string_init (&expected)) @@ -752,7 +752,7 @@ _dbus_auth_script_run (const DBusString *filename) goto parse_failed; goto next_iteration; /* skip parse_failed */ - + parse_failed: { _dbus_warn ("couldn't process line %d \"%s\"\n", @@ -785,9 +785,9 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_warn ("Leftover data: %s\n", _dbus_string_get_const_data (&from_auth)); goto out; } - + retval = TRUE; - + out: if (auth) _dbus_auth_unref (auth); @@ -795,7 +795,7 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_string_free (&file); _dbus_string_free (&line); _dbus_string_free (&from_auth); - + return retval; } |