only create chroot directory when path policies are available

This commit is contained in:
Albert S. 2019-12-07 23:26:27 +01:00
parent 7547644013
commit ff2bc24c6b

15
qssb.h
View File

@ -481,7 +481,14 @@ int qssb_enable_policy(struct qssb_policy *policy)
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)
{
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)
{
QSSB_LOG_ERROR("mount_to_chroot: setup of path policies failed\n");