MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_unix_pw

Function get_unix_pw

sys/unix/unixmain.c:731–760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729}
730
731static struct passwd *
732get_unix_pw(void)
733{
734 char *user;
735 unsigned uid;
736 static struct passwd *pw = (struct passwd *) 0;
737
738 if (pw)
739 return pw; /* cache answer */
740
741 uid = (unsigned) getuid();
742 user = getlogin();
743 if (user) {
744 pw = getpwnam(user);
745 if (pw && ((unsigned) pw->pw_uid != uid))
746 pw = 0;
747 }
748 if (pw == 0) {
749 user = nh_getenv("USER");
750 if (user) {
751 pw = getpwnam(user);
752 if (pw && ((unsigned) pw->pw_uid != uid))
753 pw = 0;
754 }
755 if (pw == 0) {
756 pw = getpwuid(uid);
757 }
758 }
759 return pw;
760}
761
762char *
763get_login_name(void)

Callers 2

check_user_stringFunction · 0.70
get_login_nameFunction · 0.70

Calls 3

getuidFunction · 0.85
getloginFunction · 0.85
nh_getenvFunction · 0.50

Tested by

no test coverage detected