kernel: Support setuid binaries
All checks were successful
continuous-integration/drone/push Build is passing

You still have to run "chmod 4755 /bin/su" as root inside Luna for now, as this is not done by the install scripts.
This commit is contained in:
apio 2023-04-08 16:32:56 +02:00
parent 8b45766aaa
commit 3887b98a7d
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 15 additions and 0 deletions

View File

@ -86,4 +86,14 @@ namespace VFS
return inode->mode() & S_IROTH;
}
bool is_setuid(SharedPtr<Inode> inode)
{
return inode->mode() & S_ISUID;
}
bool is_setgid(SharedPtr<Inode> inode)
{
return inode->mode() & S_ISGID;
}
}

View File

@ -178,6 +178,8 @@ namespace VFS
bool can_execute(SharedPtr<Inode> inode, Credentials auth);
bool can_read(SharedPtr<Inode> inode, Credentials auth);
bool can_write(SharedPtr<Inode> inode, Credentials auth);
bool is_setuid(SharedPtr<Inode> inode);
bool is_setgid(SharedPtr<Inode> inode);
Inode& root_inode();
}

View File

@ -76,6 +76,9 @@ Result<u64> sys_execve(Registers* regs, SyscallArgs args)
MMU::delete_userspace_page_directory(current->directory);
if (VFS::is_setuid(inode)) current->auth.euid = current->auth.suid = inode->uid();
if (VFS::is_setgid(inode)) current->auth.egid = current->auth.sgid = inode->gid();
current->name = path.chars();
image->apply(current);