mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:17:35 +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
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…
Add table
Add a link
Reference in a new issue