bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/get_command_line.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/get_command_line.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/get_command_line.c.psaa-compat	2016-11-13 04:24:32.000000000 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/get_command_line.c	2017-02-07 14:41:20.483509205 +0100
bdb932
@@ -65,8 +65,8 @@ proc_pid_cmdline(char *** inargv)
bdb932
                 case EOF:
bdb932
                 case '\0':
bdb932
                     if (len > 0) { 
bdb932
-                        argv = pamsshagentauth_xrealloc(argv, count + 1, sizeof(*argv));
bdb932
-                        argv[count] = pamsshagentauth_xcalloc(len + 1, sizeof(*argv[count]));
bdb932
+                        argv = xreallocarray(argv, count + 1, sizeof(*argv));
bdb932
+                        argv[count] = xcalloc(len + 1, sizeof(*argv[count]));
bdb932
                         strncpy(argv[count++], argbuf, len);
bdb932
                         memset(argbuf, '\0', MAX_LEN_PER_CMDLINE_ARG + 1);
bdb932
                         len = 0;
bdb932
@@ -105,9 +105,9 @@ pamsshagentauth_free_command_line(char *
bdb932
 {
bdb932
     size_t i;
bdb932
     for (i = 0; i < n_args; i++)
bdb932
-        pamsshagentauth_xfree(argv[i]);
bdb932
+        free(argv[i]);
bdb932
 
bdb932
-    pamsshagentauth_xfree(argv);
bdb932
+    free(argv);
bdb932
     return;
bdb932
 }
bdb932
 
bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c.psaa-compat	2017-02-07 14:41:20.479509208 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/iterate_ssh_agent_keys.c	2017-02-07 14:41:20.481509206 +0100
bdb932
@@ -58,6 +58,8 @@
87ab5f
 #include "get_command_line.h"
87ab5f
 extern char **environ;
87ab5f
 
87ab5f
+#define PAM_SSH_AGENT_AUTH_REQUESTv1 101
87ab5f
+
87ab5f
 /* 
87ab5f
  * Added by Jamie Beverly, ensure socket fd points to a socket owned by the user 
87ab5f
  * A cursory check is done, but to avoid race conditions, it is necessary 
bdb932
@@ -77,7 +79,7 @@ log_action(char ** action, size_t count)
87ab5f
     if (count == 0)
87ab5f
         return NULL;
87ab5f
    
87ab5f
-    buf = pamsshagentauth_xcalloc((count * MAX_LEN_PER_CMDLINE_ARG) + (count * 3), sizeof(*buf));
87ab5f
+    buf = xcalloc((count * MAX_LEN_PER_CMDLINE_ARG) + (count * 3), sizeof(*buf));
87ab5f
     for (i = 0; i < count; i++) {
87ab5f
         strcat(buf, (i > 0) ? " '" : "'");
87ab5f
         strncat(buf, action[i], MAX_LEN_PER_CMDLINE_ARG);
bdb932
@@ -90,12 +92,12 @@ void
87ab5f
 agent_action(Buffer *buf, char ** action, size_t count)
87ab5f
 {
87ab5f
     size_t i;
87ab5f
-    pamsshagentauth_buffer_init(buf);
87ab5f
+    buffer_init(buf);
87ab5f
 
87ab5f
-    pamsshagentauth_buffer_put_int(buf, count);
87ab5f
+    buffer_put_int(buf, count);
87ab5f
 
87ab5f
     for (i = 0; i < count; i++) {
87ab5f
-        pamsshagentauth_buffer_put_cstring(buf, action[i]);
87ab5f
+        buffer_put_cstring(buf, action[i]);
87ab5f
     }
87ab5f
 }
87ab5f
 
bdb932
@@ -119,17 +121,17 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5f
     char * retc;
87ab5f
     int32_t reti;
87ab5f
 
87ab5f
-    rnd = pamsshagentauth_arc4random();
87ab5f
+    rnd = arc4random();
87ab5f
     cookie_len = ((uint8_t) rnd);
87ab5f
     while (cookie_len < 16) { 
87ab5f
         cookie_len += 16;                                          /* Add 16 bytes to the size to ensure that while the length is random, the length is always reasonable; ticket #18 */
87ab5f
     }
87ab5f
 
87ab5f
-    cookie = pamsshagentauth_xcalloc(1,cookie_len);
87ab5f
+    cookie = xcalloc(1,cookie_len);
87ab5f
 
87ab5f
     for (i = 0; i < cookie_len; i++) {
87ab5f
         if (i % 4 == 0) {
87ab5f
-            rnd = pamsshagentauth_arc4random();
87ab5f
+            rnd = arc4random();
87ab5f
         }
87ab5f
         cookie[i] = (u_char) rnd;
87ab5f
         rnd >>= 8;
bdb932
@@ -144,7 +146,7 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5f
     }
87ab5f
     else {
87ab5f
         action_logbuf = "unknown on this platform";
87ab5f
-        pamsshagentauth_buffer_init(&action_agentbuf); /* stays empty, means unavailable */
87ab5f
+        buffer_init(&action_agentbuf); /* stays empty, means unavailable */
87ab5f
     }
87ab5f
     
87ab5f
     /*
bdb932
@@ -161,35 +163,35 @@ pamsshagentauth_session_id2_gen(Buffer *
87ab5f
     retc = getcwd(pwd, sizeof(pwd) - 1);
87ab5f
     time(&ts);
87ab5f
 
87ab5f
-    pamsshagentauth_buffer_init(session_id2);
87ab5f
+    buffer_init(session_id2);
87ab5f
 
87ab5f
-    pamsshagentauth_buffer_put_int(session_id2, PAM_SSH_AGENT_AUTH_REQUESTv1);
87ab5f
-    /* pamsshagentauth_debug3("cookie: %s", pamsshagentauth_tohex(cookie, cookie_len)); */
87ab5f
-    pamsshagentauth_buffer_put_string(session_id2, cookie, cookie_len);
87ab5f
-    /* pamsshagentauth_debug3("user: %s", user); */
87ab5f
-    pamsshagentauth_buffer_put_cstring(session_id2, user);
87ab5f
-    /* pamsshagentauth_debug3("ruser: %s", ruser); */
87ab5f
-    pamsshagentauth_buffer_put_cstring(session_id2, ruser);
87ab5f
-    /* pamsshagentauth_debug3("servicename: %s", servicename); */
87ab5f
-    pamsshagentauth_buffer_put_cstring(session_id2, servicename);
87ab5f
-    /* pamsshagentauth_debug3("pwd: %s", pwd); */
87ab5f
+    buffer_put_int(session_id2, PAM_SSH_AGENT_AUTH_REQUESTv1);
87ab5f
+    /* debug3("cookie: %s", tohex(cookie, cookie_len)); */
87ab5f
+    buffer_put_string(session_id2, cookie, cookie_len);
87ab5f
+    /* debug3("user: %s", user); */
87ab5f
+    buffer_put_cstring(session_id2, user);
87ab5f
+    /* debug3("ruser: %s", ruser); */
87ab5f
+    buffer_put_cstring(session_id2, ruser);
87ab5f
+    /* debug3("servicename: %s", servicename); */
87ab5f
+    buffer_put_cstring(session_id2, servicename);
87ab5f
+    /* debug3("pwd: %s", pwd); */
87ab5f
     if(retc)
87ab5f
-        pamsshagentauth_buffer_put_cstring(session_id2, pwd);
87ab5f
+        buffer_put_cstring(session_id2, pwd);
87ab5f
     else
87ab5f
-        pamsshagentauth_buffer_put_cstring(session_id2, "");
87ab5f
-    /* pamsshagentauth_debug3("action: %s", action_logbuf); */
87ab5f
-    pamsshagentauth_buffer_put_string(session_id2, action_agentbuf.buf + action_agentbuf.offset, action_agentbuf.end - action_agentbuf.offset);
87ab5f
+        buffer_put_cstring(session_id2, "");
87ab5f
+    /* debug3("action: %s", action_logbuf); */
87ab5f
+    buffer_put_string(session_id2, sshbuf_ptr(&action_agentbuf), sshbuf_len(&action_agentbuf));
87ab5f
     if (free_logbuf) { 
87ab5f
-        pamsshagentauth_xfree(action_logbuf);
87ab5f
-        pamsshagentauth_buffer_free(&action_agentbuf);
87ab5f
+        free(action_logbuf);
87ab5f
+        buffer_free(&action_agentbuf);
87ab5f
     }
87ab5f
-    /* pamsshagentauth_debug3("hostname: %s", hostname); */
87ab5f
+    /* debug3("hostname: %s", hostname); */
87ab5f
     if(reti >= 0)
87ab5f
-        pamsshagentauth_buffer_put_cstring(session_id2, hostname);
87ab5f
+        buffer_put_cstring(session_id2, hostname);
87ab5f
     else
87ab5f
-        pamsshagentauth_buffer_put_cstring(session_id2, "");
87ab5f
-    /* pamsshagentauth_debug3("ts: %ld", ts); */
87ab5f
-    pamsshagentauth_buffer_put_int64(session_id2, (uint64_t) ts);
87ab5f
+        buffer_put_cstring(session_id2, "");
87ab5f
+    /* debug3("ts: %ld", ts); */
87ab5f
+    buffer_put_int64(session_id2, (uint64_t) ts);
87ab5f
 
87ab5f
     free(cookie);
87ab5f
     return;
bdb932
@@ -295,29 +297,29 @@ pamsshagentauth_find_authorized_keys(con
87ab5f
     pamsshagentauth_session_id2_gen(&session_id2, user, ruser, servicename);
87ab5f
 
87ab5f
     if ((ac = ssh_get_authentication_connection_for_uid(uid))) {
87ab5f
-        pamsshagentauth_verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
87ab5f
+        verbose("Contacted ssh-agent of user %s (%u)", ruser, uid);
87ab5f
         for (key = ssh_get_first_identity(ac, &comment, 2); key != NULL; key = ssh_get_next_identity(ac, &comment, 2)) 
87ab5f
         {
87ab5f
             if(key != NULL) {
87ab5f
-                id = pamsshagentauth_xcalloc(1, sizeof(*id));
87ab5f
+                id = xcalloc(1, sizeof(*id));
87ab5f
                 id->key = key;
87ab5f
                 id->filename = comment;
87ab5f
                 id->ac = ac;
87ab5f
                 if(userauth_pubkey_from_id(ruser, id, &session_id2)) {
87ab5f
                     retval = 1;
87ab5f
                 }
87ab5f
-                pamsshagentauth_xfree(id->filename);
87ab5f
-                pamsshagentauth_key_free(id->key);
87ab5f
-                pamsshagentauth_xfree(id);
87ab5f
+                free(id->filename);
87ab5f
+                key_free(id->key);
87ab5f
+                free(id);
87ab5f
                 if(retval == 1)
87ab5f
                     break;
87ab5f
             }
87ab5f
         }
87ab5f
-        pamsshagentauth_buffer_free(&session_id2);
87ab5f
+        buffer_free(&session_id2);
87ab5f
         ssh_close_authentication_connection(ac);
87ab5f
     }
87ab5f
     else {
87ab5f
-        pamsshagentauth_verbose("No ssh-agent could be contacted");
87ab5f
+        verbose("No ssh-agent could be contacted");
87ab5f
     }
87ab5f
     /* pamsshagentauth_xfree(session_id2); */
87ab5f
     EVP_cleanup();
bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_ssh_agent_auth.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_ssh_agent_auth.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_ssh_agent_auth.c.psaa-compat	2017-02-07 14:41:20.480509207 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_ssh_agent_auth.c	2017-02-07 14:44:20.549369019 +0100
87ab5f
@@ -104,7 +104,7 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5f
  * a patch 8-)
87ab5f
  */
87ab5f
 #if ! HAVE___PROGNAME || HAVE_BUNDLE
87ab5f
-    __progname = pamsshagentauth_xstrdup(servicename);
87ab5f
+    __progname = xstrdup(servicename);
87ab5f
 #endif
87ab5f
 
87ab5f
     for(i = argc, argv_ptr = (char **) argv; i > 0; ++argv_ptr, i--) {
87ab5f
@@ -130,11 +130,11 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5f
 #endif
87ab5f
     }
87ab5f
 
bdb932
-    pamsshagentauth_log_init(__progname, log_lvl, facility, getenv("PAM_SSH_AGENT_AUTH_DEBUG") ? 1 : 0);
bdb932
+    log_init(__progname, log_lvl, facility, getenv("PAM_SSH_AGENT_AUTH_DEBUG") ? 1 : 0);
87ab5f
     pam_get_item(pamh, PAM_USER, (void *) &user);
87ab5f
     pam_get_item(pamh, PAM_RUSER, (void *) &ruser_ptr);
87ab5f
 
87ab5f
-    pamsshagentauth_verbose("Beginning pam_ssh_agent_auth for user %s", user);
87ab5f
+    verbose("Beginning pam_ssh_agent_auth for user %s", user);
87ab5f
 
87ab5f
     if(ruser_ptr) {
87ab5f
         strncpy(ruser, ruser_ptr, sizeof(ruser) - 1);
87ab5f
@@ -149,12 +149,12 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5f
 #ifdef ENABLE_SUDO_HACK
87ab5f
         if( (strlen(sudo_service_name) > 0) && strncasecmp(servicename, sudo_service_name, sizeof(sudo_service_name) - 1) == 0 && getenv("SUDO_USER") ) {
87ab5f
             strncpy(ruser, getenv("SUDO_USER"), sizeof(ruser) - 1 );
87ab5f
-            pamsshagentauth_verbose( "Using environment variable SUDO_USER (%s)", ruser );
87ab5f
+            verbose( "Using environment variable SUDO_USER (%s)", ruser );
bdb932
         } else
87ab5f
 #endif
87ab5f
         {
87ab5f
             if( ! getpwuid(getuid()) ) {
87ab5f
-                pamsshagentauth_verbose("Unable to getpwuid(getuid())");
87ab5f
+                verbose("Unable to getpwuid(getuid())");
87ab5f
                 goto cleanexit;
87ab5f
             }
87ab5f
             strncpy(ruser, getpwuid(getuid())->pw_name, sizeof(ruser) - 1);
87ab5f
@@ -163,11 +163,11 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5f
 
87ab5f
     /* Might as well explicitely confirm the user exists here */
87ab5f
     if(! getpwnam(ruser) ) {
87ab5f
-        pamsshagentauth_verbose("getpwnam(%s) failed, bailing out", ruser);
87ab5f
+        verbose("getpwnam(%s) failed, bailing out", ruser);
87ab5f
         goto cleanexit;
87ab5f
     }
87ab5f
     if( ! getpwnam(user) ) {
87ab5f
-        pamsshagentauth_verbose("getpwnam(%s) failed, bailing out", user);
87ab5f
+        verbose("getpwnam(%s) failed, bailing out", user);
87ab5f
         goto cleanexit;
87ab5f
     }
87ab5f
 
87ab5f
@@ -177,8 +177,8 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5f
          */
87ab5f
         parse_authorized_key_file(user, authorized_keys_file_input);
87ab5f
     } else {
87ab5f
-        pamsshagentauth_verbose("Using default file=/etc/security/authorized_keys");
87ab5f
-        authorized_keys_file = pamsshagentauth_xstrdup("/etc/security/authorized_keys");
87ab5f
+        verbose("Using default file=/etc/security/authorized_keys");
87ab5f
+        authorized_keys_file = xstrdup("/etc/security/authorized_keys");
87ab5f
     }
87ab5f
 
bdb932
     /*
87ab5f
@@ -187,19 +187,19 @@ pam_sm_authenticate(pam_handle_t * pamh,
87ab5f
      */
87ab5f
 
87ab5f
     if(user && strlen(ruser) > 0) {
87ab5f
-        pamsshagentauth_verbose("Attempting authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5f
+        verbose("Attempting authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5f
 
bdb932
         /*
87ab5f
          * this pw_uid is used to validate the SSH_AUTH_SOCK, and so must be the uid of the ruser invoking the program, not the target-user
87ab5f
          */
87ab5f
         if(pamsshagentauth_find_authorized_keys(user, ruser, servicename)) { /* getpwnam(ruser)->pw_uid)) { */
87ab5f
-            pamsshagentauth_logit("Authenticated: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5f
+            logit("Authenticated: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5f
             retval = PAM_SUCCESS;
87ab5f
         } else {
87ab5f
-            pamsshagentauth_logit("Failed Authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5f
+            logit("Failed Authentication: `%s' as `%s' using %s", ruser, user, authorized_keys_file);
87ab5f
         }
87ab5f
     } else {
87ab5f
-        pamsshagentauth_logit("No %s specified, cannot continue with this form of authentication", (user) ? "ruser" : "user" );
87ab5f
+        logit("No %s specified, cannot continue with this form of authentication", (user) ? "ruser" : "user" );
87ab5f
     }
87ab5f
 
87ab5f
 cleanexit:
bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_authorized_keys.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_authorized_keys.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_authorized_keys.c.psaa-compat	2016-11-13 04:24:32.000000000 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_authorized_keys.c	2017-02-07 14:41:20.484509204 +0100
bdb932
@@ -117,12 +117,12 @@ parse_authorized_key_file(const char *us
bdb932
         } else {
bdb932
             slash_ptr = strchr(auth_keys_file_buf, '/');
bdb932
             if(!slash_ptr)
bdb932
-                pamsshagentauth_fatal
bdb932
+                fatal
bdb932
                     ("cannot expand tilde in path without a `/'");
87ab5f
 
bdb932
             owner_uname_len = slash_ptr - auth_keys_file_buf - 1;
bdb932
             if(owner_uname_len > (sizeof(owner_uname) - 1))
bdb932
-                pamsshagentauth_fatal("Username too long");
bdb932
+                fatal("Username too long");
87ab5f
 
bdb932
             strncat(owner_uname, auth_keys_file_buf + 1, owner_uname_len);
bdb932
             if(!authorized_keys_file_allowed_owner_uid)
bdb932
@@ -130,11 +130,11 @@ parse_authorized_key_file(const char *us
bdb932
                     getpwnam(owner_uname)->pw_uid;
bdb932
         }
bdb932
         authorized_keys_file =
bdb932
-            pamsshagentauth_tilde_expand_filename(auth_keys_file_buf,
bdb932
+            tilde_expand_filename(auth_keys_file_buf,
bdb932
                                                   authorized_keys_file_allowed_owner_uid);
bdb932
         strncpy(auth_keys_file_buf, authorized_keys_file,
bdb932
                 sizeof(auth_keys_file_buf) - 1);
bdb932
-        pamsshagentauth_xfree(authorized_keys_file)        /* when we
bdb932
+        free(authorized_keys_file)        /* when we
bdb932
                                                               percent_expand
bdb932
                                                               later, we'd step
bdb932
                                                               on this, so free
bdb932
@@ -150,7 +150,7 @@ parse_authorized_key_file(const char *us
bdb932
     strncat(hostname, fqdn, strcspn(fqdn, "."));
bdb932
 #endif
bdb932
     authorized_keys_file =
bdb932
-        pamsshagentauth_percent_expand(auth_keys_file_buf, "h",
bdb932
+        percent_expand(auth_keys_file_buf, "h",
bdb932
                                        getpwnam(user)->pw_dir, "H", hostname,
bdb932
                                        "f", fqdn, "u", user, NULL);
87ab5f
 }
bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c.psaa-compat	2016-11-13 04:24:32.000000000 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/pam_user_key_allowed2.c	2017-02-07 14:41:20.484509204 +0100
bdb932
@@ -48,11 +48,13 @@
87ab5f
 #include "buffer.h"
87ab5f
 #include "log.h"
87ab5f
 #include "compat.h"
87ab5f
+#include "digest.h"
87ab5f
 #include "key.h"
87ab5f
 #include "pathnames.h"
87ab5f
 #include "misc.h"
87ab5f
 #include "secure_filename.h"
87ab5f
 #include "uidswap.h"
87ab5f
+#include <unistd.h>
87ab5f
 
87ab5f
 #include "identity.h"
87ab5f
 
bdb932
@@ -68,7 +70,7 @@ pamsshagentauth_check_authkeys_file(FILE
87ab5f
     char *fp;
87ab5f
 
87ab5f
     found_key = 0;
87ab5f
-    found = pamsshagentauth_key_new(key->type);
87ab5f
+    found = key_new(key->type);
87ab5f
 
87ab5f
     while(read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
87ab5f
         char *cp = NULL; /* *key_options = NULL; */
bdb932
@@ -78,11 +80,11 @@ pamsshagentauth_check_authkeys_file(FILE
87ab5f
         if(!*cp || *cp == '\n' || *cp == '#')
87ab5f
             continue;
87ab5f
 
87ab5f
-        if(pamsshagentauth_key_read(found, &cp) != 1) {
87ab5f
+        if(key_read(found, &cp) != 1) {
87ab5f
             /* no key? check if there are options for this key */
87ab5f
             int quoted = 0;
87ab5f
 
87ab5f
-            pamsshagentauth_verbose("user_key_allowed: check options: '%s'", cp);
87ab5f
+            verbose("user_key_allowed: check options: '%s'", cp);
87ab5f
             /* key_options = cp; */
87ab5f
             for(; *cp && (quoted || (*cp != ' ' && *cp != '\t')); cp++) {
87ab5f
                 if(*cp == '\\' && cp[1] == '"')
bdb932
@@ -92,26 +94,26 @@ pamsshagentauth_check_authkeys_file(FILE
87ab5f
             }
87ab5f
             /* Skip remaining whitespace. */
87ab5f
             for(; *cp == ' ' || *cp == '\t'; cp++);
87ab5f
-            if(pamsshagentauth_key_read(found, &cp) != 1) {
87ab5f
-                pamsshagentauth_verbose("user_key_allowed: advance: '%s'", cp);
87ab5f
+            if(key_read(found, &cp) != 1) {
87ab5f
+                verbose("user_key_allowed: advance: '%s'", cp);
87ab5f
                 /* still no key? advance to next line */
87ab5f
                 continue;
87ab5f
             }
87ab5f
         }
87ab5f
-        if(pamsshagentauth_key_equal(found, key)) {
87ab5f
+        if(key_equal(found, key)) {
87ab5f
             found_key = 1;
87ab5f
-            pamsshagentauth_logit("matching key found: file/command %s, line %lu", file,
87ab5f
+            logit("matching key found: file/command %s, line %lu", file,
87ab5f
                                   linenum);
87ab5f
-            fp = pamsshagentauth_key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX);
87ab5f
-            pamsshagentauth_logit("Found matching %s key: %s",
87ab5f
-                                  pamsshagentauth_key_type(found), fp);
87ab5f
-            pamsshagentauth_xfree(fp);
87ab5f
+            fp = sshkey_fingerprint(found, SSH_DIGEST_MD5, SSH_FP_HEX);
87ab5f
+            logit("Found matching %s key: %s",
87ab5f
+                                  key_type(found), fp);
87ab5f
+            free(fp);
87ab5f
             break;
87ab5f
         }
87ab5f
     }
87ab5f
-    pamsshagentauth_key_free(found);
87ab5f
+    key_free(found);
87ab5f
     if(!found_key)
87ab5f
-        pamsshagentauth_verbose("key not found");
87ab5f
+        verbose("key not found");
87ab5f
     return found_key;
87ab5f
 }
87ab5f
 
bdb932
@@ -128,11 +130,11 @@ pamsshagentauth_user_key_allowed2(struct
87ab5f
     char buf[SSH_MAX_PUBKEY_BYTES];
87ab5f
 
87ab5f
     /* Temporarily use the user's uid. */
87ab5f
-    pamsshagentauth_verbose("trying public key file %s", file);
87ab5f
+    verbose("trying public key file %s", file);
87ab5f
 
87ab5f
     /* Fail not so quietly if file does not exist */
87ab5f
     if(stat(file, &st) < 0) {
87ab5f
-        pamsshagentauth_verbose("File not found: %s", file);
87ab5f
+        verbose("File not found: %s", file);
87ab5f
         return 0;
87ab5f
     }
87ab5f
 
bdb932
@@ -144,7 +146,7 @@ pamsshagentauth_user_key_allowed2(struct
87ab5f
 
87ab5f
     if(pamsshagentauth_secure_filename(f, file, pw, buf, sizeof(buf)) != 0) {
87ab5f
         fclose(f);
87ab5f
-        pamsshagentauth_logit("Authentication refused: %s", buf);
87ab5f
+        logit("Authentication refused: %s", buf);
87ab5f
         return 0;
87ab5f
     }
87ab5f
 
bdb932
@@ -187,44 +189,44 @@ pamsshagentauth_user_key_command_allowed
87ab5f
     else {
87ab5f
         pw = getpwnam(authorized_keys_command_user);
87ab5f
         if(pw == NULL) {
87ab5f
-            pamsshagentauth_logerror("authorized_keys_command_user \"%s\" not found: %s",
87ab5f
+            error("authorized_keys_command_user \"%s\" not found: %s",
87ab5f
                  authorized_keys_command_user, strerror(errno));
87ab5f
             return 0;
87ab5f
         }
87ab5f
     }
87ab5f
 
87ab5f
-    pamsshagentauth_temporarily_use_uid(pw);
87ab5f
+    temporarily_use_uid(pw);
87ab5f
 
87ab5f
     if(stat(authorized_keys_command, &st) < 0) {
87ab5f
-        pamsshagentauth_logerror
87ab5f
+        error
87ab5f
             ("Could not stat AuthorizedKeysCommand \"%s\": %s",
87ab5f
              authorized_keys_command, strerror(errno));
87ab5f
         goto out;
87ab5f
     }
87ab5f
     if(pamsshagentauth_auth_secure_path
87ab5f
        (authorized_keys_command, &st, NULL, 0, errmsg, sizeof(errmsg)) != 0) {
87ab5f
-        pamsshagentauth_logerror("Unsafe AuthorizedKeysCommand: %s", errmsg);
87ab5f
+        error("Unsafe AuthorizedKeysCommand: %s", errmsg);
87ab5f
         goto out;
87ab5f
     }
87ab5f
 
87ab5f
     /* open the pipe and read the keys */
87ab5f
     if(pipe(p) != 0) {
87ab5f
-        pamsshagentauth_logerror("%s: pipe: %s", __func__, strerror(errno));
87ab5f
+        error("%s: pipe: %s", __func__, strerror(errno));
87ab5f
         goto out;
87ab5f
     }
87ab5f
 
87ab5f
-    pamsshagentauth_debug("Running AuthorizedKeysCommand: \"%s\" as \"%s\" with argument: \"%s\"",
87ab5f
+    debug("Running AuthorizedKeysCommand: \"%s\" as \"%s\" with argument: \"%s\"",
87ab5f
                           authorized_keys_command, pw->pw_name, username);
87ab5f
 
87ab5f
     /* 
87ab5f
      * Don't want to call this in the child, where it can fatal() and
87ab5f
      * run cleanup_exit() code.
87ab5f
      */
87ab5f
-    pamsshagentauth_restore_uid();
87ab5f
+    restore_uid();
87ab5f
 
87ab5f
     switch ((pid = fork())) {
87ab5f
     case -1:                                              /* error */
87ab5f
-        pamsshagentauth_logerror("%s: fork: %s", __func__, strerror(errno));
87ab5f
+        error("%s: fork: %s", __func__, strerror(errno));
87ab5f
         close(p[0]);
87ab5f
         close(p[1]);
87ab5f
         return 0;
bdb932
@@ -234,13 +236,13 @@ pamsshagentauth_user_key_command_allowed
87ab5f
 
87ab5f
         /* do this before the setresuid so thta they can be logged */
87ab5f
         if((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) {
87ab5f
-            pamsshagentauth_logerror("%s: open %s: %s", __func__, _PATH_DEVNULL,
87ab5f
+            error("%s: open %s: %s", __func__, _PATH_DEVNULL,
87ab5f
                                      strerror(errno));
87ab5f
             _exit(1);
87ab5f
         }
87ab5f
         if(dup2(devnull, STDIN_FILENO) == -1 || dup2(p[1], STDOUT_FILENO) == -1
87ab5f
            || dup2(devnull, STDERR_FILENO) == -1) {
87ab5f
-            pamsshagentauth_logerror("%s: dup2: %s", __func__, strerror(errno));
87ab5f
+            error("%s: dup2: %s", __func__, strerror(errno));
87ab5f
             _exit(1);
87ab5f
         }
87ab5f
 #if defined(HAVE_SETRESGID) && !defined(BROKEN_SETRESGID)
bdb932
@@ -248,7 +250,7 @@ pamsshagentauth_user_key_command_allowed
87ab5f
 #else
87ab5f
         if (setgid(pw->pw_gid) != 0 || setegid(pw->pw_gid) != 0) {
87ab5f
 #endif
87ab5f
-            pamsshagentauth_logerror("setresgid %u: %s", (u_int) pw->pw_gid,
87ab5f
+            error("setresgid %u: %s", (u_int) pw->pw_gid,
87ab5f
                                      strerror(errno));
87ab5f
             _exit(1);
87ab5f
         }
bdb932
@@ -258,7 +260,7 @@ pamsshagentauth_user_key_command_allowed
87ab5f
 #else
87ab5f
         if (setuid(pw->pw_uid) != 0 || seteuid(pw->pw_uid) != 0) {
87ab5f
 #endif
87ab5f
-            pamsshagentauth_logerror("setresuid %u: %s", (u_int) pw->pw_uid,
87ab5f
+            error("setresuid %u: %s", (u_int) pw->pw_uid,
87ab5f
                                      strerror(errno));
87ab5f
             _exit(1);
87ab5f
         }
bdb932
@@ -270,18 +272,18 @@ pamsshagentauth_user_key_command_allowed
87ab5f
 
87ab5f
         /* pretty sure this will barf because we are now suid, but since we
87ab5f
            should't reach this anyway, I'll leave it here */
87ab5f
-        pamsshagentauth_logerror("AuthorizedKeysCommand %s exec failed: %s",
87ab5f
+        error("AuthorizedKeysCommand %s exec failed: %s",
87ab5f
                                  authorized_keys_command, strerror(errno));
87ab5f
         _exit(127);
87ab5f
     default:                                              /* parent */
87ab5f
         break;
87ab5f
     }
87ab5f
 
87ab5f
-    pamsshagentauth_temporarily_use_uid(pw);
87ab5f
+    temporarily_use_uid(pw);
87ab5f
 
87ab5f
     close(p[1]);
87ab5f
     if((f = fdopen(p[0], "r")) == NULL) {
87ab5f
-        pamsshagentauth_logerror("%s: fdopen: %s", __func__, strerror(errno));
87ab5f
+        error("%s: fdopen: %s", __func__, strerror(errno));
87ab5f
         close(p[0]);
87ab5f
         /* Don't leave zombie child */
87ab5f
         while(waitpid(pid, NULL, 0) == -1 && errno == EINTR);
bdb932
@@ -292,22 +294,22 @@ pamsshagentauth_user_key_command_allowed
87ab5f
 
87ab5f
     while(waitpid(pid, &status, 0) == -1) {
87ab5f
         if(errno != EINTR) {
87ab5f
-            pamsshagentauth_logerror("%s: waitpid: %s", __func__,
87ab5f
+            error("%s: waitpid: %s", __func__,
87ab5f
                                      strerror(errno));
87ab5f
             goto out;
87ab5f
         }
87ab5f
     }
87ab5f
     if(WIFSIGNALED(status)) {
87ab5f
-        pamsshagentauth_logerror("AuthorizedKeysCommand %s exited on signal %d",
87ab5f
+        error("AuthorizedKeysCommand %s exited on signal %d",
87ab5f
                                  authorized_keys_command, WTERMSIG(status));
87ab5f
         goto out;
87ab5f
     } else if(WEXITSTATUS(status) != 0) {
87ab5f
-        pamsshagentauth_logerror("AuthorizedKeysCommand %s returned status %d",
87ab5f
+        error("AuthorizedKeysCommand %s returned status %d",
87ab5f
                                  authorized_keys_command, WEXITSTATUS(status));
87ab5f
         goto out;
87ab5f
     }
87ab5f
     found_key = ok;
87ab5f
   out:
87ab5f
-    pamsshagentauth_restore_uid();
87ab5f
+    restore_uid();
87ab5f
     return found_key;
87ab5f
 }
bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/secure_filename.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/secure_filename.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/secure_filename.c.psaa-compat	2016-11-13 04:24:32.000000000 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/secure_filename.c	2017-02-07 14:41:20.481509206 +0100
bdb932
@@ -80,7 +80,7 @@ pamsshagentauth_auth_secure_path(const c
bdb932
 	int comparehome = 0;
bdb932
 	struct stat st;
87ab5f
 
bdb932
-    pamsshagentauth_verbose("auth_secure_filename: checking for uid: %u", uid);
bdb932
+    verbose("auth_secure_filename: checking for uid: %u", uid);
87ab5f
 
bdb932
 	if (realpath(name, buf) == NULL) {
bdb932
 		snprintf(err, errlen, "realpath %s failed: %s", name,
bdb932
@@ -115,9 +115,9 @@ pamsshagentauth_auth_secure_path(const c
bdb932
 			snprintf(err, errlen, "dirname() failed");
bdb932
 			return -1;
bdb932
 		}
bdb932
-		pamsshagentauth_strlcpy(buf, cp, sizeof(buf));
bdb932
+		strlcpy(buf, cp, sizeof(buf));
bdb932
 
bdb932
-		pamsshagentauth_verbose("secure_filename: checking '%s'", buf);
bdb932
+		verbose("secure_filename: checking '%s'", buf);
bdb932
 		if (stat(buf, &st) < 0 ||
bdb932
 		    (st.st_uid != 0 && st.st_uid != uid) ||
bdb932
 		    (st.st_mode & 022) != 0) {
bdb932
@@ -128,7 +128,7 @@ pamsshagentauth_auth_secure_path(const c
bdb932
 
bdb932
 		/* If are passed the homedir then we can stop */
bdb932
 		if (comparehome && strcmp(homedir, buf) == 0) {
bdb932
-			pamsshagentauth_verbose("secure_filename: terminating check at '%s'",
bdb932
+			verbose("secure_filename: terminating check at '%s'",
bdb932
 			    buf);
bdb932
 			break;
bdb932
 		}
bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c.psaa-compat	2016-11-13 04:24:32.000000000 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/userauth_pubkey_from_id.c	2017-02-07 14:41:20.484509204 +0100
bdb932
@@ -48,6 +48,8 @@
bdb932
 #include "identity.h"
bdb932
 #include "pam_user_authorized_keys.h"
bdb932
 
bdb932
+#define SSH2_MSG_USERAUTH_TRUST_REQUEST          54
bdb932
+
bdb932
 /* extern u_char  *session_id2;
bdb932
 extern uint8_t  session_id_len;
bdb932
  */
bdb932
@@ -65,37 +67,38 @@ userauth_pubkey_from_id(const char *ruse
bdb932
 
bdb932
     /* first test if this key is even allowed */
bdb932
     if(! pam_user_key_allowed(ruser, id->key))
bdb932
-        goto user_auth_clean_exit;
bdb932
+        goto user_auth_clean_exit_without_buffer;
bdb932
 
bdb932
-    if(pamsshagentauth_key_to_blob(id->key, &pkblob, &blen) == 0)
bdb932
-        goto user_auth_clean_exit;
bdb932
+    if(key_to_blob(id->key, &pkblob, &blen) == 0)
bdb932
+        goto user_auth_clean_exit_without_buffer;
bdb932
 
bdb932
     /* construct packet to sign and test */
bdb932
-    pamsshagentauth_buffer_init(&b);
bdb932
+    buffer_init(&b);
bdb932
 
bdb932
-    pamsshagentauth_buffer_put_string(&b, session_id2->buf + session_id2->offset, session_id2->end - session_id2->offset);
bdb932
-    pamsshagentauth_buffer_put_char(&b, SSH2_MSG_USERAUTH_TRUST_REQUEST); 
bdb932
-    pamsshagentauth_buffer_put_cstring(&b, ruser);
bdb932
-    pamsshagentauth_buffer_put_cstring(&b, "pam_ssh_agent_auth");
bdb932
-    pamsshagentauth_buffer_put_cstring(&b, "publickey");
bdb932
-    pamsshagentauth_buffer_put_char(&b, 1);
bdb932
-    pamsshagentauth_buffer_put_cstring(&b, pkalg);
bdb932
-    pamsshagentauth_buffer_put_string(&b, pkblob, blen);
bdb932
+    buffer_put_string(&b, sshbuf_ptr(session_id2), sshbuf_len(session_id2));
bdb932
+    buffer_put_char(&b, SSH2_MSG_USERAUTH_TRUST_REQUEST); 
bdb932
+    buffer_put_cstring(&b, ruser);
bdb932
+    buffer_put_cstring(&b, "pam_ssh_agent_auth");
bdb932
+    buffer_put_cstring(&b, "publickey");
bdb932
+    buffer_put_char(&b, 1);
bdb932
+    buffer_put_cstring(&b, pkalg);
bdb932
+    buffer_put_string(&b, pkblob, blen);
bdb932
 
bdb932
-    if(ssh_agent_sign(id->ac, id->key, &sig, &slen, pamsshagentauth_buffer_ptr(&b), pamsshagentauth_buffer_len(&b)) != 0)
bdb932
+    if(ssh_agent_sign(id->ac, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b)) != 0)
bdb932
         goto user_auth_clean_exit;
bdb932
 
bdb932
     /* test for correct signature */
bdb932
-    if(pamsshagentauth_key_verify(id->key, sig, slen, pamsshagentauth_buffer_ptr(&b), pamsshagentauth_buffer_len(&b)) == 1)
bdb932
+    if(key_verify(id->key, sig, slen, buffer_ptr(&b), buffer_len(&b)) == 1)
bdb932
         authenticated = 1;
bdb932
 
bdb932
   user_auth_clean_exit:
bdb932
     /* if(&b != NULL) */
bdb932
-    pamsshagentauth_buffer_free(&b);
bdb932
+    buffer_free(&b);
bdb932
+  user_auth_clean_exit_without_buffer:
bdb932
     if(sig != NULL)
bdb932
-        pamsshagentauth_xfree(sig);
bdb932
+        free(sig);
bdb932
     if(pkblob != NULL)
bdb932
-        pamsshagentauth_xfree(pkblob);
bdb932
+        free(pkblob);
bdb932
     CRYPTO_cleanup_all_ex_data();
bdb932
     return authenticated;
87ab5f
 }
bdb932
diff -up openssh-7.4p1/pam_ssh_agent_auth-0.10.3/uuencode.c.psaa-compat openssh-7.4p1/pam_ssh_agent_auth-0.10.3/uuencode.c
bdb932
--- openssh-7.4p1/pam_ssh_agent_auth-0.10.3/uuencode.c.psaa-compat	2016-11-13 04:24:32.000000000 +0100
bdb932
+++ openssh-7.4p1/pam_ssh_agent_auth-0.10.3/uuencode.c	2017-02-07 14:41:20.484509204 +0100
87ab5f
@@ -56,7 +56,7 @@ pamsshagentauth_uudecode(const char *src
87ab5f
 	/* and remove trailing whitespace because __b64_pton needs this */
87ab5f
 	*p = '\0';
87ab5f
 	len = pamsshagentauth___b64_pton(encoded, target, targsize);
87ab5f
-	pamsshagentauth_xfree(encoded);
87ab5f
+	xfree(encoded);
87ab5f
 	return len;
87ab5f
 }
87ab5f
 
bdb932
@@ -70,7 +70,7 @@ pamsshagentauth_dump_base64(FILE *fp, co
87ab5f
 		fprintf(fp, "dump_base64: len > 65536\n");
87ab5f
 		return;
87ab5f
 	}
87ab5f
-	buf = pamsshagentauth_xmalloc(2*len);
87ab5f
+	buf = malloc(2*len);
87ab5f
 	n = pamsshagentauth_uuencode(data, len, buf, 2*len);
87ab5f
 	for (i = 0; i < n; i++) {
87ab5f
 		fprintf(fp, "%c", buf[i]);
bdb932
@@ -79,5 +79,5 @@ pamsshagentauth_dump_base64(FILE *fp, co
87ab5f
 	}
87ab5f
 	if (i % 70 != 69)
87ab5f
 		fprintf(fp, "\n");
87ab5f
-	pamsshagentauth_xfree(buf);
87ab5f
+	free(buf);
87ab5f
 }