[CRIU] [PATCH v3 02/33] zdtm: Add userns01 test

Kirill Tkhai ktkhai at virtuozzo.com
Wed Feb 22 00:53:18 PST 2017


On 22.02.2017 07:59, Andrei Vagin wrote:
> On Tue, Feb 21, 2017 at 05:05:56PM +0300, Kirill Tkhai wrote:
>> On 21.02.2017 08:32, Andrei Vagin wrote:
>>> On Thu, Feb 16, 2017 at 03:06:52PM +0300, Kirill Tkhai wrote:
>>>> FIXME: use custom UID and GID, not 0 and 0.
>>> Why are non-zero uid-s not supported now?
>>
>> Because currently it's need to have uid/gid 0 mapped to use prctl's PR_SET_MM_MAP
>> argument on restore. If I map custom UID to 0, then it's need a UID to map 0 to
>> (for prctl), but this UID may not exists in parent environment. I'm going to extend
>> this test to find an existing UID in parent environment, but it's not for now.
>>  
>>> Why do we need a second test to check uid and gid? Can we check them in
>>> the first test?
>>
>> As I see in criu's tests, every test is for testing one feature,
>> and the main style is to do not create overloaded tests. It is
>> good seen in socket tests. I just follow this trend.
> 
> I'm agree with this sentence, but I think setuid and getuid will not
> overload the test. Maybe I'm wrong...
> 
> I modified a test, the patch is attached. Now test fails with c/r and
> passes without c/r.

There is a mistake with convertation. The below fixes that.
Hm, we can add custom uid/gid, but I'm not sure about environment.
Are we able to do any assumptions about user_ns mappings in test CT?
How do we prepare it?

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 9fb4691d7..c6aea7448 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -907,7 +907,7 @@ unsigned int root_userns_gid(struct ns_id *ns, unsigned int gid)
 	if (!(root_ns_mask & CLONE_NEWUSER))
 		return gid;
 	while (ns != root_user_ns) {
-		gid = parent_userns_uid(ns->user.e, gid);
+		gid = parent_userns_gid(ns->user.e, gid);
 		ns = ns->parent;
 	}
 	return gid;



More information about the CRIU mailing list