execve: SUID and SGID

This commit is contained in:
Matheus
2024-08-24 21:53:05 -03:00
parent cd51d4eaf0
commit 4308317ea5
3 changed files with 29 additions and 0 deletions
+12
View File
@@ -1,5 +1,6 @@
#include <kernel/cred.h>
#include <errno.h>
#include <logging.h>
int cred_setuids(cred_t *cred, int uid, int euid, int suid) {
if (uid < -1 || euid < -1 || suid < -1 || (uid == -1 && euid == -1 && suid == -1))
@@ -27,6 +28,17 @@ int cred_setgids(cred_t *cred, int gid, int egid, int sgid) {
return 0;
}
void cred_doexec(cred_t *cred, int suid, int sgid) {
if (suid > -1)
cred->euid = suid;
if (sgid > -1)
cred->egid = sgid;
cred->suid = cred->euid;
cred->sgid = cred->egid;
}
void cred_getuids(cred_t *cred, int *uidp, int *euidp, int *suidp) {
*uidp = cred->uid;
*euidp = cred->euid;