Blame SOURCES/0101-fix-11-basic-basic_errors-on-old-kernels.patch

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