Compare commits
2 次程式碼提交
WIP/enosys
...
3fa73b0b97
作者 | SHA1 | 提交日期 | |
---|---|---|---|
3fa73b0b97 | |||
8f38dc4480 |
27
exile.c
27
exile.c
@ -1410,6 +1410,11 @@ static int check_policy_sanity(struct exile_policy *policy)
|
|||||||
{
|
{
|
||||||
if(syscall_policy->syscall == EXILE_SYSCALL_MATCH_ALL)
|
if(syscall_policy->syscall == EXILE_SYSCALL_MATCH_ALL)
|
||||||
{
|
{
|
||||||
|
if(policy->vow_promises != 0)
|
||||||
|
{
|
||||||
|
EXILE_LOG_ERROR("It's not possible to specify a default, all matching syscall policy while also using vows\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
last_match_all = i;
|
last_match_all = i;
|
||||||
match_all_policy = syscall_policy->policy;
|
match_all_policy = syscall_policy->policy;
|
||||||
}
|
}
|
||||||
@ -1420,7 +1425,7 @@ static int check_policy_sanity(struct exile_policy *policy)
|
|||||||
syscall_policy = syscall_policy->next;
|
syscall_policy = syscall_policy->next;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
if(last_match_all == -1 || i - last_match_all != 1)
|
if(policy->vow_promises == 0 && (last_match_all == -1 || i - last_match_all != 1))
|
||||||
{
|
{
|
||||||
EXILE_LOG_ERROR("The last entry in the syscall policy list must match all syscalls (default rule)\n");
|
EXILE_LOG_ERROR("The last entry in the syscall policy list must match all syscalls (default rule)\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -1441,7 +1446,20 @@ static void close_file_fds()
|
|||||||
long max_files = sysconf(_SC_OPEN_MAX);
|
long max_files = sysconf(_SC_OPEN_MAX);
|
||||||
for(long i = 3; i <= max_files; i++)
|
for(long i = 3; i <= max_files; i++)
|
||||||
{
|
{
|
||||||
close((int)i);
|
struct stat statbuf;
|
||||||
|
int fd = (int) max_files;
|
||||||
|
int result = fstat(i, &statbuf);
|
||||||
|
if(result == -1 && errno != EBADF && errno != EACCES)
|
||||||
|
{
|
||||||
|
EXILE_LOG_ERROR("Could not fstat %i: %s\n", fd, strerror(errno));
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
int type = statbuf.st_mode & S_IFMT;
|
||||||
|
if(type != S_IFIFO && type != S_IFSOCK)
|
||||||
|
{
|
||||||
|
/* No error check, retrying not recommended */
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1504,6 +1522,11 @@ int exile_enable_policy(struct exile_policy *policy)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(policy->keep_fds_open != 1)
|
||||||
|
{
|
||||||
|
close_file_fds();
|
||||||
|
}
|
||||||
|
|
||||||
if(enter_namespaces(policy->namespace_options) < 0)
|
if(enter_namespaces(policy->namespace_options) < 0)
|
||||||
{
|
{
|
||||||
EXILE_LOG_ERROR("Error while trying to enter namespaces\n");
|
EXILE_LOG_ERROR("Error while trying to enter namespaces\n");
|
||||||
|
1
exile.h
1
exile.h
@ -364,6 +364,7 @@ struct exile_policy
|
|||||||
int no_new_privs;
|
int no_new_privs;
|
||||||
int no_fs;
|
int no_fs;
|
||||||
int no_new_fds;
|
int no_new_fds;
|
||||||
|
int keep_fds_open;
|
||||||
int namespace_options;
|
int namespace_options;
|
||||||
int disable_syscall_filter;
|
int disable_syscall_filter;
|
||||||
/* Bind mounts all paths in path_policies into the chroot and applies
|
/* Bind mounts all paths in path_policies into the chroot and applies
|
||||||
|
Reference in New Issue
Block a user