[CRIU] [PATCH 4/N] crtools: resolve work_dir and imgs_dir path to absolute

Pavel Emelyanov xemul at parallels.com
Fri Nov 15 06:26:42 PST 2013


>>> @@ -163,13 +165,20 @@ int main(int argc, char *argv[])
>>>   			opts.restore_detach = true;
>>>   			break;
>>>   		case 'D':
>>> -			if (chdir(optarg)) {
>>> -				pr_perror("Can't change directory to %s",
>>> -						optarg);
>>> +			imgs_dir = xmalloc(PATH_MAX);
>>> +			imgs_dir = realpath(optarg, imgs_dir);
>> NAK. Image dir should be passed into open_image_dir() as is.
>>
>>> +			if (!imgs_dir) {
>>> +				pr_perror("Bad images directory path");
>>>   				return -1;
>>>   			}
>>>   			break;
>>>   		case 'W':
>>> +			work_dir = xmalloc(PATH_MAX);
>>> +			work_dir = realpath(optarg, work_dir);
>> Same for work dir -- we should chrdir into what user gave us, not
>> to somehow converted path.
> 
> Why? Isn't it comfortable to use relative to cwd paths for work and 
> images dirs?

It is.

> We chdir into what user gave us, but we convert relative into full paths 
> to not mess around with relative paths.

This conversion is pointless and in some corner cases leads to wrong results.


More information about the CRIU mailing list