1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-transport.c DBusTransport object (internal to D-BUS implementation)
4 * Copyright (C) 2002, 2003 Red Hat Inc.
6 * Licensed under the Academic Free License version 2.1
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "dbus-transport-protected.h"
25 #include "dbus-transport-unix.h"
26 #include "dbus-connection-internal.h"
27 #include "dbus-watch.h"
28 #include "dbus-auth.h"
29 #include "dbus-address.h"
30 #ifdef DBUS_BUILD_TESTS
31 #include "dbus-server-debug-pipe.h"
35 * @defgroup DBusTransport DBusTransport object
36 * @ingroup DBusInternals
37 * @brief "Backend" for a DBusConnection.
39 * Types and functions related to DBusTransport. A transport is an
40 * abstraction that can send and receive data via various kinds of
41 * network connections or other IPC mechanisms.
47 * @typedef DBusTransport
49 * Opaque object representing a way message stream.
50 * DBusTransport abstracts various kinds of actual
51 * transport mechanism, such as different network protocols,
52 * or encryption schemes.
56 live_messages_size_notify (DBusCounter *counter,
59 DBusTransport *transport = user_data;
61 _dbus_transport_ref (transport);
64 _dbus_verbose ("Counter value is now %d\n",
65 (int) _dbus_counter_get_value (counter));
68 /* disable or re-enable the read watch for the transport if
71 if (* transport->vtable->live_messages_changed)
72 (* transport->vtable->live_messages_changed) (transport);
74 _dbus_transport_unref (transport);
78 * Initializes the base class members of DBusTransport. Chained up to
79 * by subclasses in their constructor. The server GUID is the
80 * globally unique ID for the server creating this connection
81 * and will be #NULL for the client side of a connection. The GUID
84 * @param transport the transport being created.
85 * @param vtable the subclass vtable.
86 * @param server_guid non-#NULL if this transport is on the server side of a connection
87 * @param address the address of the transport
88 * @returns #TRUE on success.
91 _dbus_transport_init_base (DBusTransport *transport,
92 const DBusTransportVTable *vtable,
93 const DBusString *server_guid,
94 const DBusString *address)
96 DBusMessageLoader *loader;
101 loader = _dbus_message_loader_new ();
106 auth = _dbus_auth_server_new (server_guid);
108 auth = _dbus_auth_client_new ();
111 _dbus_message_loader_unref (loader);
115 counter = _dbus_counter_new ();
118 _dbus_auth_unref (auth);
119 _dbus_message_loader_unref (loader);
125 _dbus_assert (address == NULL);
130 _dbus_assert (address != NULL);
132 if (!_dbus_string_copy_data (address, &address_copy))
134 _dbus_counter_unref (counter);
135 _dbus_auth_unref (auth);
136 _dbus_message_loader_unref (loader);
141 transport->refcount = 1;
142 transport->vtable = vtable;
143 transport->loader = loader;
144 transport->auth = auth;
145 transport->live_messages_size = counter;
146 transport->authenticated = FALSE;
147 transport->disconnected = FALSE;
148 transport->is_server = (server_guid != NULL);
149 transport->send_credentials_pending = !transport->is_server;
150 transport->receive_credentials_pending = transport->is_server;
151 transport->address = address_copy;
153 transport->unix_user_function = NULL;
154 transport->unix_user_data = NULL;
155 transport->free_unix_user_data = NULL;
157 transport->expected_guid = NULL;
159 /* Try to default to something that won't totally hose the system,
160 * but doesn't impose too much of a limitation.
162 transport->max_live_messages_size = _DBUS_ONE_MEGABYTE * 63;
164 transport->credentials.pid = -1;
165 transport->credentials.uid = -1;
166 transport->credentials.gid = -1;
168 _dbus_counter_set_notify (transport->live_messages_size,
169 transport->max_live_messages_size,
170 live_messages_size_notify,
173 if (transport->address)
174 _dbus_verbose ("Initialized transport on address %s\n", transport->address);
180 * Finalizes base class members of DBusTransport.
181 * Chained up to from subclass finalizers.
183 * @param transport the transport.
186 _dbus_transport_finalize_base (DBusTransport *transport)
188 if (!transport->disconnected)
189 _dbus_transport_disconnect (transport);
191 if (transport->free_unix_user_data != NULL)
192 (* transport->free_unix_user_data) (transport->unix_user_data);
194 _dbus_message_loader_unref (transport->loader);
195 _dbus_auth_unref (transport->auth);
196 _dbus_counter_set_notify (transport->live_messages_size,
198 _dbus_counter_unref (transport->live_messages_size);
199 dbus_free (transport->address);
200 dbus_free (transport->expected_guid);
204 * Try to open a new transport for the given address entry. (This
205 * opens a client-side-of-the-connection transport.)
207 * @param entry the address entry
208 * @param error location to store reason for failure.
209 * @returns new transport of #NULL on failure.
212 _dbus_transport_open (DBusAddressEntry *entry,
215 DBusTransport *transport;
216 const char *address_problem_type;
217 const char *address_problem_field;
218 const char *address_problem_other;
220 const char *expected_guid_orig;
223 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
226 address_problem_type = NULL;
227 address_problem_field = NULL;
228 address_problem_other = NULL;
229 expected_guid_orig = dbus_address_entry_get_value (entry, "guid");
230 expected_guid = _dbus_strdup (expected_guid_orig);
232 if (expected_guid_orig != NULL && expected_guid == NULL)
234 _DBUS_SET_OOM (error);
238 method = dbus_address_entry_get_method (entry);
239 _dbus_assert (method != NULL);
241 if (strcmp (method, "unix") == 0)
243 const char *path = dbus_address_entry_get_value (entry, "path");
244 const char *tmpdir = dbus_address_entry_get_value (entry, "tmpdir");
245 const char *abstract = dbus_address_entry_get_value (entry, "abstract");
249 address_problem_other = "cannot use the \"tmpdir\" option for an address to connect to, only in an address to listen on";
253 if (path == NULL && abstract == NULL)
255 address_problem_type = "unix";
256 address_problem_field = "path or abstract";
260 if (path != NULL && abstract != NULL)
262 address_problem_other = "can't specify both \"path\" and \"abstract\" options in an address";
267 transport = _dbus_transport_new_for_domain_socket (path, FALSE,
270 transport = _dbus_transport_new_for_domain_socket (abstract, TRUE,
273 else if (strcmp (method, "tcp") == 0)
275 const char *host = dbus_address_entry_get_value (entry, "host");
276 const char *port = dbus_address_entry_get_value (entry, "port");
283 address_problem_type = "tcp";
284 address_problem_field = "port";
288 _dbus_string_init_const (&str, port);
289 sresult = _dbus_string_parse_int (&str, 0, &lport, NULL);
290 _dbus_string_free (&str);
292 if (sresult == FALSE || lport <= 0 || lport > 65535)
294 address_problem_other = "Port is not an integer between 0 and 65535";
298 transport = _dbus_transport_new_for_tcp_socket (host, lport, error);
300 #ifdef DBUS_BUILD_TESTS
301 else if (strcmp (method, "debug-pipe") == 0)
303 const char *name = dbus_address_entry_get_value (entry, "name");
307 address_problem_type = "debug-pipe";
308 address_problem_field = "name";
312 transport = _dbus_transport_debug_pipe_new (name, error);
317 address_problem_other = "Unknown address type (examples of valid types are \"unix\" and \"tcp\")";
321 if (transport == NULL)
323 _DBUS_ASSERT_ERROR_IS_SET (error);
324 dbus_free (expected_guid);
328 transport->expected_guid = expected_guid;
334 dbus_free (expected_guid);
336 if (address_problem_type != NULL)
337 dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
338 "Address of type %s was missing argument %s",
339 address_problem_type, address_problem_field);
341 dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
342 "Could not parse address: %s",
343 address_problem_other);
349 * Increments the reference count for the transport.
351 * @param transport the transport.
352 * @returns the transport.
355 _dbus_transport_ref (DBusTransport *transport)
357 _dbus_assert (transport->refcount > 0);
359 transport->refcount += 1;
365 * Decrements the reference count for the transport.
366 * Disconnects and finalizes the transport if
367 * the reference count reaches zero.
369 * @param transport the transport.
372 _dbus_transport_unref (DBusTransport *transport)
374 _dbus_assert (transport != NULL);
375 _dbus_assert (transport->refcount > 0);
377 transport->refcount -= 1;
378 if (transport->refcount == 0)
380 _dbus_verbose ("%s: finalizing\n", _DBUS_FUNCTION_NAME);
382 _dbus_assert (transport->vtable->finalize != NULL);
384 (* transport->vtable->finalize) (transport);
389 * Closes our end of the connection to a remote application. Further
390 * attempts to use this transport will fail. Only the first call to
391 * _dbus_transport_disconnect() will have an effect.
393 * @param transport the transport.
397 _dbus_transport_disconnect (DBusTransport *transport)
399 _dbus_verbose ("%s start\n", _DBUS_FUNCTION_NAME);
401 _dbus_assert (transport->vtable->disconnect != NULL);
403 if (transport->disconnected)
406 (* transport->vtable->disconnect) (transport);
408 transport->disconnected = TRUE;
410 _dbus_verbose ("%s end\n", _DBUS_FUNCTION_NAME);
414 * Returns #TRUE if the transport has not been disconnected.
415 * Disconnection can result from _dbus_transport_disconnect()
416 * or because the server drops its end of the connection.
418 * @param transport the transport.
419 * @returns whether we're connected
422 _dbus_transport_get_is_connected (DBusTransport *transport)
424 return !transport->disconnected;
428 * Returns #TRUE if we have been authenticated. Will return #TRUE
429 * even if the transport is disconnected.
431 * @todo we drop connection->mutex when calling the unix_user_function,
432 * which may not be safe really.
434 * @param transport the transport
435 * @returns whether we're authenticated
438 _dbus_transport_get_is_authenticated (DBusTransport *transport)
440 if (transport->authenticated)
444 dbus_bool_t maybe_authenticated;
446 if (transport->disconnected)
449 /* paranoia ref since we call user callbacks sometimes */
450 _dbus_connection_ref_unlocked (transport->connection);
452 maybe_authenticated =
453 (!(transport->send_credentials_pending ||
454 transport->receive_credentials_pending));
456 if (maybe_authenticated)
458 switch (_dbus_auth_do_work (transport->auth))
460 case DBUS_AUTH_STATE_AUTHENTICATED:
461 /* leave as maybe_authenticated */
464 maybe_authenticated = FALSE;
468 if (maybe_authenticated && !transport->is_server)
470 const char *server_guid;
472 server_guid = _dbus_auth_get_guid_from_server (transport->auth);
473 _dbus_assert (server_guid != NULL);
475 if (transport->expected_guid &&
476 strcmp (transport->expected_guid, server_guid) != 0)
478 _dbus_verbose ("Client expected GUID '%s' and we got '%s' from the server\n",
479 transport->expected_guid, server_guid);
480 _dbus_transport_disconnect (transport);
481 _dbus_connection_unref_unlocked (transport->connection);
485 if (transport->expected_guid == NULL)
487 transport->expected_guid = _dbus_strdup (server_guid);
489 if (transport->expected_guid == NULL)
491 _dbus_verbose ("No memory to complete auth in %s\n", _DBUS_FUNCTION_NAME);
497 /* If we've authenticated as some identity, check that the auth
498 * identity is the same as our own identity. In the future, we
499 * may have API allowing applications to specify how this is
500 * done, for example they may allow connection as any identity,
501 * but then impose restrictions on certain identities.
502 * Or they may give certain identities extra privileges.
505 if (maybe_authenticated && transport->is_server)
507 DBusCredentials auth_identity;
509 _dbus_auth_get_identity (transport->auth, &auth_identity);
511 if (transport->unix_user_function != NULL)
514 DBusConnection *connection;
515 DBusAllowUnixUserFunction unix_user_function;
516 void *unix_user_data;
518 /* Dropping the lock here probably isn't that safe. */
520 connection = transport->connection;
521 unix_user_function = transport->unix_user_function;
522 unix_user_data = transport->unix_user_data;
524 _dbus_verbose ("unlock %s\n", _DBUS_FUNCTION_NAME);
525 _dbus_connection_unlock (connection);
527 allow = (* unix_user_function) (connection,
531 _dbus_verbose ("lock %s post unix user function\n", _DBUS_FUNCTION_NAME);
532 _dbus_connection_lock (connection);
536 _dbus_verbose ("Client UID "DBUS_UID_FORMAT" authorized\n", auth_identity.uid);
540 _dbus_verbose ("Client UID "DBUS_UID_FORMAT
541 " was rejected, disconnecting\n",
543 _dbus_transport_disconnect (transport);
544 _dbus_connection_unref_unlocked (connection);
550 DBusCredentials our_identity;
552 _dbus_credentials_from_current_process (&our_identity);
554 if (!_dbus_credentials_match (&our_identity,
557 _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT
558 " but our UID is "DBUS_UID_FORMAT", disconnecting\n",
559 auth_identity.uid, our_identity.uid);
560 _dbus_transport_disconnect (transport);
561 _dbus_connection_unref_unlocked (transport->connection);
566 _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT
567 " matching our UID "DBUS_UID_FORMAT"\n",
568 auth_identity.uid, our_identity.uid);
573 transport->authenticated = maybe_authenticated;
575 _dbus_connection_unref_unlocked (transport->connection);
576 return maybe_authenticated;
581 * Gets the address of a transport. It will be
582 * #NULL for a server-side transport.
584 * @param transport the transport
585 * @returns transport's address
588 _dbus_transport_get_address (DBusTransport *transport)
590 return transport->address;
594 * Handles a watch by reading data, writing data, or disconnecting
595 * the transport, as appropriate for the given condition.
597 * @param transport the transport.
598 * @param watch the watch.
599 * @param condition the current state of the watched file descriptor.
600 * @returns #FALSE if not enough memory to fully handle the watch
603 _dbus_transport_handle_watch (DBusTransport *transport,
605 unsigned int condition)
609 _dbus_assert (transport->vtable->handle_watch != NULL);
611 if (transport->disconnected)
614 if (dbus_watch_get_fd (watch) < 0)
616 _dbus_warn ("Tried to handle an invalidated watch; this watch should have been removed\n");
620 _dbus_watch_sanitize_condition (watch, &condition);
622 _dbus_transport_ref (transport);
623 _dbus_watch_ref (watch);
624 retval = (* transport->vtable->handle_watch) (transport, watch, condition);
625 _dbus_watch_unref (watch);
626 _dbus_transport_unref (transport);
632 * Sets the connection using this transport. Allows the transport
633 * to add watches to the connection, queue incoming messages,
634 * and pull outgoing messages.
636 * @param transport the transport.
637 * @param connection the connection.
638 * @returns #FALSE if not enough memory
641 _dbus_transport_set_connection (DBusTransport *transport,
642 DBusConnection *connection)
644 _dbus_assert (transport->vtable->connection_set != NULL);
645 _dbus_assert (transport->connection == NULL);
647 transport->connection = connection;
649 _dbus_transport_ref (transport);
650 if (!(* transport->vtable->connection_set) (transport))
651 transport->connection = NULL;
652 _dbus_transport_unref (transport);
654 return transport->connection != NULL;
658 * Get the UNIX file descriptor, if any.
660 * @param transport the transport
661 * @param fd_p pointer to fill in with the descriptor
662 * @returns #TRUE if a descriptor was available
665 _dbus_transport_get_unix_fd (DBusTransport *transport,
670 if (transport->vtable->get_unix_fd == NULL)
673 if (transport->disconnected)
676 _dbus_transport_ref (transport);
678 retval = (* transport->vtable->get_unix_fd) (transport,
681 _dbus_transport_unref (transport);
687 * Performs a single poll()/select() on the transport's file
688 * descriptors and then reads/writes data as appropriate,
689 * queueing incoming messages and sending outgoing messages.
690 * This is the backend for _dbus_connection_do_iteration().
691 * See _dbus_connection_do_iteration() for full details.
693 * @param transport the transport.
694 * @param flags indicates whether to read or write, and whether to block.
695 * @param timeout_milliseconds if blocking, timeout or -1 for no timeout.
698 _dbus_transport_do_iteration (DBusTransport *transport,
700 int timeout_milliseconds)
702 _dbus_assert (transport->vtable->do_iteration != NULL);
704 _dbus_verbose ("Transport iteration flags 0x%x timeout %d connected = %d\n",
705 flags, timeout_milliseconds, !transport->disconnected);
707 if ((flags & (DBUS_ITERATION_DO_WRITING |
708 DBUS_ITERATION_DO_READING)) == 0)
709 return; /* Nothing to do */
711 if (transport->disconnected)
714 _dbus_transport_ref (transport);
715 (* transport->vtable->do_iteration) (transport, flags,
716 timeout_milliseconds);
717 _dbus_transport_unref (transport);
719 _dbus_verbose ("%s end\n", _DBUS_FUNCTION_NAME);
723 recover_unused_bytes (DBusTransport *transport)
725 if (_dbus_auth_needs_decoding (transport->auth))
727 DBusString plaintext;
728 const DBusString *encoded;
732 if (!_dbus_string_init (&plaintext))
735 _dbus_auth_get_unused_bytes (transport->auth,
738 if (!_dbus_auth_decode_data (transport->auth,
739 encoded, &plaintext))
741 _dbus_string_free (&plaintext);
745 _dbus_message_loader_get_buffer (transport->loader,
748 orig_len = _dbus_string_get_length (buffer);
750 if (!_dbus_string_move (&plaintext, 0, buffer,
753 _dbus_string_free (&plaintext);
757 _dbus_verbose (" %d unused bytes sent to message loader\n",
758 _dbus_string_get_length (buffer) -
761 _dbus_message_loader_return_buffer (transport->loader,
763 _dbus_string_get_length (buffer) -
766 _dbus_auth_delete_unused_bytes (transport->auth);
768 _dbus_string_free (&plaintext);
772 const DBusString *bytes;
775 dbus_bool_t succeeded;
777 _dbus_message_loader_get_buffer (transport->loader,
780 orig_len = _dbus_string_get_length (buffer);
782 _dbus_auth_get_unused_bytes (transport->auth,
786 if (!_dbus_string_copy (bytes, 0, buffer, _dbus_string_get_length (buffer)))
789 _dbus_verbose (" %d unused bytes sent to message loader\n",
790 _dbus_string_get_length (buffer) -
793 _dbus_message_loader_return_buffer (transport->loader,
795 _dbus_string_get_length (buffer) -
799 _dbus_auth_delete_unused_bytes (transport->auth);
807 _dbus_verbose ("Not enough memory to transfer unused bytes from auth conversation\n");
812 * Reports our current dispatch status (whether there's buffered
813 * data to be queued as messages, or not, or we need memory).
815 * @param transport the transport
816 * @returns current status
819 _dbus_transport_get_dispatch_status (DBusTransport *transport)
821 if (_dbus_counter_get_value (transport->live_messages_size) >= transport->max_live_messages_size)
822 return DBUS_DISPATCH_COMPLETE; /* complete for now */
824 if (!_dbus_transport_get_is_authenticated (transport))
826 if (_dbus_auth_do_work (transport->auth) ==
827 DBUS_AUTH_STATE_WAITING_FOR_MEMORY)
828 return DBUS_DISPATCH_NEED_MEMORY;
829 else if (!_dbus_transport_get_is_authenticated (transport))
830 return DBUS_DISPATCH_COMPLETE;
833 if (!transport->unused_bytes_recovered &&
834 !recover_unused_bytes (transport))
835 return DBUS_DISPATCH_NEED_MEMORY;
837 transport->unused_bytes_recovered = TRUE;
839 if (!_dbus_message_loader_queue_messages (transport->loader))
840 return DBUS_DISPATCH_NEED_MEMORY;
842 if (_dbus_message_loader_peek_message (transport->loader) != NULL)
843 return DBUS_DISPATCH_DATA_REMAINS;
845 return DBUS_DISPATCH_COMPLETE;
849 * Processes data we've read while handling a watch, potentially
850 * converting some of it to messages and queueing those messages on
853 * @param transport the transport
854 * @returns #TRUE if we had enough memory to queue all messages
857 _dbus_transport_queue_messages (DBusTransport *transport)
859 DBusDispatchStatus status;
862 _dbus_verbose ("_dbus_transport_queue_messages()\n");
865 /* Queue any messages */
866 while ((status = _dbus_transport_get_dispatch_status (transport)) == DBUS_DISPATCH_DATA_REMAINS)
868 DBusMessage *message;
871 link = _dbus_message_loader_pop_message_link (transport->loader);
872 _dbus_assert (link != NULL);
874 message = link->data;
876 _dbus_verbose ("queueing received message %p\n", message);
878 if (!_dbus_message_add_size_counter (message, transport->live_messages_size))
880 _dbus_message_loader_putback_message_link (transport->loader,
882 status = DBUS_DISPATCH_NEED_MEMORY;
887 /* pass ownership of link and message ref to connection */
888 _dbus_connection_queue_received_message_link (transport->connection,
893 if (_dbus_message_loader_get_is_corrupted (transport->loader))
895 _dbus_verbose ("Corrupted message stream, disconnecting\n");
896 _dbus_transport_disconnect (transport);
899 return status != DBUS_DISPATCH_NEED_MEMORY;
903 * See dbus_connection_set_max_message_size().
905 * @param transport the transport
906 * @param size the max size of a single message
909 _dbus_transport_set_max_message_size (DBusTransport *transport,
912 _dbus_message_loader_set_max_message_size (transport->loader, size);
916 * See dbus_connection_get_max_message_size().
918 * @param transport the transport
919 * @returns max message size
922 _dbus_transport_get_max_message_size (DBusTransport *transport)
924 return _dbus_message_loader_get_max_message_size (transport->loader);
928 * See dbus_connection_set_max_received_size().
930 * @param transport the transport
931 * @param size the max size of all incoming messages
934 _dbus_transport_set_max_received_size (DBusTransport *transport,
937 transport->max_live_messages_size = size;
938 _dbus_counter_set_notify (transport->live_messages_size,
939 transport->max_live_messages_size,
940 live_messages_size_notify,
946 * See dbus_connection_get_max_received_size().
948 * @param transport the transport
949 * @returns max bytes for all live messages
952 _dbus_transport_get_max_received_size (DBusTransport *transport)
954 return transport->max_live_messages_size;
958 * See dbus_connection_get_unix_user().
960 * @param transport the transport
961 * @param uid return location for the user ID
962 * @returns #TRUE if uid is filled in with a valid user ID
965 _dbus_transport_get_unix_user (DBusTransport *transport,
968 DBusCredentials auth_identity;
970 *uid = _DBUS_INT32_MAX; /* better than some root or system user in
971 * case of bugs in the caller. Caller should
972 * never use this value on purpose, however.
975 if (!transport->authenticated)
978 _dbus_auth_get_identity (transport->auth, &auth_identity);
980 if (auth_identity.uid != DBUS_UID_UNSET)
982 *uid = auth_identity.uid;
990 * See dbus_connection_get_unix_process_id().
992 * @param transport the transport
993 * @param pid return location for the process ID
994 * @returns #TRUE if uid is filled in with a valid process ID
997 _dbus_transport_get_unix_process_id (DBusTransport *transport,
1000 DBusCredentials auth_identity;
1002 *pid = DBUS_PID_UNSET; /* Caller should never use this value on purpose,
1003 * but we set it to a safe number, INT_MAX,
1004 * just to root out possible bugs in bad callers.
1007 if (!transport->authenticated)
1010 _dbus_auth_get_identity (transport->auth, &auth_identity);
1012 if (auth_identity.pid != DBUS_PID_UNSET)
1014 *pid = auth_identity.pid;
1022 * See dbus_connection_set_unix_user_function().
1024 * @param transport the transport
1025 * @param function the predicate
1026 * @param data data to pass to the predicate
1027 * @param free_data_function function to free the data
1028 * @param old_data the old user data to be freed
1029 * @param old_free_data_function old free data function to free it with
1032 _dbus_transport_set_unix_user_function (DBusTransport *transport,
1033 DBusAllowUnixUserFunction function,
1035 DBusFreeFunction free_data_function,
1037 DBusFreeFunction *old_free_data_function)
1039 *old_data = transport->unix_user_data;
1040 *old_free_data_function = transport->free_unix_user_data;
1042 transport->unix_user_function = function;
1043 transport->unix_user_data = data;
1044 transport->free_unix_user_data = free_data_function;
1048 * Sets the SASL authentication mechanisms supported by this transport.
1050 * @param transport the transport
1051 * @param mechanisms the #NULL-terminated array of mechanisms
1053 * @returns #FALSE if no memory
1056 _dbus_transport_set_auth_mechanisms (DBusTransport *transport,
1057 const char **mechanisms)
1059 return _dbus_auth_set_mechanisms (transport->auth, mechanisms);