linux: return UNSUPPORTED in tst-mount if support_become_root fails
Checks
Context |
Check |
Description |
dj/TryBot-32bit |
success
|
Build for i686
|
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
Otherwise the test fails if run in a chroot by a non-root user:
warning: could not become root outside namespace (Operation not permitted)
../sysdeps/unix/sysv/linux/tst-mount.c:36: numeric comparison failure
left: 1 (0x1); from: errno
right: 19 (0x13); from: ENODEV
error: ../sysdeps/unix/sysv/linux/tst-mount.c:39: not true: fd != -1
error: ../sysdeps/unix/sysv/linux/tst-mount.c:46: not true: r != -1
error: ../sysdeps/unix/sysv/linux/tst-mount.c:48: not true: r != -1
../sysdeps/unix/sysv/linux/tst-mount.c:52: numeric comparison failure
left: 1 (0x1); from: errno
right: 9 (0x9); from: EBADF
error: ../sysdeps/unix/sysv/linux/tst-mount.c:55: not true: mfd != -1
../sysdeps/unix/sysv/linux/tst-mount.c:58: numeric comparison failure
left: 1 (0x1); from: errno
right: 2 (0x2); from: ENOENT
error: ../sysdeps/unix/sysv/linux/tst-mount.c:61: not true: r != -1
../sysdeps/unix/sysv/linux/tst-mount.c:65: numeric comparison failure
left: 1 (0x1); from: errno
right: 2 (0x2); from: ENOENT
error: ../sysdeps/unix/sysv/linux/tst-mount.c:68: not true: pfd != -1
error: ../sysdeps/unix/sysv/linux/tst-mount.c:75: not true: fd_tree != -1
../sysdeps/unix/sysv/linux/tst-mount.c:88: numeric comparison failure
left: 1 (0x1); from: errno
right: 38 (0x26); from: ENOSYS
error: 12 test failures
---
sysdeps/unix/sysv/linux/tst-mount.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On 14/07/22 00:23, Michael Hudson-Doyle via Libc-alpha wrote:
> Otherwise the test fails if run in a chroot by a non-root user:
>
> warning: could not become root outside namespace (Operation not permitted)
> ../sysdeps/unix/sysv/linux/tst-mount.c:36: numeric comparison failure
> left: 1 (0x1); from: errno
> right: 19 (0x13); from: ENODEV
> error: ../sysdeps/unix/sysv/linux/tst-mount.c:39: not true: fd != -1
> error: ../sysdeps/unix/sysv/linux/tst-mount.c:46: not true: r != -1
> error: ../sysdeps/unix/sysv/linux/tst-mount.c:48: not true: r != -1
> ../sysdeps/unix/sysv/linux/tst-mount.c:52: numeric comparison failure
> left: 1 (0x1); from: errno
> right: 9 (0x9); from: EBADF
> error: ../sysdeps/unix/sysv/linux/tst-mount.c:55: not true: mfd != -1
> ../sysdeps/unix/sysv/linux/tst-mount.c:58: numeric comparison failure
> left: 1 (0x1); from: errno
> right: 2 (0x2); from: ENOENT
> error: ../sysdeps/unix/sysv/linux/tst-mount.c:61: not true: r != -1
> ../sysdeps/unix/sysv/linux/tst-mount.c:65: numeric comparison failure
> left: 1 (0x1); from: errno
> right: 2 (0x2); from: ENOENT
> error: ../sysdeps/unix/sysv/linux/tst-mount.c:68: not true: pfd != -1
> error: ../sysdeps/unix/sysv/linux/tst-mount.c:75: not true: fd_tree != -1
> ../sysdeps/unix/sysv/linux/tst-mount.c:88: numeric comparison failure
> left: 1 (0x1); from: errno
> right: 38 (0x26); from: ENOSYS
> error: 12 test failures
> ---
> sysdeps/unix/sysv/linux/tst-mount.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/tst-mount.c b/sysdeps/unix/sysv/linux/tst-mount.c
> index 502d7e3433..bd75c9e704 100644
> --- a/sysdeps/unix/sysv/linux/tst-mount.c
> +++ b/sysdeps/unix/sysv/linux/tst-mount.c
> @@ -103,7 +103,8 @@ subprocess (void)
> static int
> do_test (void)
> {
> - support_become_root ();
> + if (!support_become_root ())
> + FAIL_UNSUPPORTED("could not become root");
>
I think the usual way is to check if process can chroot:
support_become_root ();
if (!support_can_chroot ())
return EXIT_UNSUPPORTED;
As done by other tests.
> pid_t pid = xfork ();
> if (pid == 0)
On 7/14/22 07:24, Adhemerval Zanella Netto via Libc-alpha wrote:
>
>
> On 14/07/22 00:23, Michael Hudson-Doyle via Libc-alpha wrote:
>> Otherwise the test fails if run in a chroot by a non-root user:
>>
>> warning: could not become root outside namespace (Operation not permitted)
>> ../sysdeps/unix/sysv/linux/tst-mount.c:36: numeric comparison failure
>> left: 1 (0x1); from: errno
>> right: 19 (0x13); from: ENODEV
>> error: ../sysdeps/unix/sysv/linux/tst-mount.c:39: not true: fd != -1
>> error: ../sysdeps/unix/sysv/linux/tst-mount.c:46: not true: r != -1
>> error: ../sysdeps/unix/sysv/linux/tst-mount.c:48: not true: r != -1
>> ../sysdeps/unix/sysv/linux/tst-mount.c:52: numeric comparison failure
>> left: 1 (0x1); from: errno
>> right: 9 (0x9); from: EBADF
>> error: ../sysdeps/unix/sysv/linux/tst-mount.c:55: not true: mfd != -1
>> ../sysdeps/unix/sysv/linux/tst-mount.c:58: numeric comparison failure
>> left: 1 (0x1); from: errno
>> right: 2 (0x2); from: ENOENT
>> error: ../sysdeps/unix/sysv/linux/tst-mount.c:61: not true: r != -1
>> ../sysdeps/unix/sysv/linux/tst-mount.c:65: numeric comparison failure
>> left: 1 (0x1); from: errno
>> right: 2 (0x2); from: ENOENT
>> error: ../sysdeps/unix/sysv/linux/tst-mount.c:68: not true: pfd != -1
>> error: ../sysdeps/unix/sysv/linux/tst-mount.c:75: not true: fd_tree != -1
>> ../sysdeps/unix/sysv/linux/tst-mount.c:88: numeric comparison failure
>> left: 1 (0x1); from: errno
>> right: 38 (0x26); from: ENOSYS
>> error: 12 test failures
>> ---
>> sysdeps/unix/sysv/linux/tst-mount.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/tst-mount.c b/sysdeps/unix/sysv/linux/tst-mount.c
>> index 502d7e3433..bd75c9e704 100644
>> --- a/sysdeps/unix/sysv/linux/tst-mount.c
>> +++ b/sysdeps/unix/sysv/linux/tst-mount.c
>> @@ -103,7 +103,8 @@ subprocess (void)
>> static int
>> do_test (void)
>> {
>> - support_become_root ();
>> + if (!support_become_root ())
>> + FAIL_UNSUPPORTED("could not become root");
>>
>
> I think the usual way is to check if process can chroot:
>
> support_become_root ();
> if (!support_can_chroot ())
> return EXIT_UNSUPPORTED;
>
> As done by other tests.
Agreed. We need this same fix for Fedora. I didn't catch this in my review.
>> pid_t pid = xfork ();
>> if (pid == 0)
>
Michael Hudson-Doyle via Libc-alpha <libc-alpha@sourceware.org> writes:
> Otherwise the test fails if run in a chroot by a non-root user:
Can this test run in the test-container container? I'm wondering if
there's some subtle difference between support_become_root() and a more
complete containerization that might enable it to run in more cases.
(yes, I know the test-container might not have tmpfs pre-mounted. But
then again, not all real systems will either)
On Fri, 15 Jul 2022 at 07:19, DJ Delorie <dj@redhat.com> wrote:
>
> Michael Hudson-Doyle via Libc-alpha <libc-alpha@sourceware.org> writes:
> > Otherwise the test fails if run in a chroot by a non-root user:
>
> Can this test run in the test-container container? I'm wondering if
> there's some subtle difference between support_become_root() and a more
> complete containerization that might enable it to run in more cases.
>
All the test-container tests in Ubuntu builds end up UNSUPPORTED with
test-container.c:1130: unable to unshare user/fs: Operation not permitted
so that wouldn't really help here (I should probably look into why this is).
Cheers,
mwh
(yes, I know the test-container might not have tmpfs pre-mounted. But
> then again, not all real systems will either)
>
>
Michael Hudson-Doyle <michael.hudson@canonical.com> writes:
> All the test-container tests in Ubuntu builds end up UNSUPPORTED with
> test-container.c:1130: unable to unshare user/fs: Operation not permitted
> so that wouldn't really help here (I should probably look into why this is).
Yeah, Debian-based distros default to disabling user containers. There
should be a hint printed as to how to re-enable them, but that's on a
per-system basis, and up to the admin.
@@ -103,7 +103,8 @@ subprocess (void)
static int
do_test (void)
{
- support_become_root ();
+ if (!support_become_root ())
+ FAIL_UNSUPPORTED("could not become root");
pid_t pid = xfork ();
if (pid == 0)