[LTP] [PATCH v3 2/9] Rewrite userns02.c using new LTP API
    Cyril Hrubis 
    chrubis@suse.cz
       
    Fri Mar 25 16:58:52 CET 2022
    
    
  
Hi!
> +	parentuid = geteuid();
> +	parentgid = getegid();
> +
> +	sprintf(path, "/proc/%d/uid_map", childpid);
> +	sprintf(content, "100 %d 1", parentuid);
> +
> +	fd = SAFE_OPEN(path, O_WRONLY, 0644);
> +	SAFE_WRITE(1, fd, content, strlen(content));
> +	SAFE_CLOSE(fd);
> +
> +	if (access("/proc/self/setgroups", F_OK) == 0) {
> +		sprintf(path, "/proc/%d/setgroups", childpid);
> +
> +		fd = SAFE_OPEN(path, O_WRONLY, 0644);
> +		SAFE_WRITE(1, fd, "deny", 4);
> +		SAFE_CLOSE(fd);
>  	}
> -	cleanup();
> -	tst_exit();
> +
> +	sprintf(path, "/proc/%d/gid_map", childpid);
> +	sprintf(content, "100 %d 1", parentgid);
> +
> +	fd = SAFE_OPEN(path, O_WRONLY, 0644);
> +	SAFE_WRITE(1, fd, content, strlen(content));
> +	SAFE_CLOSE(fd);
I've shortened this part significantly with SAFE_FILE_PRINTF() and
pushed, thanks.
-- 
Cyril Hrubis
chrubis@suse.cz
    
    
More information about the ltp
mailing list