Commit f3ca99fd by Serge Hallyn

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 avatarS.Çağlar Onur" <caglar@10ur.org> Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent bb787bc5
...@@ -1422,6 +1422,9 @@ int lxc_config_readline(char *buffer, struct lxc_conf *conf) ...@@ -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) 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 */ /* Catch only the top level config file name in the structure */
if( ! conf->rcfile ) { if( ! conf->rcfile ) {
conf->rcfile = strdup( file ); conf->rcfile = strdup( file );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment