2015-12-14 09:55:25 +00:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
static void
|
2015-12-14 11:58:23 +00:00
|
|
|
usage(void)
|
2015-12-14 09:55:25 +00:00
|
|
|
{
|
|
|
|
eprintf("usage: %s\n", argv0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2015-12-14 11:58:23 +00:00
|
|
|
main(int argc, char *argv[])
|
2015-12-14 09:55:25 +00:00
|
|
|
{
|
|
|
|
uid_t uid;
|
|
|
|
struct passwd *pw;
|
|
|
|
|
2017-08-05 21:50:39 +00:00
|
|
|
argv0 = *argv, argv0 ? (argc--, argv++) : (void *)0;
|
2015-12-14 09:55:25 +00:00
|
|
|
|
|
|
|
if (argc)
|
|
|
|
usage();
|
|
|
|
|
|
|
|
uid = geteuid();
|
|
|
|
errno = 0;
|
|
|
|
if (!(pw = getpwuid(uid))) {
|
|
|
|
if (errno)
|
|
|
|
eprintf("getpwuid %d:", uid);
|
|
|
|
else
|
|
|
|
eprintf("getpwuid %d: no such user\n", uid);
|
|
|
|
}
|
|
|
|
puts(pw->pw_name);
|
|
|
|
|
|
|
|
return fshut(stdout, "<stdout>");
|
|
|
|
}
|