1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

LibCore+su+passwd: Don't keep /etc/passwd and /etc/shadow open

Now that we've moved to atomic replacement of these files when altering
them, we don't need to keep them open for the lifetime of Core::Account
so just simplify this and close them when they are not needed.
This commit is contained in:
Andreas Kling 2021-01-21 11:17:06 +01:00
parent 77e0598c6d
commit 439f447ba8
4 changed files with 22 additions and 71 deletions

View file

@ -58,8 +58,8 @@ int main(int argc, char** argv)
}
auto account_or_error = (user)
? Core::Account::from_name(user, Core::Account::OpenPasswdFile::No, Core::Account::OpenShadowFile::ReadOnly)
: Core::Account::from_uid(0, Core::Account::OpenPasswdFile::No, Core::Account::OpenShadowFile::ReadOnly);
? Core::Account::from_name(user)
: Core::Account::from_uid(0);
if (account_or_error.is_error()) {
fprintf(stderr, "Core::Account::from_name: %s\n", account_or_error.error().characters());
return 1;