test-capability.c revision 70d7aea5c7270764ee71d6828e76402001afed13
/***
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 <pwd.h>
#include <sys/capability.h>
#include <unistd.h>
#include "capability-util.h"
#include "fd-util.h"
#include "macro.h"
#include "util.h"
/* We keep CAP_DAC_OVERRIDE to avoid errors with gcov when doing test coverage */
if (pid == 0) {
test_func();
exit(0);
} else if (pid > 0) {
int status;
}
}
static void show_capabilities(void) {
char *text;
caps = cap_get_proc();
}
static int setup_tests(bool *run_ambient) {
int r;
if (!nobody) {
return -EXIT_TEST_SKIP;
}
*run_ambient = false;
/* There's support for PR_CAP_AMBIENT if the prctl() call
* succeeded or error code was something else than EINVAL. The
* EINVAL check should be good enough to rule out false
* positives. */
*run_ambient = true;
return 0;
}
static void test_drop_privileges_keep_net_raw(void) {
int sock;
}
static void test_drop_privileges_dontkeep_net_raw(void) {
int sock;
}
static void test_drop_privileges_fail(void) {
}
static void test_drop_privileges(void) {
}
static void test_have_effective_cap(void) {
}
static void test_update_inherited_set(void) {
caps = cap_get_proc();
}
static void test_set_ambient_caps(void) {
caps = cap_get_proc();
caps = cap_get_proc();
}
int r;
bool run_ambient;
log_open();
if (getuid() != 0)
return EXIT_TEST_SKIP;
r = setup_tests(&run_ambient);
if (r < 0)
return -r;
if (run_ambient)
return 0;
}