bin/xbps-uunshare: allow relative chroot directory
This commit is contained in:
		@@ -157,7 +157,7 @@ main(int argc, char **argv)
 | 
			
		||||
	if (argc < 2)
 | 
			
		||||
		usage(argv0);
 | 
			
		||||
 | 
			
		||||
	chrootdir = argv[0];
 | 
			
		||||
	chrootdir = argv[-1];
 | 
			
		||||
	cmd = argv[1];
 | 
			
		||||
	cmdargs = argv + 1;
 | 
			
		||||
 | 
			
		||||
@@ -165,6 +165,14 @@ main(int argc, char **argv)
 | 
			
		||||
	if (strcmp(chrootdir, "/") == 0)
 | 
			
		||||
		die("/ is not allowed to be used as chrootdir");
 | 
			
		||||
 | 
			
		||||
	/* Make chrootdir absolute */
 | 
			
		||||
	if (chrootdir[0] != '/') {
 | 
			
		||||
		char cwd[PATH_MAX-1];
 | 
			
		||||
		if (getcwd(cwd, sizeof(cwd)) == NULL)
 | 
			
		||||
			die("getcwd");
 | 
			
		||||
		chrootdir = xbps_xasprintf("%s/%s", cwd, chrootdir);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Unshare from the current process namespaces and set ours.
 | 
			
		||||
	 */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user