|
|
2b8778 |
diff --color -ru a/tests/11-basic-basic_errors.c b/tests/11-basic-basic_errors.c
|
|
|
2b8778 |
--- a/tests/11-basic-basic_errors.c 2021-09-01 18:57:34.018676687 +0200
|
|
|
2b8778 |
+++ b/tests/11-basic-basic_errors.c 2021-11-05 15:04:34.647739284 +0100
|
|
|
2b8778 |
@@ -29,9 +29,13 @@
|
|
|
2b8778 |
int rc;
|
|
|
2b8778 |
scmp_filter_ctx ctx;
|
|
|
2b8778 |
uint32_t attr;
|
|
|
2b8778 |
+ unsigned int api;
|
|
|
2b8778 |
struct seccomp_notif *req = NULL;
|
|
|
2b8778 |
struct seccomp_notif_resp *resp = NULL;
|
|
|
2b8778 |
|
|
|
2b8778 |
+ /* get the api level */
|
|
|
2b8778 |
+ api = seccomp_api_get();
|
|
|
2b8778 |
+
|
|
|
2b8778 |
/* seccomp_init errors */
|
|
|
2b8778 |
ctx = seccomp_init(SCMP_ACT_ALLOW + 1);
|
|
|
2b8778 |
if (ctx != NULL)
|
|
|
2b8778 |
@@ -199,39 +203,41 @@
|
|
|
2b8778 |
ctx = NULL;
|
|
|
2b8778 |
|
|
|
2b8778 |
/* seccomp notify errors */
|
|
|
2b8778 |
- ctx = seccomp_init(SCMP_ACT_ALLOW);
|
|
|
2b8778 |
- if (ctx == NULL)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- rc = seccomp_notify_alloc(NULL, NULL);
|
|
|
2b8778 |
- if (rc != 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- rc = seccomp_notify_alloc(&req, NULL);
|
|
|
2b8778 |
- if (rc != 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- rc = seccomp_notify_alloc(NULL, &resp);
|
|
|
2b8778 |
- if (rc != 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- seccomp_notify_free(NULL, NULL);
|
|
|
2b8778 |
- seccomp_notify_free(req, resp);
|
|
|
2b8778 |
- req = NULL;
|
|
|
2b8778 |
- resp = NULL;
|
|
|
2b8778 |
- rc = seccomp_notify_receive(-1, NULL);
|
|
|
2b8778 |
- if (rc == 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- rc = seccomp_notify_respond(-1, NULL);
|
|
|
2b8778 |
- if (rc == 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- rc = seccomp_notify_id_valid(-1, 0);
|
|
|
2b8778 |
- if (rc == 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- rc = seccomp_notify_fd(NULL);
|
|
|
2b8778 |
- if (rc == 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- rc = seccomp_notify_fd(ctx);
|
|
|
2b8778 |
- if (rc == 0)
|
|
|
2b8778 |
- return -1;
|
|
|
2b8778 |
- seccomp_release(ctx);
|
|
|
2b8778 |
- ctx = NULL;
|
|
|
2b8778 |
+ if (api >= 5) {
|
|
|
2b8778 |
+ ctx = seccomp_init(SCMP_ACT_ALLOW);
|
|
|
2b8778 |
+ if (ctx == NULL)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ rc = seccomp_notify_alloc(NULL, NULL);
|
|
|
2b8778 |
+ if (rc != 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ rc = seccomp_notify_alloc(&req, NULL);
|
|
|
2b8778 |
+ if (rc != 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ rc = seccomp_notify_alloc(NULL, &resp);
|
|
|
2b8778 |
+ if (rc != 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ seccomp_notify_free(NULL, NULL);
|
|
|
2b8778 |
+ seccomp_notify_free(req, resp);
|
|
|
2b8778 |
+ req = NULL;
|
|
|
2b8778 |
+ resp = NULL;
|
|
|
2b8778 |
+ rc = seccomp_notify_receive(-1, NULL);
|
|
|
2b8778 |
+ if (rc == 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ rc = seccomp_notify_respond(-1, NULL);
|
|
|
2b8778 |
+ if (rc == 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ rc = seccomp_notify_id_valid(-1, 0);
|
|
|
2b8778 |
+ if (rc == 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ rc = seccomp_notify_fd(NULL);
|
|
|
2b8778 |
+ if (rc == 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ rc = seccomp_notify_fd(ctx);
|
|
|
2b8778 |
+ if (rc == 0)
|
|
|
2b8778 |
+ return -1;
|
|
|
2b8778 |
+ seccomp_release(ctx);
|
|
|
2b8778 |
+ ctx = NULL;
|
|
|
2b8778 |
+ }
|
|
|
2b8778 |
|
|
|
2b8778 |
return 0;
|
|
|
2b8778 |
}
|