only create chroot directory when path policies are available

This commit is contained in:
Albert S. 2019-12-07 23:26:27 +01:00
والد 7547644013
کامیت ff2bc24c6b
1فایلهای تغییر یافته به همراه26 افزوده شده و 27 حذف شده

15
qssb.h
مشاهده پرونده

@ -481,7 +481,14 @@ int qssb_enable_policy(struct qssb_policy *policy)
return -EINVAL; return -EINVAL;
} }
if(enter_namespaces(policy->namespace_options) < 0)
{
QSSB_LOG_ERROR("Error while trying to enter namespaces\n");
return -1;
}
if(policy->path_policies != NULL)
{
if(policy->chroot_target_path == NULL) if(policy->chroot_target_path == NULL)
{ {
char *target_dir = (char *) calloc(1, PATH_MAX * sizeof(char)); char *target_dir = (char *) calloc(1, PATH_MAX * sizeof(char));
@ -508,14 +515,6 @@ int qssb_enable_policy(struct qssb_policy *policy)
} }
} }
if(enter_namespaces(policy->namespace_options) < 0)
{
QSSB_LOG_ERROR("Error while trying to enter namespaces\n");
return -1;
}
if(policy->path_policies != NULL)
{
if(mount_to_chroot(policy->chroot_target_path, policy->path_policies) < 0) if(mount_to_chroot(policy->chroot_target_path, policy->path_policies) < 0)
{ {
QSSB_LOG_ERROR("mount_to_chroot: setup of path policies failed\n"); QSSB_LOG_ERROR("mount_to_chroot: setup of path policies failed\n");