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

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