X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/96f3a8a54eeb3b2294ed953dad8b15349f3e2703..82eb6e3832dea63be4c22ac4415c3190add43f0b:/components/user.c?ds=sidebyside diff --git a/components/user.c b/components/user.c index ffbd945..8ab6db9 100644 --- a/components/user.c +++ b/components/user.c @@ -1,6 +1,8 @@ /* See LICENSE file for copyright and license details. */ +#include #include #include +#include #include #include @@ -15,10 +17,10 @@ gid(void) const char * username(void) { - struct passwd *pw = getpwuid(geteuid()); + struct passwd *pw; - if (pw == NULL) { - fprintf(stderr, "Failed to get username"); + if (!(pw = getpwuid(geteuid()))) { + fprintf(stderr, "getpwuid '%d': %s\n", geteuid(), strerror(errno)); return NULL; }