2021-11-26 06:41:56 +03:00
|
|
|
/**
|
|
|
|
* @brief uses getpwuid and geteuid to retrieve the current user's name.
|
|
|
|
*
|
|
|
|
* @copyright
|
2018-06-04 05:29:28 +03:00
|
|
|
* This file is part of ToaruOS and is released under the terms
|
|
|
|
* of the NCSA / University of Illinois License - see LICENSE.md
|
2021-11-26 06:41:56 +03:00
|
|
|
* Copyright (C) 2013-2021 K. Lange
|
2018-06-04 05:29:28 +03:00
|
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
|
|
|
|
int main(int argc, char ** argv) {
|
2018-10-31 04:28:41 +03:00
|
|
|
struct passwd * p = getpwuid(geteuid());
|
2018-06-04 05:29:28 +03:00
|
|
|
if (!p) return 0;
|
|
|
|
|
|
|
|
fprintf(stdout, "%s\n", p->pw_name);
|
|
|
|
|
|
|
|
endpwent();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|