1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:17:35 +00:00

Kernel: Create new files with the current process EUID/EGID

We were using the UID/GID and not the EUID/EGID, which didn't match
other systems.
This commit is contained in:
Andreas Kling 2021-01-21 09:56:18 +01:00
parent 928ee2c791
commit c9a7f81dc3

View file

@ -379,7 +379,7 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
LexicalPath p(path); LexicalPath p(path);
dbgln("VFS::mknod: '{}' mode={} dev={} in {}", p.basename(), mode, dev, parent_inode.identifier()); dbgln("VFS::mknod: '{}' mode={} dev={} in {}", p.basename(), mode, dev, parent_inode.identifier());
return parent_inode.create_child(p.basename(), mode, dev, current_process->uid(), current_process->gid()).result(); return parent_inode.create_child(p.basename(), mode, dev, current_process->euid(), current_process->egid()).result();
} }
KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> owner) KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> owner)
@ -404,8 +404,8 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
#ifdef VFS_DEBUG #ifdef VFS_DEBUG
dbg() << "VFS::create: '" << p.basename() << "' in " << parent_inode.identifier(); dbg() << "VFS::create: '" << p.basename() << "' in " << parent_inode.identifier();
#endif #endif
uid_t uid = owner.has_value() ? owner.value().uid : current_process->uid(); uid_t uid = owner.has_value() ? owner.value().uid : current_process->euid();
gid_t gid = owner.has_value() ? owner.value().gid : current_process->gid(); gid_t gid = owner.has_value() ? owner.value().gid : current_process->egid();
auto inode_or_error = parent_inode.create_child(p.basename(), mode, 0, uid, gid); auto inode_or_error = parent_inode.create_child(p.basename(), mode, 0, uid, gid);
if (inode_or_error.is_error()) if (inode_or_error.is_error())
return inode_or_error.error(); return inode_or_error.error();
@ -448,7 +448,7 @@ KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
#ifdef VFS_DEBUG #ifdef VFS_DEBUG
dbg() << "VFS::mkdir: '" << p.basename() << "' in " << parent_inode.identifier(); dbg() << "VFS::mkdir: '" << p.basename() << "' in " << parent_inode.identifier();
#endif #endif
return parent_inode.create_child(p.basename(), S_IFDIR | mode, 0, current_process->uid(), current_process->gid()).result(); return parent_inode.create_child(p.basename(), S_IFDIR | mode, 0, current_process->euid(), current_process->egid()).result();
} }
KResult VFS::access(StringView path, int mode, Custody& base) KResult VFS::access(StringView path, int mode, Custody& base)
@ -743,7 +743,7 @@ KResult VFS::symlink(StringView target, StringView linkpath, Custody& base)
LexicalPath p(linkpath); LexicalPath p(linkpath);
dbgln("VFS::symlink: '{}' (-> '{}') in {}", p.basename(), target, parent_inode.identifier()); dbgln("VFS::symlink: '{}' (-> '{}') in {}", p.basename(), target, parent_inode.identifier());
auto inode_or_error = parent_inode.create_child(p.basename(), S_IFLNK | 0644, 0, current_process->uid(), current_process->gid()); auto inode_or_error = parent_inode.create_child(p.basename(), S_IFLNK | 0644, 0, current_process->euid(), current_process->egid());
if (inode_or_error.is_error()) if (inode_or_error.is_error())
return inode_or_error.error(); return inode_or_error.error();
auto& inode = inode_or_error.value(); auto& inode = inode_or_error.value();