vishalmishra434 / rpms / openssh

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