diff options
author | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-23 15:18:01 +0200 |
commit | dbb41ce2b7f309d394054a6bd1e33afd578798a5 (patch) | |
tree | 6a31092063d9f2fb5ac5720ec6759040e793c3d5 /src/kernel/tests/lib/tst_lockdown.c | |
parent | Set Linux kernel version to unknown if it is not detectable (diff) | |
download | xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.gz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.tar.xz xloop-dbb41ce2b7f309d394054a6bd1e33afd578798a5.zip |
Move the source code of all xloop components to the common 'src' directory
Diffstat (limited to 'src/kernel/tests/lib/tst_lockdown.c')
-rw-r--r-- | src/kernel/tests/lib/tst_lockdown.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/kernel/tests/lib/tst_lockdown.c b/src/kernel/tests/lib/tst_lockdown.c new file mode 100644 index 0000000..e7c1981 --- /dev/null +++ b/src/kernel/tests/lib/tst_lockdown.c @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#define TST_NO_DEFAULT_MAIN + +#include <stdio.h> +#include <stdlib.h> +#include <sys/mount.h> + +#include "tst_test.h" +#include "tst_safe_macros.h" +#include "tst_safe_stdio.h" +#include "tst_lockdown.h" + +int tst_lockdown_enabled(void) +{ + char line[BUFSIZ]; + FILE *file; + + if (access(PATH_LOCKDOWN, F_OK) != 0) { + tst_res(TINFO, "Unable to determine system lockdown state"); + return 0; + } + + file = SAFE_FOPEN(PATH_LOCKDOWN, "r"); + if (!fgets(line, sizeof(line), file)) + tst_brk(TBROK | TERRNO, "fgets %s", PATH_LOCKDOWN); + SAFE_FCLOSE(file); + + return (strstr(line, "[none]") == NULL); +} |