Hi Bruno and all,

keinflue <keinf...@posteo.net> writes:

>> Instead, how about
>>   a) if you just ignore the test failures — since you know you are
>>      running them in a very special environment, or
>>   b) we can mark these 3 tests as expected test failures if you
>>      provide an identifier to mark them with, and a corresponding
>>      condition, so that we can extend gnulib/modules/test-xfail.
>
> I am only a relatively new user of guix, so I can't speak for which
> approach would be preferable from their perspective. I CC'ed Ludovic
> since he implemented the unprivileged guix daemon approach.

I’m not sure how ‘modules/test-xfail’ is supposed to work, I don’t see
any use of its conditionals.

My inclination would be to do something as attached (untested):

diff --git a/tests/test-chown.h b/tests/test-chown.h
index 6af6b69755..182eaa4cd0 100644
--- a/tests/test-chown.h
+++ b/tests/test-chown.h
@@ -32,6 +32,21 @@
    headers are already included.  If PRINT, warn before skipping
    symlink tests with status 77.  */
 
+static gid_t
+overflow_gid (void)
+{
+#ifdef __linux__
+  char buf[64];
+  int fd = open ("/proc/sys/kernel/overflowgid", O_RDONLY);
+  if (fd == -1)
+    return -1;
+  full_read (fd, buf, sizeof buf);
+  return atoi (buf);
+#else
+  return -1;
+#endif
+}
+
 static int
 test_chown (int (*func) (char const *, uid_t, gid_t), bool print)
 {
@@ -138,6 +153,12 @@ test_chown (int (*func) (char const *, uid_t, gid_t), bool print)
   gids_count = mgetgroups (NULL, st1.st_gid, &gids);
   if (1 < gids_count)
     {
+#ifdef __linux__
+      if (gids[1] == overflow_gid ())
+	/* Cannot chown to the "overflow GID", so mark test as skipped.  */
+	return 77;
+#endif
+
       ASSERT (gids[1] != st1.st_gid);
       if (getgid () != (gid_t) -1)
         ASSERT (gids[1] != (gid_t) -1);
WDYT?

(I agree that it’s unfortunate that Linux user namespaces break POSIX
semantics in surprising way.  More and more programs are running in such
environments though, for example for CI.)

Thanks,
Ludo’.

Reply via email to