summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-06-16 22:16:09 +0300
committerAndreas Kling <kling@serenityos.org>2020-06-17 15:02:03 +0200
commitedef6ccff532714967682dc87f144f7300339772 (patch)
treebccc67d103ab061f1a00def0fd218e6e95c04eca
parent8ecac16c0372b337b59f150dc39f1a240bec0ee4 (diff)
downloadserenity-edef6ccff532714967682dc87f144f7300339772.zip
Userland: Compliment the user when running su(1) :^)
-rw-r--r--Userland/su.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Userland/su.cpp b/Userland/su.cpp
index 7529af6efe..2c59b8751e 100644
--- a/Userland/su.cpp
+++ b/Userland/su.cpp
@@ -36,6 +36,13 @@ extern "C" int main(int, char**);
int main(int argc, char** argv)
{
+ if (geteuid() != 0) {
+ fprintf(stderr, "Not running as root :(\n");
+ } else if (getuid() != 0) {
+ const char* target_user = argc > 1 ? argv[1] : "root";
+ fprintf(stderr, "Since you're such a good boy, %s, here's a %s shell for you\n", getlogin(), target_user);
+ }
+
uid_t uid = 0;
gid_t gid = 0;
struct passwd* pwd = nullptr;