2 .TH "SD_BUS_OPEN_USER" "3" "" "systemd 214" "sd_bus_open_user"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
17 .\" disable justification (adjust text to left margin only)
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
23 sd_bus_open_user, sd_bus_open_system, sd_bus_open_system_remote, sd_bus_open_system_container, sd_bus_default_user, sd_bus_default_system \- Open a connection to the system or user bus
28 #include <systemd/sd\-bus\&.h>
31 .HP \w'int\ sd_bus_open_user('u
32 .BI "int sd_bus_open_user(sd_bus\ **" "bus" ");"
33 .HP \w'int\ sd_bus_open_system('u
34 .BI "int sd_bus_open_system(sd_bus\ **" "bus" ");"
35 .HP \w'int\ sd_bus_open_system_remote('u
36 .BI "int sd_bus_open_system_remote(const\ char\ *" "host" ", sd_bus\ **" "bus" ");"
37 .HP \w'int\ sd_bus_open_system_container('u
38 .BI "int sd_bus_open_system_container(const\ char\ *" "machine" ", sd_bus\ **" "bus" ");"
39 .HP \w'int\ sd_bus_default_user('u
40 .BI "int sd_bus_default_user(sd_bus\ **" "bus" ");"
41 .HP \w'int\ sd_bus_default_system('u
42 .BI "int sd_bus_default_system(sd_bus\ **" "bus" ");"
45 \fBsd_bus_open_user()\fR
46 creates a new bus object and opens a connection to the user bus\&.
47 \fBsd_bus_open_system()\fR
48 does the same, but connects to the system bus\&.
51 \fI$DBUS_SESSION_BUS_ADDRESS\fR
52 environment variable is set (cf\&.
53 \fBenviron\fR(7)), it will be used as the address of the user bus\&. This variable can contain multiple addresses separated by
54 ";"\&. If this variable is not set, a suitable default for the default user D\-Bus instance will be used\&.
57 \fI$DBUS_SYSTEM_BUS_ADDRESS\fR
58 environment variable is set, it will be used as the address of the system bus\&. This variable uses the same syntax as
59 \fI$DBUS_SESSION_BUS_ADDRESS\fR/\&. If this variable is not set, a suitable default for the default system D\-Bus instance will be used\&.
61 \fBsd_bus_open_system_remote()\fR
62 connects to the system bus on the specified
66 consists of an optional user name followed by the
68 symbol, and the hostname\&.
70 \fBsd_bus_open_system_remote()\fR
71 connects to the system bus in the specified
74 is the name of a container\&. See
76 for more information about "machines"\&.
78 \fBsd_bus_default_user()\fR
79 returns a bus object connected to the user bus\&. Each thread has its own object, but it may be passed around\&. It is created on the first invocation of
80 \fBsd_bus_default_user()\fR, and subsequent invocations returns a reference to the same object\&.
82 \fBsd_bus_default_system()\fR
84 \fBsd_bus_default_user()\fR, but connects to the system bus\&.
87 On success, these calls return 0 or a positive integer\&. On failure, these calls return a negative errno\-style error code\&.
88 .SH "REFERENCE OWNERSHIP"
91 \fBsd_bus_open_user()\fR,
92 \fBsd_bus_open_system()\fR,
93 \fBsd_bus_open_system_remote()\fR, and
94 \fBsd_bus_open_system_machine()\fR
95 return a new object and the caller owns the sole reference\&. When not needed anymore, this reference should be destroyed with
96 \fBsd_bus_unref\fR(3)\&.
99 \fBsd_bus_default_user()\fR
101 \fBsd_bus_default_system()\fR
102 do not create a new reference\&.
105 Returned errors may indicate the following problems:
109 Specified parameter is invalid (\fBNULL\fR
110 in case of output parameters)\&.
115 Memory allocation failed\&.
118 In addition, any further connection\-related errors may be by returned\&. See
119 \fBsd_bus_send\fR(3)\&.
122 \fBsd_bus_open_user()\fR
123 and other functions described here are available as a shared library, which can be compiled and linked to with the
124 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
132 \fBsd_bus_unref\fR(3),
134 \fBsystemd-machined.service\fR(8),