D-Bus  1.10.24
dbus-transport.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-transport.c DBusTransport object (internal to D-Bus implementation)
3  *
4  * Copyright (C) 2002, 2003 Red Hat Inc.
5  *
6  * Licensed under the Academic Free License version 2.1
7  *
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.
12  *
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.
17  *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 #include <config.h>
25 #include "dbus-transport-protected.h"
26 #include "dbus-transport-unix.h"
27 #include "dbus-transport-socket.h"
28 #include "dbus-connection-internal.h"
29 #include "dbus-watch.h"
30 #include "dbus-auth.h"
31 #include "dbus-address.h"
32 #include "dbus-credentials.h"
33 #include "dbus-mainloop.h"
34 #include "dbus-message.h"
35 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
36 #include "dbus-server-debug-pipe.h"
37 #endif
38 
60 static void
61 live_messages_notify (DBusCounter *counter,
62  void *user_data)
63 {
64  DBusTransport *transport = user_data;
65 
66  _dbus_connection_lock (transport->connection);
67  _dbus_transport_ref (transport);
68 
69 #if 0
70  _dbus_verbose ("Size counter value is now %d\n",
71  (int) _dbus_counter_get_size_value (counter));
72  _dbus_verbose ("Unix FD counter value is now %d\n",
73  (int) _dbus_counter_get_unix_fd_value (counter));
74 #endif
75 
76  /* disable or re-enable the read watch for the transport if
77  * required.
78  */
79  if (transport->vtable->live_messages_changed)
80  {
81  (* transport->vtable->live_messages_changed) (transport);
82  }
83 
84  _dbus_transport_unref (transport);
86 }
87 
103  const DBusTransportVTable *vtable,
104  const DBusString *server_guid,
105  const DBusString *address)
106 {
107  DBusMessageLoader *loader;
108  DBusAuth *auth;
109  DBusCounter *counter;
110  char *address_copy;
111  DBusCredentials *creds;
112 
113  loader = _dbus_message_loader_new ();
114  if (loader == NULL)
115  return FALSE;
116 
117  if (server_guid)
118  auth = _dbus_auth_server_new (server_guid);
119  else
120  auth = _dbus_auth_client_new ();
121  if (auth == NULL)
122  {
124  return FALSE;
125  }
126 
127  counter = _dbus_counter_new ();
128  if (counter == NULL)
129  {
130  _dbus_auth_unref (auth);
132  return FALSE;
133  }
134 
135  creds = _dbus_credentials_new ();
136  if (creds == NULL)
137  {
138  _dbus_counter_unref (counter);
139  _dbus_auth_unref (auth);
141  return FALSE;
142  }
143 
144  if (server_guid)
145  {
146  _dbus_assert (address == NULL);
147  address_copy = NULL;
148  }
149  else
150  {
151  _dbus_assert (address != NULL);
152 
153  if (!_dbus_string_copy_data (address, &address_copy))
154  {
155  _dbus_credentials_unref (creds);
156  _dbus_counter_unref (counter);
157  _dbus_auth_unref (auth);
159  return FALSE;
160  }
161  }
162 
163  transport->refcount = 1;
164  transport->vtable = vtable;
165  transport->loader = loader;
166  transport->auth = auth;
167  transport->live_messages = counter;
168  transport->authenticated = FALSE;
169  transport->disconnected = FALSE;
170  transport->is_server = (server_guid != NULL);
171  transport->send_credentials_pending = !transport->is_server;
172  transport->receive_credentials_pending = transport->is_server;
173  transport->address = address_copy;
174 
175  transport->unix_user_function = NULL;
176  transport->unix_user_data = NULL;
177  transport->free_unix_user_data = NULL;
178 
179  transport->windows_user_function = NULL;
180  transport->windows_user_data = NULL;
181  transport->free_windows_user_data = NULL;
182 
183  transport->expected_guid = NULL;
184 
185  /* Try to default to something that won't totally hose the system,
186  * but doesn't impose too much of a limitation.
187  */
188  transport->max_live_messages_size = _DBUS_ONE_MEGABYTE * 63;
189 
190  /* On Linux RLIMIT_NOFILE defaults to 1024, so allowing 4096 fds live
191  should be more than enough */
192  transport->max_live_messages_unix_fds = 4096;
193 
194  /* credentials read from socket if any */
195  transport->credentials = creds;
196 
198  transport->max_live_messages_size,
199  transport->max_live_messages_unix_fds,
200  live_messages_notify,
201  transport);
202 
203  if (transport->address)
204  _dbus_verbose ("Initialized transport on address %s\n", transport->address);
205 
206  return TRUE;
207 }
208 
215 void
217 {
218  if (!transport->disconnected)
219  _dbus_transport_disconnect (transport);
220 
221  if (transport->free_unix_user_data != NULL)
222  (* transport->free_unix_user_data) (transport->unix_user_data);
223 
224  if (transport->free_windows_user_data != NULL)
225  (* transport->free_windows_user_data) (transport->windows_user_data);
226 
227  _dbus_message_loader_unref (transport->loader);
228  _dbus_auth_unref (transport->auth);
230  0, 0, NULL, NULL);
231  _dbus_counter_unref (transport->live_messages);
232  dbus_free (transport->address);
233  dbus_free (transport->expected_guid);
234  if (transport->credentials)
236 }
237 
238 
249 static DBusTransport*
250 check_address (const char *address, DBusError *error)
251 {
252  DBusAddressEntry **entries;
253  DBusTransport *transport = NULL;
254  int len, i;
255 
256  _dbus_assert (address != NULL);
257  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
258 
259  if (!dbus_parse_address (address, &entries, &len, error))
260  return NULL; /* not a valid address */
261 
262  for (i = 0; i < len; i++)
263  {
264  dbus_error_free (error);
265  transport = _dbus_transport_open (entries[i], error);
266 
267  if (transport != NULL)
268  break;
269  }
270 
271  dbus_address_entries_free (entries);
272  return transport;
273 }
274 
283 static DBusTransport*
284 _dbus_transport_new_for_autolaunch (const char *scope, DBusError *error)
285 {
286  DBusString address;
287  DBusTransport *result = NULL;
288 
289  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
290 
291  if (!_dbus_string_init (&address))
292  {
294  return NULL;
295  }
296 
297  if (!_dbus_get_autolaunch_address (scope, &address, error))
298  {
299  _DBUS_ASSERT_ERROR_IS_SET (error);
300  goto out;
301  }
302 
303  result = check_address (_dbus_string_get_const_data (&address), error);
304  if (result == NULL)
305  _DBUS_ASSERT_ERROR_IS_SET (error);
306  else
307  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
308 
309  out:
310  _dbus_string_free (&address);
311  return result;
312 }
313 
314 static DBusTransportOpenResult
315 _dbus_transport_open_autolaunch (DBusAddressEntry *entry,
316  DBusTransport **transport_p,
317  DBusError *error)
318 {
319  const char *method;
320 
321  method = dbus_address_entry_get_method (entry);
322  _dbus_assert (method != NULL);
323 
324  if (strcmp (method, "autolaunch") == 0)
325  {
326  const char *scope = dbus_address_entry_get_value (entry, "scope");
327 
328  *transport_p = _dbus_transport_new_for_autolaunch (scope, error);
329 
330  if (*transport_p == NULL)
331  {
332  _DBUS_ASSERT_ERROR_IS_SET (error);
333  return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT;
334  }
335  else
336  {
337  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
338  return DBUS_TRANSPORT_OPEN_OK;
339  }
340  }
341  else
342  {
343  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
344  return DBUS_TRANSPORT_OPEN_NOT_HANDLED;
345  }
346 }
347 
348 static const struct {
349  DBusTransportOpenResult (* func) (DBusAddressEntry *entry,
350  DBusTransport **transport_p,
351  DBusError *error);
352 } open_funcs[] = {
355  { _dbus_transport_open_autolaunch }
356 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
357  , { _dbus_transport_open_debug_pipe }
358 #endif
359 };
360 
371  DBusError *error)
372 {
373  DBusTransport *transport;
374  const char *expected_guid_orig;
375  char *expected_guid;
376  int i;
377  DBusError tmp_error = DBUS_ERROR_INIT;
378 
379  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
380 
381  transport = NULL;
382  expected_guid_orig = dbus_address_entry_get_value (entry, "guid");
383  expected_guid = _dbus_strdup (expected_guid_orig);
384 
385  if (expected_guid_orig != NULL && expected_guid == NULL)
386  {
387  _DBUS_SET_OOM (error);
388  return NULL;
389  }
390 
391  for (i = 0; i < (int) _DBUS_N_ELEMENTS (open_funcs); ++i)
392  {
393  DBusTransportOpenResult result;
394 
395  _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
396  result = (* open_funcs[i].func) (entry, &transport, &tmp_error);
397 
398  switch (result)
399  {
400  case DBUS_TRANSPORT_OPEN_OK:
401  _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
402  goto out;
403  break;
404  case DBUS_TRANSPORT_OPEN_NOT_HANDLED:
405  _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
406  /* keep going through the loop of open funcs */
407  break;
408  case DBUS_TRANSPORT_OPEN_BAD_ADDRESS:
409  _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
410  goto out;
411  break;
412  case DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT:
413  _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
414  goto out;
415  break;
416  }
417  }
418 
419  out:
420 
421  if (transport == NULL)
422  {
423  if (!dbus_error_is_set (&tmp_error))
424  _dbus_set_bad_address (&tmp_error,
425  NULL, NULL,
426  "Unknown address type (examples of valid types are \"tcp\" and on UNIX \"unix\")");
427 
428  _DBUS_ASSERT_ERROR_IS_SET (&tmp_error);
429  dbus_move_error(&tmp_error, error);
430  dbus_free (expected_guid);
431  }
432  else
433  {
434  _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error);
435 
436  /* In the case of autostart the initial guid is NULL
437  * and the autostart transport recursively calls
438  * _dbus_open_transport wich returns a transport
439  * with a guid. That guid is the definitive one.
440  *
441  * FIXME: if more transports are added they may have
442  * an effect on the expected_guid semantics (i.e.
443  * expected_guid and transport->expected_guid may
444  * both have values). This is very unlikely though
445  * we should either throw asserts here for those
446  * corner cases or refactor the code so it is
447  * clearer on what is expected and what is not
448  */
449  if(expected_guid)
450  transport->expected_guid = expected_guid;
451  }
452 
453  return transport;
454 }
455 
464 {
465  _dbus_assert (transport->refcount > 0);
466 
467  transport->refcount += 1;
468 
469  return transport;
470 }
471 
479 void
481 {
482  _dbus_assert (transport != NULL);
483  _dbus_assert (transport->refcount > 0);
484 
485  transport->refcount -= 1;
486  if (transport->refcount == 0)
487  {
488  _dbus_verbose ("finalizing\n");
489 
490  _dbus_assert (transport->vtable->finalize != NULL);
491 
492  (* transport->vtable->finalize) (transport);
493  }
494 }
495 
504 void
506 {
507  _dbus_verbose ("start\n");
508 
509  _dbus_assert (transport->vtable->disconnect != NULL);
510 
511  if (transport->disconnected)
512  return;
513 
514  (* transport->vtable->disconnect) (transport);
515 
516  transport->disconnected = TRUE;
517 
518  _dbus_verbose ("end\n");
519 }
520 
531 {
532  return !transport->disconnected;
533 }
534 
535 static dbus_bool_t
536 auth_via_unix_user_function (DBusTransport *transport)
537 {
538  DBusCredentials *auth_identity;
539  dbus_bool_t allow;
540  DBusConnection *connection;
541  DBusAllowUnixUserFunction unix_user_function;
542  void *unix_user_data;
543  dbus_uid_t uid;
544 
545  /* Dropping the lock here probably isn't that safe. */
546 
547  auth_identity = _dbus_auth_get_identity (transport->auth);
548  _dbus_assert (auth_identity != NULL);
549 
550  connection = transport->connection;
551  unix_user_function = transport->unix_user_function;
552  unix_user_data = transport->unix_user_data;
553  uid = _dbus_credentials_get_unix_uid (auth_identity);
554 
555  _dbus_verbose ("unlock\n");
556  _dbus_connection_unlock (connection);
557 
558  allow = (* unix_user_function) (connection,
559  uid,
560  unix_user_data);
561 
562  _dbus_verbose ("lock post unix user function\n");
563  _dbus_connection_lock (connection);
564 
565  if (allow)
566  {
567  _dbus_verbose ("Client UID "DBUS_UID_FORMAT" authorized\n", uid);
568  }
569  else
570  {
571  _dbus_verbose ("Client UID "DBUS_UID_FORMAT
572  " was rejected, disconnecting\n",
573  _dbus_credentials_get_unix_uid (auth_identity));
574  _dbus_transport_disconnect (transport);
575  }
576 
577  return allow;
578 }
579 
580 static dbus_bool_t
581 auth_via_windows_user_function (DBusTransport *transport)
582 {
583  DBusCredentials *auth_identity;
584  dbus_bool_t allow;
585  DBusConnection *connection;
586  DBusAllowWindowsUserFunction windows_user_function;
587  void *windows_user_data;
588  char *windows_sid;
589 
590  /* Dropping the lock here probably isn't that safe. */
591 
592  auth_identity = _dbus_auth_get_identity (transport->auth);
593  _dbus_assert (auth_identity != NULL);
594 
595  connection = transport->connection;
596  windows_user_function = transport->windows_user_function;
597  windows_user_data = transport->unix_user_data;
598  windows_sid = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity));
599 
600  if (windows_sid == NULL)
601  {
602  /* OOM */
603  return FALSE;
604  }
605 
606  _dbus_verbose ("unlock\n");
607  _dbus_connection_unlock (connection);
608 
609  allow = (* windows_user_function) (connection,
610  windows_sid,
611  windows_user_data);
612 
613  _dbus_verbose ("lock post windows user function\n");
614  _dbus_connection_lock (connection);
615 
616  if (allow)
617  {
618  _dbus_verbose ("Client SID '%s' authorized\n", windows_sid);
619  }
620  else
621  {
622  _dbus_verbose ("Client SID '%s' was rejected, disconnecting\n",
623  _dbus_credentials_get_windows_sid (auth_identity));
624  _dbus_transport_disconnect (transport);
625  }
626 
627  return allow;
628 }
629 
630 static dbus_bool_t
631 auth_via_default_rules (DBusTransport *transport)
632 {
633  DBusCredentials *auth_identity;
634  DBusCredentials *our_identity;
635  dbus_bool_t allow;
636 
637  auth_identity = _dbus_auth_get_identity (transport->auth);
638  _dbus_assert (auth_identity != NULL);
639 
640  /* By default, connection is allowed if the client is 1) root or 2)
641  * has the same UID as us or 3) anonymous is allowed.
642  */
643 
645  if (our_identity == NULL)
646  {
647  /* OOM */
648  return FALSE;
649  }
650 
651  if (transport->allow_anonymous ||
652  _dbus_credentials_get_unix_uid (auth_identity) == 0 ||
653  _dbus_credentials_same_user (our_identity,
654  auth_identity))
655  {
656  if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID))
657  _dbus_verbose ("Client authorized as SID '%s'"
658  "matching our SID '%s'\n",
659  _dbus_credentials_get_windows_sid(auth_identity),
660  _dbus_credentials_get_windows_sid(our_identity));
661  else
662  _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT
663  " matching our UID "DBUS_UID_FORMAT"\n",
664  _dbus_credentials_get_unix_uid(auth_identity),
665  _dbus_credentials_get_unix_uid(our_identity));
666  /* We have authenticated! */
667  allow = TRUE;
668  }
669  else
670  {
671  if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID))
672  _dbus_verbose ("Client authorized as SID '%s'"
673  " but our SID is '%s', disconnecting\n",
674  (_dbus_credentials_get_windows_sid(auth_identity) ?
675  _dbus_credentials_get_windows_sid(auth_identity) : "<null>"),
676  (_dbus_credentials_get_windows_sid(our_identity) ?
677  _dbus_credentials_get_windows_sid(our_identity) : "<null>"));
678  else
679  _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT
680  " but our UID is "DBUS_UID_FORMAT", disconnecting\n",
681  _dbus_credentials_get_unix_uid(auth_identity),
682  _dbus_credentials_get_unix_uid(our_identity));
683  _dbus_transport_disconnect (transport);
684  allow = FALSE;
685  }
686 
687  _dbus_credentials_unref (our_identity);
688 
689  return allow;
690 }
691 
705 {
706  return transport->authenticated;
707 }
708 
728 {
729  if (transport->authenticated)
730  return TRUE;
731  else
732  {
733  dbus_bool_t maybe_authenticated;
734 
735  if (transport->disconnected)
736  return FALSE;
737 
738  /* paranoia ref since we call user callbacks sometimes */
740 
741  maybe_authenticated =
742  (!(transport->send_credentials_pending ||
743  transport->receive_credentials_pending));
744 
745  if (maybe_authenticated)
746  {
747  switch (_dbus_auth_do_work (transport->auth))
748  {
749  case DBUS_AUTH_STATE_AUTHENTICATED:
750  /* leave as maybe_authenticated */
751  break;
752  default:
753  maybe_authenticated = FALSE;
754  }
755  }
756 
757  /* If we're the client, verify the GUID
758  */
759  if (maybe_authenticated && !transport->is_server)
760  {
761  const char *server_guid;
762 
763  server_guid = _dbus_auth_get_guid_from_server (transport->auth);
764  _dbus_assert (server_guid != NULL);
765 
766  if (transport->expected_guid &&
767  strcmp (transport->expected_guid, server_guid) != 0)
768  {
769  _dbus_verbose ("Client expected GUID '%s' and we got '%s' from the server\n",
770  transport->expected_guid, server_guid);
771  _dbus_transport_disconnect (transport);
773  return FALSE;
774  }
775  }
776 
777  /* If we're the server, see if we want to allow this identity to proceed.
778  */
779  if (maybe_authenticated && transport->is_server)
780  {
781  dbus_bool_t allow;
782  DBusCredentials *auth_identity;
783 
784  auth_identity = _dbus_auth_get_identity (transport->auth);
785  _dbus_assert (auth_identity != NULL);
786 
787  /* If we have an auth'd user and a user function, delegate
788  * deciding whether auth credentials are good enough to the
789  * app; otherwise, use our default decision process.
790  */
791  if (transport->unix_user_function != NULL &&
792  _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_UNIX_USER_ID))
793  {
794  allow = auth_via_unix_user_function (transport);
795  }
796  else if (transport->windows_user_function != NULL &&
797  _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_WINDOWS_SID))
798  {
799  allow = auth_via_windows_user_function (transport);
800  }
801  else
802  {
803  allow = auth_via_default_rules (transport);
804  }
805 
806  if (!allow)
807  maybe_authenticated = FALSE;
808  }
809 
810  transport->authenticated = maybe_authenticated;
811 
813  return maybe_authenticated;
814  }
815 }
816 
825 {
826  DBusCredentials *auth_identity;
827 
828  if (!transport->authenticated)
829  return TRUE;
830 
831  auth_identity = _dbus_auth_get_identity (transport->auth);
832 
833  if (_dbus_credentials_are_anonymous (auth_identity))
834  return TRUE;
835  else
836  return FALSE;
837 }
838 
847 {
848  return DBUS_TRANSPORT_CAN_SEND_UNIX_FD(transport);
849 }
850 
858 const char*
860 {
861  return transport->address;
862 }
863 
871 const char*
873 {
874  if (transport->is_server)
875  return NULL;
876  else if (transport->authenticated)
877  return _dbus_auth_get_guid_from_server (transport->auth);
878  else
879  return transport->expected_guid;
880 }
881 
893  DBusWatch *watch,
894  unsigned int condition)
895 {
896  dbus_bool_t retval;
897 
898  _dbus_assert (transport->vtable->handle_watch != NULL);
899 
900  if (transport->disconnected)
901  return TRUE;
902 
903  if (dbus_watch_get_socket (watch) < 0)
904  {
905  _dbus_warn_check_failed ("Tried to handle an invalidated watch; this watch should have been removed\n");
906  return TRUE;
907  }
908 
909  _dbus_watch_sanitize_condition (watch, &condition);
910 
911  _dbus_transport_ref (transport);
912  _dbus_watch_ref (watch);
913  retval = (* transport->vtable->handle_watch) (transport, watch, condition);
914  _dbus_watch_unref (watch);
915  _dbus_transport_unref (transport);
916 
917  return retval;
918 }
919 
931  DBusConnection *connection)
932 {
933  _dbus_assert (transport->vtable->connection_set != NULL);
934  _dbus_assert (transport->connection == NULL);
935 
936  transport->connection = connection;
937 
938  _dbus_transport_ref (transport);
939  if (!(* transport->vtable->connection_set) (transport))
940  transport->connection = NULL;
941  _dbus_transport_unref (transport);
942 
943  return transport->connection != NULL;
944 }
945 
955  DBusSocket *fd_p)
956 {
957  dbus_bool_t retval;
958 
959  if (transport->vtable->get_socket_fd == NULL)
960  return FALSE;
961 
962  if (transport->disconnected)
963  return FALSE;
964 
965  _dbus_transport_ref (transport);
966 
967  retval = (* transport->vtable->get_socket_fd) (transport,
968  fd_p);
969 
970  _dbus_transport_unref (transport);
971 
972  return retval;
973 }
974 
986 void
988  unsigned int flags,
989  int timeout_milliseconds)
990 {
991  _dbus_assert (transport->vtable->do_iteration != NULL);
992 
993  _dbus_verbose ("Transport iteration flags 0x%x timeout %d connected = %d\n",
994  flags, timeout_milliseconds, !transport->disconnected);
995 
996  if ((flags & (DBUS_ITERATION_DO_WRITING |
997  DBUS_ITERATION_DO_READING)) == 0)
998  return; /* Nothing to do */
999 
1000  if (transport->disconnected)
1001  return;
1002 
1003  _dbus_transport_ref (transport);
1004  (* transport->vtable->do_iteration) (transport, flags,
1005  timeout_milliseconds);
1006  _dbus_transport_unref (transport);
1007 
1008  _dbus_verbose ("end\n");
1009 }
1010 
1011 static dbus_bool_t
1012 recover_unused_bytes (DBusTransport *transport)
1013 {
1014  if (_dbus_auth_needs_decoding (transport->auth))
1015  {
1016  DBusString plaintext;
1017  const DBusString *encoded;
1018  DBusString *buffer;
1019  int orig_len;
1020 
1021  if (!_dbus_string_init (&plaintext))
1022  goto nomem;
1023 
1024  _dbus_auth_get_unused_bytes (transport->auth,
1025  &encoded);
1026 
1027  if (!_dbus_auth_decode_data (transport->auth,
1028  encoded, &plaintext))
1029  {
1030  _dbus_string_free (&plaintext);
1031  goto nomem;
1032  }
1033 
1035  &buffer,
1036  NULL,
1037  NULL);
1038 
1039  orig_len = _dbus_string_get_length (buffer);
1040 
1041  if (!_dbus_string_move (&plaintext, 0, buffer,
1042  orig_len))
1043  {
1044  _dbus_string_free (&plaintext);
1045  goto nomem;
1046  }
1047 
1048  _dbus_verbose (" %d unused bytes sent to message loader\n",
1049  _dbus_string_get_length (buffer) -
1050  orig_len);
1051 
1053  buffer);
1054 
1055  _dbus_auth_delete_unused_bytes (transport->auth);
1056 
1057  _dbus_string_free (&plaintext);
1058  }
1059  else
1060  {
1061  const DBusString *bytes;
1062  DBusString *buffer;
1063  int orig_len;
1064  dbus_bool_t succeeded;
1065 
1067  &buffer,
1068  NULL,
1069  NULL);
1070 
1071  orig_len = _dbus_string_get_length (buffer);
1072 
1073  _dbus_auth_get_unused_bytes (transport->auth,
1074  &bytes);
1075 
1076  succeeded = TRUE;
1077  if (!_dbus_string_copy (bytes, 0, buffer, _dbus_string_get_length (buffer)))
1078  succeeded = FALSE;
1079 
1080  _dbus_verbose (" %d unused bytes sent to message loader\n",
1081  _dbus_string_get_length (buffer) -
1082  orig_len);
1083 
1085  buffer);
1086 
1087  if (succeeded)
1088  _dbus_auth_delete_unused_bytes (transport->auth);
1089  else
1090  goto nomem;
1091  }
1092 
1093  return TRUE;
1094 
1095  nomem:
1096  _dbus_verbose ("Not enough memory to transfer unused bytes from auth conversation\n");
1097  return FALSE;
1098 }
1099 
1109 {
1110  if (_dbus_counter_get_size_value (transport->live_messages) >= transport->max_live_messages_size ||
1112  return DBUS_DISPATCH_COMPLETE; /* complete for now */
1113 
1114  if (!_dbus_transport_try_to_authenticate (transport))
1115  {
1116  if (_dbus_auth_do_work (transport->auth) ==
1117  DBUS_AUTH_STATE_WAITING_FOR_MEMORY)
1119  else if (!_dbus_transport_try_to_authenticate (transport))
1120  return DBUS_DISPATCH_COMPLETE;
1121  }
1122 
1123  if (!transport->unused_bytes_recovered &&
1124  !recover_unused_bytes (transport))
1126 
1127  transport->unused_bytes_recovered = TRUE;
1128 
1129  if (!_dbus_message_loader_queue_messages (transport->loader))
1131 
1132  if (_dbus_message_loader_peek_message (transport->loader) != NULL)
1134  else
1135  return DBUS_DISPATCH_COMPLETE;
1136 }
1137 
1148 {
1149  DBusDispatchStatus status;
1150 
1151 #if 0
1152  _dbus_verbose ("_dbus_transport_queue_messages()\n");
1153 #endif
1154 
1155  /* Queue any messages */
1156  while ((status = _dbus_transport_get_dispatch_status (transport)) == DBUS_DISPATCH_DATA_REMAINS)
1157  {
1158  DBusMessage *message;
1159  DBusList *link;
1160 
1161  link = _dbus_message_loader_pop_message_link (transport->loader);
1162  _dbus_assert (link != NULL);
1163 
1164  message = link->data;
1165 
1166  _dbus_verbose ("queueing received message %p\n", message);
1167 
1168  if (!_dbus_message_add_counter (message, transport->live_messages))
1169  {
1171  link);
1172  status = DBUS_DISPATCH_NEED_MEMORY;
1173  break;
1174  }
1175  else
1176  {
1177  /* We didn't call the notify function when we added the counter, so
1178  * catch up now. Since we have the connection's lock, it's desirable
1179  * that we bypass the notify function and call this virtual method
1180  * directly. */
1181  if (transport->vtable->live_messages_changed)
1182  (* transport->vtable->live_messages_changed) (transport);
1183 
1184  /* pass ownership of link and message ref to connection */
1186  link);
1187  }
1188  }
1189 
1191  {
1192  _dbus_verbose ("Corrupted message stream, disconnecting\n");
1193  _dbus_transport_disconnect (transport);
1194  }
1195 
1196  return status != DBUS_DISPATCH_NEED_MEMORY;
1197 }
1198 
1205 void
1207  long size)
1208 {
1210 }
1211 
1218 void
1220  long n)
1221 {
1223 }
1224 
1231 long
1233 {
1235 }
1236 
1243 long
1245 {
1247 }
1248 
1255 void
1257  long size)
1258 {
1259  transport->max_live_messages_size = size;
1261  transport->max_live_messages_size,
1262  transport->max_live_messages_unix_fds,
1263  live_messages_notify,
1264  transport);
1265 }
1266 
1273 void
1275  long n)
1276 {
1277  transport->max_live_messages_unix_fds = n;
1279  transport->max_live_messages_size,
1280  transport->max_live_messages_unix_fds,
1281  live_messages_notify,
1282  transport);
1283 }
1284 
1291 long
1293 {
1294  return transport->max_live_messages_size;
1295 }
1296 
1303 long
1305 {
1306  return transport->max_live_messages_unix_fds;
1307 }
1308 
1318  unsigned long *uid)
1319 {
1320  DBusCredentials *auth_identity;
1321 
1322  *uid = _DBUS_INT32_MAX; /* better than some root or system user in
1323  * case of bugs in the caller. Caller should
1324  * never use this value on purpose, however.
1325  */
1326 
1327  if (!transport->authenticated)
1328  return FALSE;
1329 
1330  auth_identity = _dbus_auth_get_identity (transport->auth);
1331 
1332  if (_dbus_credentials_include (auth_identity,
1333  DBUS_CREDENTIAL_UNIX_USER_ID))
1334  {
1335  *uid = _dbus_credentials_get_unix_uid (auth_identity);
1336  return TRUE;
1337  }
1338  else
1339  return FALSE;
1340 }
1341 
1351  unsigned long *pid)
1352 {
1353  DBusCredentials *auth_identity;
1354 
1355  *pid = DBUS_PID_UNSET; /* Caller should never use this value on purpose,
1356  * but we set it to a safe number, INT_MAX,
1357  * just to root out possible bugs in bad callers.
1358  */
1359 
1360  if (!transport->authenticated)
1361  return FALSE;
1362 
1363  auth_identity = _dbus_auth_get_identity (transport->auth);
1364 
1365  if (_dbus_credentials_include (auth_identity,
1366  DBUS_CREDENTIAL_UNIX_PROCESS_ID))
1367  {
1368  *pid = _dbus_credentials_get_pid (auth_identity);
1369  return TRUE;
1370  }
1371  else
1372  return FALSE;
1373 }
1374 
1385  void **data,
1386  int *data_size)
1387 {
1388  DBusCredentials *auth_identity;
1389 
1390  *data = NULL;
1391  *data_size = 0;
1392 
1393  if (!transport->authenticated)
1394  return FALSE;
1395 
1396  auth_identity = _dbus_auth_get_identity (transport->auth);
1397 
1398  if (_dbus_credentials_include (auth_identity,
1399  DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID))
1400  {
1401  *data = (void *) _dbus_credentials_get_adt_audit_data (auth_identity);
1402  *data_size = _dbus_credentials_get_adt_audit_data_size (auth_identity);
1403  return TRUE;
1404  }
1405  else
1406  return FALSE;
1407 }
1408 
1419 void
1421  DBusAllowUnixUserFunction function,
1422  void *data,
1423  DBusFreeFunction free_data_function,
1424  void **old_data,
1425  DBusFreeFunction *old_free_data_function)
1426 {
1427  *old_data = transport->unix_user_data;
1428  *old_free_data_function = transport->free_unix_user_data;
1429 
1430  transport->unix_user_function = function;
1431  transport->unix_user_data = data;
1432  transport->free_unix_user_data = free_data_function;
1433 }
1434 
1436 _dbus_transport_get_linux_security_label (DBusTransport *transport,
1437  char **label_p)
1438 {
1439  DBusCredentials *auth_identity;
1440 
1441  *label_p = NULL;
1442 
1443  if (!transport->authenticated)
1444  return FALSE;
1445 
1446  auth_identity = _dbus_auth_get_identity (transport->auth);
1447 
1448  if (_dbus_credentials_include (auth_identity,
1449  DBUS_CREDENTIAL_LINUX_SECURITY_LABEL))
1450  {
1451  /* If no memory, we are supposed to return TRUE and set NULL */
1452  *label_p = _dbus_strdup (_dbus_credentials_get_linux_security_label (auth_identity));
1453 
1454  return TRUE;
1455  }
1456  else
1457  {
1458  return FALSE;
1459  }
1460 }
1461 
1471  char **windows_sid_p)
1472 {
1473  DBusCredentials *auth_identity;
1474 
1475  *windows_sid_p = NULL;
1476 
1477  if (!transport->authenticated)
1478  return FALSE;
1479 
1480  auth_identity = _dbus_auth_get_identity (transport->auth);
1481 
1482  if (_dbus_credentials_include (auth_identity,
1483  DBUS_CREDENTIAL_WINDOWS_SID))
1484  {
1485  /* If no memory, we are supposed to return TRUE and set NULL */
1486  *windows_sid_p = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity));
1487 
1488  return TRUE;
1489  }
1490  else
1491  return FALSE;
1492 }
1493 
1505 void
1508  void *data,
1509  DBusFreeFunction free_data_function,
1510  void **old_data,
1511  DBusFreeFunction *old_free_data_function)
1512 {
1513  *old_data = transport->windows_user_data;
1514  *old_free_data_function = transport->free_windows_user_data;
1515 
1516  transport->windows_user_function = function;
1517  transport->windows_user_data = data;
1518  transport->free_windows_user_data = free_data_function;
1519 }
1520 
1531  const char **mechanisms)
1532 {
1533  return _dbus_auth_set_mechanisms (transport->auth, mechanisms);
1534 }
1535 
1542 void
1544  dbus_bool_t value)
1545 {
1546  transport->allow_anonymous = value != FALSE;
1547 }
1548 
1554 int
1556 {
1558 }
1559 
1567 void
1569  void (* callback) (void *),
1570  void *data)
1571 {
1573  callback, data);
1574 }
1575 
1576 #ifdef DBUS_ENABLE_STATS
1577 void
1578 _dbus_transport_get_stats (DBusTransport *transport,
1579  dbus_uint32_t *queue_bytes,
1580  dbus_uint32_t *queue_fds,
1581  dbus_uint32_t *peak_queue_bytes,
1582  dbus_uint32_t *peak_queue_fds)
1583 {
1584  if (queue_bytes != NULL)
1585  *queue_bytes = _dbus_counter_get_size_value (transport->live_messages);
1586 
1587  if (queue_fds != NULL)
1588  *queue_fds = _dbus_counter_get_unix_fd_value (transport->live_messages);
1589 
1590  if (peak_queue_bytes != NULL)
1591  *peak_queue_bytes = _dbus_counter_get_peak_size_value (transport->live_messages);
1592 
1593  if (peak_queue_fds != NULL)
1594  *peak_queue_fds = _dbus_counter_get_peak_unix_fd_value (transport->live_messages);
1595 }
1596 #endif /* DBUS_ENABLE_STATS */
1597 
void _dbus_transport_set_max_received_unix_fds(DBusTransport *transport, long n)
See dbus_connection_set_max_received_unix_fds().
dbus_uid_t _dbus_credentials_get_unix_uid(DBusCredentials *credentials)
Gets the UNIX user ID in the credentials, or DBUS_UID_UNSET if the credentials object doesn&#39;t contain...
const char * _dbus_transport_get_server_id(DBusTransport *transport)
Gets the id of the server we are connected to (see dbus_server_get_id()).
long max_live_messages_unix_fds
Max total unix fds of received messages.
DBusDispatchStatus
Indicates the status of incoming data on a DBusConnection.
void _dbus_auth_delete_unused_bytes(DBusAuth *auth)
Gets rid of unused bytes returned by _dbus_auth_get_unused_bytes() after we&#39;ve gotten them and succes...
Definition: dbus-auth.c:2648
const char * _dbus_transport_get_address(DBusTransport *transport)
Gets the address of a transport.
Implementation of DBusWatch.
Definition: dbus-watch.c:40
#define NULL
A null pointer, defined appropriately for C or C++.
void(* DBusFreeFunction)(void *memory)
The type of a function which frees a block of memory.
Definition: dbus-memory.h:64
dbus_bool_t _dbus_credentials_include(DBusCredentials *credentials, DBusCredentialType type)
Checks whether the given credential is present.
void _dbus_auth_get_unused_bytes(DBusAuth *auth, const DBusString **str)
Returns leftover bytes that were not used as part of the auth conversation.
Definition: dbus-auth.c:2631
DBUS_PRIVATE_EXPORT long _dbus_message_loader_get_max_message_size(DBusMessageLoader *loader)
Gets the maximum allowed message size in bytes.
DBusTransportOpenResult _dbus_transport_open_platform_specific(DBusAddressEntry *entry, DBusTransport **transport_p, DBusError *error)
Opens platform specific transport types.
void _dbus_message_loader_putback_message_link(DBusMessageLoader *loader, DBusList *link)
Returns a popped message link, used to undo a pop.
DBUS_PRIVATE_EXPORT void _dbus_message_loader_return_buffer(DBusMessageLoader *loader, DBusString *buffer)
Returns a buffer obtained from _dbus_message_loader_get_buffer(), indicating to the loader how many b...
More memory is needed to continue.
DBusAuth * auth
Authentication conversation.
void(* do_iteration)(DBusTransport *transport, unsigned int flags, int timeout_milliseconds)
Called to do a single &quot;iteration&quot; (block on select/poll followed by reading or writing data)...
unsigned int disconnected
TRUE if we are disconnected.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:701
dbus_int32_t _dbus_credentials_get_adt_audit_data_size(DBusCredentials *credentials)
Gets the ADT audit data size in the credentials, or 0 if the credentials object doesn&#39;t contain ADT a...
dbus_bool_t _dbus_auth_needs_decoding(DBusAuth *auth)
Called post-authentication, indicates whether we need to decode the message stream with _dbus_auth_de...
Definition: dbus-auth.c:2724
long max_live_messages_size
Max total size of received messages.
DBusFreeFunction free_windows_user_data
Function to free windows_user_data.
DBUS_PRIVATE_EXPORT void _dbus_connection_lock(DBusConnection *connection)
Acquires the connection lock.
dbus_bool_t _dbus_transport_get_socket_fd(DBusTransport *transport, DBusSocket *fd_p)
Get the socket file descriptor, if any.
char * expected_guid
GUID we expect the server to have, NULL on server side or if we don&#39;t have an expectation.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
Internals of DBusCounter.
#define DBUS_ERROR_INIT
Expands to a suitable initializer for a DBusError on the stack.
Definition: dbus-errors.h:62
void * data
Data stored at this element.
Definition: dbus-list.h:38
unsigned int authenticated
Cache of auth state; use _dbus_transport_peek_is_authenticated() to query value.
const char * dbus_address_entry_get_method(DBusAddressEntry *entry)
Returns the method string of an address entry.
Definition: dbus-address.c:227
DBusTransportOpenResult _dbus_transport_open_socket(DBusAddressEntry *entry, DBusTransport **transport_p, DBusError *error)
Opens a TCP socket transport.
void _dbus_warn_check_failed(const char *format,...)
Prints a &quot;critical&quot; warning to stderr when an assertion fails; differs from _dbus_warn primarily in t...
dbus_bool_t _dbus_transport_get_unix_process_id(DBusTransport *transport, unsigned long *pid)
See dbus_connection_get_unix_process_id().
dbus_bool_t _dbus_transport_queue_messages(DBusTransport *transport)
Processes data we&#39;ve read while handling a watch, potentially converting some of it to messages and q...
void _dbus_transport_set_unix_user_function(DBusTransport *transport, DBusAllowUnixUserFunction function, void *data, DBusFreeFunction free_data_function, void **old_data, DBusFreeFunction *old_free_data_function)
See dbus_connection_set_unix_user_function().
DBusAuthState _dbus_auth_do_work(DBusAuth *auth)
Analyzes buffered input and moves the auth conversation forward, returning the new state of the auth ...
Definition: dbus-auth.c:2505
void dbus_error_free(DBusError *error)
Frees an error that&#39;s been set (or just initialized), then reinitializes the error as in dbus_error_i...
Definition: dbus-errors.c:211
DBUS_PRIVATE_EXPORT void _dbus_message_loader_unref(DBusMessageLoader *loader)
Decrements the reference count of the loader and finalizes the loader when the count reaches zero...
DBusConnection * connection
Connection owning this transport.
int refcount
Reference count.
void dbus_address_entries_free(DBusAddressEntry **entries)
Frees a NULL-terminated array of address entries.
Definition: dbus-address.c:189
dbus_bool_t _dbus_transport_get_windows_user(DBusTransport *transport, char **windows_sid_p)
See dbus_connection_get_windows_user().
Implementation details of DBusConnection.
unsigned int send_credentials_pending
TRUE if we need to send credentials
dbus_bool_t _dbus_auth_set_mechanisms(DBusAuth *auth, const char **mechanisms)
Sets an array of authentication mechanism names that we are willing to use.
Definition: dbus-auth.c:2470
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
Definition: dbus-string.c:175
long _dbus_transport_get_max_message_size(DBusTransport *transport)
See dbus_connection_get_max_message_size().
dbus_bool_t _dbus_string_copy(const DBusString *source, int start, DBusString *dest, int insert_at)
Like _dbus_string_move(), but does not delete the section of the source string that&#39;s copied to the d...
Definition: dbus-string.c:1283
#define DBUS_PID_UNSET
an invalid PID used to represent an uninitialized dbus_pid_t field
Definition: dbus-sysdeps.h:112
dbus_bool_t _dbus_message_add_counter(DBusMessage *message, DBusCounter *counter)
Adds a counter to be incremented immediately with the size/unix fds of this message, and decremented by the size/unix fds of this message when this message if finalized.
Definition: dbus-message.c:352
void(* finalize)(DBusTransport *transport)
The finalize method must free the transport.
dbus_bool_t _dbus_transport_get_is_connected(DBusTransport *transport)
Returns TRUE if the transport has not been disconnected.
dbus_bool_t _dbus_get_autolaunch_address(const char *scope, DBusString *address, DBusError *error)
Returns the address of a new session bus.
dbus_bool_t(* connection_set)(DBusTransport *transport)
Called when transport-&gt;connection has been filled in.
dbus_bool_t _dbus_transport_set_auth_mechanisms(DBusTransport *transport, const char **mechanisms)
Sets the SASL authentication mechanisms supported by this transport.
dbus_bool_t _dbus_transport_init_base(DBusTransport *transport, const DBusTransportVTable *vtable, const DBusString *server_guid, const DBusString *address)
Initializes the base class members of DBusTransport.
There is more data to potentially convert to messages.
Socket interface.
Definition: dbus-sysdeps.h:148
DBusCredentials * _dbus_auth_get_identity(DBusAuth *auth)
Gets the identity we authorized the client as.
Definition: dbus-auth.c:2805
Internals of DBusMessage.
dbus_bool_t _dbus_auth_decode_data(DBusAuth *auth, const DBusString *encoded, DBusString *plaintext)
Called post-authentication, decodes a block of bytes received from the peer.
Definition: dbus-auth.c:2755
dbus_bool_t _dbus_string_move(DBusString *source, int start, DBusString *dest, int insert_at)
Moves the end of one string into another string.
Definition: dbus-string.c:1259
const char * dbus_address_entry_get_value(DBusAddressEntry *entry, const char *key)
Returns a value from a key of an entry.
Definition: dbus-address.c:244
long _dbus_transport_get_max_received_unix_fds(DBusTransport *transport)
See dbus_connection_set_max_received_unix_fds().
dbus_bool_t _dbus_credentials_are_anonymous(DBusCredentials *credentials)
Checks whether a credentials object contains a user identity.
void _dbus_transport_set_windows_user_function(DBusTransport *transport, DBusAllowWindowsUserFunction function, void *data, DBusFreeFunction free_data_function, void **old_data, DBusFreeFunction *old_free_data_function)
See dbus_connection_set_windows_user_function().
unsigned int receive_credentials_pending
TRUE if we need to receive credentials
dbus_bool_t _dbus_string_copy_data(const DBusString *str, char **data_return)
Copies the data from the string into a char*.
Definition: dbus-string.c:672
dbus_bool_t _dbus_transport_get_adt_audit_session_data(DBusTransport *transport, void **data, int *data_size)
See dbus_connection_get_adt_audit_session_data().
DBusCounter * live_messages
Counter for size/unix fds of all live messages.
Internal members of DBusAuth.
Definition: dbus-auth.c:153
void _dbus_message_loader_set_max_message_size(DBusMessageLoader *loader, long size)
Sets the maximum size message we allow.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
DBUS_EXPORT int dbus_watch_get_socket(DBusWatch *watch)
Returns a socket to be watched, on UNIX this will return -1 if our transport is not socket-based so d...
Definition: dbus-watch.c:594
dbus_bool_t _dbus_transport_peek_is_authenticated(DBusTransport *transport)
Returns TRUE if we have been authenticated.
void * unix_user_data
Data for unix_user_function.
All currently available data has been processed.
DBusAllowWindowsUserFunction windows_user_function
Function for checking whether a user is authorized.
DBusCredentials * _dbus_credentials_new_from_current_process(void)
Creates a new object with credentials (user ID and process ID) from the current process.
DBusAuth * _dbus_auth_server_new(const DBusString *guid)
Creates a new auth conversation object for the server side.
Definition: dbus-auth.c:2321
void _dbus_counter_unref(DBusCounter *counter)
Decrements refcount of the counter and possibly finalizes the counter.
void _dbus_watch_sanitize_condition(DBusWatch *watch, unsigned int *condition)
Sanitizes the given condition so that it only contains flags that the DBusWatch requested.
Definition: dbus-watch.c:185
unsigned int allow_anonymous
TRUE if an anonymous client can connect
Internals of DBusAddressEntry.
Definition: dbus-address.c:43
DBUS_PRIVATE_EXPORT DBusMessageLoader * _dbus_message_loader_new(void)
Creates a new message loader.
void _dbus_set_bad_address(DBusError *error, const char *address_problem_type, const char *address_problem_field, const char *address_problem_other)
Sets DBUS_ERROR_BAD_ADDRESS.
Definition: dbus-address.c:65
DBUS_PRIVATE_EXPORT void _dbus_connection_unref_unlocked(DBusConnection *connection)
Decrements the reference count of a DBusConnection.
Object representing an exception.
Definition: dbus-errors.h:48
dbus_bool_t(* DBusAllowUnixUserFunction)(DBusConnection *connection, unsigned long uid, void *data)
Called during authentication to check whether the given UNIX user ID is allowed to connect...
dbus_bool_t _dbus_transport_get_is_anonymous(DBusTransport *transport)
See dbus_connection_get_is_anonymous().
dbus_bool_t(* get_socket_fd)(DBusTransport *transport, DBusSocket *fd_p)
Get socket file descriptor.
void _dbus_message_loader_set_pending_fds_function(DBusMessageLoader *loader, void(*callback)(void *), void *data)
Register a function to be called whenever the number of pending file descriptors in the loader change...
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
Definition: dbus-errors.c:354
unsigned int unused_bytes_recovered
TRUE if we&#39;ve recovered unused bytes from auth
The virtual table that must be implemented to create a new kind of transport.
char * address
Address of the server we are connecting to (NULL for the server side of a transport) ...
const char * _dbus_auth_get_guid_from_server(DBusAuth *auth)
Gets the GUID from the server if we&#39;ve authenticated; gets NULL otherwise.
Definition: dbus-auth.c:2829
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_message_loader_get_is_corrupted(DBusMessageLoader *loader)
Checks whether the loader is confused due to bad data.
#define _DBUS_N_ELEMENTS(array)
Computes the number of elements in a fixed-size array using sizeof().
DBusTransport * _dbus_transport_open(DBusAddressEntry *entry, DBusError *error)
Try to open a new transport for the given address entry.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
Definition: dbus-string.c:259
dbus_bool_t _dbus_transport_get_unix_user(DBusTransport *transport, unsigned long *uid)
See dbus_connection_get_unix_user().
long _dbus_message_loader_get_max_message_unix_fds(DBusMessageLoader *loader)
Gets the maximum allowed number of unix fds per message.
#define TRUE
Expands to &quot;1&quot;.
DBusMessageLoader * loader
Message-loading buffer.
unsigned int is_server
TRUE if on the server side
void(* live_messages_changed)(DBusTransport *transport)
Outstanding messages counter changed.
void _dbus_counter_set_notify(DBusCounter *counter, long size_guard_value, long unix_fd_guard_value, DBusCounterNotifyFunction function, void *user_data)
Sets the notify function for this counter; the notify function is called whenever the counter&#39;s value...
dbus_bool_t _dbus_transport_set_connection(DBusTransport *transport, DBusConnection *connection)
Sets the connection using this transport.
void dbus_move_error(DBusError *src, DBusError *dest)
Moves an error src into dest, freeing src and overwriting dest.
Definition: dbus-errors.c:279
Object representing a transport such as a socket.
#define DBUS_UID_FORMAT
an appropriate printf format for dbus_uid_t
Definition: dbus-sysdeps.h:121
DBusCredentials * _dbus_credentials_new(void)
Creates a new credentials object.
dbus_bool_t _dbus_transport_handle_watch(DBusTransport *transport, DBusWatch *watch, unsigned int condition)
Handles a watch by reading data, writing data, or disconnecting the transport, as appropriate for the...
DBusList * _dbus_message_loader_pop_message_link(DBusMessageLoader *loader)
Pops a loaded message inside a list link (passing ownership of the message and link to the caller)...
A node in a linked list.
Definition: dbus-list.h:34
DBusTransport * _dbus_transport_ref(DBusTransport *transport)
Increments the reference count for the transport.
dbus_bool_t _dbus_transport_try_to_authenticate(DBusTransport *transport)
Returns TRUE if we have been authenticated.
void _dbus_auth_unref(DBusAuth *auth)
Decrements the refcount of an auth object.
Definition: dbus-auth.c:2420
void _dbus_transport_do_iteration(DBusTransport *transport, unsigned int flags, int timeout_milliseconds)
Performs a single poll()/select() on the transport&#39;s file descriptors and then reads/writes data as a...
long _dbus_transport_get_max_received_size(DBusTransport *transport)
See dbus_connection_get_max_received_size().
long _dbus_transport_get_max_message_unix_fds(DBusTransport *transport)
See dbus_connection_get_max_message_unix_fds().
DBusAllowUnixUserFunction unix_user_function
Function for checking whether a user is authorized.
dbus_pid_t _dbus_credentials_get_pid(DBusCredentials *credentials)
Gets the UNIX process ID in the credentials, or DBUS_PID_UNSET if the credentials object doesn&#39;t cont...
void _dbus_watch_unref(DBusWatch *watch)
Decrements the reference count of a DBusWatch object and finalizes the object if the count reaches ze...
Definition: dbus-watch.c:138
void _dbus_transport_set_pending_fds_function(DBusTransport *transport, void(*callback)(void *), void *data)
Register a function to be called whenever the number of pending file descriptors in the loader change...
DBusCounter * _dbus_counter_new(void)
Creates a new DBusCounter.
void _dbus_connection_queue_received_message_link(DBusConnection *connection, DBusList *link)
Adds a message-containing list link to the incoming message queue, taking ownership of the link and t...
void _dbus_transport_set_allow_anonymous(DBusTransport *transport, dbus_bool_t value)
See dbus_connection_set_allow_anonymous()
dbus_bool_t(* DBusAllowWindowsUserFunction)(DBusConnection *connection, const char *user_sid, void *data)
Called during authentication to check whether the given Windows user ID is allowed to connect...
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
#define _DBUS_INT32_MAX
Maximum value of type &quot;int32&quot;.
void _dbus_credentials_unref(DBusCredentials *credentials)
Decrement refcount on credentials.
void _dbus_transport_set_max_received_size(DBusTransport *transport, long size)
See dbus_connection_set_max_received_size().
#define FALSE
Expands to &quot;0&quot;.
const char * _dbus_credentials_get_linux_security_label(DBusCredentials *credentials)
Gets the Linux security label (as used by LSMs) from the credentials, or NULL if the credentials obje...
dbus_bool_t _dbus_credentials_same_user(DBusCredentials *credentials, DBusCredentials *other_credentials)
Check whether the user-identifying credentials in two credentials objects are identical.
DBusCredentials * credentials
Credentials of other end read from the socket.
int _dbus_transport_get_pending_fds_count(DBusTransport *transport)
Return how many file descriptors are pending in the loader.
dbus_bool_t dbus_parse_address(const char *address, DBusAddressEntry ***entry, int *array_len, DBusError *error)
Parses an address string of the form:
Definition: dbus-address.c:363
dbus_bool_t _dbus_transport_can_pass_unix_fd(DBusTransport *transport)
Returns TRUE if the transport supports sending unix fds.
DBusWatch * _dbus_watch_ref(DBusWatch *watch)
Increments the reference count of a DBusWatch object.
Definition: dbus-watch.c:124
DBusMessage * _dbus_message_loader_peek_message(DBusMessageLoader *loader)
Peeks at first loaded message, returns NULL if no messages have been queued.
DBUS_PRIVATE_EXPORT void _dbus_message_loader_get_buffer(DBusMessageLoader *loader, DBusString **buffer, int *max_to_read, dbus_bool_t *may_read_unix_fds)
Gets the buffer to use for reading data from the network.
const char * _dbus_credentials_get_windows_sid(DBusCredentials *credentials)
Gets the Windows user SID in the credentials, or NULL if the credentials object doesn&#39;t contain a Win...
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_message_loader_queue_messages(DBusMessageLoader *loader)
Converts buffered data into messages, if we have enough data.
DBUS_PRIVATE_EXPORT DBusConnection * _dbus_connection_ref_unlocked(DBusConnection *connection)
Increments the reference count of a DBusConnection.
char * _dbus_strdup(const char *str)
Duplicates a string.
void _dbus_transport_disconnect(DBusTransport *transport)
Closes our end of the connection to a remote application.
void _dbus_transport_finalize_base(DBusTransport *transport)
Finalizes base class members of DBusTransport.
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:107
void(* disconnect)(DBusTransport *transport)
Disconnect this transport.
DBusAuth * _dbus_auth_client_new(void)
Creates a new auth conversation object for the client side.
Definition: dbus-auth.c:2367
void _dbus_message_loader_set_max_message_unix_fds(DBusMessageLoader *loader, long n)
Sets the maximum unix fds per message we allow.
const DBusTransportVTable * vtable
Virtual methods for this instance.
DBUS_PRIVATE_EXPORT void _dbus_connection_unlock(DBusConnection *connection)
Releases the connection lock.
void _dbus_transport_set_max_message_size(DBusTransport *transport, long size)
See dbus_connection_set_max_message_size().
Implementation details of DBusMessageLoader.
void * windows_user_data
Data for windows_user_function.
DBusDispatchStatus _dbus_transport_get_dispatch_status(DBusTransport *transport)
Reports our current dispatch status (whether there&#39;s buffered data to be queued as messages...
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).
Definition: dbus-errors.c:329
dbus_bool_t(* handle_watch)(DBusTransport *transport, DBusWatch *watch, unsigned int flags)
The handle_watch method handles reading/writing data as indicated by the flags.
void _dbus_transport_set_max_message_unix_fds(DBusTransport *transport, long n)
See dbus_connection_set_max_message_unix_fds().
DBusFreeFunction free_unix_user_data
Function to free unix_user_data.
void _dbus_transport_unref(DBusTransport *transport)
Decrements the reference count for the transport.
long _dbus_counter_get_unix_fd_value(DBusCounter *counter)
Gets the current value of the unix fd counter.
int _dbus_message_loader_get_pending_fds_count(DBusMessageLoader *loader)
Return how many file descriptors are pending in the loader.
long _dbus_counter_get_size_value(DBusCounter *counter)
Gets the current value of the size counter.
void * _dbus_credentials_get_adt_audit_data(DBusCredentials *credentials)
Gets the ADT audit data in the credentials, or NULL if the credentials object doesn&#39;t contain ADT aud...