mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
cred: setuid, setgid, seteuid, setegid and auth check
This commit is contained in:
@@ -4,9 +4,10 @@
|
||||
#include <kernel/cred.h>
|
||||
#include <kernel/vfs.h>
|
||||
|
||||
#define AUTH_SCOPE_COUNT 2
|
||||
#define AUTH_SCOPE_COUNT 3
|
||||
#define AUTH_SCOPE_SYSTEM 0
|
||||
#define AUTH_SCOPE_FILESYSTEM 1
|
||||
#define AUTH_SCOPE_CRED 2
|
||||
|
||||
#define AUTH_LISTENER_LIMIT 8
|
||||
|
||||
@@ -23,6 +24,13 @@
|
||||
#define AUTH_ACTIONS_FILESYSTEM_SETATTR 8
|
||||
#define AUTH_ACTIONS_FILESYSTEM_MOUNT 16
|
||||
|
||||
#define AUTH_ACTIONS_CRED_SETRESUID 1
|
||||
#define AUTH_ACTIONS_CRED_SETRESGID 2
|
||||
#define AUTH_ACTIONS_CRED_SETUID 4
|
||||
#define AUTH_ACTIONS_CRED_SETGID 8
|
||||
#define AUTH_ACTIONS_CRED_SETEUID 16
|
||||
#define AUTH_ACTIONS_CRED_SETEGID 32
|
||||
|
||||
typedef int (*authlistener_t)(cred_t *cred, int actions, void *arg0, void *arg1, void *arg2);
|
||||
|
||||
typedef struct {
|
||||
@@ -40,6 +48,10 @@ static inline int auth_system_check(cred_t *cred, int actions) {
|
||||
return auth_check(AUTH_SCOPE_SYSTEM, cred, actions, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static inline int auth_cred_check(cred_t *cred, int actions, int id, int eid, int sid) {
|
||||
return auth_check(AUTH_SCOPE_CRED, cred, actions, &id, &eid, &sid);
|
||||
}
|
||||
|
||||
static inline int auth_filesystem_convertaccess(int access) {
|
||||
int r = 0;
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ typedef struct {
|
||||
|
||||
int cred_setuids(cred_t *cred, int uid, int euid, int suid);
|
||||
int cred_setgids(cred_t *cred, int uid, int euid, int suid);
|
||||
int cred_setuid(cred_t *cred, int uid);
|
||||
int cred_seteuid(cred_t *cred, int euid);
|
||||
int cred_setgid(cred_t *cred, int gid);
|
||||
int cred_setegid(cred_t *cred, int egid);
|
||||
void cred_getuids(cred_t *cred, int *uidp, int *euidp, int *suidp);
|
||||
void cred_getgids(cred_t *cred, int *gidp, int *egidp, int *sgidp);
|
||||
void cred_doexec(cred_t *cred, int suid, int sgid);
|
||||
|
||||
Reference in New Issue
Block a user