[lxc-devel] [PATCH] Fix compile error when building with -Wp, -D_FORTIFY_SOURCE=2

Serge Hallyn serge.hallyn at canonical.com
Fri Nov 30 15:29:56 UTC 2012


Quoting Dwight Engen (dwight.engen at oracle.com):
> Fedora by default builds with this flag, and complains about not checking the
> return from fchdir. There isn't much we can do if we can't change back to the
> original directory, so just log an error message.
> 
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
> ---
>  src/lxc/conf.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index e3f1d53..c02e109 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -928,7 +928,8 @@ static void run_makedev(char *devpath)
>  	}
>  	if (run_buffer("/sbin/MAKEDEV console"))
>  		INFO("Error running MAKEDEV console in %s", devpath);
> -	fchdir(curd);
> +	if (fchdir(curd) < 0)
> +		ERROR("Error restoring cwd");

Thanks, Dwight, Stephane had actually noticed this last night and I
pushed the fix (exactly the same as yours) to staging last night.

I considered actually failing the start at this point, since if
this happens we're probably completely hosed.

I also briefly considered going ahead and doing a fork+waitpid()
so we can avoid the potentially failing fchdir...  but doesn't
seem worth it.

>  	close(curd);
>  }
>  
> -- 
> 1.7.11.7
> 
> 
> ------------------------------------------------------------------------------
> Keep yourself connected to Go Parallel: 
> TUNE You got it built. Now make it sing. Tune shows you how.
> http://goparallel.sourceforge.net
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list