mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
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.
This commit is contained in:
parent
f000193ee5
commit
945d2079b4
2 changed files with 8 additions and 2 deletions
|
@ -231,6 +231,8 @@ ErrorOr<DeprecatedString> Account::generate_passwd_file() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (pwd->pw_name == m_username) {
|
if (pwd->pw_name == m_username) {
|
||||||
|
if (m_deleted)
|
||||||
|
continue;
|
||||||
builder.appendff("{}:!:{}:{}:{}:{}:{}\n",
|
builder.appendff("{}:!:{}:{}:{}:{}:{}\n",
|
||||||
m_username,
|
m_username,
|
||||||
m_uid, m_gid,
|
m_uid, m_gid,
|
||||||
|
@ -259,9 +261,11 @@ ErrorOr<DeprecatedString> Account::generate_shadow_file() const
|
||||||
struct spwd* p;
|
struct spwd* p;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
while ((p = getspent())) {
|
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);
|
builder.appendff("{}:{}", m_username, m_password_hash);
|
||||||
else
|
} else
|
||||||
builder.appendff("{}:{}", p->sp_namp, p->sp_pwdp);
|
builder.appendff("{}:{}", p->sp_namp, p->sp_pwdp);
|
||||||
|
|
||||||
builder.appendff(":{}:{}:{}:{}:{}:{}:{}\n",
|
builder.appendff(":{}:{}:{}:{}:{}:{}:{}\n",
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
void set_gid(gid_t gid) { m_gid = gid; }
|
void set_gid(gid_t gid) { m_gid = gid; }
|
||||||
void set_shell(StringView shell) { m_shell = shell; }
|
void set_shell(StringView shell) { m_shell = shell; }
|
||||||
void set_gecos(StringView gecos) { m_gecos = gecos; }
|
void set_gecos(StringView gecos) { m_gecos = gecos; }
|
||||||
|
void set_deleted() { m_deleted = true; };
|
||||||
void delete_password();
|
void delete_password();
|
||||||
|
|
||||||
// A null password means that this account was missing from /etc/shadow.
|
// A null password means that this account was missing from /etc/shadow.
|
||||||
|
@ -86,6 +87,7 @@ private:
|
||||||
DeprecatedString m_home_directory;
|
DeprecatedString m_home_directory;
|
||||||
DeprecatedString m_shell;
|
DeprecatedString m_shell;
|
||||||
Vector<gid_t> m_extra_gids;
|
Vector<gid_t> m_extra_gids;
|
||||||
|
bool m_deleted { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue