/***
This file is part of systemd.
Copyright 2014 Ronny Chevalier
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 <grp.h>
#include <pwd.h>
#include <stdio.h>
#include "fileio.h"
#include "fs-util.h"
#include "macro.h"
#include "manager.h"
#include "mkdir.h"
#include "path-util.h"
#include "rm-rf.h"
#include "test-helper.h"
#include "unit.h"
#include "util.h"
assert_se(m);
int r;
usec_t n;
assert_se(r >= 0);
n = now(CLOCK_MONOTONIC);
}
}
}
}
}
#if defined(__x86_64__)
#else
#endif
}
}
}
}
#ifdef HAVE_SECCOMP
#endif
}
#ifdef HAVE_SECCOMP
#endif
}
if (getpwnam("nobody"))
else
}
if (getgrnam("nobody"))
else
}
}
static const char e[] =
"VAR1='word1 word2'\n"
"VAR2=word3 \n"
"# comment1\n"
"\n"
"; comment2\n"
" ; # comment3\n"
"line without an equal\n"
"VAR3='$word 5 6'\n";
int r;
assert_se(r == 0);
}
/* test-execute runs under MANAGER_USER which, by default, forwards all
* variables present in the environment, but only those that are
* present _at the time it is created_!
*
* So these PassEnvironment checks are still expected to work, since we
* are ensuring the variables are not present at manager creation (they
* are unset explicitly in main) and are only set here.
*
* This is still a good approximation of how a test for MANAGER_SYSTEM
* would work.
*/
}
}
if (getgrnam("nobody"))
else
log_error_errno(errno, "Skipping test_exec_runtimedirectory-owner, could not find nobody group: %m");
}
int r;
/* We use capsh to test if the capabilities are
* properly set, so be sure that it exists */
if (r < 0) {
log_error_errno(r, "Skipping test_exec_capabilityboundingset, could not find capsh binary: %m");
return;
}
}
int r;
/* Check if the kernel has support for ambient capabilities. Run
* the tests only if that's the case. Clearing all ambient
* capabilities is fine, since we are expecting them to be unset
* in the first place for the tests. */
}
}
int r;
if (r < 0) {
log_error_errno(r, "Skipping test_exec_privatenetwork, could not find ip binary: %m");
return;
}
}
}
}
NULL,
};
int r;
log_open();
/* It is needed otherwise cgroup creation fails */
if (getuid() != 0) {
printf("Skipping test: not root\n");
return EXIT_TEST_SKIP;
}
/* Unset VAR1, VAR2 and VAR3 which are used in the PassEnvironment test
* cases, otherwise (and if they are present in the environment),
* `manager_default_environment` will copy them into the default
* environment which is passed to each created job, which will make the
* tests that expect those not to be present to fail.
*/
r = manager_new(MANAGER_USER, true, &m);
if (MANAGER_SKIP_TEST(r)) {
return EXIT_TEST_SKIP;
}
assert_se(r >= 0);
(*test)(m);
manager_free(m);
return 0;
}