Re: [LTP] [RFC] 'nobody' user for testing

Cyril Hrubis
2025-10-16T13:34:56Z

Hi!
> OK, I can write it unless Jan plans to work on it (Jan, please let me know).
>
> I propose to have the usual LTP approach to have functionality used by C API
> (e.g. lib/tst_sudo.c) and reused by thin wrapper available for shell API
> (testcases/lib/tst_sudo.c).
>
> Few C API tests would use it (prctl06 and other mentioned previously [1] as 3)),
> in shell API only these 2 IMA tests.

There are likely more nuances in the tests that use C, some set real
uid/git some only uid etc. So I wouldn't bother adding helper for six
tests or so and write directly just the shell helper.

> > And I think that the question if we need a separate user for LTP testing is
> > orthogonal.
>
> Agree. I just brought these two topics together as they are related.
> So, as a separate topic/effort, do you see any room for C API functions for 1)
> and 2) in [1]?

Technically most of the C tests does not even need an user to be created
on the system. They just need UID/GID that is not priviledged, kernel
does not really care about the users in /etc/passwd that's purely
userspace thing. All that kernel does is to compare numbers before it
allows/disallows access. So we may get away with a function that returns
UID and GID suitable for the tests, or even a global varible.

Possibly we may add:

struct tst_usr {
uid_t uid;
gid_t gid;
};

struct tst_usr tst_usr = {
.uid = 65534,
.gid = 65534,
};

and add an option to override these values with TST_USR_UID and
TST_USR_GID.

--
Cyril Hrubis
chrubis@suse.cz