]>
git.proxmox.com Git - systemd.git/blob - src/test/test-ns.c
2 This file is part of systemd.
4 Copyright 2010 Lennart Poettering
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "namespace.h"
26 int main(int argc
, char *argv
[]) {
27 const char * const writable
[] = {
32 const char * const readonly
[] = {
39 const char *inaccessible
[] = {
40 "/home/lennart/projects",
44 char *projects_directory
;
47 char tmp_dir
[] = "/tmp/systemd-private-XXXXXX",
48 var_tmp_dir
[] = "/var/tmp/systemd-private-XXXXXX";
50 assert_se(mkdtemp(tmp_dir
));
51 assert_se(mkdtemp(var_tmp_dir
));
53 root_directory
= getenv("TEST_NS_CHROOT");
54 projects_directory
= getenv("TEST_NS_PROJECTS");
56 if (projects_directory
)
57 inaccessible
[0] = projects_directory
;
59 log_info("Inaccessible directory: '%s'", inaccessible
[0]);
61 log_info("Chroot: '%s'", root_directory
);
63 log_info("Not chrooted");
65 r
= setup_namespace(root_directory
,
68 (char **) inaccessible
,
77 log_error_errno(r
, "Failed to setup namespace: %m");
80 " sudo TEST_NS_PROJECTS=/home/lennart/projects ./test-ns\n"
81 " sudo TEST_NS_CHROOT=/home/alban/debian-tree TEST_NS_PROJECTS=/home/alban/debian-tree/home/alban/Documents ./test-ns");
86 execl("/bin/sh", "/bin/sh", NULL
);
87 log_error_errno(errno
, "execl(): %m");