From 385ca858ac89efccffd557eccc1113281306bd88 Mon Sep 17 00:00:00 2001
From: Kirill Smelkov <kirr@nexedi.com>
Date: Mon, 6 Dec 2021 22:50:27 +0300
Subject: [PATCH] syscall: tests: Fix TestSCMCredentials for `unshare -Umc`

---
 src/syscall/creds_test.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/syscall/creds_test.go b/src/syscall/creds_test.go
index c1a8b516e8..ed6e80c0c3 100644
--- a/src/syscall/creds_test.go
+++ b/src/syscall/creds_test.go
@@ -78,8 +78,10 @@ func TestSCMCredentials(t *testing.T) {
 			if sys, ok := err.(*os.SyscallError); ok {
 				err = sys.Err
 			}
-			if err != syscall.EPERM {
-				t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err)
+			// can get EINVAL instead of EPERM under `unshare -Umc` because uid0 is not mapped and maps to -1
+			// see also https://github.com/golang/go/issues/42525
+			if !(err == syscall.EPERM || err == syscall.EINVAL) {
+				t.Fatalf("WriteMsgUnix failed with %v, want EPERM/EINVAL", err)
 			}
 		}
 
-- 
2.30.2

