#include "lib/string/printf.h"
#include <stdbool.h>
+#include <errno.h>
static smartlist_t *config_get_file_list(const char *path,
smartlist_t *opened_files);
smartlist_t *matches = tor_glob(pattern);
if (!matches) {
+ if (errno == EPERM) {
+ log_err(LD_CONFIG, "Sandbox is active, but the configuration pattern "
+ "\"%s\" listed with %%include would access files or folders not "
+ "allowed by it. Cannot proceed.", pattern);
+ }
return NULL;
}
static DIR *
prot_opendir(const char *name)
{
+ if (sandbox_interned_string_is_missing(name)) {
+ errno = EPERM;
+ return NULL;
+ }
return opendir(sandbox_intern_string(name));
}
static int
prot_stat(const char *pathname, struct stat *buf)
{
+ if (sandbox_interned_string_is_missing(pathname)) {
+ errno = EPERM;
+ return -1;
+ }
return stat(sandbox_intern_string(pathname), buf);
}
static int
prot_lstat(const char *pathname, struct stat *buf)
{
+ if (sandbox_interned_string_is_missing(pathname)) {
+ errno = EPERM;
+ return -1;
+ }
return lstat(sandbox_intern_string(pathname), buf);
}
/** As closedir, but has the right type for gl_closedir */
/** Return a new list containing the paths that match the pattern
* <b>pattern</b>. Return NULL on error. On POSIX systems, errno is set by the
- * glob function.
+ * glob function or is set to EPERM if glob tried to access a file not allowed
+ * by the seccomp sandbox.
*/
struct smartlist_t *
tor_glob(const char *pattern)