diff --git a/Userland/passwd.cpp b/Userland/passwd.cpp index 3ec586adc05..cfb2e7e57a0 100644 --- a/Userland/passwd.cpp +++ b/Userland/passwd.cpp @@ -35,7 +35,7 @@ int main(int argc, char** argv) { if (geteuid() != 0) { - fprintf(stderr, "Not running as root :^(\n"); + warnln("Not running as root :^("); return 1; } @@ -82,7 +82,7 @@ int main(int argc, char** argv) : Core::Account::from_uid(current_uid, Core::Account::OpenPasswdFile::ReadWrite, Core::Account::OpenShadowFile::ReadWrite); if (account_or_error.is_error()) { - fprintf(stderr, "Core::Account::%s: %s\n", (username) ? "from_name" : "from_uid", account_or_error.error().characters()); + warnln("Core::Account::{}: {}", (username) ? "from_name" : "from_uid", account_or_error.error()); return 1; } @@ -111,7 +111,7 @@ int main(int argc, char** argv) auto& target_account = account_or_error.value(); if (current_uid != 0 && current_uid != target_account.uid()) { - fprintf(stderr, "You can't modify passwd for %s\n", username); + warnln("You can't modify passwd for {}", username); return 1; } @@ -124,7 +124,7 @@ int main(int argc, char** argv) } else { auto new_password = Core::get_password("New password: "); if (new_password.is_error()) { - fprintf(stderr, "%s\n", strerror(new_password.error())); + warnln("{}", strerror(new_password.error())); return 1; } diff --git a/Userland/su.cpp b/Userland/su.cpp index 070070bf040..d74e9a38e8a 100644 --- a/Userland/su.cpp +++ b/Userland/su.cpp @@ -52,8 +52,10 @@ int main(int argc, char** argv) args_parser.add_positional_argument(user, "User to switch to (defaults to user with UID 0)", "user", Core::ArgsParser::Required::No); args_parser.parse(argc, argv); - if (geteuid() != 0) - fprintf(stderr, "Not running as root :(\n"); + if (geteuid() != 0) { + warnln("Not running as root :("); + return 1; + } auto account_or_error = (user) ? Core::Account::from_name(user, Core::Account::OpenPasswdFile::No, Core::Account::OpenShadowFile::ReadOnly) @@ -73,12 +75,12 @@ int main(int argc, char** argv) if (getuid() != 0 && account.has_password()) { auto password = Core::get_password(); if (password.is_error()) { - fprintf(stderr, "%s\n", strerror(password.error())); + warnln("{}", strerror(password.error())); return 1; } if (!account.authenticate(password.value().characters())) { - fprintf(stderr, "Incorrect or disabled password.\n"); + warnln("Incorrect or disabled password."); return 1; } }