parent a842308f
...@@ -1461,6 +1461,9 @@ static int set_config_log_file(const char *key, const char *value, ...@@ -1461,6 +1461,9 @@ static int set_config_log_file(const char *key, const char *value,
return 0; return 0;
} }
if (!abspath(value))
return ret_errno(EINVAL);
/* /*
* Store these values in the lxc_conf, and then try to set for actual * Store these values in the lxc_conf, and then try to set for actual
* current logging. * current logging.
......
...@@ -489,6 +489,12 @@ static int build_dir(const char *name) ...@@ -489,6 +489,12 @@ static int build_dir(const char *name)
__do_free char *n = NULL; __do_free char *n = NULL;
char *e, *p; char *e, *p;
if (is_empty_string(name))
return ret_errno(EINVAL);
if (!abspath(name))
return ret_errno(EINVAL);
/* Make copy of the string since we'll be modifying it. */ /* Make copy of the string since we'll be modifying it. */
n = strdup(name); n = strdup(name);
if (!n) if (!n)
...@@ -604,7 +610,7 @@ static int __lxc_log_set_file(const char *fname, int create_dirs) ...@@ -604,7 +610,7 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
if (lxc_log_fd >= 0) if (lxc_log_fd >= 0)
lxc_log_close(); lxc_log_close();
if (!fname) if (is_empty_string(fname))
return ret_errno(EINVAL); return ret_errno(EINVAL);
if (strlen(fname) == 0) { if (strlen(fname) == 0) {
...@@ -820,6 +826,9 @@ int lxc_log_set_file(int *fd, const char *fname) ...@@ -820,6 +826,9 @@ int lxc_log_set_file(int *fd, const char *fname)
if (*fd >= 0) if (*fd >= 0)
close_prot_errno_disarm(*fd); close_prot_errno_disarm(*fd);
if (is_empty_string(fname))
return ret_errno(EINVAL);
if (build_dir(fname)) if (build_dir(fname))
return -errno; return -errno;
......
...@@ -884,6 +884,11 @@ int main(int argc, char *argv[]) ...@@ -884,6 +884,11 @@ int main(int argc, char *argv[])
return -1; return -1;
} }
if (c->set_config_item(c, "lxc.log.file=", "./")) {
lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.log.file\" to \"./\"");
return -1;
}
fret = EXIT_SUCCESS; fret = EXIT_SUCCESS;
non_test_error: non_test_error:
......
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