bus: add API calls for connecting to starter bus

Add new calls sd_bus_open() and sd_bus_default() for connecting to the
starter bus a service was invoked for, or -- if the process is not a
bus-activated service -- the appropriate bus for the scope the process
has been started in.
This commit is contained in:
Lennart Poettering
2014-01-27 21:34:54 +01:00
parent 968d3d242c
commit af08d2f9cd
5 changed files with 107 additions and 13 deletions
+10 -8
View File
@@ -1332,11 +1332,10 @@ int cg_pid_get_machine_name(pid_t pid, char **machine) {
int cg_path_get_session(const char *path, char **session) {
const char *e, *n, *x;
char *s, *r;
char *s;
size_t l;
assert(path);
assert(session);
/* Skip slices, if there are any */
e = skip_slices(path);
@@ -1358,11 +1357,16 @@ int cg_path_get_session(const char *path, char **session) {
if (l <= 6)
return -ENOENT;
r = strndup(x, l - 6);
if (!r)
return -ENOMEM;
if (session) {
char *r;
r = strndup(x, l - 6);
if (!r)
return -ENOMEM;
*session = r;
}
*session = r;
return 0;
}
@@ -1370,8 +1374,6 @@ int cg_pid_get_session(pid_t pid, char **session) {
_cleanup_free_ char *cgroup = NULL;
int r;
assert(session);
r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
if (r < 0)
return r;