[CRIU] [PATCH] sk-unix: Don't affect cwd for relative named sockets

Pavel Emelyanov xemul at parallels.com
Wed Oct 7 04:54:06 PDT 2015


> +static int prep_unix_sk_cwd(struct unix_sk_info *ui, char **prev_cwd)
>  {
>  	if (ui->name_dir) {
> +		*prev_cwd = get_current_dir_name();

This looks quite fragile. Can we instead open the "." and then
call fchdir() on it?

> +		if (!*prev_cwd) {
> +			pr_err("Can't allocate current dir\n");
> +			return -1;
> +		}
>  		if (chdir(ui->name_dir)) {
>  			pr_perror("Can't change working dir %s\n",
>  				  ui->name_dir);
> +			revert_unix_sk_cwd(prev_cwd);
>  			return -1;
>  		}
> -		pr_debug("Change working dir to %s\n", ui->name_dir);
> -	}
> +		pr_debug("Change working dir to %s (was %s)\n",
> +			 ui->name_dir, *prev_cwd);
> +	} else
> +		*prev_cwd = NULL;
>  	return 0;



More information about the CRIU mailing list