mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +00:00
su: Only check for an interactive tty if a password is actually needed
This commit is contained in:
parent
a8a5707467
commit
3c04d22e38
1 changed files with 3 additions and 3 deletions
|
@ -16,9 +16,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
TRY(Core::System::pledge("stdio rpath tty exec id"));
|
TRY(Core::System::pledge("stdio rpath tty exec id"));
|
||||||
|
|
||||||
if (!TRY(Core::System::isatty(STDIN_FILENO)))
|
|
||||||
return Error::from_string_literal("Standard input is not a terminal");
|
|
||||||
|
|
||||||
StringView first_positional;
|
StringView first_positional;
|
||||||
StringView second_positional;
|
StringView second_positional;
|
||||||
DeprecatedString command;
|
DeprecatedString command;
|
||||||
|
@ -46,6 +43,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(Core::System::pledge("stdio rpath tty exec id"));
|
TRY(Core::System::pledge("stdio rpath tty exec id"));
|
||||||
|
|
||||||
if (getuid() != 0 && account.has_password()) {
|
if (getuid() != 0 && account.has_password()) {
|
||||||
|
if (!TRY(Core::System::isatty(STDIN_FILENO)))
|
||||||
|
return Error::from_string_literal("Standard input is not a terminal");
|
||||||
|
|
||||||
auto password = TRY(Core::get_password());
|
auto password = TRY(Core::get_password());
|
||||||
if (!account.authenticate(password))
|
if (!account.authenticate(password))
|
||||||
return Error::from_string_literal("Incorrect or disabled password.");
|
return Error::from_string_literal("Incorrect or disabled password.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue