bus-control.c revision 392d5b378ceae5e1fd7c91ca545fcf4cd105744a
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stddef.h>
#include <errno.h>
#include "strv.h"
#include "sd-bus.h"
#include "bus-internal.h"
#include "bus-message.h"
#include "bus-control.h"
int r;
if (!bus)
return -EINVAL;
if (!unique)
return -EINVAL;
r = bus_ensure_running(bus);
if (r < 0)
return r;
return 0;
}
int r;
if (!bus)
return -EINVAL;
if (!name)
return -EINVAL;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"RequestName",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
return ret;
}
int r;
if (!bus)
return -EINVAL;
if (!name)
return -EINVAL;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"ReleaseName",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
return ret;
}
char **x = NULL;
int r;
if (!bus)
return -EINVAL;
if (!l)
return -EINVAL;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"ListNames",
&m1);
if (r < 0)
return r;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"ListActivatableNames",
&m2);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
r = bus_message_read_strv_extend(reply1, &x);
if (r < 0) {
strv_free(x);
return r;
}
r = bus_message_read_strv_extend(reply2, &x);
if (r < 0) {
strv_free(x);
return r;
}
*l = strv_uniq(x);
return 0;
}
const char *found;
int r;
if (!bus)
return -EINVAL;
if (!name)
return -EINVAL;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"GetNameOwner",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (owner) {
char *t;
if (!t)
return -ENOMEM;
*owner = t;
}
return 0;
}
uint32_t u;
int r;
if (!bus)
return -EINVAL;
if (!name)
return -EINVAL;
if (!uid)
return -EINVAL;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"GetConnectionUnixUser",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
return 0;
}
uint32_t u;
int r;
if (!bus)
return -EINVAL;
if (!name)
return -EINVAL;
if (!pid)
return -EINVAL;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"GetConnectionUnixProcessID",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (u == 0)
return -EIO;
return 0;
}
int r;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"AddMatch",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
}
int r;
bus,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
"RemoveMatch",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
}