8cf031
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
8cf031
--- a/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c
8cf031
+++ b/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c
8cf031
@@ -158,11 +158,12 @@ parse_authorized_key_file(const char *user,
ea9421
 int
ea9421
 pam_user_key_allowed(const char *ruser, Key * key)
ea9421
 {
8cf031
+    struct passwd *pw;
8cf031
     return
ea9421
-        pamsshagentauth_user_key_allowed2(getpwuid(authorized_keys_file_allowed_owner_uid),
ea9421
-                                          key, authorized_keys_file)
ea9421
-        || pamsshagentauth_user_key_allowed2(getpwuid(0), key,
ea9421
-                                             authorized_keys_file)
8cf031
+        ( (pw = getpwuid(authorized_keys_file_allowed_owner_uid)) &&
8cf031
+            pamsshagentauth_user_key_allowed2(pw, key, authorized_keys_file))
8cf031
+        || ((pw = getpwuid(0)) &&
8cf031
+            pamsshagentauth_user_key_allowed2(pw, key, authorized_keys_file))
ea9421
         || pamsshagentauth_user_key_command_allowed2(authorized_keys_command,
ea9421
                                                      authorized_keys_command_user,
ea9421
                                                      getpwnam(ruser), key);