00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "dbus-transport-protected.h"
00025 #include "dbus-transport-unix.h"
00026 #include "dbus-connection-internal.h"
00027 #include "dbus-watch.h"
00028 #include "dbus-auth.h"
00029 #include "dbus-address.h"
00030 #ifdef DBUS_BUILD_TESTS
00031 #include "dbus-server-debug-pipe.h"
00032 #endif
00033
00055 static void
00056 live_messages_size_notify (DBusCounter *counter,
00057 void *user_data)
00058 {
00059 DBusTransport *transport = user_data;
00060
00061 _dbus_transport_ref (transport);
00062
00063 #if 0
00064 _dbus_verbose ("Counter value is now %d\n",
00065 (int) _dbus_counter_get_value (counter));
00066 #endif
00067
00068
00069
00070
00071 if (* transport->vtable->live_messages_changed)
00072 (* transport->vtable->live_messages_changed) (transport);
00073
00074 _dbus_transport_unref (transport);
00075 }
00076
00087 dbus_bool_t
00088 _dbus_transport_init_base (DBusTransport *transport,
00089 const DBusTransportVTable *vtable,
00090 dbus_bool_t server,
00091 const DBusString *address)
00092 {
00093 DBusMessageLoader *loader;
00094 DBusAuth *auth;
00095 DBusCounter *counter;
00096 char *address_copy;
00097
00098 loader = _dbus_message_loader_new ();
00099 if (loader == NULL)
00100 return FALSE;
00101
00102 if (server)
00103 auth = _dbus_auth_server_new ();
00104 else
00105 auth = _dbus_auth_client_new ();
00106 if (auth == NULL)
00107 {
00108 _dbus_message_loader_unref (loader);
00109 return FALSE;
00110 }
00111
00112 counter = _dbus_counter_new ();
00113 if (counter == NULL)
00114 {
00115 _dbus_auth_unref (auth);
00116 _dbus_message_loader_unref (loader);
00117 return FALSE;
00118 }
00119
00120 if (server)
00121 {
00122 _dbus_assert (address == NULL);
00123 address_copy = NULL;
00124 }
00125 else
00126 {
00127 _dbus_assert (address != NULL);
00128
00129 if (!_dbus_string_copy_data (address, &address_copy))
00130 {
00131 _dbus_counter_unref (counter);
00132 _dbus_auth_unref (auth);
00133 _dbus_message_loader_unref (loader);
00134 return FALSE;
00135 }
00136 }
00137
00138 transport->refcount = 1;
00139 transport->vtable = vtable;
00140 transport->loader = loader;
00141 transport->auth = auth;
00142 transport->live_messages_size = counter;
00143 transport->authenticated = FALSE;
00144 transport->disconnected = FALSE;
00145 transport->send_credentials_pending = !server;
00146 transport->receive_credentials_pending = server;
00147 transport->is_server = server;
00148 transport->address = address_copy;
00149
00150 transport->unix_user_function = NULL;
00151 transport->unix_user_data = NULL;
00152 transport->free_unix_user_data = NULL;
00153
00154
00155
00156
00157 transport->max_live_messages_size = _DBUS_ONE_MEGABYTE * 63;
00158
00159 transport->credentials.pid = -1;
00160 transport->credentials.uid = -1;
00161 transport->credentials.gid = -1;
00162
00163 _dbus_counter_set_notify (transport->live_messages_size,
00164 transport->max_live_messages_size,
00165 live_messages_size_notify,
00166 transport);
00167
00168 if (transport->address)
00169 _dbus_verbose ("Initialized transport on address %s\n", transport->address);
00170
00171 return TRUE;
00172 }
00173
00180 void
00181 _dbus_transport_finalize_base (DBusTransport *transport)
00182 {
00183 if (!transport->disconnected)
00184 _dbus_transport_disconnect (transport);
00185
00186 if (transport->free_unix_user_data != NULL)
00187 (* transport->free_unix_user_data) (transport->unix_user_data);
00188
00189 _dbus_message_loader_unref (transport->loader);
00190 _dbus_auth_unref (transport->auth);
00191 _dbus_counter_set_notify (transport->live_messages_size,
00192 0, NULL, NULL);
00193 _dbus_counter_unref (transport->live_messages_size);
00194 dbus_free (transport->address);
00195 }
00196
00208 DBusTransport*
00209 _dbus_transport_open (const char *address,
00210 DBusError *error)
00211 {
00212 DBusTransport *transport;
00213 DBusAddressEntry **entries;
00214 DBusError tmp_error;
00215 DBusError first_error;
00216 int len, i;
00217 const char *address_problem_type;
00218 const char *address_problem_field;
00219 const char *address_problem_other;
00220
00221 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00222
00223 if (!dbus_parse_address (address, &entries, &len, error))
00224 return NULL;
00225
00226 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00227
00228 transport = NULL;
00229 address_problem_type = NULL;
00230 address_problem_field = NULL;
00231 address_problem_other = NULL;
00232
00233 dbus_error_init (&tmp_error);
00234 dbus_error_init (&first_error);
00235 for (i = 0; i < len; i++)
00236 {
00237 const char *method;
00238
00239 method = dbus_address_entry_get_method (entries[i]);
00240
00241 if (strcmp (method, "unix") == 0)
00242 {
00243 const char *path = dbus_address_entry_get_value (entries[i], "path");
00244 const char *tmpdir = dbus_address_entry_get_value (entries[i], "tmpdir");
00245 const char *abstract = dbus_address_entry_get_value (entries[i], "abstract");
00246
00247 if (tmpdir != NULL)
00248 {
00249 address_problem_other = "cannot use the \"tmpdir\" option for an address to connect to, only in an address to listen on";
00250 goto bad_address;
00251 }
00252
00253 if (path == NULL && abstract == NULL)
00254 {
00255 address_problem_type = "unix";
00256 address_problem_field = "path or abstract";
00257 goto bad_address;
00258 }
00259
00260 if (path != NULL && abstract != NULL)
00261 {
00262 address_problem_other = "can't specify both \"path\" and \"abstract\" options in an address";
00263 goto bad_address;
00264 }
00265
00266 if (path)
00267 transport = _dbus_transport_new_for_domain_socket (path, FALSE,
00268 &tmp_error);
00269 else
00270 transport = _dbus_transport_new_for_domain_socket (abstract, TRUE,
00271 &tmp_error);
00272 }
00273 else if (strcmp (method, "tcp") == 0)
00274 {
00275 const char *host = dbus_address_entry_get_value (entries[i], "host");
00276 const char *port = dbus_address_entry_get_value (entries[i], "port");
00277 DBusString str;
00278 long lport;
00279 dbus_bool_t sresult;
00280
00281 if (port == NULL)
00282 {
00283 address_problem_type = "tcp";
00284 address_problem_field = "port";
00285 goto bad_address;
00286 }
00287
00288 _dbus_string_init_const (&str, port);
00289 sresult = _dbus_string_parse_int (&str, 0, &lport, NULL);
00290 _dbus_string_free (&str);
00291
00292 if (sresult == FALSE || lport <= 0 || lport > 65535)
00293 {
00294 address_problem_other = "Port is not an integer between 0 and 65535";
00295 goto bad_address;
00296 }
00297
00298 transport = _dbus_transport_new_for_tcp_socket (host, lport, &tmp_error);
00299 }
00300 #ifdef DBUS_BUILD_TESTS
00301 else if (strcmp (method, "debug-pipe") == 0)
00302 {
00303 const char *name = dbus_address_entry_get_value (entries[i], "name");
00304
00305 if (name == NULL)
00306 {
00307 address_problem_type = "debug-pipe";
00308 address_problem_field = "name";
00309 goto bad_address;
00310 }
00311
00312 transport = _dbus_transport_debug_pipe_new (name, &tmp_error);
00313 }
00314 #endif
00315 else
00316 {
00317 address_problem_other = "Unknown address type (examples of valid types are \"unix\" and \"tcp\")";
00318 goto bad_address;
00319 }
00320
00321 if (transport)
00322 break;
00323
00324 _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
00325
00326 if (i == 0)
00327 dbus_move_error (&tmp_error, &first_error);
00328 else
00329 dbus_error_free (&tmp_error);
00330 }
00331
00332 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00333 _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
00334
00335 if (transport == NULL)
00336 {
00337 _DBUS_ASSERT_ERROR_IS_SET (&first_error);
00338 dbus_move_error (&first_error, error);
00339 }
00340 else
00341 {
00342 dbus_error_free (&first_error);
00343 }
00344
00345 dbus_address_entries_free (entries);
00346 return transport;
00347
00348 bad_address:
00349 dbus_address_entries_free (entries);
00350
00351 if (address_problem_type != NULL)
00352 dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
00353 "Address of type %s was missing argument %s",
00354 address_problem_type, address_problem_field);
00355 else
00356 dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
00357 "Could not parse address: %s",
00358 address_problem_other);
00359
00360 return NULL;
00361 }
00362
00369 DBusTransport *
00370 _dbus_transport_ref (DBusTransport *transport)
00371 {
00372 _dbus_assert (transport->refcount > 0);
00373
00374 transport->refcount += 1;
00375
00376 return transport;
00377 }
00378
00386 void
00387 _dbus_transport_unref (DBusTransport *transport)
00388 {
00389 _dbus_assert (transport != NULL);
00390 _dbus_assert (transport->refcount > 0);
00391
00392 transport->refcount -= 1;
00393 if (transport->refcount == 0)
00394 {
00395 _dbus_verbose ("%s: finalizing\n", _DBUS_FUNCTION_NAME);
00396
00397 _dbus_assert (transport->vtable->finalize != NULL);
00398
00399 (* transport->vtable->finalize) (transport);
00400 }
00401 }
00402
00411 void
00412 _dbus_transport_disconnect (DBusTransport *transport)
00413 {
00414 _dbus_verbose ("%s start\n", _DBUS_FUNCTION_NAME);
00415
00416 _dbus_assert (transport->vtable->disconnect != NULL);
00417
00418 if (transport->disconnected)
00419 return;
00420
00421 (* transport->vtable->disconnect) (transport);
00422
00423 transport->disconnected = TRUE;
00424
00425 _dbus_verbose ("%s end\n", _DBUS_FUNCTION_NAME);
00426 }
00427
00436 dbus_bool_t
00437 _dbus_transport_get_is_connected (DBusTransport *transport)
00438 {
00439 return !transport->disconnected;
00440 }
00441
00452 dbus_bool_t
00453 _dbus_transport_get_is_authenticated (DBusTransport *transport)
00454 {
00455 if (transport->authenticated)
00456 return TRUE;
00457 else
00458 {
00459 dbus_bool_t maybe_authenticated;
00460
00461 if (transport->disconnected)
00462 return FALSE;
00463
00464
00465 _dbus_connection_ref_unlocked (transport->connection);
00466
00467 maybe_authenticated =
00468 (!(transport->send_credentials_pending ||
00469 transport->receive_credentials_pending));
00470
00471 if (maybe_authenticated)
00472 {
00473 switch (_dbus_auth_do_work (transport->auth))
00474 {
00475 case DBUS_AUTH_STATE_AUTHENTICATED:
00476
00477 break;
00478 default:
00479 maybe_authenticated = FALSE;
00480 }
00481 }
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491 if (maybe_authenticated && transport->is_server)
00492 {
00493 DBusCredentials auth_identity;
00494
00495 _dbus_auth_get_identity (transport->auth, &auth_identity);
00496
00497 if (transport->unix_user_function != NULL)
00498 {
00499 dbus_bool_t allow;
00500 DBusConnection *connection;
00501 DBusAllowUnixUserFunction unix_user_function;
00502 void *unix_user_data;
00503
00504
00505
00506 connection = transport->connection;
00507 unix_user_function = transport->unix_user_function;
00508 unix_user_data = transport->unix_user_data;
00509
00510 _dbus_verbose ("unlock %s\n", _DBUS_FUNCTION_NAME);
00511 _dbus_connection_unlock (connection);
00512
00513 allow = (* unix_user_function) (connection,
00514 auth_identity.uid,
00515 unix_user_data);
00516
00517 _dbus_verbose ("lock %s post unix user function\n", _DBUS_FUNCTION_NAME);
00518 _dbus_connection_lock (connection);
00519
00520 if (allow)
00521 {
00522 _dbus_verbose ("Client UID "DBUS_UID_FORMAT" authorized\n", auth_identity.uid);
00523 }
00524 else
00525 {
00526 _dbus_verbose ("Client UID "DBUS_UID_FORMAT
00527 " was rejected, disconnecting\n",
00528 auth_identity.uid);
00529 _dbus_transport_disconnect (transport);
00530 _dbus_connection_unref_unlocked (connection);
00531 return FALSE;
00532 }
00533 }
00534 else
00535 {
00536 DBusCredentials our_identity;
00537
00538 _dbus_credentials_from_current_process (&our_identity);
00539
00540 if (!_dbus_credentials_match (&our_identity,
00541 &auth_identity))
00542 {
00543 _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT
00544 " but our UID is "DBUS_UID_FORMAT", disconnecting\n",
00545 auth_identity.uid, our_identity.uid);
00546 _dbus_transport_disconnect (transport);
00547 _dbus_connection_unref_unlocked (transport->connection);
00548 return FALSE;
00549 }
00550 else
00551 {
00552 _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT
00553 " matching our UID "DBUS_UID_FORMAT"\n",
00554 auth_identity.uid, our_identity.uid);
00555 }
00556 }
00557 }
00558
00559 transport->authenticated = maybe_authenticated;
00560
00561 _dbus_connection_unref_unlocked (transport->connection);
00562 return maybe_authenticated;
00563 }
00564 }
00565
00573 const char*
00574 _dbus_transport_get_address (DBusTransport *transport)
00575 {
00576 return transport->address;
00577 }
00578
00588 dbus_bool_t
00589 _dbus_transport_handle_watch (DBusTransport *transport,
00590 DBusWatch *watch,
00591 unsigned int condition)
00592 {
00593 dbus_bool_t retval;
00594
00595 _dbus_assert (transport->vtable->handle_watch != NULL);
00596
00597 if (transport->disconnected)
00598 return TRUE;
00599
00600 if (dbus_watch_get_fd (watch) < 0)
00601 {
00602 _dbus_warn ("Tried to handle an invalidated watch; this watch should have been removed\n");
00603 return TRUE;
00604 }
00605
00606 _dbus_watch_sanitize_condition (watch, &condition);
00607
00608 _dbus_transport_ref (transport);
00609 _dbus_watch_ref (watch);
00610 retval = (* transport->vtable->handle_watch) (transport, watch, condition);
00611 _dbus_watch_unref (watch);
00612 _dbus_transport_unref (transport);
00613
00614 return retval;
00615 }
00616
00626 dbus_bool_t
00627 _dbus_transport_set_connection (DBusTransport *transport,
00628 DBusConnection *connection)
00629 {
00630 _dbus_assert (transport->vtable->connection_set != NULL);
00631 _dbus_assert (transport->connection == NULL);
00632
00633 transport->connection = connection;
00634
00635 _dbus_transport_ref (transport);
00636 if (!(* transport->vtable->connection_set) (transport))
00637 transport->connection = NULL;
00638 _dbus_transport_unref (transport);
00639
00640 return transport->connection != NULL;
00641 }
00642
00650 dbus_bool_t
00651 _dbus_transport_get_unix_fd (DBusTransport *transport,
00652 int *fd_p)
00653 {
00654 dbus_bool_t retval;
00655
00656 if (transport->vtable->get_unix_fd == NULL)
00657 return FALSE;
00658
00659 if (transport->disconnected)
00660 return FALSE;
00661
00662 _dbus_transport_ref (transport);
00663
00664 retval = (* transport->vtable->get_unix_fd) (transport,
00665 fd_p);
00666
00667 _dbus_transport_unref (transport);
00668
00669 return retval;
00670 }
00671
00683 void
00684 _dbus_transport_do_iteration (DBusTransport *transport,
00685 unsigned int flags,
00686 int timeout_milliseconds)
00687 {
00688 _dbus_assert (transport->vtable->do_iteration != NULL);
00689
00690 _dbus_verbose ("Transport iteration flags 0x%x timeout %d connected = %d\n",
00691 flags, timeout_milliseconds, !transport->disconnected);
00692
00693 if ((flags & (DBUS_ITERATION_DO_WRITING |
00694 DBUS_ITERATION_DO_READING)) == 0)
00695 return;
00696
00697 if (transport->disconnected)
00698 return;
00699
00700 _dbus_transport_ref (transport);
00701 (* transport->vtable->do_iteration) (transport, flags,
00702 timeout_milliseconds);
00703 _dbus_transport_unref (transport);
00704
00705 _dbus_verbose ("%s end\n", _DBUS_FUNCTION_NAME);
00706 }
00707
00708 static dbus_bool_t
00709 recover_unused_bytes (DBusTransport *transport)
00710 {
00711 if (_dbus_auth_needs_decoding (transport->auth))
00712 {
00713 DBusString plaintext;
00714 const DBusString *encoded;
00715 DBusString *buffer;
00716 int orig_len;
00717
00718 if (!_dbus_string_init (&plaintext))
00719 goto nomem;
00720
00721 _dbus_auth_get_unused_bytes (transport->auth,
00722 &encoded);
00723
00724 if (!_dbus_auth_decode_data (transport->auth,
00725 encoded, &plaintext))
00726 {
00727 _dbus_string_free (&plaintext);
00728 goto nomem;
00729 }
00730
00731 _dbus_message_loader_get_buffer (transport->loader,
00732 &buffer);
00733
00734 orig_len = _dbus_string_get_length (buffer);
00735
00736 if (!_dbus_string_move (&plaintext, 0, buffer,
00737 orig_len))
00738 {
00739 _dbus_string_free (&plaintext);
00740 goto nomem;
00741 }
00742
00743 _dbus_verbose (" %d unused bytes sent to message loader\n",
00744 _dbus_string_get_length (buffer) -
00745 orig_len);
00746
00747 _dbus_message_loader_return_buffer (transport->loader,
00748 buffer,
00749 _dbus_string_get_length (buffer) -
00750 orig_len);
00751
00752 _dbus_auth_delete_unused_bytes (transport->auth);
00753
00754 _dbus_string_free (&plaintext);
00755 }
00756 else
00757 {
00758 const DBusString *bytes;
00759 DBusString *buffer;
00760 int orig_len;
00761 dbus_bool_t succeeded;
00762
00763 _dbus_message_loader_get_buffer (transport->loader,
00764 &buffer);
00765
00766 orig_len = _dbus_string_get_length (buffer);
00767
00768 _dbus_auth_get_unused_bytes (transport->auth,
00769 &bytes);
00770
00771 succeeded = TRUE;
00772 if (!_dbus_string_copy (bytes, 0, buffer, _dbus_string_get_length (buffer)))
00773 succeeded = FALSE;
00774
00775 _dbus_verbose (" %d unused bytes sent to message loader\n",
00776 _dbus_string_get_length (buffer) -
00777 orig_len);
00778
00779 _dbus_message_loader_return_buffer (transport->loader,
00780 buffer,
00781 _dbus_string_get_length (buffer) -
00782 orig_len);
00783
00784 if (succeeded)
00785 _dbus_auth_delete_unused_bytes (transport->auth);
00786 else
00787 goto nomem;
00788 }
00789
00790 return TRUE;
00791
00792 nomem:
00793 _dbus_verbose ("Not enough memory to transfer unused bytes from auth conversation\n");
00794 return FALSE;
00795 }
00796
00804 DBusDispatchStatus
00805 _dbus_transport_get_dispatch_status (DBusTransport *transport)
00806 {
00807 if (_dbus_counter_get_value (transport->live_messages_size) >= transport->max_live_messages_size)
00808 return DBUS_DISPATCH_COMPLETE;
00809
00810 if (!_dbus_transport_get_is_authenticated (transport))
00811 {
00812 if (_dbus_auth_do_work (transport->auth) ==
00813 DBUS_AUTH_STATE_WAITING_FOR_MEMORY)
00814 return DBUS_DISPATCH_NEED_MEMORY;
00815 else if (!_dbus_transport_get_is_authenticated (transport))
00816 return DBUS_DISPATCH_COMPLETE;
00817 }
00818
00819 if (!transport->unused_bytes_recovered &&
00820 !recover_unused_bytes (transport))
00821 return DBUS_DISPATCH_NEED_MEMORY;
00822
00823 transport->unused_bytes_recovered = TRUE;
00824
00825 if (!_dbus_message_loader_queue_messages (transport->loader))
00826 return DBUS_DISPATCH_NEED_MEMORY;
00827
00828 if (_dbus_message_loader_peek_message (transport->loader) != NULL)
00829 return DBUS_DISPATCH_DATA_REMAINS;
00830 else
00831 return DBUS_DISPATCH_COMPLETE;
00832 }
00833
00842 dbus_bool_t
00843 _dbus_transport_queue_messages (DBusTransport *transport)
00844 {
00845 DBusDispatchStatus status;
00846
00847 #if 0
00848 _dbus_verbose ("_dbus_transport_queue_messages()\n");
00849 #endif
00850
00851
00852 while ((status = _dbus_transport_get_dispatch_status (transport)) == DBUS_DISPATCH_DATA_REMAINS)
00853 {
00854 DBusMessage *message;
00855 DBusList *link;
00856
00857 link = _dbus_message_loader_pop_message_link (transport->loader);
00858 _dbus_assert (link != NULL);
00859
00860 message = link->data;
00861
00862 _dbus_verbose ("queueing received message %p\n", message);
00863
00864 if (!_dbus_message_add_size_counter (message, transport->live_messages_size))
00865 {
00866 _dbus_message_loader_putback_message_link (transport->loader,
00867 link);
00868 status = DBUS_DISPATCH_NEED_MEMORY;
00869 break;
00870 }
00871 else
00872 {
00873
00874 _dbus_connection_queue_received_message_link (transport->connection,
00875 link);
00876 }
00877 }
00878
00879 if (_dbus_message_loader_get_is_corrupted (transport->loader))
00880 {
00881 _dbus_verbose ("Corrupted message stream, disconnecting\n");
00882 _dbus_transport_disconnect (transport);
00883 }
00884
00885 return status != DBUS_DISPATCH_NEED_MEMORY;
00886 }
00887
00894 void
00895 _dbus_transport_set_max_message_size (DBusTransport *transport,
00896 long size)
00897 {
00898 _dbus_message_loader_set_max_message_size (transport->loader, size);
00899 }
00900
00907 long
00908 _dbus_transport_get_max_message_size (DBusTransport *transport)
00909 {
00910 return _dbus_message_loader_get_max_message_size (transport->loader);
00911 }
00912
00919 void
00920 _dbus_transport_set_max_received_size (DBusTransport *transport,
00921 long size)
00922 {
00923 transport->max_live_messages_size = size;
00924 _dbus_counter_set_notify (transport->live_messages_size,
00925 transport->max_live_messages_size,
00926 live_messages_size_notify,
00927 transport);
00928 }
00929
00930
00937 long
00938 _dbus_transport_get_max_received_size (DBusTransport *transport)
00939 {
00940 return transport->max_live_messages_size;
00941 }
00942
00950 dbus_bool_t
00951 _dbus_transport_get_unix_user (DBusTransport *transport,
00952 unsigned long *uid)
00953 {
00954 DBusCredentials auth_identity;
00955
00956 *uid = _DBUS_INT_MAX;
00957
00958
00959
00960
00961 if (!transport->authenticated)
00962 return FALSE;
00963
00964 _dbus_auth_get_identity (transport->auth, &auth_identity);
00965
00966 if (auth_identity.uid != DBUS_UID_UNSET)
00967 {
00968 *uid = auth_identity.uid;
00969 return TRUE;
00970 }
00971 else
00972 return FALSE;
00973 }
00974
00982 dbus_bool_t
00983 _dbus_transport_get_unix_process_id (DBusTransport *transport,
00984 unsigned long *pid)
00985 {
00986 DBusCredentials auth_identity;
00987
00988 *pid = DBUS_PID_UNSET;
00989
00990
00991
00992
00993 if (!transport->authenticated)
00994 return FALSE;
00995
00996 _dbus_auth_get_identity (transport->auth, &auth_identity);
00997
00998 if (auth_identity.pid != DBUS_PID_UNSET)
00999 {
01000 *pid = auth_identity.pid;
01001 return TRUE;
01002 }
01003 else
01004 return FALSE;
01005 }
01006
01017 void
01018 _dbus_transport_set_unix_user_function (DBusTransport *transport,
01019 DBusAllowUnixUserFunction function,
01020 void *data,
01021 DBusFreeFunction free_data_function,
01022 void **old_data,
01023 DBusFreeFunction *old_free_data_function)
01024 {
01025 *old_data = transport->unix_user_data;
01026 *old_free_data_function = transport->free_unix_user_data;
01027
01028 transport->unix_user_function = function;
01029 transport->unix_user_data = data;
01030 transport->free_unix_user_data = free_data_function;
01031 }
01032
01041 dbus_bool_t
01042 _dbus_transport_set_auth_mechanisms (DBusTransport *transport,
01043 const char **mechanisms)
01044 {
01045 return _dbus_auth_set_mechanisms (transport->auth, mechanisms);
01046 }
01047
01048