auth: chroot

This commit is contained in:
Matheus
2024-08-24 21:52:44 -03:00
parent 806fa3a333
commit cd51d4eaf0
3 changed files with 28 additions and 3 deletions
+18
View File
@@ -75,6 +75,24 @@ static int filesystem(cred_t *cred, int actions, void *arg0, void *arg1, void *a
return weight ? AUTH_DECISION_ALLOW : AUTH_DECISION_DEFER;
}
static int system(cred_t *cred, int actions, void *arg0, void *arg1, void *arg2) {
int weight = 0;
if (actions & AUTH_ACTIONS_SYSTEM_CHROOT) {
if (CRED_IS_ESU(cred))
weight += 1;
else
return AUTH_DECISION_DENY;
DONE_CHECK(actions);
}
done:
return weight ? AUTH_DECISION_ALLOW : AUTH_DECISION_DEFER;
}
void defaultauth_init() {
auth_registerlistener(AUTH_SCOPE_FILESYSTEM, filesystem);
auth_registerlistener(AUTH_SCOPE_SYSTEM, system);
}
+5
View File
@@ -3,12 +3,17 @@
#include <kernel/vfs.h>
#include <kernel/alloc.h>
#include <errno.h>
#include <kernel/auth.h>
syscallret_t syscall_chroot(context_t *, char *upath) {
syscallret_t ret = {
.ret = -1
};
ret.errno = auth_system_check(&_cpu()->thread->proc->cred, AUTH_ACTIONS_SYSTEM_CHROOT);
if (ret.errno)
return ret;
size_t pathlen;
ret.errno = usercopy_strlen(upath, &pathlen);
if (ret.errno)