From 8175d754321ee1b5c017b4b48c739fb21e9c7b97 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 10 Mar 2019 03:15:36 +0100 Subject: [PATCH] LibC: Implement getlogin(). --- LibC/unistd.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp index e5e2e90fbe..fe9ade86b8 100644 --- a/LibC/unistd.cpp +++ b/LibC/unistd.cpp @@ -397,7 +397,12 @@ int seal_shared_buffer(int shared_buffer_id) char* getlogin() { - assert(false); + static char __getlogin_buffer[256]; + if (auto* passwd = getpwuid(getuid())) { + strncpy(__getlogin_buffer, passwd->pw_name, sizeof(__getlogin_buffer)); + return __getlogin_buffer; + } + return nullptr; } }