8cf031f
diff --git a/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c b/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c
8cf031f
--- a/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c
8cf031f
+++ b/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c
8cf031f
@@ -158,11 +158,12 @@ parse_authorized_key_file(const char *user,
ea94213
 int
bbf61da
 pam_user_key_allowed(const char *ruser, struct sshkey * key)
ea94213
 {
8cf031f
+    struct passwd *pw;
8cf031f
     return
ea94213
-        pamsshagentauth_user_key_allowed2(getpwuid(authorized_keys_file_allowed_owner_uid),
ea94213
-                                          key, authorized_keys_file)
ea94213
-        || pamsshagentauth_user_key_allowed2(getpwuid(0), key,
ea94213
-                                             authorized_keys_file)
8cf031f
+        ( (pw = getpwuid(authorized_keys_file_allowed_owner_uid)) &&
8cf031f
+            pamsshagentauth_user_key_allowed2(pw, key, authorized_keys_file))
8cf031f
+        || ((pw = getpwuid(0)) &&
8cf031f
+            pamsshagentauth_user_key_allowed2(pw, key, authorized_keys_file))
ea94213
         || pamsshagentauth_user_key_command_allowed2(authorized_keys_command,
ea94213
                                                      authorized_keys_command_user,
ea94213
                                                      getpwnam(ruser), key);