From 4449b7d258db35b7d0e9c7adbc3261a7006c0538 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 9 Aug 2016 18:36:19 +0200 Subject: Remove trailing whitespaces Signed-off-by: Thomas Zimmermann --- bus/dir-watch-inotify.c | 4 +- dbus/dbus-auth.c | 306 +++++++++++++++++++++--------------------- dbus/dbus-marshal-recursive.c | 18 +-- dbus/dbus-shell.c | 54 ++++---- dbus/dbus-transport.c | 168 +++++++++++------------ tools/dbus-launch.c | 124 ++++++++--------- 6 files changed, 337 insertions(+), 337 deletions(-) diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index ce19fdc..e9ea0ed 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -5,7 +5,7 @@ * (c) 2006 Mandriva * * 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 @@ -15,7 +15,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 diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index f222787..acc259e 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -4,7 +4,7 @@ * Copyright (C) 2002, 2003, 2004 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 @@ -50,7 +50,7 @@ * * @todo the cookie keyring needs to be cached globally not just * per-auth (which raises threadsafety issues too) - * + * * @todo grep FIXME in dbus-auth.c */ @@ -157,7 +157,7 @@ struct DBusAuth DBusString incoming; /**< Incoming data buffer */ DBusString outgoing; /**< Outgoing data buffer */ - + const DBusAuthStateData *state; /**< Current protocol state */ const DBusAuthMechanismHandler *mech; /**< Current auth mechanism */ @@ -165,14 +165,14 @@ struct DBusAuth DBusString identity; /**< Current identity we're authorizing * as. */ - + DBusCredentials *credentials; /**< Credentials read from socket */ DBusCredentials *authorized_identity; /**< Credentials that are authorized */ DBusCredentials *desired_identity; /**< Identity client has requested */ - + DBusString context; /**< Cookie scope */ DBusKeyring *keyring; /**< Keyring for cookie mechanism. */ int cookie_id; /**< ID of cookie to use */ @@ -181,7 +181,7 @@ struct DBusAuth char **allowed_mechs; /**< Mechanisms we're allowed to use, * or #NULL if we can use any */ - + unsigned int needed_memory : 1; /**< We needed memory to continue since last * successful getting something done */ @@ -203,7 +203,7 @@ typedef struct DBusList *mechs_to_try; /**< Mechanisms we got from the server that we're going to try using */ DBusString guid_from_server; /**< GUID received from server */ - + } DBusAuthClient; /** @@ -217,7 +217,7 @@ typedef struct int max_failures; /**< Number of times we reject before disconnect */ DBusString guid; /**< Our globally unique ID in hex encoding */ - + } DBusAuthServer; static void goto_state (DBusAuth *auth, @@ -238,7 +238,7 @@ static dbus_bool_t send_agree_unix_fd (DBusAuth *auth); /** * Client states */ - + static dbus_bool_t handle_server_state_waiting_for_auth (DBusAuth *auth, DBusAuthCommand command, const DBusString *args); @@ -248,7 +248,7 @@ static dbus_bool_t handle_server_state_waiting_for_data (DBusAuth *auth static dbus_bool_t handle_server_state_waiting_for_begin (DBusAuth *auth, DBusAuthCommand command, const DBusString *args); - + static const DBusAuthStateData server_state_waiting_for_auth = { "WaitingForAuth", handle_server_state_waiting_for_auth }; @@ -258,11 +258,11 @@ static const DBusAuthStateData server_state_waiting_for_data = { static const DBusAuthStateData server_state_waiting_for_begin = { "WaitingForBegin", handle_server_state_waiting_for_begin }; - + /** * Client states */ - + static dbus_bool_t handle_client_state_waiting_for_data (DBusAuth *auth, DBusAuthCommand command, const DBusString *args); @@ -338,16 +338,16 @@ static DBusAuth* _dbus_auth_new (int size) { DBusAuth *auth; - + auth = dbus_malloc0 (size); if (auth == NULL) return NULL; - + auth->refcount = 1; - + auth->keyring = NULL; auth->cookie_id = -1; - + /* note that we don't use the max string length feature, * because you can't use that feature if you're going to * try to recover from out-of-memory (it creates @@ -355,13 +355,13 @@ _dbus_auth_new (int size) * more space in the string). But we do handle * overlong buffers in _dbus_auth_do_work(). */ - + if (!_dbus_string_init (&auth->incoming)) goto enomem_0; if (!_dbus_string_init (&auth->outgoing)) goto enomem_1; - + if (!_dbus_string_init (&auth->identity)) goto enomem_2; @@ -378,7 +378,7 @@ _dbus_auth_new (int size) auth->credentials = _dbus_credentials_new (); if (auth->credentials == NULL) goto enomem_6; - + auth->authorized_identity = _dbus_credentials_new (); if (auth->authorized_identity == NULL) goto enomem_7; @@ -386,7 +386,7 @@ _dbus_auth_new (int size) auth->desired_identity = _dbus_credentials_new (); if (auth->desired_identity == NULL) goto enomem_8; - + return auth; #if 0 @@ -423,17 +423,17 @@ shutdown_mech (DBusAuth *auth) _dbus_credentials_clear (auth->authorized_identity); _dbus_credentials_clear (auth->desired_identity); - + if (auth->mech != NULL) { _dbus_verbose ("%s: Shutting down mechanism %s\n", DBUS_AUTH_NAME (auth), auth->mech->mechanism); - + if (DBUS_AUTH_IS_CLIENT (auth)) (* auth->mech->client_shutdown_func) (auth); else (* auth->mech->server_shutdown_func) (auth); - + auth->mech = NULL; } } @@ -456,11 +456,11 @@ sha1_compute_hash (DBusAuth *auth, DBusString cookie; DBusString to_hash; dbus_bool_t retval; - + _dbus_assert (auth->keyring != NULL); retval = FALSE; - + if (!_dbus_string_init (&cookie)) return FALSE; @@ -476,14 +476,14 @@ sha1_compute_hash (DBusAuth *auth, if (!_dbus_string_init (&to_hash)) goto out_0; - + if (!_dbus_string_copy (server_challenge, 0, &to_hash, _dbus_string_get_length (&to_hash))) goto out_1; if (!_dbus_string_append (&to_hash, ":")) goto out_1; - + if (!_dbus_string_copy (client_challenge, 0, &to_hash, _dbus_string_get_length (&to_hash))) goto out_1; @@ -497,7 +497,7 @@ sha1_compute_hash (DBusAuth *auth, if (!_dbus_sha_compute (&to_hash, hash)) goto out_1; - + retval = TRUE; out_1: @@ -528,7 +528,7 @@ sha1_handle_first_client_response (DBusAuth *auth, DBusError error = DBUS_ERROR_INIT; _dbus_string_set_length (&auth->challenge, 0); - + if (_dbus_string_get_length (data) > 0) { if (_dbus_string_get_length (&auth->identity) > 0) @@ -545,14 +545,14 @@ sha1_handle_first_client_response (DBusAuth *auth, return FALSE; } } - + if (!_dbus_credentials_add_from_user (auth->desired_identity, data)) { _dbus_verbose ("%s: Did not get a valid username from client\n", DBUS_AUTH_NAME (auth)); return send_rejected (auth); } - + if (!_dbus_string_init (&tmp)) return FALSE; @@ -573,7 +573,7 @@ sha1_handle_first_client_response (DBusAuth *auth, _dbus_keyring_unref (auth->keyring); auth->keyring = NULL; } - + if (auth->keyring == NULL) { auth->keyring = _dbus_keyring_new_for_credentials (auth->desired_identity, @@ -634,8 +634,8 @@ sha1_handle_first_client_response (DBusAuth *auth, goto out; if (!_dbus_string_append (&tmp2, " ")) - goto out; - + goto out; + if (!_dbus_generate_random_bytes (&tmp, N_CHALLENGE_BYTES, &error)) { if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) @@ -659,17 +659,17 @@ sha1_handle_first_client_response (DBusAuth *auth, _dbus_string_set_length (&auth->challenge, 0); if (!_dbus_string_hex_encode (&tmp, 0, &auth->challenge, 0)) goto out; - + if (!_dbus_string_hex_encode (&tmp, 0, &tmp2, _dbus_string_get_length (&tmp2))) goto out; if (!send_data (auth, &tmp2)) goto out; - + goto_state (auth, &server_state_waiting_for_data); retval = TRUE; - + out: _dbus_string_zero (&tmp); _dbus_string_free (&tmp); @@ -693,28 +693,28 @@ sha1_handle_second_client_response (DBusAuth *auth, DBusString client_hash; dbus_bool_t retval; DBusString correct_hash; - + retval = FALSE; - + if (!_dbus_string_find_blank (data, 0, &i)) { _dbus_verbose ("%s: no space separator in client response\n", DBUS_AUTH_NAME (auth)); return send_rejected (auth); } - + if (!_dbus_string_init (&client_challenge)) goto out_0; if (!_dbus_string_init (&client_hash)) - goto out_1; + goto out_1; if (!_dbus_string_copy_len (data, 0, i, &client_challenge, 0)) goto out_2; _dbus_string_skip_blank (data, i, &i); - + if (!_dbus_string_copy_len (data, i, _dbus_string_get_length (data) - i, &client_hash, @@ -735,7 +735,7 @@ sha1_handle_second_client_response (DBusAuth *auth, goto out_2; if (!sha1_compute_hash (auth, auth->cookie_id, - &auth->challenge, + &auth->challenge, &client_challenge, &correct_hash)) goto out_3; @@ -747,7 +747,7 @@ sha1_handle_second_client_response (DBusAuth *auth, retval = TRUE; goto out_3; } - + if (!_dbus_string_equal (&client_hash, &correct_hash)) { if (send_rejected (auth)) @@ -765,15 +765,15 @@ sha1_handle_second_client_response (DBusAuth *auth, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) goto out_3; - + if (!send_ok (auth)) goto out_3; _dbus_verbose ("%s: authenticated client using DBUS_COOKIE_SHA1\n", DBUS_AUTH_NAME (auth)); - + retval = TRUE; - + out_3: _dbus_string_zero (&correct_hash); _dbus_string_free (&correct_hash); @@ -799,7 +799,7 @@ handle_server_data_cookie_sha1_mech (DBusAuth *auth, static void handle_server_shutdown_cookie_sha1_mech (DBusAuth *auth) { - auth->cookie_id = -1; + auth->cookie_id = -1; _dbus_string_set_length (&auth->challenge, 0); } @@ -814,7 +814,7 @@ handle_client_initial_response_cookie_sha1_mech (DBusAuth *auth, if (!_dbus_string_init (&username)) return FALSE; - + if (!_dbus_append_user_from_current_process (&username)) goto out_0; @@ -824,10 +824,10 @@ handle_client_initial_response_cookie_sha1_mech (DBusAuth *auth, goto out_0; retval = TRUE; - + out_0: _dbus_string_free (&username); - + return retval; } @@ -864,7 +864,7 @@ handle_client_data_cookie_sha1_mech (DBusAuth *auth, if (!_dbus_string_copy_len (data, 0, i, &context, 0)) goto out_1; - + _dbus_string_skip_blank (data, i, &i); if (!_dbus_string_find_blank (data, i, &j)) { @@ -876,10 +876,10 @@ handle_client_data_cookie_sha1_mech (DBusAuth *auth, if (!_dbus_string_init (&cookie_id_str)) goto out_1; - + if (!_dbus_string_copy_len (data, i, j - i, &cookie_id_str, 0)) - goto out_2; + goto out_2; if (!_dbus_string_init (&server_challenge)) goto out_2; @@ -933,10 +933,10 @@ handle_client_data_cookie_sha1_mech (DBusAuth *auth, _dbus_verbose ("%s: Error loading keyring: %s\n", DBUS_AUTH_NAME (auth), error.message); - + if (send_error (auth, "Could not load cookie file")) retval = TRUE; /* retval is only about mem */ - + dbus_error_free (&error); goto out_3; } @@ -946,9 +946,9 @@ handle_client_data_cookie_sha1_mech (DBusAuth *auth, _dbus_assert (!dbus_error_is_set (&error)); } } - + _dbus_assert (auth->keyring != NULL); - + if (!_dbus_string_init (&tmp)) goto out_3; @@ -982,7 +982,7 @@ handle_client_data_cookie_sha1_mech (DBusAuth *auth, if (!_dbus_string_init (&correct_hash)) goto out_5; - + if (!sha1_compute_hash (auth, val, &server_challenge, &client_challenge, @@ -996,9 +996,9 @@ handle_client_data_cookie_sha1_mech (DBusAuth *auth, retval = TRUE; goto out_6; } - + _dbus_string_set_length (&tmp, 0); - + if (!_dbus_string_copy (&client_challenge, 0, &tmp, _dbus_string_get_length (&tmp))) goto out_6; @@ -1036,7 +1036,7 @@ handle_client_data_cookie_sha1_mech (DBusAuth *auth, static void handle_client_shutdown_cookie_sha1_mech (DBusAuth *auth) { - auth->cookie_id = -1; + auth->cookie_id = -1; _dbus_string_set_length (&auth->challenge, 0); } @@ -1054,7 +1054,7 @@ handle_server_data_external_mech (DBusAuth *auth, DBUS_AUTH_NAME (auth)); return send_rejected (auth); } - + if (_dbus_string_get_length (data) > 0) { if (_dbus_string_get_length (&auth->identity) > 0) @@ -1089,7 +1089,7 @@ handle_server_data_external_mech (DBusAuth *auth, } _dbus_credentials_clear (auth->desired_identity); - + /* If auth->identity is still empty here, then client * responded with an empty string after we poked it for * an initial response. This means to try to auth the @@ -1121,7 +1121,7 @@ handle_server_data_external_mech (DBusAuth *auth, _dbus_string_get_const_data (&auth->identity)); return send_rejected (auth); } - + if (_dbus_credentials_are_superset (auth->credentials, auth->desired_identity)) { @@ -1192,19 +1192,19 @@ handle_client_initial_response_external_mech (DBusAuth *auth, goto failed; _dbus_string_free (&plaintext); - + return TRUE; failed: _dbus_string_free (&plaintext); - return FALSE; + return FALSE; } static dbus_bool_t handle_client_data_external_mech (DBusAuth *auth, const DBusString *data) { - + return TRUE; } @@ -1221,7 +1221,7 @@ handle_client_shutdown_external_mech (DBusAuth *auth) static dbus_bool_t handle_server_data_anonymous_mech (DBusAuth *auth, const DBusString *data) -{ +{ if (_dbus_string_get_length (data) > 0) { /* Client is allowed to send "trace" data, the only defined @@ -1235,7 +1235,7 @@ handle_server_data_anonymous_mech (DBusAuth *auth, DBUS_AUTH_NAME (auth)); return send_rejected (auth); } - + _dbus_verbose ("%s: ANONYMOUS client sent trace string: '%s'\n", DBUS_AUTH_NAME (auth), _dbus_string_get_const_data (data)); @@ -1250,7 +1250,7 @@ handle_server_data_anonymous_mech (DBusAuth *auth, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) return FALSE; - + /* Anonymous is always allowed */ if (!send_ok (auth)) return FALSE; @@ -1264,7 +1264,7 @@ handle_server_data_anonymous_mech (DBusAuth *auth, static void handle_server_shutdown_anonymous_mech (DBusAuth *auth) { - + } static dbus_bool_t @@ -1292,26 +1292,26 @@ handle_client_initial_response_anonymous_mech (DBusAuth *auth, goto failed; _dbus_string_free (&plaintext); - + return TRUE; failed: _dbus_string_free (&plaintext); - return FALSE; + return FALSE; } static dbus_bool_t handle_client_data_anonymous_mech (DBusAuth *auth, const DBusString *data) { - + return TRUE; } static void handle_client_shutdown_anonymous_mech (DBusAuth *auth) { - + } /* Put mechanisms here in order of preference. @@ -1323,7 +1323,7 @@ handle_client_shutdown_anonymous_mech (DBusAuth *auth) * * We might ideally add a mechanism to chain to Cyrus SASL so we can * use its mechanisms as well. - * + * */ static const DBusAuthMechanismHandler all_mechanisms[] = { @@ -1350,7 +1350,7 @@ all_mechanisms[] = { handle_client_initial_response_anonymous_mech, handle_client_data_anonymous_mech, NULL, NULL, - handle_client_shutdown_anonymous_mech }, + handle_client_shutdown_anonymous_mech }, { NULL, NULL } }; @@ -1359,23 +1359,23 @@ find_mech (const DBusString *name, char **allowed_mechs) { int i; - + if (allowed_mechs != NULL && !_dbus_string_array_contains ((const char**) allowed_mechs, _dbus_string_get_const_data (name))) return NULL; - + i = 0; while (all_mechanisms[i].mechanism != NULL) - { + { if (_dbus_string_equal_c_str (name, all_mechanisms[i].mechanism)) return &all_mechanisms[i]; - + ++i; } - + return NULL; } @@ -1386,14 +1386,14 @@ send_auth (DBusAuth *auth, const DBusAuthMechanismHandler *mech) if (!_dbus_string_init (&auth_command)) return FALSE; - + if (!_dbus_string_append (&auth_command, "AUTH ")) { _dbus_string_free (&auth_command); return FALSE; - } - + } + if (!_dbus_string_append (&auth_command, mech->mechanism)) { @@ -1408,14 +1408,14 @@ send_auth (DBusAuth *auth, const DBusAuthMechanismHandler *mech) _dbus_string_free (&auth_command); return FALSE; } - + if (!(* mech->client_initial_response_func) (auth, &auth_command)) { _dbus_string_free (&auth_command); return FALSE; } } - + if (!_dbus_string_append (&auth_command, "\r\n")) { @@ -1433,7 +1433,7 @@ send_auth (DBusAuth *auth, const DBusAuthMechanismHandler *mech) _dbus_string_free (&auth_command); shutdown_mech (auth); - auth->mech = mech; + auth->mech = mech; goto_state (auth, &client_state_waiting_for_data); return TRUE; @@ -1474,10 +1474,10 @@ send_rejected (DBusAuth *auth) DBusString command; DBusAuthServer *server_auth; int i; - + if (!_dbus_string_init (&command)) return FALSE; - + if (!_dbus_string_append (&command, "REJECTED")) goto nomem; @@ -1492,10 +1492,10 @@ send_rejected (DBusAuth *auth) if (!_dbus_string_append (&command, all_mechanisms[i].mechanism)) goto nomem; - + ++i; } - + if (!_dbus_string_append (&command, "\r\n")) goto nomem; @@ -1504,7 +1504,7 @@ send_rejected (DBusAuth *auth) goto nomem; shutdown_mech (auth); - + _dbus_assert (DBUS_AUTH_IS_SERVER (auth)); server_auth = DBUS_AUTH_SERVER (auth); server_auth->failures += 1; @@ -1515,7 +1515,7 @@ send_rejected (DBusAuth *auth) goto_state (auth, &server_state_waiting_for_auth); _dbus_string_free (&command); - + return TRUE; nomem: @@ -1536,7 +1536,7 @@ send_ok (DBusAuth *auth) int orig_len; orig_len = _dbus_string_get_length (&auth->outgoing); - + if (_dbus_string_append (&auth->outgoing, "OK ") && _dbus_string_copy (& DBUS_AUTH_SERVER (auth)->guid, 0, @@ -1571,12 +1571,12 @@ process_ok(DBusAuth *auth, const DBusString *args_from_ok) { int end_of_hex; - + /* "args_from_ok" should be the GUID, whitespace already pulled off the front */ _dbus_assert (_dbus_string_get_length (& DBUS_AUTH_CLIENT (auth)->guid_from_server) == 0); /* We decode the hex string to binary, using guid_from_server as scratch... */ - + end_of_hex = 0; if (!_dbus_string_hex_decode (args_from_ok, 0, &end_of_hex, & DBUS_AUTH_CLIENT (auth)->guid_from_server, 0)) @@ -1584,7 +1584,7 @@ process_ok(DBusAuth *auth, /* now clear out the scratch */ _dbus_string_set_length (& DBUS_AUTH_CLIENT (auth)->guid_from_server, 0); - + if (end_of_hex != _dbus_string_get_length (args_from_ok) || end_of_hex == 0) { @@ -1654,7 +1654,7 @@ process_data (DBusAuth *auth, DBUS_AUTH_NAME (auth), _dbus_string_get_const_data (&decoded)); #endif - + if (!(* data_func) (auth, &decoded)) { _dbus_string_free (&decoded); @@ -1708,7 +1708,7 @@ handle_auth (DBusAuth *auth, const DBusString *args) int i; DBusString mech; DBusString hex_response; - + _dbus_string_find_blank (args, 0, &i); if (!_dbus_string_init (&mech)) @@ -1719,21 +1719,21 @@ handle_auth (DBusAuth *auth, const DBusString *args) _dbus_string_free (&mech); return FALSE; } - + if (!_dbus_string_copy_len (args, 0, i, &mech, 0)) goto failed; _dbus_string_skip_blank (args, i, &i); if (!_dbus_string_copy (args, i, &hex_response, 0)) goto failed; - + auth->mech = find_mech (&mech, auth->allowed_mechs); if (auth->mech != NULL) { _dbus_verbose ("%s: Trying mechanism %s\n", DBUS_AUTH_NAME (auth), auth->mech->mechanism); - + if (!process_data (auth, &hex_response, auth->mech->server_data_func)) goto failed; @@ -1744,16 +1744,16 @@ handle_auth (DBusAuth *auth, const DBusString *args) _dbus_verbose ("%s: Unsupported mechanism %s\n", DBUS_AUTH_NAME (auth), _dbus_string_get_const_data (&mech)); - + if (!send_rejected (auth)) goto failed; } - _dbus_string_free (&mech); + _dbus_string_free (&mech); _dbus_string_free (&hex_response); return TRUE; - + failed: auth->mech = NULL; _dbus_string_free (&mech); @@ -1874,12 +1874,12 @@ get_word (const DBusString *str, _dbus_string_skip_blank (str, *start, start); _dbus_string_find_blank (str, *start, &i); - + if (i > *start) { if (!_dbus_string_copy_len (str, *start, i - *start, word, 0)) return FALSE; - + *start = i; } @@ -1895,18 +1895,18 @@ record_mechanisms (DBusAuth *auth, if (auth->already_got_mechanisms) return TRUE; - + len = _dbus_string_get_length (args); - + next = 0; while (next < len) { DBusString m; const DBusAuthMechanismHandler *mech; - + if (!_dbus_string_init (&m)) goto nomem; - + if (!get_word (args, &next, &m)) { _dbus_string_free (&m); @@ -1930,7 +1930,7 @@ record_mechanisms (DBusAuth *auth, { _dbus_verbose ("%s: Adding mechanism %s to list we will try\n", DBUS_AUTH_NAME (auth), mech->mechanism); - + if (!_dbus_list_append (& DBUS_AUTH_CLIENT (auth)->mechs_to_try, (void*) mech)) { @@ -1953,14 +1953,14 @@ record_mechanisms (DBusAuth *auth, _dbus_string_free (&m); } - + auth->already_got_mechanisms = TRUE; - + return TRUE; nomem: _dbus_list_clear (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); - + return FALSE; } @@ -1977,7 +1977,7 @@ process_rejected (DBusAuth *auth, const DBusString *args) if (!record_mechanisms (auth, args)) return FALSE; } - + if (DBUS_AUTH_CLIENT (auth)->mechs_to_try != NULL) { mech = client->mechs_to_try->data; @@ -1998,7 +1998,7 @@ process_rejected (DBusAuth *auth, const DBusString *args) DBUS_AUTH_NAME (auth)); goto_state (auth, &common_state_need_disconnect); } - + return TRUE; } @@ -2009,7 +2009,7 @@ handle_client_state_waiting_for_data (DBusAuth *auth, const DBusString *args) { _dbus_assert (auth->mech != NULL); - + switch (command) { case DBUS_AUTH_COMMAND_DATA: @@ -2072,7 +2072,7 @@ handle_client_state_waiting_for_reject (DBusAuth *auth, { case DBUS_AUTH_COMMAND_REJECTED: return process_rejected (auth, args); - + case DBUS_AUTH_COMMAND_AUTH: case DBUS_AUTH_COMMAND_CANCEL: case DBUS_AUTH_COMMAND_DATA: @@ -2179,13 +2179,13 @@ process_command (DBusAuth *auth) dbus_bool_t retval; /* _dbus_verbose ("%s: trying process_command()\n"); */ - + retval = FALSE; - + eol = 0; if (!_dbus_string_find (&auth->incoming, 0, "\r\n", &eol)) return FALSE; - + if (!_dbus_string_init (&line)) { auth->needed_memory = TRUE; @@ -2198,7 +2198,7 @@ process_command (DBusAuth *auth) auth->needed_memory = TRUE; return FALSE; } - + if (!_dbus_string_copy_len (&auth->incoming, 0, eol, &line, 0)) goto out; @@ -2212,41 +2212,41 @@ process_command (DBusAuth *auth) else goto next_command; } - + _dbus_verbose ("%s: got command \"%s\"\n", DBUS_AUTH_NAME (auth), _dbus_string_get_const_data (&line)); - + _dbus_string_find_blank (&line, 0, &i); _dbus_string_skip_blank (&line, i, &j); if (j > i) _dbus_string_delete (&line, i, j - i); - + if (!_dbus_string_move (&line, i, &args, 0)) goto out; /* FIXME 1.0 we should probably validate that only the allowed * chars are in the command name */ - + command = lookup_command_from_name (&line); if (!(* auth->state->handler) (auth, command, &args)) goto out; next_command: - + /* We've succeeded in processing the whole command so drop it out * of the incoming buffer and return TRUE to try another command. */ _dbus_string_delete (&auth->incoming, 0, eol); - + /* kill the \r\n */ _dbus_string_delete (&auth->incoming, 0, 2); retval = TRUE; - + out: _dbus_string_free (&args); _dbus_string_free (&line); @@ -2255,7 +2255,7 @@ process_command (DBusAuth *auth) auth->needed_memory = TRUE; else auth->needed_memory = FALSE; - + return retval; } @@ -2296,20 +2296,20 @@ _dbus_auth_server_new (const DBusString *guid) _dbus_string_free (&guid_copy); return NULL; } - + auth->side = auth_side_server; auth->state = &server_state_waiting_for_auth; server_auth = DBUS_AUTH_SERVER (auth); server_auth->guid = guid_copy; - + /* perhaps this should be per-mechanism with a lower * max */ server_auth->failures = 0; server_auth->max_failures = 6; - + return auth; } @@ -2348,7 +2348,7 @@ _dbus_auth_client_new (void) _dbus_auth_unref (auth); return NULL; } - + return auth; } @@ -2362,9 +2362,9 @@ DBusAuth * _dbus_auth_ref (DBusAuth *auth) { _dbus_assert (auth != NULL); - + auth->refcount += 1; - + return auth; } @@ -2410,7 +2410,7 @@ _dbus_auth_unref (DBusAuth *auth) _dbus_credentials_unref (auth->credentials); _dbus_credentials_unref (auth->authorized_identity); _dbus_credentials_unref (auth->desired_identity); - + dbus_free (auth); } } @@ -2437,7 +2437,7 @@ _dbus_auth_set_mechanisms (DBusAuth *auth, } else copy = NULL; - + dbus_free_string_array (auth->allowed_mechs); auth->allowed_mechs = copy; @@ -2470,7 +2470,7 @@ _dbus_auth_do_work (DBusAuth *auth) { if (DBUS_AUTH_IN_END_STATE (auth)) break; - + if (_dbus_string_get_length (&auth->incoming) > MAX_BUFFER || _dbus_string_get_length (&auth->outgoing) > MAX_BUFFER) { @@ -2510,7 +2510,7 @@ _dbus_auth_get_bytes_to_send (DBusAuth *auth, _dbus_assert (str != NULL); *str = NULL; - + if (_dbus_string_get_length (&auth->outgoing) == 0) return FALSE; @@ -2535,7 +2535,7 @@ _dbus_auth_bytes_sent (DBusAuth *auth, DBUS_AUTH_NAME (auth), bytes_sent, _dbus_string_get_const_data (&auth->outgoing)); - + _dbus_string_delete (&auth->outgoing, 0, bytes_sent); } @@ -2553,7 +2553,7 @@ _dbus_auth_get_buffer (DBusAuth *auth, { _dbus_assert (auth != NULL); _dbus_assert (!auth->buffer_outstanding); - + *buffer = &auth->incoming; auth->buffer_outstanding = TRUE; @@ -2623,7 +2623,7 @@ _dbus_auth_needs_encoding (DBusAuth *auth) { if (auth->state != &common_state_authenticated) return FALSE; - + if (auth->mech != NULL) { if (DBUS_AUTH_IS_CLIENT (auth)) @@ -2651,10 +2651,10 @@ _dbus_auth_encode_data (DBusAuth *auth, DBusString *encoded) { _dbus_assert (plaintext != encoded); - + if (auth->state != &common_state_authenticated) return FALSE; - + if (_dbus_auth_needs_encoding (auth)) { if (DBUS_AUTH_IS_CLIENT (auth)) @@ -2682,7 +2682,7 @@ _dbus_auth_needs_decoding (DBusAuth *auth) { if (auth->state != &common_state_authenticated) return FALSE; - + if (auth->mech != NULL) { if (DBUS_AUTH_IS_CLIENT (auth)) @@ -2714,10 +2714,10 @@ _dbus_auth_decode_data (DBusAuth *auth, DBusString *plaintext) { _dbus_assert (plaintext != encoded); - + if (auth->state != &common_state_authenticated) return FALSE; - + if (_dbus_auth_needs_decoding (auth)) { if (DBUS_AUTH_IS_CLIENT (auth)) @@ -2786,7 +2786,7 @@ const char* _dbus_auth_get_guid_from_server (DBusAuth *auth) { _dbus_assert (DBUS_AUTH_IS_CLIENT (auth)); - + if (auth->state == &common_state_authenticated) return _dbus_string_get_const_data (& DBUS_AUTH_CLIENT (auth)->guid_from_server); else diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c index b58a283..bb39165 100644 --- a/dbus/dbus-marshal-recursive.c +++ b/dbus/dbus-marshal-recursive.c @@ -176,7 +176,7 @@ struct_or_dict_entry_types_only_reader_recurse (DBusTypeReader *sub, DBusTypeReader *parent) { base_reader_recurse (sub, parent); - + _dbus_assert (_dbus_string_get_byte (sub->type_str, sub->type_pos) == DBUS_STRUCT_BEGIN_CHAR || _dbus_string_get_byte (sub->type_str, @@ -293,7 +293,7 @@ variant_reader_recurse (DBusTypeReader *sub, contained_alignment = _dbus_type_get_alignment (_dbus_first_type_in_signature (sub->type_str, sub->type_pos)); - + sub->value_pos = _DBUS_ALIGN_VALUE (sub->value_pos, contained_alignment); #if RECURSIVE_MARSHAL_READ_TRACE @@ -346,19 +346,19 @@ _dbus_type_signature_next (const char *type_str, _dbus_assert (type_str != NULL); _dbus_assert (type_pos != NULL); - + start = (const unsigned char *)type_str; p = start + *type_pos; _dbus_assert (*p != DBUS_STRUCT_END_CHAR); _dbus_assert (*p != DBUS_DICT_ENTRY_END_CHAR); - + while (*p == DBUS_TYPE_ARRAY) ++p; _dbus_assert (*p != DBUS_STRUCT_END_CHAR); _dbus_assert (*p != DBUS_DICT_ENTRY_END_CHAR); - + if (*p == DBUS_STRUCT_BEGIN_CHAR) { int depth; @@ -799,7 +799,7 @@ _dbus_type_reader_get_current_type (const DBusTypeReader *reader) _dbus_assert (t != DBUS_STRUCT_BEGIN_CHAR); _dbus_assert (t != DBUS_DICT_ENTRY_END_CHAR); _dbus_assert (t != DBUS_DICT_ENTRY_BEGIN_CHAR); - + #if 0 _dbus_verbose (" type reader %p current type_pos = %d type = %s\n", reader, reader->type_pos, @@ -1674,7 +1674,7 @@ writer_recurse_init_and_check (DBusTypeWriter *writer, "The overall signature expected here was '%s' and we are on byte %d of that signature.\n", _dbus_type_to_string (sub->container_type), _dbus_string_get_const_data (writer->type_str), writer->type_pos); - + _dbus_assert_not_reached ("bad array element or variant content written"); } } @@ -1988,7 +1988,7 @@ writer_recurse_variant (DBusTypeWriter *writer, DBusTypeWriter *sub) { int contained_alignment; - + if (writer->enabled) { /* Allocate space for the worst case, which is 1 byte sig @@ -2040,7 +2040,7 @@ writer_recurse_variant (DBusTypeWriter *writer, sub->value_pos += 1; contained_alignment = _dbus_type_get_alignment (_dbus_first_type_in_signature (contained_type, contained_type_start)); - + if (!_dbus_string_insert_bytes (sub->value_str, sub->value_pos, _DBUS_ALIGN_VALUE (sub->value_pos, contained_alignment) - sub->value_pos, diff --git a/dbus/dbus-shell.c b/dbus/dbus-shell.c index 2384961..de7c21b 100644 --- a/dbus/dbus-shell.c +++ b/dbus/dbus-shell.c @@ -45,11 +45,11 @@ unquote_string_inplace (char* str, char** end) char* dest; char* s; char quote_char; - + dest = s = str; quote_char = *s; - + if (!(*s == '"' || *s == '\'')) { *end = str; @@ -64,7 +64,7 @@ unquote_string_inplace (char* str, char** end) while (*s) { _dbus_assert(s > dest); /* loop invariant */ - + switch (*s) { case '"': @@ -113,7 +113,7 @@ unquote_string_inplace (char* str, char** end) while (*s) { _dbus_assert(s > dest); /* loop invariant */ - + if (*s == '\'') { /* End of the string, return now */ @@ -132,16 +132,16 @@ unquote_string_inplace (char* str, char** end) _dbus_assert(s > dest); /* loop invariant */ } } - + /* If we reach here this means the close quote was never encountered */ *dest = '\0'; - + *end = s; return FALSE; } -/** +/** * Unquotes a string as the shell (/bin/sh) would. Only handles * quotes; if a string contains file globs, arithmetic operators, * variables, backticks, redirections, or other special-to-the-shell @@ -155,7 +155,7 @@ unquote_string_inplace (char* str, char** end) * unquotes/unescapes anything that the shell would. Both single and * double quotes are handled, as are escapes including escaped * newlines. The return value must be freed with dbus_free(). - * + * * Shell quoting rules are a bit strange. Single quotes preserve the * literal string exactly. escape sequences are not allowed; not even * \' - if you want a ' in the quoted text, you have to do something @@ -193,7 +193,7 @@ _dbus_shell_unquote (const char *quoted_string) { /* Append all non-quoted chars, honoring backslash escape */ - + while (*start && !(*start == '"' || *start == '\'')) { if (*start == '\\') @@ -202,7 +202,7 @@ _dbus_shell_unquote (const char *quoted_string) * except newline, which is removed if it follows * a backslash outside of quotes */ - + ++start; if (*start) { @@ -241,9 +241,9 @@ _dbus_shell_unquote (const char *quoted_string) dbus_free (unquoted); _dbus_string_free (&retval); - + return ret; - + error: dbus_free (unquoted); _dbus_string_free (&retval); @@ -270,7 +270,7 @@ _dbus_shell_unquote (const char *quoted_string) * * Tokenization steps, from UNIX98 with operator stuff removed, * are: - * + * * 1) "If the current character is backslash, single-quote or * double-quote (\, ' or ") and it is not quoted, it will affect * quoting for subsequent characters up to the end of the quoted @@ -372,7 +372,7 @@ tokenize_command_line (const char *command_line, DBusError *error) } else { - if (!_dbus_string_append_byte (¤t_token, '\\') || + if (!_dbus_string_append_byte (¤t_token, '\\') || !_dbus_string_append_byte (¤t_token, *p)) { _DBUS_SET_OOM (error); @@ -389,7 +389,7 @@ tokenize_command_line (const char *command_line, DBusError *error) ++p; current_quote = '\0'; - + if (*p == '\0') break; } @@ -451,7 +451,7 @@ tokenize_command_line (const char *command_line, DBusError *error) } } - + /* discard all unquoted blanks (don't add them to a token) */ break; @@ -460,7 +460,7 @@ tokenize_command_line (const char *command_line, DBusError *error) * escapes are maybe appended next time through the loop, * comment chars are never appended. */ - + case '\'': case '"': if (!_dbus_string_append_byte (¤t_token, *p)) @@ -470,7 +470,7 @@ tokenize_command_line (const char *command_line, DBusError *error) } /* FALL THRU */ - + case '#': case '\\': current_quote = *p; @@ -489,7 +489,7 @@ tokenize_command_line (const char *command_line, DBusError *error) } } - /* We need to count consecutive backslashes mod 2, + /* We need to count consecutive backslashes mod 2, * to detect escaped doublequotes. */ if (*p != '\\') @@ -514,9 +514,9 @@ tokenize_command_line (const char *command_line, DBusError *error) dbus_set_error_const (error, DBUS_ERROR_INVALID_ARGS, "No tokens found in command line"); goto error; } - + _dbus_string_free (¤t_token); - + return retval; error: @@ -534,7 +534,7 @@ tokenize_command_line (const char *command_line, DBusError *error) /** * _dbus_shell_parse_argv: - * + * * Parses a command line into an argument vector, in much the same way * the shell would, but without many of the expansions the shell would * perform (variable expansion, globs, operators, filename expansion, @@ -543,7 +543,7 @@ tokenize_command_line (const char *command_line, DBusError *error) * contains none of the unsupported shell expansions. If the input * does contain such expansions, they are passed through * literally. Free the returned vector with dbus_free_string_array(). - * + * * @param command_line command line to parse * @param argcp return location for number of args * @param argvp return location for array of args @@ -561,7 +561,7 @@ _dbus_shell_parse_argv (const char *command_line, DBusList *tokens = NULL; int i; DBusList *tmp_list; - + if (!command_line) { _dbus_verbose ("Command line is NULL\n"); @@ -583,7 +583,7 @@ _dbus_shell_parse_argv (const char *command_line, * remove any zero-length words that didn't contain quotes * originally; but since there's no expansion we know all words have * nonzero length, unless they contain quotes. - * + * * So, we simply remove quotes, and don't do any field splitting or * empty word removal, since we know there was no way to introduce * such things. @@ -618,10 +618,10 @@ _dbus_shell_parse_argv (const char *command_line, ++i; } argv[argc] = NULL; - + _dbus_list_foreach (&tokens, (DBusForeachFunction) dbus_free, NULL); _dbus_list_clear (&tokens); - + if (argcp) *argcp = argc; diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 31586b1..f573646 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -4,7 +4,7 @@ * Copyright (C) 2002, 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 @@ -44,7 +44,7 @@ * Types and functions related to DBusTransport. A transport is an * abstraction that can send and receive data via various kinds of * network connections or other IPC mechanisms. - * + * * @{ */ @@ -109,11 +109,11 @@ _dbus_transport_init_base (DBusTransport *transport, DBusCounter *counter; char *address_copy; DBusCredentials *creds; - + loader = _dbus_message_loader_new (); if (loader == NULL) return FALSE; - + if (server_guid) auth = _dbus_auth_server_new (server_guid); else @@ -130,7 +130,7 @@ _dbus_transport_init_base (DBusTransport *transport, _dbus_auth_unref (auth); _dbus_message_loader_unref (loader); return FALSE; - } + } creds = _dbus_credentials_new (); if (creds == NULL) @@ -140,7 +140,7 @@ _dbus_transport_init_base (DBusTransport *transport, _dbus_message_loader_unref (loader); return FALSE; } - + if (server_guid) { _dbus_assert (address == NULL); @@ -159,7 +159,7 @@ _dbus_transport_init_base (DBusTransport *transport, return FALSE; } } - + transport->refcount = 1; transport->vtable = vtable; transport->loader = loader; @@ -171,7 +171,7 @@ _dbus_transport_init_base (DBusTransport *transport, transport->send_credentials_pending = !transport->is_server; transport->receive_credentials_pending = transport->is_server; transport->address = address_copy; - + transport->unix_user_function = NULL; transport->unix_user_data = NULL; transport->free_unix_user_data = NULL; @@ -179,9 +179,9 @@ _dbus_transport_init_base (DBusTransport *transport, transport->windows_user_function = NULL; transport->windows_user_data = NULL; transport->free_windows_user_data = NULL; - + transport->expected_guid = NULL; - + /* Try to default to something that won't totally hose the system, * but doesn't impose too much of a limitation. */ @@ -223,7 +223,7 @@ _dbus_transport_finalize_base (DBusTransport *transport) if (transport->free_windows_user_data != NULL) (* transport->free_windows_user_data) (transport->windows_user_data); - + _dbus_message_loader_unref (transport->loader); _dbus_auth_unref (transport->auth); _dbus_counter_set_notify (transport->live_messages, @@ -314,7 +314,7 @@ _dbus_transport_open_autolaunch (DBusAddressEntry *entry, DBusError *error) { const char *method; - + method = dbus_address_entry_get_method (entry); _dbus_assert (method != NULL); @@ -333,7 +333,7 @@ _dbus_transport_open_autolaunch (DBusAddressEntry *entry, { _DBUS_ASSERT_ERROR_IS_CLEAR (error); return DBUS_TRANSPORT_OPEN_OK; - } + } } else { @@ -358,7 +358,7 @@ static const struct { /** * Try to open a new transport for the given address entry. (This * opens a client-side-of-the-connection transport.) - * + * * @param entry the address entry * @param error location to store reason for failure. * @returns new transport of #NULL on failure. @@ -374,7 +374,7 @@ _dbus_transport_open (DBusAddressEntry *entry, DBusError tmp_error = DBUS_ERROR_INIT; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - + transport = NULL; expected_guid_orig = dbus_address_entry_get_value (entry, "guid"); expected_guid = _dbus_strdup (expected_guid_orig); @@ -414,14 +414,14 @@ _dbus_transport_open (DBusAddressEntry *entry, } out: - + if (transport == NULL) { if (!dbus_error_is_set (&tmp_error)) _dbus_set_bad_address (&tmp_error, NULL, NULL, "Unknown address type (examples of valid types are \"tcp\" and on UNIX \"unix\")"); - + _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); dbus_move_error(&tmp_error, error); dbus_free (expected_guid); @@ -436,11 +436,11 @@ _dbus_transport_open (DBusAddressEntry *entry, * with a guid. That guid is the definitive one. * * FIXME: if more transports are added they may have - * an effect on the expected_guid semantics (i.e. + * an effect on the expected_guid semantics (i.e. * expected_guid and transport->expected_guid may * both have values). This is very unlikely though - * we should either throw asserts here for those - * corner cases or refactor the code so it is + * we should either throw asserts here for those + * corner cases or refactor the code so it is * clearer on what is expected and what is not */ if(expected_guid) @@ -460,7 +460,7 @@ DBusTransport * _dbus_transport_ref (DBusTransport *transport) { _dbus_assert (transport->refcount > 0); - + transport->refcount += 1; return transport; @@ -478,14 +478,14 @@ _dbus_transport_unref (DBusTransport *transport) { _dbus_assert (transport != NULL); _dbus_assert (transport->refcount > 0); - + transport->refcount -= 1; if (transport->refcount == 0) { _dbus_verbose ("finalizing\n"); - + _dbus_assert (transport->vtable->finalize != NULL); - + (* transport->vtable->finalize) (transport); } } @@ -496,20 +496,20 @@ _dbus_transport_unref (DBusTransport *transport) * _dbus_transport_disconnect() will have an effect. * * @param transport the transport. - * + * */ void _dbus_transport_disconnect (DBusTransport *transport) { _dbus_verbose ("start\n"); - + _dbus_assert (transport->vtable->disconnect != NULL); - + if (transport->disconnected) return; (* transport->vtable->disconnect) (transport); - + transport->disconnected = TRUE; _dbus_verbose ("end\n"); @@ -540,7 +540,7 @@ auth_via_unix_user_function (DBusTransport *transport) dbus_uid_t uid; /* Dropping the lock here probably isn't that safe. */ - + auth_identity = _dbus_auth_get_identity (transport->auth); _dbus_assert (auth_identity != NULL); @@ -548,14 +548,14 @@ auth_via_unix_user_function (DBusTransport *transport) unix_user_function = transport->unix_user_function; unix_user_data = transport->unix_user_data; uid = _dbus_credentials_get_unix_uid (auth_identity); - + _dbus_verbose ("unlock\n"); _dbus_connection_unlock (connection); allow = (* unix_user_function) (connection, uid, unix_user_data); - + _dbus_verbose ("lock post unix user function\n"); _dbus_connection_lock (connection); @@ -577,7 +577,7 @@ auth_via_unix_user_function (DBusTransport *transport) static dbus_bool_t auth_via_windows_user_function (DBusTransport *transport) { - DBusCredentials *auth_identity; + DBusCredentials *auth_identity; dbus_bool_t allow; DBusConnection *connection; DBusAllowWindowsUserFunction windows_user_function; @@ -585,7 +585,7 @@ auth_via_windows_user_function (DBusTransport *transport) char *windows_sid; /* Dropping the lock here probably isn't that safe. */ - + auth_identity = _dbus_auth_get_identity (transport->auth); _dbus_assert (auth_identity != NULL); @@ -599,14 +599,14 @@ auth_via_windows_user_function (DBusTransport *transport) /* OOM */ return FALSE; } - + _dbus_verbose ("unlock\n"); _dbus_connection_unlock (connection); allow = (* windows_user_function) (connection, windows_sid, windows_user_data); - + _dbus_verbose ("lock post windows user function\n"); _dbus_connection_lock (connection); @@ -630,21 +630,21 @@ auth_via_default_rules (DBusTransport *transport) DBusCredentials *auth_identity; DBusCredentials *our_identity; dbus_bool_t allow; - + auth_identity = _dbus_auth_get_identity (transport->auth); _dbus_assert (auth_identity != NULL); /* By default, connection is allowed if the client is 1) root or 2) * has the same UID as us or 3) anonymous is allowed. */ - + our_identity = _dbus_credentials_new_from_current_process (); if (our_identity == NULL) { /* OOM */ return FALSE; } - + if (transport->allow_anonymous || _dbus_credentials_get_unix_uid (auth_identity) == 0 || _dbus_credentials_same_user (our_identity, @@ -679,10 +679,10 @@ auth_via_default_rules (DBusTransport *transport) _dbus_credentials_get_unix_uid(our_identity)); _dbus_transport_disconnect (transport); allow = FALSE; - } + } _dbus_credentials_unref (our_identity); - + return allow; } @@ -722,19 +722,19 @@ _dbus_transport_peek_is_authenticated (DBusTransport *transport) */ dbus_bool_t _dbus_transport_try_to_authenticate (DBusTransport *transport) -{ +{ if (transport->authenticated) return TRUE; else { dbus_bool_t maybe_authenticated; - + if (transport->disconnected) return FALSE; /* paranoia ref since we call user callbacks sometimes */ _dbus_connection_ref_unlocked (transport->connection); - + maybe_authenticated = (!(transport->send_credentials_pending || transport->receive_credentials_pending)); @@ -777,10 +777,10 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) { dbus_bool_t allow; DBusCredentials *auth_identity; - + auth_identity = _dbus_auth_get_identity (transport->auth); _dbus_assert (auth_identity != NULL); - + /* If we have an auth'd user and a user function, delegate * deciding whether auth credentials are good enough to the * app; otherwise, use our default decision process. @@ -794,12 +794,12 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_WINDOWS_SID)) { allow = auth_via_windows_user_function (transport); - } + } else { allow = auth_via_default_rules (transport); } - + if (!allow) maybe_authenticated = FALSE; } @@ -821,10 +821,10 @@ dbus_bool_t _dbus_transport_get_is_anonymous (DBusTransport *transport) { DBusCredentials *auth_identity; - + if (!transport->authenticated) return TRUE; - + auth_identity = _dbus_auth_get_identity (transport->auth); if (_dbus_credentials_are_anonymous (auth_identity)) @@ -891,7 +891,7 @@ _dbus_transport_handle_watch (DBusTransport *transport, unsigned int condition) { dbus_bool_t retval; - + _dbus_assert (transport->vtable->handle_watch != NULL); if (transport->disconnected) @@ -902,7 +902,7 @@ _dbus_transport_handle_watch (DBusTransport *transport, _dbus_warn_check_failed ("Tried to handle an invalidated watch; this watch should have been removed\n"); return TRUE; } - + _dbus_watch_sanitize_condition (watch, &condition); _dbus_transport_ref (transport); @@ -929,7 +929,7 @@ _dbus_transport_set_connection (DBusTransport *transport, { _dbus_assert (transport->vtable->connection_set != NULL); _dbus_assert (transport->connection == NULL); - + transport->connection = connection; _dbus_transport_ref (transport); @@ -952,7 +952,7 @@ _dbus_transport_get_socket_fd (DBusTransport *transport, DBusSocket *fd_p) { dbus_bool_t retval; - + if (transport->vtable->get_socket_fd == NULL) return FALSE; @@ -963,7 +963,7 @@ _dbus_transport_get_socket_fd (DBusTransport *transport, retval = (* transport->vtable->get_socket_fd) (transport, fd_p); - + _dbus_transport_unref (transport); return retval; @@ -989,7 +989,7 @@ _dbus_transport_do_iteration (DBusTransport *transport, _dbus_verbose ("Transport iteration flags 0x%x timeout %d connected = %d\n", flags, timeout_milliseconds, !transport->disconnected); - + if ((flags & (DBUS_ITERATION_DO_WRITING | DBUS_ITERATION_DO_READING)) == 0) return; /* Nothing to do */ @@ -1014,10 +1014,10 @@ recover_unused_bytes (DBusTransport *transport) const DBusString *encoded; DBusString *buffer; int orig_len; - + if (!_dbus_string_init (&plaintext)) goto nomem; - + _dbus_auth_get_unused_bytes (transport->auth, &encoded); @@ -1027,28 +1027,28 @@ recover_unused_bytes (DBusTransport *transport) _dbus_string_free (&plaintext); goto nomem; } - + _dbus_message_loader_get_buffer (transport->loader, &buffer); - + orig_len = _dbus_string_get_length (buffer); - + if (!_dbus_string_move (&plaintext, 0, buffer, orig_len)) { _dbus_string_free (&plaintext); goto nomem; } - - _dbus_verbose (" %d unused bytes sent to message loader\n", + + _dbus_verbose (" %d unused bytes sent to message loader\n", _dbus_string_get_length (buffer) - orig_len); - + _dbus_message_loader_return_buffer (transport->loader, buffer); _dbus_auth_delete_unused_bytes (transport->auth); - + _dbus_string_free (&plaintext); } else @@ -1060,20 +1060,20 @@ recover_unused_bytes (DBusTransport *transport) _dbus_message_loader_get_buffer (transport->loader, &buffer); - + orig_len = _dbus_string_get_length (buffer); - + _dbus_auth_get_unused_bytes (transport->auth, &bytes); succeeded = TRUE; if (!_dbus_string_copy (bytes, 0, buffer, _dbus_string_get_length (buffer))) succeeded = FALSE; - - _dbus_verbose (" %d unused bytes sent to message loader\n", + + _dbus_verbose (" %d unused bytes sent to message loader\n", _dbus_string_get_length (buffer) - orig_len); - + _dbus_message_loader_return_buffer (transport->loader, buffer); @@ -1118,7 +1118,7 @@ _dbus_transport_get_dispatch_status (DBusTransport *transport) return DBUS_DISPATCH_NEED_MEMORY; transport->unused_bytes_recovered = TRUE; - + if (!_dbus_message_loader_queue_messages (transport->loader)) return DBUS_DISPATCH_NEED_MEMORY; @@ -1144,7 +1144,7 @@ _dbus_transport_queue_messages (DBusTransport *transport) #if 0 _dbus_verbose ("_dbus_transport_queue_messages()\n"); #endif - + /* Queue any messages */ while ((status = _dbus_transport_get_dispatch_status (transport)) == DBUS_DISPATCH_DATA_REMAINS) { @@ -1153,9 +1153,9 @@ _dbus_transport_queue_messages (DBusTransport *transport) link = _dbus_message_loader_pop_message_link (transport->loader); _dbus_assert (link != NULL); - + message = link->data; - + _dbus_verbose ("queueing received message %p\n", message); if (!_dbus_message_add_counter (message, transport->live_messages)) @@ -1316,10 +1316,10 @@ _dbus_transport_get_unix_user (DBusTransport *transport, * case of bugs in the caller. Caller should * never use this value on purpose, however. */ - + if (!transport->authenticated) return FALSE; - + auth_identity = _dbus_auth_get_identity (transport->auth); if (_dbus_credentials_include (auth_identity, @@ -1349,10 +1349,10 @@ _dbus_transport_get_unix_process_id (DBusTransport *transport, * but we set it to a safe number, INT_MAX, * just to root out possible bugs in bad callers. */ - + if (!transport->authenticated) return FALSE; - + auth_identity = _dbus_auth_get_identity (transport->auth); if (_dbus_credentials_include (auth_identity, @@ -1369,7 +1369,7 @@ _dbus_transport_get_unix_process_id (DBusTransport *transport, * See dbus_connection_get_adt_audit_session_data(). * * @param transport the transport - * @param data return location for the ADT audit data + * @param data return location for the ADT audit data * @param data_size return length of audit data * @returns #TRUE if audit data is filled in with a valid ucred */ @@ -1382,10 +1382,10 @@ _dbus_transport_get_adt_audit_session_data (DBusTransport *transport, *data = NULL; *data_size = 0; - + if (!transport->authenticated) return FALSE; - + auth_identity = _dbus_auth_get_identity (transport->auth); if (_dbus_credentials_include (auth_identity, @@ -1416,7 +1416,7 @@ _dbus_transport_set_unix_user_function (DBusTransport *transport, DBusFreeFunction free_data_function, void **old_data, DBusFreeFunction *old_free_data_function) -{ +{ *old_data = transport->unix_user_data; *old_free_data_function = transport->free_unix_user_data; @@ -1466,10 +1466,10 @@ _dbus_transport_get_windows_user (DBusTransport *transport, DBusCredentials *auth_identity; *windows_sid_p = NULL; - + if (!transport->authenticated) return FALSE; - + auth_identity = _dbus_auth_get_identity (transport->auth); if (_dbus_credentials_include (auth_identity, diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index afc1d91..3d388fb 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -5,7 +5,7 @@ * Copyright (C) 2006 Thiago Macieira * * 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 @@ -15,7 +15,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 @@ -140,14 +140,14 @@ verbose (const char *format, va_list args; static int verbose = TRUE; static int verbose_initted = FALSE; - + /* things are written a bit oddly here so that * in the non-verbose case we just have the one * conditional and return immediately. */ if (!verbose) return; - + if (!verbose_initted) { verbose = getenv ("DBUS_VERBOSE") != NULL; @@ -157,7 +157,7 @@ verbose (const char *format, } fprintf (stderr, "%lu: ", (unsigned long) getpid ()); - + va_start (args, format); vfprintf (stderr, format, args); va_end (args); @@ -190,10 +190,10 @@ xstrdup (const char *str) { int len; char *copy; - + if (str == NULL) return NULL; - + len = strlen (str); copy = malloc (len + 1); @@ -201,7 +201,7 @@ xstrdup (const char *str) return NULL; memcpy (copy, str, len + 1); - + return copy; } @@ -242,26 +242,26 @@ read_line (int fd, memset (buf, '\0', maxlen); maxlen -= 1; /* ensure nul term */ - + retval = READ_STATUS_OK; - + while (TRUE) { - ssize_t chunk; + ssize_t chunk; size_t to_read; - + again: to_read = maxlen - bytes; if (to_read == 0) break; - + chunk = read (fd, buf + bytes, to_read); if (chunk < 0 && errno == EINTR) goto again; - + if (chunk < 0) { retval = READ_STATUS_ERROR; @@ -279,13 +279,13 @@ read_line (int fd, if (retval == READ_STATUS_EOF && bytes > 0) retval = READ_STATUS_OK; - + /* whack newline */ if (retval != READ_STATUS_ERROR && bytes > 0 && buf[bytes-1] == '\n') buf[bytes-1] = '\0'; - + return retval; } @@ -297,24 +297,24 @@ read_pid (int fd, ReadStatus retval; retval = READ_STATUS_OK; - + while (TRUE) { - ssize_t chunk; + ssize_t chunk; size_t to_read; - + again: to_read = sizeof (pid_t) - bytes; if (to_read == 0) break; - + chunk = read (fd, ((char*)buf) + bytes, to_read); if (chunk < 0 && errno == EINTR) goto again; - + if (chunk < 0) { retval = READ_STATUS_ERROR; @@ -337,11 +337,11 @@ do_write (int fd, const void *buf, size_t count) { size_t bytes_written; int ret; - + bytes_written = 0; - + again: - + ret = write (fd, ((const char*)buf) + bytes_written, count - bytes_written); if (ret < 0) @@ -357,7 +357,7 @@ do_write (int fd, const void *buf, size_t count) } else bytes_written += ret; - + if (bytes_written < count) goto again; } @@ -373,7 +373,7 @@ static int do_waitpid (pid_t pid) { int ret; - + again: ret = waitpid (pid, NULL, 0); @@ -425,7 +425,7 @@ print_variables (const char *bus_address, pid_t bus_pid, long bus_wid, } else if (c_shell_syntax) { - printf ("setenv DBUS_SESSION_BUS_ADDRESS '%s';\n", bus_address); + printf ("setenv DBUS_SESSION_BUS_ADDRESS '%s';\n", bus_address); if (bus_pid) printf ("set DBUS_SESSION_BUS_PID=%ld;\n", (long) bus_pid); if (bus_wid) @@ -477,7 +477,7 @@ kill_bus_when_session_ends (void) fd_set err_set; struct sigaction act; sigset_t empty_mask; - + /* install SIGHUP handler */ got_sighup = FALSE; sigemptyset (&empty_mask); @@ -487,7 +487,7 @@ kill_bus_when_session_ends (void) sigaction (SIGHUP, &act, NULL); sigaction (SIGTERM, &act, NULL); sigaction (SIGINT, &act, NULL); - + #ifdef DBUS_BUILD_X11 x11_init(); if (xdisplay != NULL) @@ -524,7 +524,7 @@ kill_bus_when_session_ends (void) fprintf (stderr, "No terminal on standard input and no X display; cannot attach message bus to session lifetime\n"); kill_bus_and_exit (1); } - + while (TRUE) { #ifdef DBUS_BUILD_X11 @@ -537,7 +537,7 @@ kill_bus_when_session_ends (void) */ x11_handle_event (); #endif - + FD_ZERO (&read_set); FD_ZERO (&err_set); @@ -561,7 +561,7 @@ kill_bus_when_session_ends (void) verbose ("Got SIGHUP, exiting\n"); kill_bus_and_exit (0); } - + #ifdef DBUS_BUILD_X11 /* Events will be processed before we select again */ @@ -579,12 +579,12 @@ kill_bus_when_session_ends (void) char discard[512]; verbose ("TTY ready for reading\n"); - + bytes_read = read (tty_fd, discard, sizeof (discard)); verbose ("Read %d bytes from TTY errno = %d\n", bytes_read, errno); - + if (bytes_read == 0) kill_bus_and_exit (0); /* EOF */ else if (bytes_read < 0 && errno != EINTR) @@ -600,7 +600,7 @@ kill_bus_when_session_ends (void) else if (FD_ISSET (tty_fd, &err_set)) { verbose ("TTY has error condition\n"); - + kill_bus_and_exit (0); } } @@ -618,7 +618,7 @@ babysit (int exit_with_session, verbose ("babysitting, exit_with_session = %d, child_pid = %ld, read_bus_pid_fd = %d\n", exit_with_session, (long) child_pid, read_bus_pid_fd); - + /* We chdir ("/") since we are persistent and daemon-like, and fork * again so dbus-launch can reap the parent. However, we don't * setsid() or close fd 0 because the idea is to remain attached @@ -669,7 +669,7 @@ babysit (int exit_with_session, */ verbose ("=== Babysitter's intermediate parent continues again\n"); - + if (do_waitpid (child_pid) < 0) { /* shouldn't happen */ @@ -678,7 +678,7 @@ babysit (int exit_with_session, } verbose ("Babysitter's intermediate parent exiting\n"); - + exit (0); } @@ -686,7 +686,7 @@ babysit (int exit_with_session, verbose ("=== Babysitter process created\n"); verbose ("Reading PID from bus\n"); - + switch (read_pid (read_bus_pid_fd, &bus_pid_to_kill)) { case READ_STATUS_OK: @@ -704,19 +704,19 @@ babysit (int exit_with_session, verbose ("Got PID %ld from daemon\n", (long) bus_pid_to_kill); - + if (exit_with_session) { /* Bus is now started and launcher has needed info; * we connect to X display and tty and wait to * kill bus if requested. */ - + kill_bus_when_session_ends (); } verbose ("Babysitter exiting\n"); - + exit (0); } @@ -853,7 +853,7 @@ main (int argc, char **argv) while (i < argc) { const char *arg = argv[i]; - + if (strcmp (arg, "--help") == 0 || strcmp (arg, "-h") == 0 || strcmp (arg, "-?") == 0) @@ -885,7 +885,7 @@ main (int argc, char **argv) fprintf (stderr, "--autolaunch given twice\n"); exit (1); } - + autolaunch = TRUE; s = strchr (arg, '='); @@ -901,7 +901,7 @@ main (int argc, char **argv) fprintf (stderr, "--autolaunch given twice\n"); exit (1); } - + autolaunch = TRUE; save_machine_uuid (arg); @@ -918,7 +918,7 @@ main (int argc, char **argv) fprintf (stderr, "--config-file given twice\n"); exit (1); } - + file = strchr (arg, '='); ++file; @@ -958,9 +958,9 @@ main (int argc, char **argv) remaining_args = i+1; break; } - + prev_arg = arg; - + ++i; } if (requires_arg) @@ -980,7 +980,7 @@ main (int argc, char **argv) } else bourne_shell_syntax = TRUE; - } + } if (exit_with_session) verbose ("--exit-with-session enabled\n"); @@ -989,7 +989,7 @@ main (int argc, char **argv) verbose ("--exit-with-x11 enabled\n"); if (autolaunch) - { + { #ifndef DBUS_BUILD_X11 fprintf (stderr, "Autolaunch requested, but X11 support not compiled in.\n" "Cannot continue.\n"); @@ -1003,7 +1003,7 @@ main (int argc, char **argv) pid_t pid; long wid; DBusError error = DBUS_ERROR_INIT; - + if (get_machine_uuid () == NULL) { fprintf (stderr, "Machine UUID not provided as arg to --autolaunch\n"); @@ -1132,7 +1132,7 @@ main (int argc, char **argv) verbose ("=== Babysitter's intermediate parent created\n"); /* Fork once more to create babysitter */ - + ret = fork (); if (ret < 0) { @@ -1140,12 +1140,12 @@ main (int argc, char **argv) strerror (errno)); exit (1); } - + if (ret > 0) { /* In babysitter */ verbose ("=== Babysitter's intermediate parent continues\n"); - + close (bus_pid_to_launcher_pipe[READ_END]); close (bus_pid_to_launcher_pipe[WRITE_END]); close (bus_address_to_launcher_pipe[READ_END]); @@ -1162,7 +1162,7 @@ main (int argc, char **argv) } verbose ("=== Bus exec process created\n"); - + /* Now we are the bus process (well, almost; * dbus-daemon itself forks again) */ @@ -1194,7 +1194,7 @@ main (int argc, char **argv) "%d", bus_address_to_launcher_pipe[WRITE_END]); verbose ("Calling exec()\n"); - + #ifdef DBUS_ENABLE_EMBEDDED_TESTS { /* exec from testdir */ @@ -1243,7 +1243,7 @@ main (int argc, char **argv) fprintf (stderr, "Failed to execute message bus daemon %s: %s. Will try again without full path.\n", DBUS_DAEMONDIR"/dbus-daemon", strerror (errno)); - + /* * If it failed, try running without full PATH. Note this is needed * because the build process builds the run-with-tmp-session-bus.conf @@ -1268,7 +1268,7 @@ main (int argc, char **argv) { /* Parent */ #define MAX_PID_LEN 64 - pid_t bus_pid; + pid_t bus_pid; char bus_address[MAX_ADDR_LEN]; char buf[MAX_PID_LEN]; char *end; @@ -1276,13 +1276,13 @@ main (int argc, char **argv) long val; verbose ("=== Parent dbus-launch continues\n"); - + close (bus_pid_to_launcher_pipe[WRITE_END]); close (bus_address_to_launcher_pipe[WRITE_END]); close (bus_pid_to_babysitter_pipe[READ_END]); verbose ("Waiting for babysitter's intermediate parent\n"); - + /* Immediately reap parent of babysitter * (which was created just for us to reap) */ @@ -1294,7 +1294,7 @@ main (int argc, char **argv) } verbose ("Reading address from bus\n"); - + /* Read the pipe data, print, and exit */ switch (read_line (bus_address_to_launcher_pipe[READ_END], bus_address, MAX_ADDR_LEN)) @@ -1311,7 +1311,7 @@ main (int argc, char **argv) exit (1); break; } - + close (bus_address_to_launcher_pipe[READ_END]); verbose ("Reading PID from daemon\n"); -- 2.7.4