busctl.c revision 89ffcd2ad5bf87866314e96c4179ba622851cd6e
/*-*- 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 "strv.h"
#include "util.h"
#include "log.h"
#include "sd-bus.h"
#include "bus-message.h"
#include "bus-internal.h"
_cleanup_strv_free_ char **l = NULL;
char **i;
int r;
r = sd_bus_open_user(&bus);
if (r < 0) {
goto fail;
}
r = sd_bus_list_names(bus, &l);
if (r < 0) {
goto fail;
}
strv_sort(l);
STRV_FOREACH(i, l)
printf("%-*s %*s %-*s %-*s CONNECTION\n",
STRV_FOREACH(i, l) {
/* if ((*i)[0] == ':') */
/* continue; */
if (r >= 0) {
} else
printf(" - - ");
if (r >= 0) {
_cleanup_free_ char *u = NULL;
u = uid_to_name(uid);
if (!u) {
log_oom();
goto fail;
}
if (strlen(u) > 16)
u[16] = 0;
printf(" %-16s", u);
} else
printf(" - ");
if (r >= 0)
else
printf(" -\n");
}
r = 0;
fail:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}