]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
5b12334d LP |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2013 Lennart Poettering | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
8 | under the terms of the GNU Lesser General Public License as published by | |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | Lesser General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU Lesser General Public License | |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
19 | ***/ | |
20 | ||
21 | #include "sd-bus.h" | |
cf0fbc49 | 22 | |
5b12334d LP |
23 | #include "bus-dump.h" |
24 | #include "bus-util.h" | |
3b3a64d7 | 25 | #include "cgroup-util.h" |
5b12334d LP |
26 | |
27 | int main(int argc, char *argv[]) { | |
4afd3348 | 28 | _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL; |
5b12334d LP |
29 | int r; |
30 | ||
9aa8fa70 ZJS |
31 | log_set_max_level(LOG_DEBUG); |
32 | log_parse_environment(); | |
33 | log_open(); | |
34 | ||
415fc41c | 35 | if (cg_unified_flush() == -ENOMEDIUM) { |
9aa8fa70 | 36 | log_info("Skipping test: /sys/fs/cgroup/ not available"); |
3b3a64d7 MP |
37 | return EXIT_TEST_SKIP; |
38 | } | |
39 | ||
151b9b96 | 40 | r = sd_bus_creds_new_from_pid(&creds, 0, _SD_BUS_CREDS_ALL); |
9aa8fa70 | 41 | log_full_errno(r < 0 ? LOG_ERR : LOG_DEBUG, r, "sd_bus_creds_new_from_pid: %m"); |
5b12334d LP |
42 | assert_se(r >= 0); |
43 | ||
d0b2babf | 44 | bus_creds_dump(creds, NULL, true); |
5b12334d LP |
45 | |
46 | creds = sd_bus_creds_unref(creds); | |
47 | ||
151b9b96 | 48 | r = sd_bus_creds_new_from_pid(&creds, 1, _SD_BUS_CREDS_ALL); |
5b12334d LP |
49 | if (r != -EACCES) { |
50 | assert_se(r >= 0); | |
51 | putchar('\n'); | |
d0b2babf | 52 | bus_creds_dump(creds, NULL, true); |
5b12334d LP |
53 | } |
54 | ||
55 | return 0; | |
56 | } |