#include <stdio.h>
#include <stdlib.h>
#include <pwd.h>
+#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
}
}
-char* whoami(void) {
- uid_t uid = geteuid();
- struct passwd *pw = getpwuid(uid);
- if (pw) {
- return pw->pw_name;
- } else {
- errx(EXIT_FAILURE, "Username not known!\n");
- }
-}
-
int main(int argc, char *argv[]) {
- char *username = whoami();
+ char *username = getpwuid(getuid())->pw_name;
char *image_path = NULL;
int ret;
struct pam_conv conv = {conv_callback, NULL};
{NULL, no_argument, NULL, 0}
};
+ if (username == NULL)
+ err(EXIT_FAILURE, "getpwuid() failed");
+
char *optstring = "hvnbdc:p:ui:teI:f";
while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) {
switch (o) {