chiark / gitweb /
Prep v236 : Add missing SPDX-License-Identifier (8/9) src/test
[elogind.git] / src / test / test-ipcrm.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3   This file is part of systemd.
4
5   Copyright 2014 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 "clean-ipc.h"
22 #include "user-util.h"
23 #include "util.h"
24
25 int main(int argc, char *argv[]) {
26         uid_t uid;
27         int r;
28 #if 0 /// not configurable in elogind
29         const char* name = argv[1] ?: NOBODY_USER_NAME;
30 #else
31         const char* name = argv[1] ?: "nobody";
32 #endif // 0
33
34         r = get_user_creds(&name, &uid, NULL, NULL, NULL);
35         if (r < 0) {
36                 log_full_errno(r == -ESRCH ? LOG_NOTICE : LOG_ERR,
37                                r, "Failed to resolve \"%s\": %m", name);
38                 return r == -ESRCH ? EXIT_TEST_SKIP : EXIT_FAILURE;
39         }
40
41         r = clean_ipc_by_uid(uid);
42         return  r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
43 }