diff --git a/kernel/include/kernel/FS/Ext2.h b/kernel/include/kernel/FS/Ext2.h index 4899444984..4326ee145a 100644 --- a/kernel/include/kernel/FS/Ext2.h +++ b/kernel/include/kernel/FS/Ext2.h @@ -146,7 +146,7 @@ namespace Kernel virtual BAN::ErrorOr read(size_t, void*, size_t) override; - virtual BAN::ErrorOr create_file(BAN::StringView, mode_t) override; + virtual BAN::ErrorOr create_file(BAN::StringView, mode_t, uid_t, gid_t) override; private: BAN::ErrorOr data_block_index(uint32_t); diff --git a/kernel/include/kernel/FS/Inode.h b/kernel/include/kernel/FS/Inode.h index 931fde86c6..956beba707 100644 --- a/kernel/include/kernel/FS/Inode.h +++ b/kernel/include/kernel/FS/Inode.h @@ -88,7 +88,7 @@ namespace Kernel virtual BAN::ErrorOr read(size_t, void*, size_t) { if (mode().ifdir()) return BAN::Error::from_errno(EISDIR); ASSERT_NOT_REACHED(); } virtual BAN::ErrorOr write(size_t, const void*, size_t) { if (mode().ifdir()) return BAN::Error::from_errno(EISDIR); ASSERT_NOT_REACHED(); } - virtual BAN::ErrorOr create_file(BAN::StringView, mode_t) { if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); ASSERT_NOT_REACHED(); } + virtual BAN::ErrorOr create_file(BAN::StringView, mode_t, uid_t, gid_t) { if (!mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); ASSERT_NOT_REACHED(); } }; } \ No newline at end of file diff --git a/kernel/include/kernel/FS/RamFS/Inode.h b/kernel/include/kernel/FS/RamFS/Inode.h index 9ec183f754..f82995c985 100644 --- a/kernel/include/kernel/FS/RamFS/Inode.h +++ b/kernel/include/kernel/FS/RamFS/Inode.h @@ -70,7 +70,7 @@ namespace Kernel virtual BAN::ErrorOr> directory_find_inode(BAN::StringView) override; virtual BAN::ErrorOr directory_read_next_entries(off_t, DirectoryEntryList*, size_t) override; - virtual BAN::ErrorOr create_file(BAN::StringView, mode_t) override; + virtual BAN::ErrorOr create_file(BAN::StringView, mode_t, uid_t, gid_t) override; private: RamDirectoryInode(RamFileSystem&, ino_t parent, mode_t, uid_t, gid_t); diff --git a/kernel/kernel/FS/Ext2.cpp b/kernel/kernel/FS/Ext2.cpp index 64e149db09..3a9395681f 100644 --- a/kernel/kernel/FS/Ext2.cpp +++ b/kernel/kernel/FS/Ext2.cpp @@ -356,7 +356,7 @@ namespace Kernel return {}; } - BAN::ErrorOr Ext2Inode::create_file(BAN::StringView name, mode_t mode) + BAN::ErrorOr Ext2Inode::create_file(BAN::StringView name, mode_t mode, uid_t uid, gid_t gid) { if (!this->mode().ifdir()) return BAN::Error::from_errno(ENOTDIR); @@ -378,13 +378,13 @@ namespace Kernel Ext2::Inode ext2_inode; ext2_inode.mode = mode; - ext2_inode.uid = 0; + ext2_inode.uid = uid; ext2_inode.size = 0; ext2_inode.atime = current_time; ext2_inode.ctime = current_time; ext2_inode.mtime = current_time; ext2_inode.dtime = current_time; - ext2_inode.gid = 0; + ext2_inode.gid = gid; ext2_inode.links_count = 1; ext2_inode.blocks = 0; ext2_inode.flags = 0; diff --git a/kernel/kernel/FS/RamFS/Inode.cpp b/kernel/kernel/FS/RamFS/Inode.cpp index 843766f250..48e6a0199b 100644 --- a/kernel/kernel/FS/RamFS/Inode.cpp +++ b/kernel/kernel/FS/RamFS/Inode.cpp @@ -153,8 +153,12 @@ namespace Kernel return {}; } - BAN::ErrorOr RamDirectoryInode::create_file(BAN::StringView, mode_t) + BAN::ErrorOr RamDirectoryInode::create_file(BAN::StringView name, mode_t mode, uid_t uid, gid_t gid) { + (void)name; + (void)mode; + (void)uid; + (void)gid; ASSERT_NOT_REACHED(); } diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index ea79915104..b9031d59b4 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -567,7 +567,7 @@ namespace Kernel auto file_name = absolute_path.sv().substring(index); auto parent_file = TRY(VirtualFileSystem::get().file_from_absolute_path(m_credentials, directory, O_WRONLY)); - TRY(parent_file.inode->create_file(file_name, mode)); + TRY(parent_file.inode->create_file(file_name, mode, m_credentials.euid(), m_credentials.egid())); return 0; }