diff options
author | Adrian Reber <areber@redhat.com> | 2019-05-02 16:47:29 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2019-05-16 19:39:30 +0300 |
commit | 149fed6480de9d4fb44632a9be69314fcbeeee58 (patch) | |
tree | 4afe14da8edfe3c85c8a1336a104df68feeda227 /test | |
parent | ae2ab5ddadc24c06c12c545f1160086713f78f59 (diff) |
test: Verify that sockcreate does not change during restore
This makes sure that sockcreate stays empty for selinux00 before and
after checkpoint/restore.
Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/zdtm/static/selinux00.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/zdtm/static/selinux00.c b/test/zdtm/static/selinux00.c index dd9096a6f..db8420eac 100644 --- a/test/zdtm/static/selinux00.c +++ b/test/zdtm/static/selinux00.c @@ -83,6 +83,31 @@ int checkprofile() return 0; } +int check_sockcreate() +{ + char *output = NULL; + FILE *f = fopen("/proc/self/attr/sockcreate", "r"); + int ret = fscanf(f, "%ms", &output); + fclose(f); + + if (ret >= 1) { + free(output); + /* sockcreate should be empty, if fscanf found something + * it is wrong.*/ + fail("sockcreate should be empty\n"); + return -1; + } + + if (output) { + free(output); + /* Same here, output should still be NULL. */ + fail("sockcreate should be empty\n"); + return -1; + } + + return 0; +} + int main(int argc, char **argv) { test_init(argc, argv); @@ -95,12 +120,21 @@ int main(int argc, char **argv) return 0; } + if (check_sockcreate()) + return -1; + if (setprofile()) return -1; + if (check_sockcreate()) + return -1; + test_daemon(); test_waitsig(); + if (check_sockcreate()) + return -1; + if (checkprofile() == 0) pass(); |