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

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