1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

LibCore: Add Directory::chown() API and use it in Core::Account

Since we already have the directory open, let's have an API to fchown()
the underlying file descriptor instead of forcing clients to do another
path lookup.
This commit is contained in:
Andreas Kling 2022-08-15 14:10:26 +02:00
parent 3f14582b85
commit c1af2f28e3
3 changed files with 12 additions and 2 deletions

View file

@ -152,8 +152,8 @@ bool Account::authenticate(SecretString const& password) const
ErrorOr<void> Account::create_user_temporary_directory_if_needed() const
{
auto const temporary_directory = String::formatted("/tmp/user/{}", m_uid);
TRY(Core::Directory::create(temporary_directory, Core::Directory::CreateDirectories::Yes));
TRY(Core::System::chown(temporary_directory, m_uid, m_gid));
auto directory = TRY(Core::Directory::create(temporary_directory, Core::Directory::CreateDirectories::Yes));
TRY(directory.chown(m_uid, m_gid));
return {};
}