mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
LibCore: Do not write disabled spwd values in generate_shadow_file
When LibC/shadow.cpp parses shadow entries in getspent, it sets the spwd member value to disabled (-1) if the value is empty. When Core::Account::sync calls getspent to generate a new shadow file, it would recieve the -1 values and write them in the shadow file. This would cause the /etc/shadow file to be cluttered with disabled values after any password change. This patch checks if the spwd member value is disabled, and prints the appropriate value to the shadow file.
This commit is contained in:
parent
92339b7fe5
commit
3cf835af6d
Notes:
sideshowbarker
2024-07-18 17:12:24 +09:00
Author: https://github.com/brapru Commit: https://github.com/SerenityOS/serenity/commit/3cf835af6d8 Pull-request: https://github.com/SerenityOS/serenity/pull/7561
1 changed files with 14 additions and 8 deletions
|
@ -224,18 +224,24 @@ String Account::generate_shadow_file() const
|
|||
if (p->sp_namp == m_username) {
|
||||
builder.appendff("{}:{}:{}:{}:{}:{}:{}:{}:{}\n",
|
||||
m_username, m_password_hash,
|
||||
p->sp_lstchg, p->sp_min,
|
||||
p->sp_max, p->sp_warn,
|
||||
p->sp_inact, p->sp_expire,
|
||||
p->sp_flag);
|
||||
(p->sp_lstchg == -1) ? "" : String::formatted("{}", p->sp_lstchg),
|
||||
(p->sp_min == -1) ? "" : String::formatted("{}", p->sp_min),
|
||||
(p->sp_max == -1) ? "" : String::formatted("{}", p->sp_max),
|
||||
(p->sp_warn == -1) ? "" : String::formatted("{}", p->sp_warn),
|
||||
(p->sp_inact == -1) ? "" : String::formatted("{}", p->sp_inact),
|
||||
(p->sp_expire == -1) ? "" : String::formatted("{}", p->sp_expire),
|
||||
(p->sp_flag == 0) ? "" : String::formatted("{}", p->sp_flag));
|
||||
|
||||
} else {
|
||||
builder.appendff("{}:{}:{}:{}:{}:{}:{}:{}:{}\n",
|
||||
p->sp_namp, p->sp_pwdp,
|
||||
p->sp_lstchg, p->sp_min,
|
||||
p->sp_max, p->sp_warn,
|
||||
p->sp_inact, p->sp_expire,
|
||||
p->sp_flag);
|
||||
(p->sp_lstchg == -1) ? "" : String::formatted("{}", p->sp_lstchg),
|
||||
(p->sp_min == -1) ? "" : String::formatted("{}", p->sp_min),
|
||||
(p->sp_max == -1) ? "" : String::formatted("{}", p->sp_max),
|
||||
(p->sp_warn == -1) ? "" : String::formatted("{}", p->sp_warn),
|
||||
(p->sp_inact == -1) ? "" : String::formatted("{}", p->sp_inact),
|
||||
(p->sp_expire == -1) ? "" : String::formatted("{}", p->sp_expire),
|
||||
(p->sp_flag == 0) ? "" : String::formatted("{}", p->sp_flag));
|
||||
}
|
||||
}
|
||||
endspent();
|
||||
|
|
Loading…
Reference in a new issue