summaryrefslogtreecommitdiff
path: root/Userland/su.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/su.cpp')
-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;