Blame SOURCES/0170-tests-linkat-reset-errno-before-SELinux-context-mani.patch

e5c382
From f5fd689e40322a7b08a97eb2d26f192610728230 Mon Sep 17 00:00:00 2001
e5c382
From: Eugene Syromyatnikov <evgsyr@gmail.com>
e5c382
Date: Tue, 18 Jan 2022 16:10:28 +0100
e5c382
Subject: [PATCH 170/174] tests/linkat: reset errno before SELinux context
e5c382
 manipulation
e5c382
e5c382
To avoid printing a stale error information in case of mismatch check
e5c382
failure.
e5c382
e5c382
* tests/linkat.c: Include <errno.h>.
e5c382
(main): Add "errno = 0" before update_secontext_field calls.
e5c382
---
e5c382
 tests/linkat.c | 4 ++++
e5c382
 1 file changed, 4 insertions(+)
e5c382
e5c382
diff --git a/tests/linkat.c b/tests/linkat.c
e5c382
index 1a869e3..c3e2ee4 100644
e5c382
--- a/tests/linkat.c
e5c382
+++ b/tests/linkat.c
e5c382
@@ -10,6 +10,7 @@
e5c382
 #include "tests.h"
e5c382
 #include "scno.h"
e5c382
 
e5c382
+#include <errno.h>
e5c382
 #include <fcntl.h>
e5c382
 #include <stdio.h>
e5c382
 #include <stdlib.h>
e5c382
@@ -91,6 +92,7 @@ main(void)
e5c382
 	free(sample_1_secontext);
e5c382
 
e5c382
 #ifdef PRINT_SECONTEXT_MISMATCH
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
e5c382
 	sample_1_secontext = SECONTEXT_FILE(sample_1);
e5c382
 
e5c382
@@ -112,6 +114,7 @@ main(void)
e5c382
 	free(sample_1_secontext);
e5c382
 #endif
e5c382
 
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
e5c382
 	sample_1_secontext = SECONTEXT_FILE(sample_1);
e5c382
 	sample_2_secontext = sample_1_secontext;
e5c382
@@ -142,6 +145,7 @@ main(void)
e5c382
 	int dfd_old = get_dir_fd(".");
e5c382
 	char *cwd = get_fd_path(dfd_old);
e5c382
 
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(".", SECONTEXT_TYPE, "default_t");
e5c382
 	char *dfd_old_secontext = SECONTEXT_FILE(".");
e5c382
 
e5c382
--- a/tests-m32/linkat.c
e5c382
+++ b/tests-m32/linkat.c
e5c382
@@ -10,6 +10,7 @@
e5c382
 #include "tests.h"
e5c382
 #include "scno.h"
e5c382
 
e5c382
+#include <errno.h>
e5c382
 #include <fcntl.h>
e5c382
 #include <stdio.h>
e5c382
 #include <stdlib.h>
e5c382
@@ -91,6 +92,7 @@ main(void)
e5c382
 	free(sample_1_secontext);
e5c382
 
e5c382
 #ifdef PRINT_SECONTEXT_MISMATCH
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
e5c382
 	sample_1_secontext = SECONTEXT_FILE(sample_1);
e5c382
 
e5c382
@@ -112,6 +114,7 @@ main(void)
e5c382
 	free(sample_1_secontext);
e5c382
 #endif
e5c382
 
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
e5c382
 	sample_1_secontext = SECONTEXT_FILE(sample_1);
e5c382
 	sample_2_secontext = sample_1_secontext;
e5c382
@@ -142,6 +145,7 @@ main(void)
e5c382
 	int dfd_old = get_dir_fd(".");
e5c382
 	char *cwd = get_fd_path(dfd_old);
e5c382
 
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(".", SECONTEXT_TYPE, "default_t");
e5c382
 	char *dfd_old_secontext = SECONTEXT_FILE(".");
e5c382
 
e5c382
--- a/tests-mx32/linkat.c
e5c382
+++ b/tests-mx32/linkat.c
e5c382
@@ -10,6 +10,7 @@
e5c382
 #include "tests.h"
e5c382
 #include "scno.h"
e5c382
 
e5c382
+#include <errno.h>
e5c382
 #include <fcntl.h>
e5c382
 #include <stdio.h>
e5c382
 #include <stdlib.h>
e5c382
@@ -91,6 +92,7 @@ main(void)
e5c382
 	free(sample_1_secontext);
e5c382
 
e5c382
 #ifdef PRINT_SECONTEXT_MISMATCH
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
e5c382
 	sample_1_secontext = SECONTEXT_FILE(sample_1);
e5c382
 
e5c382
@@ -112,6 +114,7 @@ main(void)
e5c382
 	free(sample_1_secontext);
e5c382
 #endif
e5c382
 
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
e5c382
 	sample_1_secontext = SECONTEXT_FILE(sample_1);
e5c382
 	sample_2_secontext = sample_1_secontext;
e5c382
@@ -142,6 +145,7 @@ main(void)
e5c382
 	int dfd_old = get_dir_fd(".");
e5c382
 	char *cwd = get_fd_path(dfd_old);
e5c382
 
e5c382
+	errno = 0;
e5c382
 	update_secontext_field(".", SECONTEXT_TYPE, "default_t");
e5c382
 	char *dfd_old_secontext = SECONTEXT_FILE(".");
e5c382
 
e5c382
-- 
e5c382
2.1.4
e5c382