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