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

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