From: Serge Hallyn Date: Thu, 28 Mar 2013 15:34:06 +0000 (-0500) Subject: rcfile shouldn't be recorded in lxc_conf if the attempt to load a config file fails X-Git-Tag: lxc-0.9.0~1^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3ca99fd5fe887adbb93ae56ccf629dfdd232070;p=thirdparty%2Flxc.git rcfile shouldn't be recorded in lxc_conf if the attempt to load a config file fails Though it's more subtle than that. If the file doesn't exist or we can't access it, then don't record it. But if we have parse errors, then do. This is mainly to help out API users who try to read a container configuration file before calling c->create(). If the file doesn't exist, then without this patch the subsequent create() will not use the default /etc/lxc/default.conf. The API user could check for the file ahead of time, but this check makes his life easier without costing us anything. Signed-off-by: S.Çağlar Onur" Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 8fe15410c..676878e62 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -1422,6 +1422,9 @@ int lxc_config_readline(char *buffer, struct lxc_conf *conf) int lxc_config_read(const char *file, struct lxc_conf *conf) { + if( access(file, R_OK) == -1 ) { + return -1; + } /* Catch only the top level config file name in the structure */ if( ! conf->rcfile ) { conf->rcfile = strdup( file );