summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/Account.cpp
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2022-12-07 00:42:49 +0100
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-31 04:24:05 -0700
commit945d2079b435abe1a5dc8af3e4c4015003ff90df (patch)
treed7da474fc5606cabd063bcfe80059a89940b0b33 /Userland/Libraries/LibCore/Account.cpp
parentf000193ee5ff65a064634d011f29694bb833d2fb (diff)
downloadserenity-945d2079b435abe1a5dc8af3e4c4015003ff90df.zip
LibCore: Add a deleted state for `Account`
As other setters, this only affect the in-memory copy, you need to call `sync()` to apply changes.
Diffstat (limited to 'Userland/Libraries/LibCore/Account.cpp')
-rw-r--r--Userland/Libraries/LibCore/Account.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCore/Account.cpp b/Userland/Libraries/LibCore/Account.cpp
index 647688d72a..68de38c562 100644
--- a/Userland/Libraries/LibCore/Account.cpp
+++ b/Userland/Libraries/LibCore/Account.cpp
@@ -231,6 +231,8 @@ ErrorOr<DeprecatedString> Account::generate_passwd_file() const
break;
if (pwd->pw_name == m_username) {
+ if (m_deleted)
+ continue;
builder.appendff("{}:!:{}:{}:{}:{}:{}\n",
m_username,
m_uid, m_gid,
@@ -259,9 +261,11 @@ ErrorOr<DeprecatedString> Account::generate_shadow_file() const
struct spwd* p;
errno = 0;
while ((p = getspent())) {
- if (p->sp_namp == m_username)
+ if (p->sp_namp == m_username) {
+ if (m_deleted)
+ continue;
builder.appendff("{}:{}", m_username, m_password_hash);
- else
+ } else
builder.appendff("{}:{}", p->sp_namp, p->sp_pwdp);
builder.appendff(":{}:{}:{}:{}:{}:{}:{}\n",