|
Jakub Jelen |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c.old 2016-01-22 16:27:56.867903172 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/iterate_ssh_agent_keys.c 2016-01-22 16:56:48.114868014 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -59,6 +59,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 |
87ab5f |
@@ -77,7 +77,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 |
87ab5f |
@@ -71,12 +90,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 |
87ab5f |
@@ -100,7 +119,7 @@ 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 |
@@ -126,7 +128,7 @@ pamsshagentauth_session_id2_gen(Buffer *
|
|
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 |
@@ -110,7 +129,7 @@ pamsshagentauth_session_id2_gen(Buffer *
|
|
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 |
87ab5f |
@@ -125,7 +144,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 |
87ab5f |
@@ -142,35 +161,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 |
87ab5f |
@@ -190,11 +289,11 @@ 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 |
@@ -203,18 +302,18 @@ pamsshagentauth_find_authorized_keys(con
|
|
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 |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c.old 2016-01-22 17:03:42.746602825 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_ssh_agent_auth.c 2016-01-22 17:06:07.841485483 +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 |
87ab5f |
- pamsshagentauth_log_init(__progname, log_lvl, facility, 0);
|
|
Jakub Jelen |
87ab5f |
+ log_init(__progname, log_lvl, facility, 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 |
87ab5f |
} 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 |
87ab5f |
/*
|
|
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 |
87ab5f |
/*
|
|
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 |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c.old 2016-01-22 16:57:15.210850825 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c 2016-01-22 17:03:13.913623276 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -48,6 +48,8 @@
|
|
Jakub Jelen |
87ab5f |
#include "identity.h"
|
|
Jakub Jelen |
87ab5f |
#include "pam_user_authorized_keys.h"
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
+#define SSH2_MSG_USERAUTH_TRUST_REQUEST 54
|
|
Jakub Jelen |
87ab5f |
+
|
|
Jakub Jelen |
87ab5f |
/* extern u_char *session_id2;
|
|
Jakub Jelen |
87ab5f |
extern uint8_t session_id_len;
|
|
Jakub Jelen |
87ab5f |
*/
|
|
Jakub Jelen |
87ab5f |
@@ -67,35 +67,35 @@ userauth_pubkey_from_id(const char *ruse
|
|
Jakub Jelen |
87ab5f |
if(! pam_user_key_allowed(ruser, id->key))
|
|
Jakub Jelen |
87ab5f |
goto user_auth_clean_exit;
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
- if(pamsshagentauth_key_to_blob(id->key, &pkblob, &blen) == 0)
|
|
Jakub Jelen |
87ab5f |
+ if(key_to_blob(id->key, &pkblob, &blen) == 0)
|
|
Jakub Jelen |
87ab5f |
goto user_auth_clean_exit;
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
/* construct packet to sign and test */
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_init(&b);
|
|
Jakub Jelen |
87ab5f |
+ buffer_init(&b);
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_string(&b, session_id2->buf + session_id2->offset, session_id2->end - session_id2->offset);
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_char(&b, SSH2_MSG_USERAUTH_TRUST_REQUEST);
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_cstring(&b, ruser);
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_cstring(&b, "pam_ssh_agent_auth");
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_cstring(&b, "publickey");
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_char(&b, 1);
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_cstring(&b, pkalg);
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_put_string(&b, pkblob, blen);
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_string(&b, sshbuf_ptr(session_id2), sshbuf_len(session_id2));
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_char(&b, SSH2_MSG_USERAUTH_TRUST_REQUEST);
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_cstring(&b, ruser);
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_cstring(&b, "pam_ssh_agent_auth");
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_cstring(&b, "publickey");
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_char(&b, 1);
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_cstring(&b, pkalg);
|
|
Jakub Jelen |
87ab5f |
+ buffer_put_string(&b, pkblob, blen);
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
- if(ssh_agent_sign(id->ac, id->key, &sig, &slen, pamsshagentauth_buffer_ptr(&b), pamsshagentauth_buffer_len(&b)) != 0)
|
|
Jakub Jelen |
87ab5f |
+ if(ssh_agent_sign(id->ac, id->key, &sig, &slen, buffer_ptr(&b), buffer_len(&b)) != 0)
|
|
Jakub Jelen |
87ab5f |
goto user_auth_clean_exit;
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
/* test for correct signature */
|
|
Jakub Jelen |
87ab5f |
- if(pamsshagentauth_key_verify(id->key, sig, slen, pamsshagentauth_buffer_ptr(&b), pamsshagentauth_buffer_len(&b)) == 1)
|
|
Jakub Jelen |
87ab5f |
+ if(key_verify(id->key, sig, slen, buffer_ptr(&b), buffer_len(&b)) == 1)
|
|
Jakub Jelen |
87ab5f |
authenticated = 1;
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
user_auth_clean_exit:
|
|
Jakub Jelen |
87ab5f |
/* if(&b != NULL) */
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_buffer_free(&b);
|
|
Jakub Jelen |
87ab5f |
+ buffer_free(&b);
|
|
Jakub Jelen |
87ab5f |
if(sig != NULL)
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_xfree(sig);
|
|
Jakub Jelen |
87ab5f |
+ free(sig);
|
|
Jakub Jelen |
87ab5f |
if(pkblob != NULL)
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_xfree(pkblob);
|
|
Jakub Jelen |
87ab5f |
+ free(pkblob);
|
|
Jakub Jelen |
87ab5f |
CRYPTO_cleanup_all_ex_data();
|
|
Jakub Jelen |
87ab5f |
return authenticated;
|
|
Jakub Jelen |
87ab5f |
}
|
|
Jakub Jelen |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c.old 2016-01-22 17:12:03.026198234 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/secure_filename.c 2016-01-22 17:12:31.817174950 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -80,7 +80,7 @@ pamsshagentauth_auth_secure_path(const c
|
|
Jakub Jelen |
87ab5f |
int comparehome = 0;
|
|
Jakub Jelen |
87ab5f |
struct stat st;
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_verbose("auth_secure_filename: checking for uid: %u", uid);
|
|
Jakub Jelen |
87ab5f |
+ verbose("auth_secure_filename: checking for uid: %u", uid);
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
if (realpath(name, buf) == NULL) {
|
|
Jakub Jelen |
87ab5f |
snprintf(err, errlen, "realpath %s failed: %s", name,
|
|
Jakub Jelen |
87ab5f |
@@ -115,9 +115,9 @@ pamsshagentauth_auth_secure_path(const c
|
|
Jakub Jelen |
87ab5f |
snprintf(err, errlen, "dirname() failed");
|
|
Jakub Jelen |
87ab5f |
return -1;
|
|
Jakub Jelen |
87ab5f |
}
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_strlcpy(buf, cp, sizeof(buf));
|
|
Jakub Jelen |
87ab5f |
+ strlcpy(buf, cp, sizeof(buf));
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_verbose("secure_filename: checking '%s'", buf);
|
|
Jakub Jelen |
87ab5f |
+ verbose("secure_filename: checking '%s'", buf);
|
|
Jakub Jelen |
87ab5f |
if (stat(buf, &st) < 0 ||
|
|
Jakub Jelen |
87ab5f |
(st.st_uid != 0 && st.st_uid != uid) ||
|
|
Jakub Jelen |
87ab5f |
(st.st_mode & 022) != 0) {
|
|
Jakub Jelen |
87ab5f |
@@ -128,7 +128,7 @@ pamsshagentauth_auth_secure_path(const c
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
/* If are passed the homedir then we can stop */
|
|
Jakub Jelen |
87ab5f |
if (comparehome && strcmp(homedir, buf) == 0) {
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_verbose("secure_filename: terminating check at '%s'",
|
|
Jakub Jelen |
87ab5f |
+ verbose("secure_filename: terminating check at '%s'",
|
|
Jakub Jelen |
87ab5f |
buf);
|
|
Jakub Jelen |
87ab5f |
break;
|
|
Jakub Jelen |
87ab5f |
}
|
|
Jakub Jelen |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c.old 2016-01-22 17:13:18.226137418 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/get_command_line.c 2016-01-22 17:14:27.753081189 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -65,8 +65,8 @@ proc_pid_cmdline(char *** inargv)
|
|
Jakub Jelen |
87ab5f |
case EOF:
|
|
Jakub Jelen |
87ab5f |
case '\0':
|
|
Jakub Jelen |
87ab5f |
if (len > 0) {
|
|
Jakub Jelen |
87ab5f |
- argv = pamsshagentauth_xrealloc(argv, count + 1, sizeof(*argv));
|
|
Jakub Jelen |
87ab5f |
- argv[count] = pamsshagentauth_xcalloc(len + 1, sizeof(*argv[count]));
|
|
Jakub Jelen |
87ab5f |
+ argv = xreallocarray(argv, count + 1, sizeof(*argv));
|
|
Jakub Jelen |
87ab5f |
+ argv[count] = xcalloc(len + 1, sizeof(*argv[count]));
|
|
Jakub Jelen |
87ab5f |
strncpy(argv[count++], argbuf, len);
|
|
Jakub Jelen |
87ab5f |
memset(argbuf, '\0', MAX_LEN_PER_CMDLINE_ARG + 1);
|
|
Jakub Jelen |
87ab5f |
len = 0;
|
|
Jakub Jelen |
87ab5f |
@@ -105,9 +105,9 @@ pamsshagentauth_free_command_line(char *
|
|
Jakub Jelen |
87ab5f |
{
|
|
Jakub Jelen |
87ab5f |
size_t i;
|
|
Jakub Jelen |
87ab5f |
for (i = 0; i < n_args; i++)
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_xfree(argv[i]);
|
|
Jakub Jelen |
87ab5f |
+ free(argv[i]);
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_xfree(argv);
|
|
Jakub Jelen |
87ab5f |
+ free(argv);
|
|
Jakub Jelen |
87ab5f |
return;
|
|
Jakub Jelen |
87ab5f |
}
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c.old openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c.old 2016-01-22 17:15:57.547008570 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_key_allowed2.c 2016-01-22 17:16:18.297991788 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -48,6 +48,7 @@
|
|
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 |
@@ -54,6 +54,7 @@
|
|
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 |
87ab5f |
@@ -68,7 +68,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 |
87ab5f |
@@ -78,11 +78,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 |
87ab5f |
@@ -92,26 +92,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 |
87ab5f |
@@ -128,11 +128,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 |
87ab5f |
@@ -144,7 +144,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 |
87ab5f |
@@ -187,44 +187,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 |
87ab5f |
@@ -234,13 +234,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 |
87ab5f |
@@ -248,7 +248,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 |
87ab5f |
@@ -258,7 +258,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 |
87ab5f |
@@ -270,18 +270,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 |
87ab5f |
@@ -292,22 +292,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 |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c.psaa-xfree openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c.psaa-xfree 2016-01-22 15:30:26.300302721 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/pam_user_authorized_keys.c 2016-01-22 15:33:57.567226875 +0100
|
|
Jakub Jelen |
87ab5f |
@@ -117,12 +117,12 @@ parse_authorized_key_file(const char *us
|
|
Jakub Jelen |
87ab5f |
} else {
|
|
Jakub Jelen |
87ab5f |
slash_ptr = strchr(auth_keys_file_buf, '/');
|
|
Jakub Jelen |
87ab5f |
if(!slash_ptr)
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_fatal
|
|
Jakub Jelen |
87ab5f |
+ fatal
|
|
Jakub Jelen |
87ab5f |
("cannot expand tilde in path without a `/'");
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
owner_uname_len = slash_ptr - auth_keys_file_buf - 1;
|
|
Jakub Jelen |
87ab5f |
if(owner_uname_len > (sizeof(owner_uname) - 1))
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_fatal("Username too long");
|
|
Jakub Jelen |
87ab5f |
+ fatal("Username too long");
|
|
Jakub Jelen |
87ab5f |
|
|
Jakub Jelen |
87ab5f |
strncat(owner_uname, auth_keys_file_buf + 1, owner_uname_len);
|
|
Jakub Jelen |
87ab5f |
if(!authorized_keys_file_allowed_owner_uid)
|
|
Jakub Jelen |
87ab5f |
@@ -130,11 +130,11 @@ parse_authorized_key_file(const char *us
|
|
Jakub Jelen |
87ab5f |
getpwnam(owner_uname)->pw_uid;
|
|
Jakub Jelen |
87ab5f |
}
|
|
Jakub Jelen |
87ab5f |
authorized_keys_file =
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_tilde_expand_filename(auth_keys_file_buf,
|
|
Jakub Jelen |
87ab5f |
+ tilde_expand_filename(auth_keys_file_buf,
|
|
Jakub Jelen |
87ab5f |
authorized_keys_file_allowed_owner_uid);
|
|
Jakub Jelen |
87ab5f |
strncpy(auth_keys_file_buf, authorized_keys_file,
|
|
Jakub Jelen |
87ab5f |
sizeof(auth_keys_file_buf) - 1);
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_xfree(authorized_keys_file) /* when we
|
|
Jakub Jelen |
87ab5f |
+ free(authorized_keys_file) /* when we
|
|
Jakub Jelen |
87ab5f |
percent_expand
|
|
Jakub Jelen |
87ab5f |
later, we'd step
|
|
Jakub Jelen |
87ab5f |
on this, so free
|
|
Jakub Jelen |
87ab5f |
@@ -150,7 +150,7 @@ parse_authorized_key_file(const char *us
|
|
Jakub Jelen |
87ab5f |
strncat(hostname, fqdn, strcspn(fqdn, "."));
|
|
Jakub Jelen |
87ab5f |
#endif
|
|
Jakub Jelen |
87ab5f |
authorized_keys_file =
|
|
Jakub Jelen |
87ab5f |
- pamsshagentauth_percent_expand(auth_keys_file_buf, "h",
|
|
Jakub Jelen |
87ab5f |
+ percent_expand(auth_keys_file_buf, "h",
|
|
Jakub Jelen |
87ab5f |
getpwnam(user)->pw_dir, "H", hostname,
|
|
Jakub Jelen |
87ab5f |
"f", fqdn, "u", user, NULL);
|
|
Jakub Jelen |
87ab5f |
}
|
|
Jakub Jelen |
87ab5f |
diff -up openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c.psaa-xfree openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c
|
|
Jakub Jelen |
87ab5f |
--- openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c.psaa-xfree 2014-03-23 23:52:21.000000000 +0100
|
|
Jakub Jelen |
87ab5f |
+++ openssh-7.1p2/pam_ssh_agent_auth-0.10.2/uuencode.c 2016-01-22 15:39:26.210104334 +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 |
87ab5f |
@@ -70,7 +70,7 @@ pamsshagentauth_dump_base64(FILE *fp, u_
|
|
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 |
87ab5f |
@@ -79,5 +79,5 @@ pamsshagentauth_dump_base64(FILE *fp, u_
|
|
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 |
}
|
|
Jakub Jelen |
c08255 |
diff --git a/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c b/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
c08255 |
index d5a574f..9e866c1 100644
|
|
Jakub Jelen |
c08255 |
--- a/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
c08255 |
+++ b/pam_ssh_agent_auth-0.10.2/userauth_pubkey_from_id.c
|
|
Jakub Jelen |
c08255 |
@@ -68,10 +68,10 @@ userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
|
|
Jakub Jelen |
c08255 |
|
|
Jakub Jelen |
c08255 |
/* first test if this key is even allowed */
|
|
Jakub Jelen |
c08255 |
if(! pam_user_key_allowed(ruser, id->key))
|
|
Jakub Jelen |
c08255 |
- goto user_auth_clean_exit;
|
|
Jakub Jelen |
c08255 |
+ goto user_auth_clean_exit_without_buffer;
|
|
Jakub Jelen |
c08255 |
|
|
Jakub Jelen |
c08255 |
if(key_to_blob(id->key, &pkblob, &blen) == 0)
|
|
Jakub Jelen |
c08255 |
- goto user_auth_clean_exit;
|
|
Jakub Jelen |
c08255 |
+ goto user_auth_clean_exit_without_buffer;
|
|
Jakub Jelen |
c08255 |
|
|
Jakub Jelen |
c08255 |
/* construct packet to sign and test */
|
|
Jakub Jelen |
c08255 |
buffer_init(&b);
|
|
Jakub Jelen |
c08255 |
@@ -95,6 +95,7 @@ userauth_pubkey_from_id(const char *ruser, Identity * id, Buffer * session_id2)
|
|
Jakub Jelen |
c08255 |
user_auth_clean_exit:
|
|
Jakub Jelen |
c08255 |
/* if(&b != NULL) */
|
|
Jakub Jelen |
c08255 |
buffer_free(&b);
|
|
Jakub Jelen |
c08255 |
+ user_auth_clean_exit_without_buffer:
|
|
Jakub Jelen |
c08255 |
if(sig != NULL)
|
|
Jakub Jelen |
c08255 |
free(sig);
|
|
Jakub Jelen |
c08255 |
if(pkblob != NULL)
|