#include "hashmap.h"
#include "list.h"
#include "prioq.h"
-#include "refcnt.h"
#include "socket-util.h"
-#include "util.h"
+#include "time-util.h"
+
+/* Note that we use the new /run prefix here (instead of /var/run) since we require them to be aliases and
+ * that way we become independent of /var being mounted */
+#define DEFAULT_SYSTEM_BUS_ADDRESS "unix:path=/run/dbus/system_bus_socket"
+#define DEFAULT_USER_BUS_ADDRESS_FMT "unix:path=%s/bus"
struct reply_callback {
sd_bus_message_handler_t callback;
struct node_callback {
struct node *node;
- bool is_fallback;
- sd_bus_message_handler_t callback;
-
+ bool is_fallback:1;
unsigned last_iteration;
+ sd_bus_message_handler_t callback;
+
LIST_FIELDS(struct node_callback, callbacks);
};
struct node_vtable {
struct node *node;
+ bool is_fallback:1;
+ unsigned last_iteration;
+
char *interface;
- bool is_fallback;
const sd_bus_vtable *vtable;
sd_bus_object_find_t find;
- unsigned last_iteration;
-
LIST_FIELDS(struct node_vtable, vtables);
};
struct sd_bus_slot {
unsigned n_ref;
- sd_bus *bus;
- void *userdata;
- sd_bus_destroy_t destroy_callback;
BusSlotType type:5;
/* Slots can be "floating" or not. If they are not floating (the usual case) then they reference the bus object
bool floating:1;
bool match_added:1;
+
+ sd_bus *bus;
+ void *userdata;
+ sd_bus_destroy_t destroy_callback;
+
char *description;
LIST_FIELDS(sd_bus_slot, slots);
};
struct sd_bus {
- /* We use atomic ref counting here since sd_bus_message
- objects retain references to their originating sd_bus but
- we want to allow them to be processed in a different
- thread. We won't provide full thread safety, but only the
- bare minimum that makes it possible to use sd_bus and
- sd_bus_message objects independently and on different
- threads as long as each object is used only once at the
- same time. */
- RefCount n_ref;
+ unsigned n_ref;
enum bus_state state;
int input_fd, output_fd;
bool connected_signal:1;
bool close_on_exit:1;
- int use_memfd;
+ signed int use_memfd:2;
void *rbuffer;
size_t rbuffer_size;
sd_bus_message **rqueue;
- unsigned rqueue_size;
+ size_t rqueue_size;
size_t rqueue_allocated;
sd_bus_message **wqueue;
- unsigned wqueue_size;
+ size_t wqueue_size;
size_t windex;
size_t wqueue_allocated;
union sockaddr_union sockaddr;
socklen_t sockaddr_size;
- char *machine;
pid_t nspid;
+ char *machine;
sd_id128_t server_id;
int last_connect_error;
enum bus_auth auth;
- size_t auth_rbegin;
- struct iovec auth_iovec[3];
unsigned auth_index;
+ struct iovec auth_iovec[3];
+ size_t auth_rbegin;
char *auth_buffer;
usec_t auth_timeout;
char *exec_path;
char **exec_argv;
- unsigned iteration_counter;
-
/* We do locking around the memfd cache, since we want to
* allow people to process a sd_bus_message in a different
* thread then it was generated on and free it there. Since
pid_t original_pid;
pid_t busexec_pid;
+ unsigned iteration_counter;
+
sd_event_source *input_io_event_source;
sd_event_source *output_io_event_source;
sd_event_source *time_event_source;
sd_event *event;
int event_priority;
+ pid_t tid;
+
sd_bus_message *current_message;
sd_bus_slot *current_slot;
sd_bus_message_handler_t current_handler;
void *current_userdata;
sd_bus **default_bus_ptr;
- pid_t tid;
char *description;
char *patch_sender;
#define BUS_MESSAGE_SIZE_MAX (128*1024*1024)
#define BUS_AUTH_SIZE_MAX (64*1024)
+/* Note that the D-Bus specification states that bus paths shall have no size limit. We enforce here one
+ * anyway, since truly unbounded strings are a security problem. The limit we pick is relatively large however,
+ * to not clash unnecessarily with real-life applications. */
+#define BUS_PATH_SIZE_MAX (64*1024)
#define BUS_CONTAINER_DEPTH 128