]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
rcfile shouldn't be recorded in lxc_conf if the attempt to load a config file fails
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 28 Mar 2013 15:34:06 +0000 (10:34 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 28 Mar 2013 15:34:06 +0000 (10:34 -0500)
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" <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/confile.c

index 8fe15410c38c7cf8c6cc19b08bcba48524a42e24..676878e629c2798e5efe17a8763f62a02adfcab5 100644 (file)
@@ -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 );