2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/audit-bsm.c.audit openssh-7.6p1/audit-bsm.c
|
|
|
|
--- openssh-7.6p1/audit-bsm.c.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/audit-bsm.c 2017-10-04 17:18:32.834505048 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -373,10 +373,23 @@ audit_connection_from(const char *host,
|
2013-04-08 15:17:10 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
-void
|
|
|
|
+int
|
|
|
|
audit_run_command(const char *command)
|
|
|
|
{
|
|
|
|
/* not implemented */
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_end_command(int handle, const char *command)
|
|
|
|
+{
|
|
|
|
+ /* not implemented */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_count_session_open(void)
|
|
|
|
+{
|
|
|
|
+ /* not necessary */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -391,6 +404,12 @@ audit_session_close(struct logininfo *li
|
2013-04-08 15:17:10 +00:00
|
|
|
/* not implemented */
|
|
|
|
}
|
|
|
|
|
|
|
|
+int
|
2018-01-22 10:15:15 +00:00
|
|
|
+audit_keyusage(int host_user, char *fp, int rv)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ /* not implemented */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void
|
|
|
|
audit_event(ssh_audit_event_t event)
|
|
|
|
{
|
2018-01-16 15:24:27 +00:00
|
|
|
@@ -452,4 +471,34 @@ audit_event(ssh_audit_event_t event)
|
2013-04-08 15:17:10 +00:00
|
|
|
debug("%s: unhandled event %d", __func__, event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_unsupported_body(int what)
|
|
|
|
+{
|
|
|
|
+ /* not implemented */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
2015-01-20 12:18:45 +00:00
|
|
|
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid, uid_t uid)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ /* not implemented */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+ /* not implemented */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_destroy_sensitive_data(const char *fp)
|
|
|
|
+{
|
|
|
|
+ /* not implemented */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+ /* not implemented */
|
|
|
|
+}
|
|
|
|
#endif /* BSM */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/audit.c.audit openssh-7.6p1/audit.c
|
|
|
|
--- openssh-7.6p1/audit.c.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/audit.c 2017-10-04 17:18:32.834505048 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -26,6 +26,7 @@
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
|
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
|
2018-01-19 09:45:55 +00:00
|
|
|
@@ -34,6 +35,12 @@
|
2015-06-24 12:11:59 +00:00
|
|
|
#include "key.h"
|
|
|
|
#include "hostfile.h"
|
|
|
|
#include "auth.h"
|
|
|
|
+#include "ssh-gss.h"
|
|
|
|
+#include "monitor_wrap.h"
|
|
|
|
+#include "xmalloc.h"
|
|
|
|
+#include "misc.h"
|
|
|
|
+#include "servconf.h"
|
2018-01-19 09:45:55 +00:00
|
|
|
+#include "ssherr.h"
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Care must be taken when using this since it WILL NOT be initialized when
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -41,6 +47,7 @@
|
2015-06-24 12:11:59 +00:00
|
|
|
* audit_event(CONNECTION_ABANDON) is called. Test for NULL before using.
|
|
|
|
*/
|
|
|
|
extern Authctxt *the_authctxt;
|
|
|
|
+extern ServerOptions options;
|
|
|
|
|
|
|
|
/* Maybe add the audit class to struct Authmethod? */
|
|
|
|
ssh_audit_event_t
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -69,13 +76,10 @@ audit_classify_auth(const char *method)
|
2015-06-24 12:11:59 +00:00
|
|
|
const char *
|
|
|
|
audit_username(void)
|
|
|
|
{
|
|
|
|
- static const char unknownuser[] = "(unknown user)";
|
|
|
|
- static const char invaliduser[] = "(invalid user)";
|
|
|
|
+ static const char unknownuser[] = "(unknown)";
|
|
|
|
|
|
|
|
- if (the_authctxt == NULL || the_authctxt->user == NULL)
|
|
|
|
+ if (the_authctxt == NULL || the_authctxt->user == NULL || !the_authctxt->valid)
|
|
|
|
return (unknownuser);
|
|
|
|
- if (!the_authctxt->valid)
|
|
|
|
- return (invaliduser);
|
|
|
|
return (the_authctxt->user);
|
|
|
|
}
|
|
|
|
|
2018-01-22 10:15:15 +00:00
|
|
|
@@ -109,6 +113,35 @@ audit_event_lookup(ssh_audit_event_t ev)
|
2015-06-24 12:11:59 +00:00
|
|
|
return(event_lookup[i].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
+void
|
|
|
|
+audit_key(int host_user, int *rv, const Key *key)
|
|
|
|
+{
|
|
|
|
+ char *fp;
|
|
|
|
+
|
|
|
|
+ fp = sshkey_fingerprint(key, options.fingerprint_hash, SSH_FP_HEX);
|
2018-01-22 10:15:15 +00:00
|
|
|
+ if (audit_keyusage(host_user, fp, (*rv == 0)) == 0)
|
2018-01-19 09:18:51 +00:00
|
|
|
+ *rv = -SSH_ERR_INTERNAL_ERROR;
|
2015-06-24 12:11:59 +00:00
|
|
|
+ free(fp);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_unsupported(int what)
|
|
|
|
+{
|
|
|
|
+ PRIVSEP(audit_unsupported_body(what));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs)
|
|
|
|
+{
|
|
|
|
+ PRIVSEP(audit_kex_body(ctos, enc, mac, comp, pfs, getpid(), getuid()));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_session_key_free(int ctos)
|
|
|
|
+{
|
|
|
|
+ PRIVSEP(audit_session_key_free_body(ctos, getpid(), getuid()));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
# ifndef CUSTOM_SSH_AUDIT_EVENTS
|
|
|
|
/*
|
|
|
|
* Null implementations of audit functions.
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -138,6 +173,17 @@ audit_event(ssh_audit_event_t event)
|
2015-06-24 12:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
+ * Called when a child process has called, or will soon call,
|
|
|
|
+ * audit_session_open.
|
|
|
|
+ */
|
|
|
|
+void
|
|
|
|
+audit_count_session_open(void)
|
|
|
|
+{
|
|
|
|
+ debug("audit count session open euid %d user %s", geteuid(),
|
|
|
|
+ audit_username());
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
* Called when a user session is started. Argument is the tty allocated to
|
|
|
|
* the session, or NULL if no tty was allocated.
|
|
|
|
*
|
2018-01-16 15:24:27 +00:00
|
|
|
@@ -172,13 +218,82 @@ audit_session_close(struct logininfo *li
|
2015-06-24 12:11:59 +00:00
|
|
|
/*
|
|
|
|
* This will be called when a user runs a non-interactive command. Note that
|
|
|
|
* it may be called multiple times for a single connection since SSH2 allows
|
|
|
|
- * multiple sessions within a single connection.
|
|
|
|
+ * multiple sessions within a single connection. Returns a "handle" for
|
|
|
|
+ * audit_end_command.
|
|
|
|
*/
|
|
|
|
-void
|
|
|
|
+int
|
|
|
|
audit_run_command(const char *command)
|
|
|
|
{
|
|
|
|
debug("audit run command euid %d user %s command '%.200s'", geteuid(),
|
|
|
|
audit_username(), command);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * This will be called when the non-interactive command finishes. Note that
|
|
|
|
+ * it may be called multiple times for a single connection since SSH2 allows
|
|
|
|
+ * multiple sessions within a single connection. "handle" should come from
|
|
|
|
+ * the corresponding audit_run_command.
|
|
|
|
+ */
|
|
|
|
+void
|
|
|
|
+audit_end_command(int handle, const char *command)
|
|
|
|
+{
|
|
|
|
+ debug("audit end nopty exec euid %d user %s command '%.200s'", geteuid(),
|
|
|
|
+ audit_username(), command);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * This will be called when user is successfully autherized by the RSA1/RSA/DSA key.
|
|
|
|
+ *
|
|
|
|
+ * Type is the key type, len is the key length(byte) and fp is the fingerprint of the key.
|
|
|
|
+ */
|
|
|
|
+int
|
2018-01-22 10:15:15 +00:00
|
|
|
+audit_keyusage(int host_user, char *fp, int rv)
|
2015-06-24 12:11:59 +00:00
|
|
|
+{
|
2018-01-22 10:15:15 +00:00
|
|
|
+ debug("audit %s key usage euid %d user %s fingerprint %s, result %d",
|
|
|
|
+ host_user ? "pubkey" : "hostbased", geteuid(), audit_username(),
|
2016-03-04 13:33:02 +00:00
|
|
|
+ fp, rv);
|
2015-06-24 12:11:59 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * This will be called when the protocol negotiation fails.
|
|
|
|
+ */
|
|
|
|
+void
|
|
|
|
+audit_unsupported_body(int what)
|
|
|
|
+{
|
|
|
|
+ debug("audit unsupported protocol euid %d type %d", geteuid(), what);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * This will be called on succesfull protocol negotiation.
|
|
|
|
+ */
|
|
|
|
+void
|
|
|
|
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid,
|
|
|
|
+ uid_t uid)
|
|
|
|
+{
|
|
|
|
+ debug("audit protocol negotiation euid %d direction %d cipher %s mac %s compresion %s pfs %s from pid %ld uid %u",
|
|
|
|
+ (unsigned)geteuid(), ctos, enc, mac, compress, pfs, (long)pid,
|
|
|
|
+ (unsigned)uid);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * This will be called on succesfull session key discard
|
|
|
|
+ */
|
|
|
|
+void
|
|
|
|
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+ debug("audit session key discard euid %u direction %d from pid %ld uid %u",
|
|
|
|
+ (unsigned)geteuid(), ctos, (long)pid, (unsigned)uid);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * This will be called on destroy private part of the server key
|
|
|
|
+ */
|
|
|
|
+void
|
|
|
|
+audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+ debug("audit destroy sensitive data euid %d fingerprint %s from pid %ld uid %u",
|
|
|
|
+ geteuid(), fp, (long)pid, (unsigned)uid);
|
|
|
|
}
|
|
|
|
# endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */
|
|
|
|
#endif /* SSH_AUDIT_EVENTS */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/audit.h.audit openssh-7.6p1/audit.h
|
|
|
|
--- openssh-7.6p1/audit.h.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/audit.h 2017-10-04 17:18:32.834505048 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -26,6 +26,7 @@
|
2015-06-24 12:11:59 +00:00
|
|
|
# define _SSH_AUDIT_H
|
|
|
|
|
|
|
|
#include "loginrec.h"
|
|
|
|
+#include "key.h"
|
|
|
|
|
|
|
|
enum ssh_audit_event_type {
|
|
|
|
SSH_LOGIN_EXCEED_MAXTRIES,
|
2018-01-16 15:24:27 +00:00
|
|
|
@@ -43,13 +44,32 @@ enum ssh_audit_event_type {
|
2016-03-04 13:33:02 +00:00
|
|
|
SSH_CONNECTION_ABANDON, /* closed without completing auth */
|
|
|
|
SSH_AUDIT_UNKNOWN
|
2015-06-24 12:11:59 +00:00
|
|
|
};
|
2016-03-04 13:33:02 +00:00
|
|
|
+
|
|
|
|
+enum ssh_audit_kex {
|
|
|
|
+ SSH_AUDIT_UNSUPPORTED_CIPHER,
|
|
|
|
+ SSH_AUDIT_UNSUPPORTED_MAC,
|
|
|
|
+ SSH_AUDIT_UNSUPPORTED_COMPRESSION
|
|
|
|
+};
|
2015-06-24 12:11:59 +00:00
|
|
|
typedef enum ssh_audit_event_type ssh_audit_event_t;
|
|
|
|
|
|
|
|
+int listening_for_clients(void);
|
|
|
|
+
|
|
|
|
void audit_connection_from(const char *, int);
|
|
|
|
void audit_event(ssh_audit_event_t);
|
|
|
|
+void audit_count_session_open(void);
|
|
|
|
void audit_session_open(struct logininfo *);
|
|
|
|
void audit_session_close(struct logininfo *);
|
|
|
|
-void audit_run_command(const char *);
|
|
|
|
+int audit_run_command(const char *);
|
|
|
|
+void audit_end_command(int, const char *);
|
|
|
|
ssh_audit_event_t audit_classify_auth(const char *);
|
2018-01-22 10:15:15 +00:00
|
|
|
+int audit_keyusage(int, char *, int);
|
2015-06-24 12:11:59 +00:00
|
|
|
+void audit_key(int, int *, const Key *);
|
|
|
|
+void audit_unsupported(int);
|
|
|
|
+void audit_kex(int, char *, char *, char *, char *);
|
|
|
|
+void audit_unsupported_body(int);
|
|
|
|
+void audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t);
|
|
|
|
+void audit_session_key_free(int ctos);
|
|
|
|
+void audit_session_key_free_body(int ctos, pid_t, uid_t);
|
|
|
|
+void audit_destroy_sensitive_data(const char *, pid_t, uid_t);
|
|
|
|
|
|
|
|
#endif /* _SSH_AUDIT_H */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/audit-linux.c.audit openssh-7.6p1/audit-linux.c
|
|
|
|
--- openssh-7.6p1/audit-linux.c.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/audit-linux.c 2017-10-04 17:18:32.835505053 +0200
|
2018-01-17 09:08:26 +00:00
|
|
|
@@ -33,27 +33,40 @@
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "audit.h"
|
|
|
|
+#include "key.h"
|
|
|
|
+#include "hostfile.h"
|
|
|
|
+#include "auth.h"
|
2015-01-20 12:18:45 +00:00
|
|
|
+#include "misc.h" /* servconf.h needs misc.h for struct ForwardOptions */
|
2013-04-08 15:17:10 +00:00
|
|
|
+#include "servconf.h"
|
|
|
|
#include "canohost.h"
|
2016-07-26 08:54:13 +00:00
|
|
|
#include "packet.h"
|
|
|
|
-
|
2013-04-08 15:17:10 +00:00
|
|
|
+#include "cipher.h"
|
2016-07-26 08:54:13 +00:00
|
|
|
+#include "channels.h"
|
|
|
|
+#include "session.h"
|
|
|
|
+
|
2014-12-11 13:11:31 +00:00
|
|
|
+#define AUDIT_LOG_SIZE 256
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
|
|
|
+extern ServerOptions options;
|
|
|
|
+extern Authctxt *the_authctxt;
|
|
|
|
+extern u_int utmp_len;
|
2016-07-26 08:54:13 +00:00
|
|
|
const char *audit_username(void);
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
-int
|
2016-07-26 08:54:13 +00:00
|
|
|
-linux_audit_record_event(int uid, const char *username, const char *hostname,
|
|
|
|
- const char *ip, const char *ttyn, int success)
|
2013-04-08 15:17:10 +00:00
|
|
|
+static void
|
2018-01-17 09:08:26 +00:00
|
|
|
+linux_audit_user_logxxx(int uid, const char *username,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ const char *ip, const char *ttyn, int success, int event)
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
|
|
|
int audit_fd, rc, saved_errno;
|
|
|
|
|
2016-07-26 08:54:13 +00:00
|
|
|
if ((audit_fd = audit_open()) < 0) {
|
2013-04-08 15:17:10 +00:00
|
|
|
if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
|
|
errno == EAFNOSUPPORT)
|
|
|
|
- return 1; /* No audit support in kernel */
|
|
|
|
+ return; /* No audit support in kernel */
|
|
|
|
else
|
|
|
|
- return 0; /* Must prevent login */
|
|
|
|
+ goto fatal_report; /* Must prevent login */
|
|
|
|
}
|
|
|
|
- rc = audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN,
|
|
|
|
+ rc = audit_log_acct_message(audit_fd, event,
|
|
|
|
NULL, "login", username ? username : "(unknown)",
|
2018-01-17 09:08:26 +00:00
|
|
|
- username == NULL ? uid : -1, hostname, ip, ttyn, success);
|
|
|
|
+ username == NULL ? uid : -1, NULL, ip, ttyn, success);
|
2013-04-08 15:17:10 +00:00
|
|
|
saved_errno = errno;
|
2018-01-17 09:08:26 +00:00
|
|
|
close(audit_fd);
|
|
|
|
|
2018-01-22 10:15:15 +00:00
|
|
|
@@ -65,9 +78,96 @@ linux_audit_record_event(int uid, const
|
2013-04-08 15:17:10 +00:00
|
|
|
rc = 0;
|
|
|
|
errno = saved_errno;
|
2016-07-26 08:54:13 +00:00
|
|
|
|
|
|
|
- return rc >= 0;
|
2013-04-08 15:17:10 +00:00
|
|
|
+ if (rc < 0) {
|
|
|
|
+fatal_report:
|
|
|
|
+ fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
|
|
|
+ }
|
2016-07-26 08:54:13 +00:00
|
|
|
+}
|
|
|
|
+
|
2013-04-08 15:17:10 +00:00
|
|
|
+static void
|
|
|
|
+linux_audit_user_auth(int uid, const char *username,
|
2018-01-17 09:08:26 +00:00
|
|
|
+ const char *ip, const char *ttyn, int success, int event)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ int audit_fd, rc, saved_errno;
|
|
|
|
+ static const char *event_name[] = {
|
|
|
|
+ "maxtries exceeded",
|
|
|
|
+ "root denied",
|
|
|
|
+ "success",
|
|
|
|
+ "none",
|
|
|
|
+ "password",
|
|
|
|
+ "challenge-response",
|
|
|
|
+ "pubkey",
|
|
|
|
+ "hostbased",
|
|
|
|
+ "gssapi",
|
|
|
|
+ "invalid user",
|
|
|
|
+ "nologin",
|
|
|
|
+ "connection closed",
|
|
|
|
+ "connection abandoned",
|
|
|
|
+ "unknown"
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ audit_fd = audit_open();
|
|
|
|
+ if (audit_fd < 0) {
|
|
|
|
+ if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
|
|
+ errno == EAFNOSUPPORT)
|
|
|
|
+ return; /* No audit support in kernel */
|
|
|
|
+ else
|
|
|
|
+ goto fatal_report; /* Must prevent login */
|
|
|
|
+ }
|
2016-03-04 13:33:02 +00:00
|
|
|
+
|
2013-04-08 15:17:10 +00:00
|
|
|
+ if ((event < 0) || (event > SSH_AUDIT_UNKNOWN))
|
|
|
|
+ event = SSH_AUDIT_UNKNOWN;
|
|
|
|
+
|
|
|
|
+ rc = audit_log_acct_message(audit_fd, AUDIT_USER_AUTH,
|
|
|
|
+ NULL, event_name[event], username ? username : "(unknown)",
|
2018-01-17 09:08:26 +00:00
|
|
|
+ username == NULL ? uid : -1, NULL, ip, ttyn, success);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ saved_errno = errno;
|
|
|
|
+ close(audit_fd);
|
|
|
|
+ /*
|
|
|
|
+ * Do not report error if the error is EPERM and sshd is run as non
|
|
|
|
+ * root user.
|
|
|
|
+ */
|
|
|
|
+ if ((rc == -EPERM) && (geteuid() != 0))
|
|
|
|
+ rc = 0;
|
|
|
|
+ errno = saved_errno;
|
|
|
|
+ if (rc < 0) {
|
|
|
|
+fatal_report:
|
|
|
|
+ fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
2018-01-22 10:15:15 +00:00
|
|
|
+audit_keyusage(int host_user, char *fp, int rv)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ char buf[AUDIT_LOG_SIZE];
|
|
|
|
+ int audit_fd, rc, saved_errno;
|
|
|
|
+
|
|
|
|
+ audit_fd = audit_open();
|
|
|
|
+ if (audit_fd < 0) {
|
|
|
|
+ if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
|
|
+ errno == EAFNOSUPPORT)
|
|
|
|
+ return 1; /* No audit support in kernel */
|
2016-03-04 13:33:02 +00:00
|
|
|
+ else
|
2013-04-08 15:17:10 +00:00
|
|
|
+ return 0; /* Must prevent login */
|
|
|
|
+ }
|
2018-01-22 11:18:45 +00:00
|
|
|
+ snprintf(buf, sizeof(buf), "%s_auth grantors=auth-key", host_user ? "pubkey" : "hostbased");
|
2013-04-08 15:17:10 +00:00
|
|
|
+ rc = audit_log_acct_message(audit_fd, AUDIT_USER_AUTH, NULL,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ buf, audit_username(), -1, NULL, ssh_remote_ipaddr(active_state), NULL, rv);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ if ((rc < 0) && ((rc != -1) || (getuid() == 0)))
|
|
|
|
+ goto out;
|
2018-01-22 10:15:15 +00:00
|
|
|
+ snprintf(buf, sizeof(buf), "op=negotiate kind=auth-key fp=%s", fp);
|
|
|
|
+ rc = audit_log_user_message(audit_fd, AUDIT_CRYPTO_KEY_USER, buf, NULL,
|
|
|
|
+ ssh_remote_ipaddr(active_state), NULL, rv);
|
2013-04-08 15:17:10 +00:00
|
|
|
+out:
|
|
|
|
+ saved_errno = errno;
|
|
|
|
+ audit_close(audit_fd);
|
|
|
|
+ errno = saved_errno;
|
|
|
|
+ /* do not report error if the error is EPERM and sshd is run as non root user */
|
|
|
|
+ return (rc >= 0) || ((rc == -EPERM) && (getuid() != 0));
|
2016-07-26 08:54:13 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
+static int user_login_count = 0;
|
|
|
|
+
|
|
|
|
/* Below is the sshd audit API code */
|
|
|
|
|
|
|
|
void
|
2018-01-17 09:08:26 +00:00
|
|
|
@@ -76,24 +177,55 @@ audit_connection_from(const char *host,
|
2013-04-08 15:17:10 +00:00
|
|
|
/* not implemented */
|
2016-07-26 08:54:13 +00:00
|
|
|
}
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
-void
|
|
|
|
+int
|
|
|
|
audit_run_command(const char *command)
|
|
|
|
{
|
|
|
|
- /* not implemented */
|
2016-03-04 13:33:02 +00:00
|
|
|
+ if (!user_login_count++)
|
2018-01-17 09:08:26 +00:00
|
|
|
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL,
|
|
|
|
+ ssh_remote_ipaddr(active_state),
|
|
|
|
+ "ssh", 1, AUDIT_USER_LOGIN);
|
|
|
|
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL,
|
|
|
|
+ ssh_remote_ipaddr(active_state),
|
|
|
|
+ "ssh", 1, AUDIT_USER_START);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_end_command(int handle, const char *command)
|
|
|
|
+{
|
2018-01-17 09:08:26 +00:00
|
|
|
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL,
|
|
|
|
+ ssh_remote_ipaddr(active_state),
|
|
|
|
+ "ssh", 1, AUDIT_USER_END);
|
2016-03-04 13:33:02 +00:00
|
|
|
+ if (user_login_count && !--user_login_count)
|
2018-01-17 09:08:26 +00:00
|
|
|
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL,
|
|
|
|
+ ssh_remote_ipaddr(active_state),
|
|
|
|
+ "ssh", 1, AUDIT_USER_LOGOUT);
|
2013-04-08 15:17:10 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_count_session_open(void)
|
|
|
|
+{
|
|
|
|
+ user_login_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
audit_session_open(struct logininfo *li)
|
|
|
|
{
|
2016-07-26 08:54:13 +00:00
|
|
|
- if (linux_audit_record_event(li->uid, NULL, li->hostname, NULL,
|
|
|
|
- li->line, 1) == 0)
|
2013-04-08 15:17:10 +00:00
|
|
|
- fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
2016-03-04 13:33:02 +00:00
|
|
|
+ if (!user_login_count++)
|
2013-04-08 15:17:10 +00:00
|
|
|
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
2018-01-17 09:08:26 +00:00
|
|
|
+ li->line, 1, AUDIT_USER_LOGIN);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
2018-01-17 09:08:26 +00:00
|
|
|
+ li->line, 1, AUDIT_USER_START);
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
audit_session_close(struct logininfo *li)
|
|
|
|
{
|
|
|
|
- /* not implemented */
|
|
|
|
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
2018-01-17 09:08:26 +00:00
|
|
|
+ li->line, 1, AUDIT_USER_END);
|
2016-03-04 13:33:02 +00:00
|
|
|
+ if (user_login_count && !--user_login_count)
|
2013-04-08 15:17:10 +00:00
|
|
|
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
2018-01-17 09:08:26 +00:00
|
|
|
+ li->line, 1, AUDIT_USER_LOGOUT);
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-01-22 11:21:00 +00:00
|
|
|
@@ -102,25 +231,155 @@ audit_event(ssh_audit_event_t event)
|
2018-01-22 10:16:18 +00:00
|
|
|
struct ssh *ssh = active_state; /* XXX */
|
2016-07-26 08:54:13 +00:00
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
switch(event) {
|
2018-01-22 10:16:18 +00:00
|
|
|
- case SSH_AUTH_SUCCESS:
|
2013-04-08 15:17:10 +00:00
|
|
|
- case SSH_CONNECTION_CLOSE:
|
|
|
|
case SSH_NOLOGIN:
|
|
|
|
- case SSH_LOGIN_EXCEED_MAXTRIES:
|
|
|
|
case SSH_LOGIN_ROOT_DENIED:
|
2018-01-17 09:08:26 +00:00
|
|
|
+ linux_audit_user_auth(-1, audit_username(),
|
2016-07-26 08:54:13 +00:00
|
|
|
+ ssh_remote_ipaddr(ssh), "ssh", 0, event);
|
2018-01-17 09:08:26 +00:00
|
|
|
+ linux_audit_user_logxxx(-1, audit_username(),
|
2016-07-26 08:54:13 +00:00
|
|
|
+ ssh_remote_ipaddr(ssh), "ssh", 0, AUDIT_USER_LOGIN);
|
2013-04-08 15:17:10 +00:00
|
|
|
break;
|
2018-01-22 11:21:00 +00:00
|
|
|
- case SSH_AUTH_FAIL_NONE:
|
2013-04-08 15:17:10 +00:00
|
|
|
case SSH_AUTH_FAIL_PASSWD:
|
2018-01-22 11:21:00 +00:00
|
|
|
+ if (options.use_pam)
|
|
|
|
+ break;
|
|
|
|
+ case SSH_LOGIN_EXCEED_MAXTRIES:
|
2013-04-08 15:17:10 +00:00
|
|
|
case SSH_AUTH_FAIL_KBDINT:
|
|
|
|
case SSH_AUTH_FAIL_PUBKEY:
|
|
|
|
case SSH_AUTH_FAIL_HOSTBASED:
|
|
|
|
case SSH_AUTH_FAIL_GSSAPI:
|
2018-01-17 09:08:26 +00:00
|
|
|
+ linux_audit_user_auth(-1, audit_username(),
|
2016-07-26 08:54:13 +00:00
|
|
|
+ ssh_remote_ipaddr(ssh), "ssh", 0, event);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SSH_CONNECTION_CLOSE:
|
|
|
|
+ if (user_login_count) {
|
|
|
|
+ while (user_login_count--)
|
2016-07-26 08:54:13 +00:00
|
|
|
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL,
|
2018-01-17 09:08:26 +00:00
|
|
|
+ ssh_remote_ipaddr(ssh),
|
|
|
|
+ "ssh", 1, AUDIT_USER_END);
|
2016-07-26 08:54:13 +00:00
|
|
|
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL,
|
2018-01-17 09:08:26 +00:00
|
|
|
+ ssh_remote_ipaddr(ssh),
|
|
|
|
+ "ssh", 1, AUDIT_USER_LOGOUT);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SSH_CONNECTION_ABANDON:
|
|
|
|
case SSH_INVALID_USER:
|
|
|
|
- linux_audit_record_event(-1, audit_username(), NULL,
|
2016-07-26 08:54:13 +00:00
|
|
|
- ssh_remote_ipaddr(ssh), "sshd", 0);
|
2018-01-17 09:08:26 +00:00
|
|
|
+ linux_audit_user_logxxx(-1, audit_username(),
|
2016-07-26 08:54:13 +00:00
|
|
|
+ ssh_remote_ipaddr(ssh), "ssh", 0, AUDIT_USER_LOGIN);
|
2013-04-08 15:17:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-07-26 08:54:13 +00:00
|
|
|
debug("%s: unhandled event %d", __func__, event);
|
|
|
|
break;
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-26 08:54:13 +00:00
|
|
|
+
|
2013-04-08 15:17:10 +00:00
|
|
|
+void
|
|
|
|
+audit_unsupported_body(int what)
|
|
|
|
+{
|
|
|
|
+#ifdef AUDIT_CRYPTO_SESSION
|
|
|
|
+ char buf[AUDIT_LOG_SIZE];
|
|
|
|
+ const static char *name[] = { "cipher", "mac", "comp" };
|
|
|
|
+ char *s;
|
|
|
|
+ int audit_fd;
|
|
|
|
+
|
|
|
|
+ snprintf(buf, sizeof(buf), "op=unsupported-%s direction=? cipher=? ksize=? rport=%d laddr=%s lport=%d ",
|
2016-07-26 08:54:13 +00:00
|
|
|
+ name[what], ssh_remote_port(active_state), (s = get_local_ipaddr(packet_get_connection_in())),
|
|
|
|
+ ssh_local_port(active_state));
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(s);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ audit_fd = audit_open();
|
|
|
|
+ if (audit_fd < 0)
|
|
|
|
+ /* no problem, the next instruction will be fatal() */
|
|
|
|
+ return;
|
|
|
|
+ audit_log_user_message(audit_fd, AUDIT_CRYPTO_SESSION,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ buf, NULL, ssh_remote_ipaddr(active_state), NULL, 0);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ audit_close(audit_fd);
|
|
|
|
+#endif
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const static char *direction[] = { "from-server", "from-client", "both" };
|
|
|
|
+
|
|
|
|
+void
|
2015-01-20 12:18:45 +00:00
|
|
|
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid,
|
2013-04-08 15:17:10 +00:00
|
|
|
+ uid_t uid)
|
|
|
|
+{
|
|
|
|
+#ifdef AUDIT_CRYPTO_SESSION
|
|
|
|
+ char buf[AUDIT_LOG_SIZE];
|
|
|
|
+ int audit_fd, audit_ok;
|
2015-08-13 15:43:12 +00:00
|
|
|
+ const struct sshcipher *cipher = cipher_by_name(enc);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ char *s;
|
|
|
|
+
|
2015-01-20 12:18:45 +00:00
|
|
|
+ snprintf(buf, sizeof(buf), "op=start direction=%s cipher=%s ksize=%d mac=%s pfs=%s spid=%jd suid=%jd rport=%d laddr=%s lport=%d ",
|
|
|
|
+ direction[ctos], enc, cipher ? 8 * cipher->key_len : 0, mac, pfs,
|
2013-04-08 15:17:10 +00:00
|
|
|
+ (intmax_t)pid, (intmax_t)uid,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ ssh_remote_port(active_state), (s = get_local_ipaddr(packet_get_connection_in())), ssh_local_port(active_state));
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(s);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ audit_fd = audit_open();
|
|
|
|
+ if (audit_fd < 0) {
|
|
|
|
+ if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
|
|
+ errno == EAFNOSUPPORT)
|
|
|
|
+ return; /* No audit support in kernel */
|
2016-03-04 13:33:02 +00:00
|
|
|
+ else
|
2013-04-08 15:17:10 +00:00
|
|
|
+ fatal("cannot open audit"); /* Must prevent login */
|
|
|
|
+ }
|
|
|
|
+ audit_ok = audit_log_user_message(audit_fd, AUDIT_CRYPTO_SESSION,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ buf, NULL, ssh_remote_ipaddr(active_state), NULL, 1);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ audit_close(audit_fd);
|
|
|
|
+ /* do not abort if the error is EPERM and sshd is run as non root user */
|
|
|
|
+ if ((audit_ok < 0) && ((audit_ok != -1) || (getuid() == 0)))
|
|
|
|
+ fatal("cannot write into audit"); /* Must prevent login */
|
|
|
|
+#endif
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+ char buf[AUDIT_LOG_SIZE];
|
|
|
|
+ int audit_fd, audit_ok;
|
|
|
|
+ char *s;
|
|
|
|
+
|
|
|
|
+ snprintf(buf, sizeof(buf), "op=destroy kind=session fp=? direction=%s spid=%jd suid=%jd rport=%d laddr=%s lport=%d ",
|
|
|
|
+ direction[ctos], (intmax_t)pid, (intmax_t)uid,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ ssh_remote_port(active_state),
|
2013-04-08 15:17:10 +00:00
|
|
|
+ (s = get_local_ipaddr(packet_get_connection_in())),
|
2016-07-26 08:54:13 +00:00
|
|
|
+ ssh_local_port(active_state));
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(s);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ audit_fd = audit_open();
|
|
|
|
+ if (audit_fd < 0) {
|
|
|
|
+ if (errno != EINVAL && errno != EPROTONOSUPPORT &&
|
2015-06-24 12:11:59 +00:00
|
|
|
+ errno != EAFNOSUPPORT)
|
|
|
|
+ error("cannot open audit");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ audit_ok = audit_log_user_message(audit_fd, AUDIT_CRYPTO_KEY_USER,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ buf, NULL, ssh_remote_ipaddr(active_state), NULL, 1);
|
2015-06-24 12:11:59 +00:00
|
|
|
+ audit_close(audit_fd);
|
|
|
|
+ /* do not abort if the error is EPERM and sshd is run as non root user */
|
|
|
|
+ if ((audit_ok < 0) && ((audit_ok != -1) || (getuid() == 0)))
|
|
|
|
+ error("cannot write into audit");
|
2013-04-08 15:17:10 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
|
|
+{
|
2015-06-24 12:11:59 +00:00
|
|
|
+ char buf[AUDIT_LOG_SIZE];
|
|
|
|
+ int audit_fd, audit_ok;
|
|
|
|
+
|
|
|
|
+ snprintf(buf, sizeof(buf), "op=destroy kind=server fp=%s direction=? spid=%jd suid=%jd ",
|
|
|
|
+ fp, (intmax_t)pid, (intmax_t)uid);
|
|
|
|
+ audit_fd = audit_open();
|
|
|
|
+ if (audit_fd < 0) {
|
|
|
|
+ if (errno != EINVAL && errno != EPROTONOSUPPORT &&
|
|
|
|
+ errno != EAFNOSUPPORT)
|
|
|
|
+ error("cannot open audit");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ audit_ok = audit_log_user_message(audit_fd, AUDIT_CRYPTO_KEY_USER,
|
|
|
|
+ buf, NULL,
|
2016-07-26 08:54:13 +00:00
|
|
|
+ listening_for_clients() ? NULL : ssh_remote_ipaddr(active_state),
|
2015-06-24 12:11:59 +00:00
|
|
|
+ NULL, 1);
|
|
|
|
+ audit_close(audit_fd);
|
|
|
|
+ /* do not abort if the error is EPERM and sshd is run as non root user */
|
|
|
|
+ if ((audit_ok < 0) && ((audit_ok != -1) || (getuid() == 0)))
|
|
|
|
+ error("cannot write into audit");
|
|
|
|
+}
|
|
|
|
#endif /* USE_LINUX_AUDIT */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/auditstub.c.audit openssh-7.6p1/auditstub.c
|
|
|
|
--- openssh-7.6p1/auditstub.c.audit 2017-10-04 17:18:32.835505053 +0200
|
|
|
|
+++ openssh-7.6p1/auditstub.c 2017-10-04 17:18:32.835505053 +0200
|
2013-04-08 15:17:10 +00:00
|
|
|
@@ -0,0 +1,50 @@
|
|
|
|
+/* $Id: auditstub.c,v 1.1 jfch Exp $ */
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Copyright 2010 Red Hat, Inc. All rights reserved.
|
|
|
|
+ * Use is subject to license terms.
|
|
|
|
+ *
|
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
|
+ * modification, are permitted provided that the following conditions
|
|
|
|
+ * are met:
|
|
|
|
+ * 1. Redistributions of source code must retain the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer.
|
|
|
|
+ * 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
|
+ *
|
|
|
|
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
+ *
|
|
|
|
+ * Red Hat author: Jan F. Chadima <jchadima@redhat.com>
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_unsupported(int n)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
2015-01-20 12:18:45 +00:00
|
|
|
+audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_session_key_free(int ctos)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+}
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/auth2.c.audit openssh-7.6p1/auth2.c
|
|
|
|
--- openssh-7.6p1/auth2.c.audit 2017-10-04 17:18:32.746504598 +0200
|
|
|
|
+++ openssh-7.6p1/auth2.c 2017-10-04 17:18:32.835505053 +0200
|
|
|
|
@@ -255,9 +255,6 @@ input_userauth_request(int type, u_int32
|
2015-06-24 12:11:59 +00:00
|
|
|
} else {
|
2017-03-20 14:55:43 +00:00
|
|
|
/* Invalid user, fake password information */
|
2015-06-24 12:11:59 +00:00
|
|
|
authctxt->pw = fakepw();
|
2014-11-03 15:30:07 +00:00
|
|
|
-#ifdef SSH_AUDIT_EVENTS
|
2015-06-24 12:11:59 +00:00
|
|
|
- PRIVSEP(audit_event(SSH_INVALID_USER));
|
|
|
|
-#endif
|
|
|
|
}
|
|
|
|
#ifdef USE_PAM
|
|
|
|
if (options.use_pam)
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/auth2-hostbased.c.audit openssh-7.6p1/auth2-hostbased.c
|
|
|
|
--- openssh-7.6p1/auth2-hostbased.c.audit 2017-10-04 17:18:32.683504276 +0200
|
|
|
|
+++ openssh-7.6p1/auth2-hostbased.c 2017-10-04 17:18:32.835505053 +0200
|
|
|
|
@@ -152,7 +152,7 @@ userauth_hostbased(struct ssh *ssh)
|
2013-04-08 15:17:10 +00:00
|
|
|
/* test for allowed key and correct signature */
|
|
|
|
authenticated = 0;
|
|
|
|
if (PRIVSEP(hostbased_key_allowed(authctxt->pw, cuser, chost, key)) &&
|
2017-09-26 12:04:45 +00:00
|
|
|
- PRIVSEP(sshkey_verify(key, sig, slen,
|
|
|
|
+ PRIVSEP(hostbased_key_verify(key, sig, slen,
|
|
|
|
sshbuf_ptr(b), sshbuf_len(b), ssh->compat)) == 0)
|
2013-04-08 15:17:10 +00:00
|
|
|
authenticated = 1;
|
2017-09-26 12:04:45 +00:00
|
|
|
|
|
|
|
@@ -169,6 +169,19 @@ done:
|
2013-04-08 15:17:10 +00:00
|
|
|
return authenticated;
|
|
|
|
}
|
|
|
|
|
|
|
|
+int
|
2017-09-26 12:04:45 +00:00
|
|
|
+hostbased_key_verify(const struct sshkey *key, const u_char *sig, size_t slen,
|
|
|
|
+ const u_char *data, size_t datalen, u_int compat)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ int rv;
|
|
|
|
+
|
2017-09-26 12:04:45 +00:00
|
|
|
+ rv = sshkey_verify(key, sig, slen, data, datalen, compat);
|
2013-04-08 15:17:10 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ audit_key(0, &rv, key);
|
|
|
|
+#endif
|
|
|
|
+ return rv;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* return 1 if given hostkey is allowed */
|
|
|
|
int
|
|
|
|
hostbased_key_allowed(struct passwd *pw, const char *cuser, char *chost,
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/auth2-pubkey.c.audit openssh-7.6p1/auth2-pubkey.c
|
|
|
|
--- openssh-7.6p1/auth2-pubkey.c.audit 2017-10-04 17:18:32.828505018 +0200
|
|
|
|
+++ openssh-7.6p1/auth2-pubkey.c 2017-10-04 17:18:32.835505053 +0200
|
|
|
|
@@ -206,7 +206,7 @@ userauth_pubkey(struct ssh *ssh)
|
2013-04-08 15:17:10 +00:00
|
|
|
/* test for correct signature */
|
|
|
|
authenticated = 0;
|
2015-06-24 12:11:59 +00:00
|
|
|
if (PRIVSEP(user_key_allowed(authctxt->pw, key, 1)) &&
|
2017-09-26 12:04:45 +00:00
|
|
|
- PRIVSEP(sshkey_verify(key, sig, slen, sshbuf_ptr(b),
|
|
|
|
+ PRIVSEP(user_key_verify(key, sig, slen, sshbuf_ptr(b),
|
|
|
|
sshbuf_len(b), ssh->compat)) == 0) {
|
2013-04-08 15:17:10 +00:00
|
|
|
authenticated = 1;
|
2017-09-26 12:04:45 +00:00
|
|
|
}
|
|
|
|
@@ -250,6 +250,19 @@ done:
|
|
|
|
return authenticated;
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+int
|
2017-09-26 12:04:45 +00:00
|
|
|
+user_key_verify(const struct sshkey *key, const u_char *sig, size_t slen,
|
|
|
|
+ const u_char *data, size_t datalen, u_int compat)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ int rv;
|
|
|
|
+
|
2017-09-26 12:04:45 +00:00
|
|
|
+ rv = sshkey_verify(key, sig, slen, data, datalen, compat);
|
2013-04-08 15:17:10 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ audit_key(1, &rv, key);
|
|
|
|
+#endif
|
|
|
|
+ return rv;
|
|
|
|
+}
|
|
|
|
+
|
2017-09-26 12:04:45 +00:00
|
|
|
static int
|
|
|
|
match_principals_option(const char *principal_list, struct sshkey_cert *cert)
|
|
|
|
{
|
|
|
|
diff -up openssh-7.6p1/auth.c.audit openssh-7.6p1/auth.c
|
|
|
|
--- openssh-7.6p1/auth.c.audit 2017-10-04 17:18:32.746504598 +0200
|
|
|
|
+++ openssh-7.6p1/auth.c 2017-10-04 17:18:32.835505053 +0200
|
2018-01-22 11:22:17 +00:00
|
|
|
@@ -360,7 +360,7 @@ auth_log(Authctxt *authctxt, int authent
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
- if (authenticated == 0 && !authctxt->postponed)
|
|
|
|
+ if (authenticated == 0 && !authctxt->postponed && !partial)
|
|
|
|
audit_event(audit_classify_auth(method));
|
|
|
|
#endif
|
|
|
|
}
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -599,9 +599,6 @@ getpwnamallow(const char *user)
|
2015-06-24 12:11:59 +00:00
|
|
|
record_failed_login(user,
|
2016-07-25 14:21:15 +00:00
|
|
|
auth_get_canonical_hostname(ssh, options.use_dns), "ssh");
|
2015-06-24 12:11:59 +00:00
|
|
|
#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
-#ifdef SSH_AUDIT_EVENTS
|
2015-06-24 12:11:59 +00:00
|
|
|
- audit_event(SSH_INVALID_USER);
|
|
|
|
-#endif /* SSH_AUDIT_EVENTS */
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
if (!allowed_user(pw))
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/auth.h.audit openssh-7.6p1/auth.h
|
|
|
|
--- openssh-7.6p1/auth.h.audit 2017-10-04 17:18:32.768504711 +0200
|
|
|
|
+++ openssh-7.6p1/auth.h 2017-10-04 17:18:32.836505059 +0200
|
|
|
|
@@ -198,6 +198,7 @@ struct passwd * getpwnamallow(const char
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
char *expand_authorized_keys(const char *, struct passwd *pw);
|
|
|
|
char *authorized_principals_file(struct passwd *);
|
2017-09-26 12:04:45 +00:00
|
|
|
+int user_key_verify(const struct sshkey *, const u_char *, size_t, const u_char *, size_t, u_int);
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
FILE *auth_openkeyfile(const char *, struct passwd *, int);
|
|
|
|
FILE *auth_openprincipals(const char *, struct passwd *, int);
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -217,6 +218,7 @@ struct sshkey *get_hostkey_private_by_ty
|
|
|
|
int get_hostkey_index(struct sshkey *, int, struct ssh *);
|
|
|
|
int sshd_hostkey_sign(struct sshkey *, struct sshkey *, u_char **,
|
|
|
|
size_t *, const u_char *, size_t, const char *, u_int);
|
|
|
|
+int hostbased_key_verify(const struct sshkey *, const u_char *, size_t, const u_char *, size_t, u_int);
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
/* debug messages during authentication */
|
|
|
|
void auth_debug_add(const char *fmt,...) __attribute__((format(printf, 1, 2)));
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/cipher.c.audit openssh-7.6p1/cipher.c
|
|
|
|
--- openssh-7.6p1/cipher.c.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/cipher.c 2017-10-04 17:18:32.836505059 +0200
|
|
|
|
@@ -61,25 +61,6 @@ struct sshcipher_ctx {
|
2017-01-02 14:42:13 +00:00
|
|
|
const struct sshcipher *cipher;
|
|
|
|
};
|
2013-04-08 15:17:10 +00:00
|
|
|
|
2015-01-20 12:18:45 +00:00
|
|
|
-struct sshcipher {
|
2014-07-09 19:08:53 +00:00
|
|
|
- char *name;
|
|
|
|
- u_int block_size;
|
|
|
|
- u_int key_len;
|
|
|
|
- u_int iv_len; /* defaults to block_size */
|
|
|
|
- u_int auth_len;
|
|
|
|
- u_int flags;
|
|
|
|
-#define CFLAG_CBC (1<<0)
|
|
|
|
-#define CFLAG_CHACHAPOLY (1<<1)
|
2015-01-20 12:18:45 +00:00
|
|
|
-#define CFLAG_AESCTR (1<<2)
|
|
|
|
-#define CFLAG_NONE (1<<3)
|
2017-09-26 12:04:45 +00:00
|
|
|
-#define CFLAG_INTERNAL CFLAG_NONE /* Don't use "none" for packets */
|
2015-01-20 12:18:45 +00:00
|
|
|
-#ifdef WITH_OPENSSL
|
2014-07-09 19:08:53 +00:00
|
|
|
- const EVP_CIPHER *(*evptype)(void);
|
2015-01-20 12:18:45 +00:00
|
|
|
-#else
|
|
|
|
- void *ignored;
|
|
|
|
-#endif
|
2014-07-09 19:08:53 +00:00
|
|
|
-};
|
|
|
|
-
|
2015-01-20 12:18:45 +00:00
|
|
|
static const struct sshcipher ciphers[] = {
|
2017-09-26 12:04:45 +00:00
|
|
|
#ifdef WITH_OPENSSL
|
|
|
|
{ "3des-cbc", 8, 24, 0, 0, CFLAG_CBC, EVP_des_ede3_cbc },
|
2017-11-24 13:49:00 +00:00
|
|
|
@@ -409,7 +409,7 @@ cipher_get_length(struct sshcipher_ctx *
|
|
|
|
void
|
|
|
|
cipher_free(struct sshcipher_ctx *cc)
|
|
|
|
{
|
|
|
|
- if (cc == NULL)
|
|
|
|
+ if (cc == NULL || cc->cipher == NULL)
|
|
|
|
return;
|
|
|
|
if ((cc->cipher->flags & CFLAG_CHACHAPOLY) != 0)
|
|
|
|
explicit_bzero(&cc->cp_ctx, sizeof(cc->cp_ctx));
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/cipher.h.audit openssh-7.6p1/cipher.h
|
|
|
|
--- openssh-7.6p1/cipher.h.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/cipher.h 2017-10-04 17:18:32.836505059 +0200
|
|
|
|
@@ -45,7 +45,25 @@
|
2015-01-20 12:18:45 +00:00
|
|
|
#define CIPHER_ENCRYPT 1
|
|
|
|
#define CIPHER_DECRYPT 0
|
2013-04-08 15:17:10 +00:00
|
|
|
|
2015-01-20 12:18:45 +00:00
|
|
|
-struct sshcipher;
|
2017-09-26 12:04:45 +00:00
|
|
|
+struct sshcipher {
|
2013-04-08 15:17:10 +00:00
|
|
|
+ char *name;
|
|
|
|
+ u_int block_size;
|
|
|
|
+ u_int key_len;
|
|
|
|
+ u_int iv_len; /* defaults to block_size */
|
|
|
|
+ u_int auth_len;
|
2014-07-08 13:52:24 +00:00
|
|
|
+ u_int flags;
|
|
|
|
+#define CFLAG_CBC (1<<0)
|
|
|
|
+#define CFLAG_CHACHAPOLY (1<<1)
|
2015-01-20 12:18:45 +00:00
|
|
|
+#define CFLAG_AESCTR (1<<2)
|
|
|
|
+#define CFLAG_NONE (1<<3)
|
2017-09-26 12:04:45 +00:00
|
|
|
+#define CFLAG_INTERNAL CFLAG_NONE /* Don't use "none" for packets */
|
2015-01-20 12:18:45 +00:00
|
|
|
+#ifdef WITH_OPENSSL
|
2013-04-08 15:17:10 +00:00
|
|
|
+ const EVP_CIPHER *(*evptype)(void);
|
2015-01-20 12:18:45 +00:00
|
|
|
+#else
|
|
|
|
+ void *ignored;
|
|
|
|
+#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
+};
|
2017-09-26 12:04:45 +00:00
|
|
|
+
|
2017-01-02 14:42:13 +00:00
|
|
|
struct sshcipher_ctx;
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
const struct sshcipher *cipher_by_name(const char *);
|
|
|
|
diff -up openssh-7.6p1/kex.c.audit openssh-7.6p1/kex.c
|
|
|
|
--- openssh-7.6p1/kex.c.audit 2017-10-04 17:18:32.822504987 +0200
|
|
|
|
+++ openssh-7.6p1/kex.c 2017-10-04 17:18:32.836505059 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -54,6 +54,7 @@
|
2015-03-20 13:56:04 +00:00
|
|
|
#include "ssherr.h"
|
|
|
|
#include "sshbuf.h"
|
2014-07-08 13:52:24 +00:00
|
|
|
#include "digest.h"
|
2013-04-08 15:17:10 +00:00
|
|
|
+#include "audit.h"
|
|
|
|
|
2014-07-08 13:52:24 +00:00
|
|
|
#ifdef GSSAPI
|
|
|
|
#include "ssh-gss.h"
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -692,8 +693,12 @@ choose_enc(struct sshenc *enc, char *cli
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
|
|
|
char *name = match_list(client, server, NULL);
|
2015-03-20 13:56:04 +00:00
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
- if (name == NULL)
|
|
|
|
+ if (name == NULL) {
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2016-03-04 13:33:02 +00:00
|
|
|
+ audit_unsupported(SSH_AUDIT_UNSUPPORTED_CIPHER);
|
2013-04-08 15:17:10 +00:00
|
|
|
+#endif
|
2015-03-20 13:56:04 +00:00
|
|
|
return SSH_ERR_NO_CIPHER_ALG_MATCH;
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
2017-03-20 14:55:43 +00:00
|
|
|
if ((enc->cipher = cipher_by_name(name)) == NULL) {
|
|
|
|
free(name);
|
2015-03-20 13:56:04 +00:00
|
|
|
return SSH_ERR_INTERNAL_ERROR;
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -713,8 +718,12 @@ choose_mac(struct ssh *ssh, struct sshma
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
|
|
|
char *name = match_list(client, server, NULL);
|
2015-03-20 13:56:04 +00:00
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
- if (name == NULL)
|
|
|
|
+ if (name == NULL) {
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2016-03-04 13:33:02 +00:00
|
|
|
+ audit_unsupported(SSH_AUDIT_UNSUPPORTED_MAC);
|
2013-04-08 15:17:10 +00:00
|
|
|
+#endif
|
2015-03-20 13:56:04 +00:00
|
|
|
return SSH_ERR_NO_MAC_ALG_MATCH;
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
2017-03-20 14:55:43 +00:00
|
|
|
if (mac_setup(mac, name) < 0) {
|
|
|
|
free(name);
|
2015-03-20 13:56:04 +00:00
|
|
|
return SSH_ERR_INTERNAL_ERROR;
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -733,8 +742,12 @@ choose_comp(struct sshcomp *comp, char *
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
|
|
|
char *name = match_list(client, server, NULL);
|
2015-03-20 13:56:04 +00:00
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
- if (name == NULL)
|
|
|
|
+ if (name == NULL) {
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2016-03-04 13:33:02 +00:00
|
|
|
+ audit_unsupported(SSH_AUDIT_UNSUPPORTED_COMPRESSION);
|
2013-04-08 15:17:10 +00:00
|
|
|
+#endif
|
2015-03-20 13:56:04 +00:00
|
|
|
return SSH_ERR_NO_COMPRESS_ALG_MATCH;
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
|
|
|
if (strcmp(name, "zlib@openssh.com") == 0) {
|
|
|
|
comp->type = COMP_DELAYED;
|
|
|
|
} else if (strcmp(name, "zlib") == 0) {
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -904,6 +917,10 @@ kex_choose_conf(struct ssh *ssh)
|
2017-01-02 14:42:13 +00:00
|
|
|
dh_need = MAXIMUM(dh_need, newkeys->enc.block_size);
|
|
|
|
dh_need = MAXIMUM(dh_need, newkeys->enc.iv_len);
|
|
|
|
dh_need = MAXIMUM(dh_need, newkeys->mac.key_len);
|
2015-01-20 12:18:45 +00:00
|
|
|
+ debug("kex: %s need=%d dh_need=%d", kex->name, need, dh_need);
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ audit_kex(mode, newkeys->enc.name, newkeys->mac.name, newkeys->comp.name, kex->name);
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
/* XXX need runden? */
|
|
|
|
kex->we_need = need;
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1037,3 +1054,33 @@ dump_digest(char *msg, u_char *digest, i
|
2015-03-20 13:56:04 +00:00
|
|
|
sshbuf_dump_data(digest, len, stderr);
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
+
|
|
|
|
+static void
|
2015-03-20 13:56:04 +00:00
|
|
|
+enc_destroy(struct sshenc *enc)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ if (enc == NULL)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (enc->key) {
|
|
|
|
+ memset(enc->key, 0, enc->key_len);
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(enc->key);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (enc->iv) {
|
2016-02-19 13:42:33 +00:00
|
|
|
+ memset(enc->iv, 0, enc->iv_len);
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(enc->iv);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ memset(enc, 0, sizeof(*enc));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
2015-03-20 13:56:04 +00:00
|
|
|
+newkeys_destroy(struct newkeys *newkeys)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ if (newkeys == NULL)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ enc_destroy(&newkeys->enc);
|
|
|
|
+ mac_destroy(&newkeys->mac);
|
|
|
|
+ memset(&newkeys->comp, 0, sizeof(newkeys->comp));
|
|
|
|
+}
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/kex.h.audit openssh-7.6p1/kex.h
|
|
|
|
--- openssh-7.6p1/kex.h.audit 2017-10-04 17:18:32.822504987 +0200
|
|
|
|
+++ openssh-7.6p1/kex.h 2017-10-04 17:18:32.836505059 +0200
|
|
|
|
@@ -219,6 +219,8 @@ int kexgss_client(struct ssh *);
|
2015-03-20 13:56:04 +00:00
|
|
|
int kexgss_server(struct ssh *);
|
2014-07-08 13:52:24 +00:00
|
|
|
#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
|
2015-03-20 13:56:04 +00:00
|
|
|
+void newkeys_destroy(struct newkeys *newkeys);
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
2016-07-25 14:21:15 +00:00
|
|
|
int kex_dh_hash(int, const char *, const char *,
|
2015-03-20 13:56:04 +00:00
|
|
|
const u_char *, size_t, const u_char *, size_t, const u_char *, size_t,
|
|
|
|
const BIGNUM *, const BIGNUM *, const BIGNUM *, u_char *, size_t *);
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/key.h.audit openssh-7.6p1/key.h
|
|
|
|
--- openssh-7.6p1/key.h.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/key.h 2017-10-04 17:18:32.836505059 +0200
|
|
|
|
@@ -43,6 +43,7 @@ typedef struct sshkey Key;
|
|
|
|
#define key_ssh_name_plain sshkey_ssh_name_plain
|
|
|
|
#define key_type_from_name sshkey_type_from_name
|
2015-01-20 12:18:45 +00:00
|
|
|
#define key_is_cert sshkey_is_cert
|
|
|
|
+#define key_is_private sshkey_is_private
|
|
|
|
#define key_type_plain sshkey_type_plain
|
2017-09-26 12:04:45 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
diff -up openssh-7.6p1/mac.c.audit openssh-7.6p1/mac.c
|
|
|
|
--- openssh-7.6p1/mac.c.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/mac.c 2017-10-04 17:18:32.836505059 +0200
|
|
|
|
@@ -242,6 +242,20 @@ mac_clear(struct sshmac *mac)
|
2013-04-08 15:17:10 +00:00
|
|
|
mac->umac_ctx = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
+void
|
2015-03-20 13:56:04 +00:00
|
|
|
+mac_destroy(struct sshmac *mac)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ if (mac == NULL)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (mac->key) {
|
|
|
|
+ memset(mac->key, 0, mac->key_len);
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(mac->key);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ memset(mac, 0, sizeof(*mac));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* XXX copied from ciphers_valid */
|
|
|
|
#define MAC_SEP ","
|
|
|
|
int
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/mac.h.audit openssh-7.6p1/mac.h
|
|
|
|
--- openssh-7.6p1/mac.h.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/mac.h 2017-10-04 17:18:32.837505064 +0200
|
2016-07-26 08:54:13 +00:00
|
|
|
@@ -49,5 +49,6 @@ int mac_compute(struct sshmac *, u_int3
|
2016-07-25 14:21:15 +00:00
|
|
|
int mac_check(struct sshmac *, u_int32_t, const u_char *, size_t,
|
|
|
|
const u_char *, size_t);
|
2015-03-20 13:56:04 +00:00
|
|
|
void mac_clear(struct sshmac *);
|
|
|
|
+void mac_destroy(struct sshmac *);
|
|
|
|
|
|
|
|
#endif /* SSHMAC_H */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/Makefile.in.audit openssh-7.6p1/Makefile.in
|
|
|
|
--- openssh-7.6p1/Makefile.in.audit 2017-10-04 17:18:32.749504614 +0200
|
|
|
|
+++ openssh-7.6p1/Makefile.in 2017-10-04 17:18:32.837505064 +0200
|
|
|
|
@@ -100,7 +100,8 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
|
2015-06-24 12:11:59 +00:00
|
|
|
kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \
|
|
|
|
kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \
|
2016-02-19 13:42:33 +00:00
|
|
|
kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \
|
2017-09-26 12:04:45 +00:00
|
|
|
- platform-pledge.o platform-tracing.o platform-misc.o
|
|
|
|
+ platform-pledge.o platform-tracing.o platform-misc.o \
|
|
|
|
+ auditstub.o
|
2015-06-24 12:11:59 +00:00
|
|
|
|
|
|
|
SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
|
2017-09-26 12:04:45 +00:00
|
|
|
sshconnect.o sshconnect2.o mux.o
|
|
|
|
diff -up openssh-7.6p1/monitor.c.audit openssh-7.6p1/monitor.c
|
|
|
|
--- openssh-7.6p1/monitor.c.audit 2017-10-04 17:18:32.824504997 +0200
|
|
|
|
+++ openssh-7.6p1/monitor.c 2017-10-04 17:18:32.837505064 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -102,6 +102,7 @@
|
2016-02-19 13:42:33 +00:00
|
|
|
#include "compat.h"
|
2014-07-08 13:52:24 +00:00
|
|
|
#include "ssh2.h"
|
2013-10-14 13:54:41 +00:00
|
|
|
#include "authfd.h"
|
2013-04-08 15:17:10 +00:00
|
|
|
+#include "audit.h"
|
2015-03-20 13:56:04 +00:00
|
|
|
#include "match.h"
|
|
|
|
#include "ssherr.h"
|
2013-04-08 15:17:10 +00:00
|
|
|
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -117,6 +118,8 @@ extern Buffer auth_debug;
|
2013-04-08 15:17:10 +00:00
|
|
|
extern int auth_debug_init;
|
|
|
|
extern Buffer loginmsg;
|
|
|
|
|
|
|
|
+extern void destroy_sensitive_data(int);
|
|
|
|
+
|
|
|
|
/* State exported from the child */
|
2015-03-20 13:56:04 +00:00
|
|
|
static struct sshbuf *child_state;
|
2013-04-08 15:17:10 +00:00
|
|
|
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -167,6 +170,11 @@ int mm_answer_gss_updatecreds(int, Buffe
|
2013-04-08 15:17:10 +00:00
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
int mm_answer_audit_event(int, Buffer *);
|
|
|
|
int mm_answer_audit_command(int, Buffer *);
|
|
|
|
+int mm_answer_audit_end_command(int, Buffer *);
|
|
|
|
+int mm_answer_audit_unsupported_body(int, Buffer *);
|
|
|
|
+int mm_answer_audit_kex_body(int, Buffer *);
|
|
|
|
+int mm_answer_audit_session_key_free_body(int, Buffer *);
|
|
|
|
+int mm_answer_audit_server_key_free(int, Buffer *);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int monitor_read_log(struct monitor *);
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -222,6 +230,10 @@ struct mon_table mon_dispatch_proto20[]
|
2013-04-08 15:17:10 +00:00
|
|
|
#endif
|
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
|
|
+ {MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
|
|
+ {MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
|
|
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
|
|
+ {MONITOR_REQ_AUDIT_SERVER_KEY_FREE, MON_PERMIT, mm_answer_audit_server_key_free},
|
|
|
|
#endif
|
|
|
|
#ifdef BSD_AUTH
|
|
|
|
{MONITOR_REQ_BSDAUTHQUERY, MON_ISAUTH, mm_answer_bsdauthquery},
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -260,6 +272,11 @@ struct mon_table mon_dispatch_postauth20
|
2013-04-08 15:17:10 +00:00
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
|
|
{MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command},
|
|
|
|
+ {MONITOR_REQ_AUDIT_END_COMMAND, MON_PERMIT, mm_answer_audit_end_command},
|
|
|
|
+ {MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
|
|
+ {MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
|
|
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
|
|
+ {MONITOR_REQ_AUDIT_SERVER_KEY_FREE, MON_PERMIT, mm_answer_audit_server_key_free},
|
|
|
|
#endif
|
|
|
|
{0, 0, NULL}
|
|
|
|
};
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1396,7 +1413,9 @@ mm_answer_keyverify(int sock, struct ssh
|
2013-04-08 15:17:10 +00:00
|
|
|
u_char *signature, *data, *blob;
|
2017-09-26 12:04:45 +00:00
|
|
|
size_t signaturelen, datalen, bloblen;
|
|
|
|
int r, ret, valid_data = 0, encoded_ret;
|
2013-04-08 15:17:10 +00:00
|
|
|
+ int type = 0;
|
|
|
|
|
|
|
|
+ type = buffer_get_int(m);
|
2017-09-26 12:04:45 +00:00
|
|
|
if ((r = sshbuf_get_string(m, &blob, &bloblen)) != 0 ||
|
|
|
|
(r = sshbuf_get_string(m, &signature, &signaturelen)) != 0 ||
|
|
|
|
(r = sshbuf_get_string(m, &data, &datalen)) != 0)
|
|
|
|
@@ -1405,6 +1424,8 @@ mm_answer_keyverify(int sock, struct ssh
|
2013-04-08 15:17:10 +00:00
|
|
|
if (hostbased_cuser == NULL || hostbased_chost == NULL ||
|
|
|
|
!monitor_allowed_key(blob, bloblen))
|
|
|
|
fatal("%s: bad key, not previously allowed", __func__);
|
|
|
|
+ if (type != key_blobtype)
|
|
|
|
+ fatal("%s: bad key type", __func__);
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
/* XXX use sshkey_froms here; need to change key_blob, etc. */
|
|
|
|
if ((r = sshkey_from_blob(blob, bloblen, &key)) != 0)
|
|
|
|
@@ -1414,21 +1435,24 @@ mm_answer_keyverify(int sock, struct ssh
|
|
|
|
case MM_USERKEY:
|
|
|
|
valid_data = monitor_valid_userblob(data, datalen);
|
|
|
|
auth_method = "publickey";
|
|
|
|
+ ret = user_key_verify(key, signature, signaturelen, data,
|
|
|
|
+ datalen, active_state->compat);
|
|
|
|
break;
|
|
|
|
case MM_HOSTKEY:
|
|
|
|
valid_data = monitor_valid_hostbasedblob(data, datalen,
|
|
|
|
hostbased_cuser, hostbased_chost);
|
|
|
|
+ ret = hostbased_key_verify(key, signature, signaturelen, data,
|
|
|
|
+ datalen, active_state->compat);
|
|
|
|
auth_method = "hostbased";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
valid_data = 0;
|
|
|
|
+ ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
2013-04-08 15:17:10 +00:00
|
|
|
if (!valid_data)
|
|
|
|
fatal("%s: bad signature data blob", __func__);
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
- ret = sshkey_verify(key, signature, signaturelen, data, datalen,
|
|
|
|
- active_state->compat);
|
|
|
|
debug3("%s: %s %p signature %s", __func__, auth_method, key,
|
|
|
|
(ret == 0) ? "verified" : "unverified");
|
|
|
|
auth2_record_key(authctxt, ret == 0, key);
|
|
|
|
@@ -1485,6 +1509,12 @@ mm_session_close(Session *s)
|
2013-04-08 15:17:10 +00:00
|
|
|
debug3("%s: tty %s ptyfd %d", __func__, s->tty, s->ptyfd);
|
|
|
|
session_pty_cleanup2(s);
|
|
|
|
}
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ if (s->command != NULL) {
|
|
|
|
+ debug3("%s: command %d", __func__, s->command_handle);
|
|
|
|
+ session_end_command2(s);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
session_unused(s->self);
|
|
|
|
}
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1588,6 +1618,8 @@ mm_answer_term(int sock, Buffer *req)
|
2013-04-08 15:17:10 +00:00
|
|
|
sshpam_cleanup();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+ destroy_sensitive_data(0);
|
|
|
|
+
|
|
|
|
while (waitpid(pmonitor->m_pid, &status, 0) == -1)
|
|
|
|
if (errno != EINTR)
|
|
|
|
exit(1);
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1630,11 +1662,45 @@ mm_answer_audit_command(int socket, Buff
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
|
|
|
u_int len;
|
|
|
|
char *cmd;
|
|
|
|
+ Session *s;
|
|
|
|
|
|
|
|
debug3("%s entering", __func__);
|
|
|
|
cmd = buffer_get_string(m, &len);
|
|
|
|
+
|
|
|
|
/* sanity check command, if so how? */
|
|
|
|
- audit_run_command(cmd);
|
|
|
|
+ s = session_new();
|
|
|
|
+ if (s == NULL)
|
|
|
|
+ fatal("%s: error allocating a session", __func__);
|
|
|
|
+ s->command = cmd;
|
2016-09-15 14:36:04 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2013-04-08 15:17:10 +00:00
|
|
|
+ s->command_handle = audit_run_command(cmd);
|
2016-09-15 14:36:04 +00:00
|
|
|
+#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
|
|
|
+ buffer_clear(m);
|
|
|
|
+ buffer_put_int(m, s->self);
|
|
|
|
+
|
|
|
|
+ mm_request_send(socket, MONITOR_ANS_AUDIT_COMMAND, m);
|
|
|
|
+
|
|
|
|
+ return (0);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+mm_answer_audit_end_command(int socket, Buffer *m)
|
|
|
|
+{
|
|
|
|
+ int handle;
|
|
|
|
+ u_int len;
|
|
|
|
+ char *cmd;
|
|
|
|
+ Session *s;
|
|
|
|
+
|
|
|
|
+ debug3("%s entering", __func__);
|
|
|
|
+ handle = buffer_get_int(m);
|
|
|
|
+ cmd = buffer_get_string(m, &len);
|
|
|
|
+
|
|
|
|
+ s = session_by_id(handle);
|
|
|
|
+ if (s == NULL || s->ttyfd != -1 || s->command == NULL ||
|
|
|
|
+ strcmp(s->command, cmd) != 0)
|
|
|
|
+ fatal("%s: invalid handle", __func__);
|
|
|
|
+ mm_session_close(s);
|
2013-10-14 13:54:41 +00:00
|
|
|
free(cmd);
|
2013-04-08 15:17:10 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1702,6 +1768,7 @@ monitor_apply_keystate(struct monitor *p
|
2015-03-20 13:56:04 +00:00
|
|
|
void
|
|
|
|
mm_get_keystate(struct monitor *pmonitor)
|
|
|
|
{
|
|
|
|
+ Buffer m;
|
|
|
|
debug3("%s: Waiting for new keys", __func__);
|
2013-04-08 15:17:10 +00:00
|
|
|
|
2015-03-20 13:56:04 +00:00
|
|
|
if ((child_state = sshbuf_new()) == NULL)
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1709,6 +1776,19 @@ mm_get_keystate(struct monitor *pmonitor
|
2015-03-20 13:56:04 +00:00
|
|
|
mm_request_receive_expect(pmonitor->m_sendfd, MONITOR_REQ_KEYEXPORT,
|
|
|
|
child_state);
|
|
|
|
debug3("%s: GOT new keys", __func__);
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2017-09-26 12:04:45 +00:00
|
|
|
+ buffer_init(&m);
|
|
|
|
+ mm_request_receive_expect(pmonitor->m_sendfd,
|
|
|
|
+ MONITOR_REQ_AUDIT_SESSION_KEY_FREE, &m);
|
|
|
|
+ mm_answer_audit_session_key_free_body(pmonitor->m_sendfd, &m);
|
|
|
|
+ buffer_free(&m);
|
2013-04-08 15:17:10 +00:00
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ /* Drain any buffered messages from the child */
|
|
|
|
+ while (pmonitor->m_log_recvfd >= 0 && monitor_read_log(pmonitor) == 0)
|
|
|
|
+ ;
|
|
|
|
+
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1976,3 +2056,86 @@ mm_answer_gss_updatecreds(int socket, Bu
|
2014-07-08 13:52:24 +00:00
|
|
|
|
|
|
|
#endif /* GSSAPI */
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+int
|
|
|
|
+mm_answer_audit_unsupported_body(int sock, Buffer *m)
|
|
|
|
+{
|
|
|
|
+ int what;
|
|
|
|
+
|
|
|
|
+ what = buffer_get_int(m);
|
|
|
|
+
|
|
|
|
+ audit_unsupported_body(what);
|
|
|
|
+
|
|
|
|
+ buffer_clear(m);
|
|
|
|
+
|
|
|
|
+ mm_request_send(sock, MONITOR_ANS_AUDIT_UNSUPPORTED, m);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+mm_answer_audit_kex_body(int sock, Buffer *m)
|
|
|
|
+{
|
|
|
|
+ int ctos, len;
|
2015-01-20 12:18:45 +00:00
|
|
|
+ char *cipher, *mac, *compress, *pfs;
|
2013-04-08 15:17:10 +00:00
|
|
|
+ pid_t pid;
|
|
|
|
+ uid_t uid;
|
|
|
|
+
|
|
|
|
+ ctos = buffer_get_int(m);
|
|
|
|
+ cipher = buffer_get_string(m, &len);
|
|
|
|
+ mac = buffer_get_string(m, &len);
|
|
|
|
+ compress = buffer_get_string(m, &len);
|
2015-01-20 12:18:45 +00:00
|
|
|
+ pfs = buffer_get_string(m, &len);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ pid = buffer_get_int64(m);
|
|
|
|
+ uid = buffer_get_int64(m);
|
|
|
|
+
|
2015-01-20 12:18:45 +00:00
|
|
|
+ audit_kex_body(ctos, cipher, mac, compress, pfs, pid, uid);
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(cipher);
|
|
|
|
+ free(mac);
|
|
|
|
+ free(compress);
|
2015-01-20 12:18:45 +00:00
|
|
|
+ free(pfs);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ buffer_clear(m);
|
|
|
|
+
|
|
|
|
+ mm_request_send(sock, MONITOR_ANS_AUDIT_KEX, m);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+mm_answer_audit_session_key_free_body(int sock, Buffer *m)
|
|
|
|
+{
|
|
|
|
+ int ctos;
|
|
|
|
+ pid_t pid;
|
|
|
|
+ uid_t uid;
|
|
|
|
+
|
|
|
|
+ ctos = buffer_get_int(m);
|
|
|
|
+ pid = buffer_get_int64(m);
|
|
|
|
+ uid = buffer_get_int64(m);
|
|
|
|
+
|
|
|
|
+ audit_session_key_free_body(ctos, pid, uid);
|
|
|
|
+
|
|
|
|
+ buffer_clear(m);
|
|
|
|
+
|
|
|
|
+ mm_request_send(sock, MONITOR_ANS_AUDIT_SESSION_KEY_FREE, m);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+mm_answer_audit_server_key_free(int sock, Buffer *m)
|
|
|
|
+{
|
|
|
|
+ int len;
|
|
|
|
+ char *fp;
|
|
|
|
+ pid_t pid;
|
|
|
|
+ uid_t uid;
|
|
|
|
+
|
|
|
|
+ fp = buffer_get_string(m, &len);
|
|
|
|
+ pid = buffer_get_int64(m);
|
|
|
|
+ uid = buffer_get_int64(m);
|
|
|
|
+
|
|
|
|
+ audit_destroy_sensitive_data(fp, pid, uid);
|
|
|
|
+
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(fp);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ buffer_clear(m);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+#endif /* SSH_AUDIT_EVENTS */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/monitor.h.audit openssh-7.6p1/monitor.h
|
|
|
|
--- openssh-7.6p1/monitor.h.audit 2017-10-04 17:18:32.781504777 +0200
|
|
|
|
+++ openssh-7.6p1/monitor.h 2017-10-04 17:18:32.837505064 +0200
|
2014-07-08 13:52:24 +00:00
|
|
|
@@ -69,7 +69,13 @@ enum monitor_reqtype {
|
2013-04-08 15:17:10 +00:00
|
|
|
MONITOR_REQ_PAM_QUERY = 106, MONITOR_ANS_PAM_QUERY = 107,
|
|
|
|
MONITOR_REQ_PAM_RESPOND = 108, MONITOR_ANS_PAM_RESPOND = 109,
|
|
|
|
MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111,
|
|
|
|
- MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113,
|
|
|
|
+ MONITOR_REQ_AUDIT_EVENT = 112,
|
|
|
|
+ MONITOR_REQ_AUDIT_COMMAND = 114, MONITOR_ANS_AUDIT_COMMAND = 115,
|
|
|
|
+ MONITOR_REQ_AUDIT_END_COMMAND = 116,
|
|
|
|
+ MONITOR_REQ_AUDIT_UNSUPPORTED = 118, MONITOR_ANS_AUDIT_UNSUPPORTED = 119,
|
|
|
|
+ MONITOR_REQ_AUDIT_KEX = 120, MONITOR_ANS_AUDIT_KEX = 121,
|
|
|
|
+ MONITOR_REQ_AUDIT_SESSION_KEY_FREE = 122, MONITOR_ANS_AUDIT_SESSION_KEY_FREE = 123,
|
2015-07-14 15:05:50 +00:00
|
|
|
+ MONITOR_REQ_AUDIT_SERVER_KEY_FREE = 124
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/monitor_wrap.c.audit openssh-7.6p1/monitor_wrap.c
|
|
|
|
--- openssh-7.6p1/monitor_wrap.c.audit 2017-10-04 17:18:32.750504619 +0200
|
|
|
|
+++ openssh-7.6p1/monitor_wrap.c 2017-10-04 17:18:32.838505069 +0200
|
|
|
|
@@ -463,7 +463,7 @@ mm_key_allowed(enum mm_keytype type, con
|
2013-04-08 15:17:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2017-09-26 12:04:45 +00:00
|
|
|
-mm_sshkey_verify(const struct sshkey *key, const u_char *sig, size_t siglen,
|
|
|
|
+mm_sshkey_verify(enum mm_keytype type, const struct sshkey *key, const u_char *sig, size_t siglen,
|
|
|
|
const u_char *data, size_t datalen, u_int compat)
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
|
|
|
Buffer m;
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -478,6 +478,7 @@ mm_sshkey_verify(const struct sshkey *ke
|
2013-04-08 15:17:10 +00:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
buffer_init(&m);
|
|
|
|
+ buffer_put_int(&m, type);
|
|
|
|
buffer_put_string(&m, blob, len);
|
|
|
|
buffer_put_string(&m, sig, siglen);
|
|
|
|
buffer_put_string(&m, data, datalen);
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -497,6 +498,20 @@ mm_sshkey_verify(const struct sshkey *ke
|
|
|
|
return 0;
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+int
|
2017-09-26 12:04:45 +00:00
|
|
|
+mm_hostbased_key_verify(const struct sshkey *key, const u_char *sig, size_t siglen,
|
|
|
|
+ const u_char *data, size_t datalen, u_int compat)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
2017-09-26 12:04:45 +00:00
|
|
|
+ return mm_sshkey_verify(MM_HOSTKEY, key, sig, siglen, data, datalen, compat);
|
2013-04-08 15:17:10 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
2017-09-26 12:04:45 +00:00
|
|
|
+mm_user_key_verify(const struct sshkey *key, const u_char *sig, size_t siglen,
|
|
|
|
+ const u_char *data, size_t datalen, u_int compat)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
2017-09-26 12:04:45 +00:00
|
|
|
+ return mm_sshkey_verify(MM_USERKEY, key, sig, siglen, data, datalen, compat);
|
2013-04-08 15:17:10 +00:00
|
|
|
+}
|
|
|
|
+
|
2015-03-20 13:56:04 +00:00
|
|
|
void
|
|
|
|
mm_send_keystate(struct monitor *monitor)
|
|
|
|
{
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -874,10 +889,11 @@ mm_audit_event(ssh_audit_event_t event)
|
2013-04-08 15:17:10 +00:00
|
|
|
buffer_free(&m);
|
|
|
|
}
|
|
|
|
|
|
|
|
-void
|
|
|
|
+int
|
|
|
|
mm_audit_run_command(const char *command)
|
|
|
|
{
|
|
|
|
Buffer m;
|
|
|
|
+ int handle;
|
|
|
|
|
|
|
|
debug3("%s entering command %s", __func__, command);
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -885,6 +901,26 @@ mm_audit_run_command(const char *command
|
2013-04-08 15:17:10 +00:00
|
|
|
buffer_put_cstring(&m, command);
|
|
|
|
|
|
|
|
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_COMMAND, &m);
|
|
|
|
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUDIT_COMMAND, &m);
|
|
|
|
+
|
|
|
|
+ handle = buffer_get_int(&m);
|
|
|
|
+ buffer_free(&m);
|
|
|
|
+
|
|
|
|
+ return (handle);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+mm_audit_end_command(int handle, const char *command)
|
|
|
|
+{
|
|
|
|
+ Buffer m;
|
|
|
|
+
|
|
|
|
+ debug3("%s entering command %s", __func__, command);
|
|
|
|
+
|
|
|
|
+ buffer_init(&m);
|
|
|
|
+ buffer_put_int(&m, handle);
|
|
|
|
+ buffer_put_cstring(&m, command);
|
|
|
|
+
|
|
|
|
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_END_COMMAND, &m);
|
|
|
|
buffer_free(&m);
|
|
|
|
}
|
|
|
|
#endif /* SSH_AUDIT_EVENTS */
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1020,3 +1056,70 @@ mm_ssh_gssapi_update_creds(ssh_gssapi_cc
|
2014-07-08 13:52:24 +00:00
|
|
|
|
|
|
|
#endif /* GSSAPI */
|
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+void
|
|
|
|
+mm_audit_unsupported_body(int what)
|
|
|
|
+{
|
|
|
|
+ Buffer m;
|
|
|
|
+
|
|
|
|
+ buffer_init(&m);
|
|
|
|
+ buffer_put_int(&m, what);
|
|
|
|
+
|
|
|
|
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_UNSUPPORTED, &m);
|
|
|
|
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUDIT_UNSUPPORTED,
|
|
|
|
+ &m);
|
|
|
|
+
|
|
|
|
+ buffer_free(&m);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
2015-01-20 12:18:45 +00:00
|
|
|
+mm_audit_kex_body(int ctos, char *cipher, char *mac, char *compress, char *fps, pid_t pid,
|
2013-04-08 15:17:10 +00:00
|
|
|
+ uid_t uid)
|
|
|
|
+{
|
|
|
|
+ Buffer m;
|
|
|
|
+
|
|
|
|
+ buffer_init(&m);
|
|
|
|
+ buffer_put_int(&m, ctos);
|
|
|
|
+ buffer_put_cstring(&m, cipher);
|
2015-10-16 07:58:42 +00:00
|
|
|
+ buffer_put_cstring(&m, (mac ? mac : "<implicit>"));
|
2013-04-08 15:17:10 +00:00
|
|
|
+ buffer_put_cstring(&m, compress);
|
2015-01-20 12:18:45 +00:00
|
|
|
+ buffer_put_cstring(&m, fps);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ buffer_put_int64(&m, pid);
|
|
|
|
+ buffer_put_int64(&m, uid);
|
|
|
|
+
|
|
|
|
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_KEX, &m);
|
|
|
|
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUDIT_KEX,
|
|
|
|
+ &m);
|
|
|
|
+
|
|
|
|
+ buffer_free(&m);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+mm_audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+ Buffer m;
|
|
|
|
+
|
|
|
|
+ buffer_init(&m);
|
|
|
|
+ buffer_put_int(&m, ctos);
|
|
|
|
+ buffer_put_int64(&m, pid);
|
|
|
|
+ buffer_put_int64(&m, uid);
|
|
|
|
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_SESSION_KEY_FREE, &m);
|
|
|
|
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUDIT_SESSION_KEY_FREE,
|
|
|
|
+ &m);
|
|
|
|
+ buffer_free(&m);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+mm_audit_destroy_sensitive_data(const char *fp, pid_t pid, uid_t uid)
|
|
|
|
+{
|
|
|
|
+ Buffer m;
|
|
|
|
+
|
|
|
|
+ buffer_init(&m);
|
|
|
|
+ buffer_put_cstring(&m, fp);
|
|
|
|
+ buffer_put_int64(&m, pid);
|
|
|
|
+ buffer_put_int64(&m, uid);
|
|
|
|
+
|
|
|
|
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_SERVER_KEY_FREE, &m);
|
|
|
|
+ buffer_free(&m);
|
|
|
|
+}
|
|
|
|
+#endif /* SSH_AUDIT_EVENTS */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/monitor_wrap.h.audit openssh-7.6p1/monitor_wrap.h
|
|
|
|
--- openssh-7.6p1/monitor_wrap.h.audit 2017-10-04 17:18:32.750504619 +0200
|
|
|
|
+++ openssh-7.6p1/monitor_wrap.h 2017-10-04 17:18:32.838505069 +0200
|
|
|
|
@@ -53,7 +53,9 @@ int mm_key_allowed(enum mm_keytype, cons
|
|
|
|
int mm_user_key_allowed(struct passwd *, struct sshkey *, int);
|
2017-01-02 14:42:13 +00:00
|
|
|
int mm_hostbased_key_allowed(struct passwd *, const char *,
|
2017-09-26 12:04:45 +00:00
|
|
|
const char *, struct sshkey *);
|
|
|
|
-int mm_sshkey_verify(const struct sshkey *, const u_char *, size_t,
|
|
|
|
+int mm_hostbased_key_verify(const struct sshkey *, const u_char *, size_t,
|
|
|
|
+ const u_char *, size_t, u_int);
|
|
|
|
+int mm_user_key_verify(const struct sshkey *, const u_char *, size_t,
|
|
|
|
const u_char *, size_t, u_int);
|
2017-01-02 14:42:13 +00:00
|
|
|
|
|
|
|
#ifdef GSSAPI
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -78,7 +80,12 @@ void mm_sshpam_free_ctx(void *);
|
2013-04-08 15:17:10 +00:00
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
#include "audit.h"
|
|
|
|
void mm_audit_event(ssh_audit_event_t);
|
|
|
|
-void mm_audit_run_command(const char *);
|
|
|
|
+int mm_audit_run_command(const char *);
|
|
|
|
+void mm_audit_end_command(int, const char *);
|
|
|
|
+void mm_audit_unsupported_body(int);
|
2015-01-20 12:18:45 +00:00
|
|
|
+void mm_audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t);
|
2013-04-08 15:17:10 +00:00
|
|
|
+void mm_audit_session_key_free_body(int, pid_t, uid_t);
|
|
|
|
+void mm_audit_destroy_sensitive_data(const char *, pid_t, uid_t);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct Session;
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/packet.c.audit openssh-7.6p1/packet.c
|
|
|
|
--- openssh-7.6p1/packet.c.audit 2017-10-04 17:18:32.672504220 +0200
|
|
|
|
+++ openssh-7.6p1/packet.c 2017-10-04 17:25:48.141741390 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -67,6 +67,7 @@
|
2015-03-20 13:56:04 +00:00
|
|
|
#include "key.h" /* typedefs XXX */
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
#include "xmalloc.h"
|
|
|
|
+#include "audit.h"
|
|
|
|
#include "crc32.h"
|
2015-03-20 13:56:04 +00:00
|
|
|
#include "compat.h"
|
2017-09-26 12:04:45 +00:00
|
|
|
#include "ssh2.h"
|
|
|
|
@@ -502,6 +503,13 @@ ssh_packet_get_connection_out(struct ssh
|
2015-03-20 13:56:04 +00:00
|
|
|
return ssh->state->connection_out;
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+static int
|
|
|
|
+packet_state_has_keys (const struct session_state *state)
|
|
|
|
+{
|
|
|
|
+ return state != NULL &&
|
|
|
|
+ (state->newkeys[MODE_IN] != NULL || state->newkeys[MODE_OUT] != NULL);
|
|
|
|
+}
|
|
|
|
+
|
2015-03-20 13:56:04 +00:00
|
|
|
/*
|
|
|
|
* Returns the IP-address of the remote host as a string. The returned
|
|
|
|
* string must not be freed.
|
2017-10-19 14:06:27 +00:00
|
|
|
@@ -566,22 +574,19 @@ ssh_packet_close_internal(struct ssh *ss
|
2017-09-26 12:04:45 +00:00
|
|
|
{
|
|
|
|
struct session_state *state = ssh->state;
|
|
|
|
u_int mode;
|
|
|
|
+ u_int had_keys = packet_state_has_keys(state);
|
|
|
|
|
2015-03-20 13:56:04 +00:00
|
|
|
if (!state->initialized)
|
2013-04-08 15:17:10 +00:00
|
|
|
return;
|
2015-03-20 13:56:04 +00:00
|
|
|
state->initialized = 0;
|
2017-09-26 12:04:45 +00:00
|
|
|
- if (do_close) {
|
|
|
|
- if (state->connection_in == state->connection_out) {
|
|
|
|
- close(state->connection_out);
|
|
|
|
- } else {
|
|
|
|
- close(state->connection_in);
|
|
|
|
- close(state->connection_out);
|
|
|
|
- }
|
2013-04-08 15:17:10 +00:00
|
|
|
- }
|
2015-03-20 13:56:04 +00:00
|
|
|
sshbuf_free(state->input);
|
2017-10-19 14:06:27 +00:00
|
|
|
+ state->input = NULL;
|
2015-03-20 13:56:04 +00:00
|
|
|
sshbuf_free(state->output);
|
2017-10-19 14:06:27 +00:00
|
|
|
+ state->output = NULL;
|
2015-03-20 13:56:04 +00:00
|
|
|
sshbuf_free(state->outgoing_packet);
|
2017-10-19 14:06:27 +00:00
|
|
|
+ state->outgoing_packet = NULL;
|
|
|
|
sshbuf_free(state->incoming_packet);
|
|
|
|
+ state->incoming_packet = NULL;
|
|
|
|
for (mode = 0; mode < MODE_MAX; mode++) {
|
|
|
|
kex_free_newkeys(state->newkeys[mode]); /* current keys */
|
|
|
|
state->newkeys[mode] = NULL;
|
|
|
|
@@ -615,8 +616,18 @@ ssh_packet_close_internal(struct ssh *ss
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
2017-09-26 12:04:45 +00:00
|
|
|
cipher_free(state->send_context);
|
|
|
|
cipher_free(state->receive_context);
|
2017-10-19 14:06:27 +00:00
|
|
|
+ if (had_keys && state->server_side) {
|
|
|
|
+ /* Assuming this is called only from privsep child */
|
2016-03-04 13:33:02 +00:00
|
|
|
+ audit_session_key_free(MODE_MAX);
|
2017-10-19 14:06:27 +00:00
|
|
|
+ }
|
2017-01-02 14:42:13 +00:00
|
|
|
state->send_context = state->receive_context = NULL;
|
2017-09-26 12:04:45 +00:00
|
|
|
if (do_close) {
|
|
|
|
+ if (state->connection_in == state->connection_out) {
|
|
|
|
+ close(state->connection_out);
|
|
|
|
+ } else {
|
|
|
|
+ close(state->connection_in);
|
|
|
|
+ close(state->connection_out);
|
|
|
|
+ }
|
|
|
|
free(ssh->remote_ipaddr);
|
|
|
|
ssh->remote_ipaddr = NULL;
|
|
|
|
free(ssh->state);
|
|
|
|
@@ -854,6 +863,7 @@ ssh_set_newkeys(struct ssh *ssh, int mod
|
|
|
|
(unsigned long long)state->p_read.blocks,
|
|
|
|
(unsigned long long)state->p_send.bytes,
|
|
|
|
(unsigned long long)state->p_send.blocks);
|
2015-03-20 13:56:04 +00:00
|
|
|
+ audit_session_key_free(mode);
|
2017-01-02 14:42:13 +00:00
|
|
|
cipher_free(*ccp);
|
|
|
|
*ccp = NULL;
|
2017-09-26 12:04:45 +00:00
|
|
|
kex_free_newkeys(state->newkeys[mode]);
|
|
|
|
@@ -2135,6 +2145,72 @@ ssh_packet_get_output(struct ssh *ssh)
|
2015-03-20 13:56:04 +00:00
|
|
|
return (void *)ssh->state->output;
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+static void
|
2015-03-20 13:56:04 +00:00
|
|
|
+newkeys_destroy_and_free(struct newkeys *newkeys)
|
2013-04-08 15:17:10 +00:00
|
|
|
+{
|
|
|
|
+ if (newkeys == NULL)
|
|
|
|
+ return;
|
|
|
|
+
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(newkeys->enc.name);
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
2013-04-08 16:44:17 +00:00
|
|
|
+ if (newkeys->mac.enabled) {
|
|
|
|
+ mac_clear(&newkeys->mac);
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(newkeys->mac.name);
|
2013-04-08 16:44:17 +00:00
|
|
|
+ }
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(newkeys->comp.name);
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
|
|
|
+ newkeys_destroy(newkeys);
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(newkeys);
|
2013-04-08 15:17:10 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void
|
|
|
|
+packet_destroy_state(struct session_state *state)
|
|
|
|
+{
|
|
|
|
+ if (state == NULL)
|
|
|
|
+ return;
|
|
|
|
+
|
2017-01-02 14:42:13 +00:00
|
|
|
+ cipher_free(state->receive_context);
|
|
|
|
+ cipher_free(state->send_context);
|
2013-04-08 15:17:10 +00:00
|
|
|
+
|
2015-03-20 13:56:04 +00:00
|
|
|
+ buffer_free(state->input);
|
|
|
|
+ state->input = NULL;
|
|
|
|
+ buffer_free(state->output);
|
|
|
|
+ state->output = NULL;
|
|
|
|
+ buffer_free(state->outgoing_packet);
|
|
|
|
+ state->outgoing_packet = NULL;
|
|
|
|
+ buffer_free(state->incoming_packet);
|
|
|
|
+ state->incoming_packet = NULL;
|
|
|
|
+ if( state->compression_buffer ) {
|
|
|
|
+ buffer_free(state->compression_buffer);
|
|
|
|
+ state->compression_buffer = NULL;
|
|
|
|
+ }
|
2013-04-08 15:17:10 +00:00
|
|
|
+ newkeys_destroy_and_free(state->newkeys[MODE_IN]);
|
|
|
|
+ state->newkeys[MODE_IN] = NULL;
|
|
|
|
+ newkeys_destroy_and_free(state->newkeys[MODE_OUT]);
|
|
|
|
+ state->newkeys[MODE_OUT] = NULL;
|
|
|
|
+ mac_destroy(state->packet_discard_mac);
|
|
|
|
+// TAILQ_HEAD(, packet) outgoing;
|
|
|
|
+// memset(state, 0, sizeof(state));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+packet_destroy_all(int audit_it, int privsep)
|
|
|
|
+{
|
|
|
|
+ if (audit_it)
|
2016-03-04 13:33:02 +00:00
|
|
|
+ audit_it = (active_state != NULL && packet_state_has_keys(active_state->state));
|
2015-03-26 08:44:58 +00:00
|
|
|
+ if (active_state != NULL)
|
|
|
|
+ packet_destroy_state(active_state->state);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ if (audit_it) {
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ if (privsep)
|
2016-03-04 13:33:02 +00:00
|
|
|
+ audit_session_key_free(MODE_MAX);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ else
|
2016-03-04 13:33:02 +00:00
|
|
|
+ audit_session_key_free_body(MODE_MAX, getpid(), getuid());
|
2013-04-08 15:17:10 +00:00
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
2015-01-20 12:18:45 +00:00
|
|
|
/* Reset after_authentication and reset compression in post-auth privsep */
|
2016-02-19 13:42:33 +00:00
|
|
|
static int
|
|
|
|
ssh_packet_set_postauth(struct ssh *ssh)
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/packet.h.audit openssh-7.6p1/packet.h
|
|
|
|
--- openssh-7.6p1/packet.h.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/packet.h 2017-10-04 17:18:32.838505069 +0200
|
|
|
|
@@ -217,4 +217,5 @@ extern struct ssh *active_state;
|
2015-03-20 13:56:04 +00:00
|
|
|
# undef EC_POINT
|
|
|
|
#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
+void packet_destroy_all(int, int);
|
|
|
|
#endif /* PACKET_H */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/session.c.audit openssh-7.6p1/session.c
|
|
|
|
--- openssh-7.6p1/session.c.audit 2017-10-04 17:18:32.812504936 +0200
|
|
|
|
+++ openssh-7.6p1/session.c 2017-10-04 17:18:32.839505074 +0200
|
|
|
|
@@ -138,7 +138,7 @@ extern char *__progname;
|
2013-04-08 15:17:10 +00:00
|
|
|
extern int debug_flag;
|
|
|
|
extern u_int utmp_len;
|
|
|
|
extern int startup_pipe;
|
|
|
|
-extern void destroy_sensitive_data(void);
|
|
|
|
+extern void destroy_sensitive_data(int);
|
|
|
|
extern Buffer loginmsg;
|
|
|
|
|
|
|
|
/* original command from peer. */
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -605,6 +605,14 @@ do_exec_pty(struct ssh *ssh, Session *s,
|
2013-04-08 15:17:10 +00:00
|
|
|
/* Parent. Close the slave side of the pseudo tty. */
|
|
|
|
close(ttyfd);
|
|
|
|
|
2016-03-04 13:33:02 +00:00
|
|
|
+#if !defined(HAVE_OSF_SIA) && defined(SSH_AUDIT_EVENTS)
|
2013-04-08 15:17:10 +00:00
|
|
|
+ /* do_login in the child did not affect state in this process,
|
|
|
|
+ compensate. From an architectural standpoint, this is extremely
|
|
|
|
+ ugly. */
|
2017-01-02 14:42:13 +00:00
|
|
|
+ if (command != NULL)
|
2013-04-08 15:17:10 +00:00
|
|
|
+ audit_count_session_open();
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/* Enter interactive session. */
|
|
|
|
s->ptymaster = ptymaster;
|
|
|
|
packet_set_interactive(1,
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -724,15 +732,19 @@ do_exec(struct ssh *ssh, Session *s, con
|
2016-02-19 13:42:33 +00:00
|
|
|
s->self);
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ if (s->command != NULL || s->command_handle != -1)
|
|
|
|
+ fatal("do_exec: command already set");
|
|
|
|
if (command != NULL)
|
|
|
|
- PRIVSEP(audit_run_command(command));
|
|
|
|
+ s->command = xstrdup(command);
|
|
|
|
else if (s->ttyfd == -1) {
|
|
|
|
char *shell = s->pw->pw_shell;
|
|
|
|
|
|
|
|
if (shell[0] == '\0') /* empty shell means /bin/sh */
|
|
|
|
shell =_PATH_BSHELL;
|
|
|
|
- PRIVSEP(audit_run_command(shell));
|
|
|
|
+ s->command = xstrdup(shell);
|
|
|
|
}
|
2015-03-20 14:06:06 +00:00
|
|
|
+ if (s->command != NULL && s->ptyfd == -1)
|
2013-04-08 15:17:10 +00:00
|
|
|
+ s->command_handle = PRIVSEP(audit_run_command(s->command));
|
|
|
|
#endif
|
|
|
|
if (s->ttyfd != -1)
|
2017-09-26 12:04:45 +00:00
|
|
|
ret = do_exec_pty(ssh, s, command);
|
|
|
|
@@ -1499,8 +1511,11 @@ do_child(struct ssh *ssh, Session *s, co
|
2013-04-08 15:17:10 +00:00
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
/* remove hostkey from the child's memory */
|
|
|
|
- destroy_sensitive_data();
|
|
|
|
+ destroy_sensitive_data(1);
|
2017-09-26 12:04:45 +00:00
|
|
|
packet_clear_keys();
|
2013-04-08 15:17:10 +00:00
|
|
|
+ /* Don't audit this - both us and the parent would be talking to the
|
|
|
|
+ monitor over a single socket, with no synchronization. */
|
|
|
|
+ packet_destroy_all(0, 1);
|
|
|
|
|
|
|
|
/* Force a password change */
|
|
|
|
if (s->authctxt->force_pwchange) {
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1714,6 +1729,9 @@ session_unused(int id)
|
2013-04-08 15:17:10 +00:00
|
|
|
sessions[id].ttyfd = -1;
|
|
|
|
sessions[id].ptymaster = -1;
|
|
|
|
sessions[id].x11_chanids = NULL;
|
2016-09-15 14:36:04 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2013-04-08 15:17:10 +00:00
|
|
|
+ sessions[id].command_handle = -1;
|
2016-09-15 14:36:04 +00:00
|
|
|
+#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
sessions[id].next_unused = sessions_first_unused;
|
|
|
|
sessions_first_unused = id;
|
|
|
|
}
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1796,6 +1814,19 @@ session_open(Authctxt *authctxt, int cha
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Session *
|
|
|
|
+session_by_id(int id)
|
|
|
|
+{
|
|
|
|
+ if (id >= 0 && id < sessions_nalloc) {
|
|
|
|
+ Session *s = &sessions[id];
|
|
|
|
+ if (s->used)
|
|
|
|
+ return s;
|
|
|
|
+ }
|
2016-03-04 13:33:02 +00:00
|
|
|
+ debug("%s: unknown id %d", __func__, id);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ session_dump();
|
|
|
|
+ return NULL;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Session *
|
|
|
|
session_by_tty(char *tty)
|
|
|
|
{
|
|
|
|
int i;
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -2307,6 +2338,32 @@ session_exit_message(struct ssh *ssh, Se
|
|
|
|
chan_write_failed(ssh, c);
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+void
|
|
|
|
+session_end_command2(Session *s)
|
|
|
|
+{
|
2015-03-20 14:06:06 +00:00
|
|
|
+ if (s->command != NULL) {
|
2015-04-02 15:24:56 +00:00
|
|
|
+ if (s->command_handle != -1)
|
2015-03-20 14:06:06 +00:00
|
|
|
+ audit_end_command(s->command_handle, s->command);
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(s->command);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ s->command = NULL;
|
|
|
|
+ s->command_handle = -1;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void
|
|
|
|
+session_end_command(Session *s)
|
|
|
|
+{
|
|
|
|
+ if (s->command != NULL) {
|
2015-04-02 15:24:56 +00:00
|
|
|
+ if (s->command_handle != -1)
|
|
|
|
+ PRIVSEP(audit_end_command(s->command_handle, s->command));
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(s->command);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ s->command = NULL;
|
|
|
|
+ s->command_handle = -1;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
void
|
2017-09-26 12:04:45 +00:00
|
|
|
session_close(struct ssh *ssh, Session *s)
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -2320,6 +2377,10 @@ session_close(struct ssh *ssh, Session *
|
2016-02-19 13:42:33 +00:00
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
if (s->ttyfd != -1)
|
|
|
|
session_pty_cleanup(s);
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ if (s->command)
|
|
|
|
+ session_end_command(s);
|
|
|
|
+#endif
|
2013-10-14 13:54:41 +00:00
|
|
|
free(s->term);
|
|
|
|
free(s->display);
|
|
|
|
free(s->x11_chanids);
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -2528,6 +2589,15 @@ do_authenticated2(struct ssh *ssh, Authc
|
|
|
|
server_loop2(ssh, authctxt);
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+static void
|
|
|
|
+do_cleanup_one_session(Session *s)
|
|
|
|
+{
|
|
|
|
+ session_pty_cleanup2(s);
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ session_end_command2(s);
|
|
|
|
+#endif
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void
|
2017-09-26 12:04:45 +00:00
|
|
|
do_cleanup(struct ssh *ssh, Authctxt *authctxt)
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -2585,7 +2655,7 @@ do_cleanup(struct ssh *ssh, Authctxt *au
|
2013-04-08 15:17:10 +00:00
|
|
|
* or if running in monitor.
|
|
|
|
*/
|
|
|
|
if (!use_privsep || mm_is_monitor())
|
2017-09-26 12:04:45 +00:00
|
|
|
- session_destroy_all(ssh, session_pty_cleanup2);
|
|
|
|
+ session_destroy_all(ssh, do_cleanup_one_session);
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
2016-07-25 14:21:15 +00:00
|
|
|
|
|
|
|
/* Return a name for the remote host that fits inside utmp_size */
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/session.h.audit openssh-7.6p1/session.h
|
|
|
|
--- openssh-7.6p1/session.h.audit 2017-10-02 21:34:26.000000000 +0200
|
|
|
|
+++ openssh-7.6p1/session.h 2017-10-04 17:18:32.839505074 +0200
|
2017-01-02 14:42:13 +00:00
|
|
|
@@ -60,6 +60,12 @@ struct Session {
|
2013-04-08 15:17:10 +00:00
|
|
|
char *name;
|
|
|
|
char *val;
|
|
|
|
} *env;
|
|
|
|
+
|
|
|
|
+ /* exec */
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
|
|
|
+ int command_handle;
|
|
|
|
+ char *command;
|
|
|
|
+#endif
|
|
|
|
};
|
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
void do_authenticated(struct ssh *, Authctxt *);
|
|
|
|
@@ -72,8 +78,10 @@ void session_close_by_pid(struct ssh *s
|
|
|
|
void session_close_by_channel(struct ssh *, int, void *);
|
|
|
|
void session_destroy_all(struct ssh *, void (*)(Session *));
|
2013-04-08 15:17:10 +00:00
|
|
|
void session_pty_cleanup2(Session *);
|
|
|
|
+void session_end_command2(Session *);
|
|
|
|
|
|
|
|
Session *session_new(void);
|
|
|
|
+Session *session_by_id(int);
|
|
|
|
Session *session_by_tty(char *);
|
2017-09-26 12:04:45 +00:00
|
|
|
void session_close(struct ssh *, Session *);
|
2013-04-08 15:17:10 +00:00
|
|
|
void do_setusercontext(struct passwd *);
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/sshd.c.audit openssh-7.6p1/sshd.c
|
|
|
|
--- openssh-7.6p1/sshd.c.audit 2017-10-04 17:18:32.830505028 +0200
|
|
|
|
+++ openssh-7.6p1/sshd.c 2017-10-04 17:18:32.839505074 +0200
|
|
|
|
@@ -122,6 +122,7 @@
|
2016-02-19 13:42:33 +00:00
|
|
|
#include "ssh-gss.h"
|
2013-04-08 15:17:10 +00:00
|
|
|
#endif
|
|
|
|
#include "monitor_wrap.h"
|
|
|
|
+#include "audit.h"
|
|
|
|
#include "ssh-sandbox.h"
|
|
|
|
#include "version.h"
|
2015-03-20 13:56:04 +00:00
|
|
|
#include "ssherr.h"
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -248,7 +249,7 @@ Buffer loginmsg;
|
2013-04-08 15:17:10 +00:00
|
|
|
struct passwd *privsep_pw = NULL;
|
|
|
|
|
|
|
|
/* Prototypes for various functions defined later in this file. */
|
|
|
|
-void destroy_sensitive_data(void);
|
|
|
|
+void destroy_sensitive_data(int);
|
|
|
|
void demote_sensitive_data(void);
|
2017-01-02 14:42:13 +00:00
|
|
|
static void do_ssh2_kex(void);
|
2013-04-08 15:17:10 +00:00
|
|
|
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -265,6 +266,15 @@ close_listen_socks(void)
|
2013-04-08 15:17:10 +00:00
|
|
|
num_listen_socks = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * Is this process listening for clients (i.e. not specific to any specific
|
|
|
|
+ * client connection?)
|
|
|
|
+ */
|
|
|
|
+int listening_for_clients(void)
|
|
|
|
+{
|
2016-07-26 13:14:46 +00:00
|
|
|
+ return num_listen_socks >= 0;
|
2013-04-08 15:17:10 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
static void
|
|
|
|
close_startup_pipes(void)
|
|
|
|
{
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -475,18 +485,45 @@ sshd_exchange_identification(struct ssh
|
2013-04-08 15:17:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-/* Destroy the host and server keys. They will no longer be needed. */
|
|
|
|
+/*
|
|
|
|
+ * Destroy the host and server keys. They will no longer be needed. Careful,
|
|
|
|
+ * this can be called from cleanup_exit() - i.e. from just about anywhere.
|
|
|
|
+ */
|
|
|
|
void
|
|
|
|
-destroy_sensitive_data(void)
|
|
|
|
+destroy_sensitive_data(int privsep)
|
|
|
|
{
|
|
|
|
int i;
|
2016-03-04 13:33:02 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2013-04-08 15:17:10 +00:00
|
|
|
+ pid_t pid;
|
|
|
|
+ uid_t uid;
|
|
|
|
|
2016-03-04 13:33:02 +00:00
|
|
|
+ pid = getpid();
|
|
|
|
+ uid = getuid();
|
|
|
|
+#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
for (i = 0; i < options.num_host_key_files; i++) {
|
|
|
|
if (sensitive_data.host_keys[i]) {
|
|
|
|
+ char *fp;
|
|
|
|
+
|
|
|
|
+ if (key_is_private(sensitive_data.host_keys[i]))
|
2015-03-20 13:56:04 +00:00
|
|
|
+ fp = sshkey_fingerprint(sensitive_data.host_keys[i], options.fingerprint_hash, SSH_FP_HEX);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ else
|
|
|
|
+ fp = NULL;
|
|
|
|
key_free(sensitive_data.host_keys[i]);
|
|
|
|
sensitive_data.host_keys[i] = NULL;
|
|
|
|
+ if (fp != NULL) {
|
2016-03-04 13:33:02 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2013-04-08 15:17:10 +00:00
|
|
|
+ if (privsep)
|
|
|
|
+ PRIVSEP(audit_destroy_sensitive_data(fp,
|
|
|
|
+ pid, uid));
|
|
|
|
+ else
|
|
|
|
+ audit_destroy_sensitive_data(fp,
|
|
|
|
+ pid, uid);
|
2016-03-04 13:33:02 +00:00
|
|
|
+#endif
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(fp);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
- if (sensitive_data.host_certificates[i]) {
|
|
|
|
+ if (sensitive_data.host_certificates
|
|
|
|
+ && sensitive_data.host_certificates[i]) {
|
|
|
|
key_free(sensitive_data.host_certificates[i]);
|
|
|
|
sensitive_data.host_certificates[i] = NULL;
|
|
|
|
}
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -499,12 +536,30 @@ demote_sensitive_data(void)
|
2013-04-08 15:17:10 +00:00
|
|
|
{
|
2017-09-26 12:04:45 +00:00
|
|
|
struct sshkey *tmp;
|
2016-03-04 13:33:02 +00:00
|
|
|
int i;
|
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2013-04-08 15:17:10 +00:00
|
|
|
+ pid_t pid;
|
|
|
|
+ uid_t uid;
|
|
|
|
|
|
|
|
+ pid = getpid();
|
|
|
|
+ uid = getuid();
|
2016-03-04 13:33:02 +00:00
|
|
|
+#endif
|
2013-04-08 15:17:10 +00:00
|
|
|
for (i = 0; i < options.num_host_key_files; i++) {
|
|
|
|
if (sensitive_data.host_keys[i]) {
|
|
|
|
+ char *fp;
|
|
|
|
+
|
|
|
|
+ if (key_is_private(sensitive_data.host_keys[i]))
|
2015-03-20 13:56:04 +00:00
|
|
|
+ fp = sshkey_fingerprint(sensitive_data.host_keys[i], options.fingerprint_hash, SSH_FP_HEX);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ else
|
|
|
|
+ fp = NULL;
|
|
|
|
tmp = key_demote(sensitive_data.host_keys[i]);
|
|
|
|
key_free(sensitive_data.host_keys[i]);
|
|
|
|
sensitive_data.host_keys[i] = tmp;
|
|
|
|
+ if (fp != NULL) {
|
2016-03-04 13:33:02 +00:00
|
|
|
+#ifdef SSH_AUDIT_EVENTS
|
2013-04-08 15:17:10 +00:00
|
|
|
+ audit_destroy_sensitive_data(fp, pid, uid);
|
2016-03-04 13:33:02 +00:00
|
|
|
+#endif
|
2013-10-14 13:54:41 +00:00
|
|
|
+ free(fp);
|
2013-04-08 15:17:10 +00:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
/* Certs do not need demotion */
|
|
|
|
}
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -587,7 +642,7 @@ privsep_preauth(Authctxt *authctxt)
|
2013-11-26 12:22:08 +00:00
|
|
|
|
|
|
|
if (use_privsep == PRIVSEP_ON)
|
2014-07-08 13:52:24 +00:00
|
|
|
box = ssh_sandbox_init(pmonitor);
|
2013-11-26 12:22:08 +00:00
|
|
|
- pid = fork();
|
|
|
|
+ pmonitor->m_pid = pid = fork();
|
|
|
|
if (pid == -1) {
|
|
|
|
fatal("fork of unprivileged child failed");
|
|
|
|
} else if (pid != 0) {
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -1162,6 +1217,7 @@ server_accept_loop(int *sock_in, int *so
|
2013-04-08 15:17:10 +00:00
|
|
|
if (received_sigterm) {
|
|
|
|
logit("Received signal %d; terminating.",
|
|
|
|
(int) received_sigterm);
|
|
|
|
+ destroy_sensitive_data(0);
|
|
|
|
close_listen_socks();
|
2015-03-20 13:56:04 +00:00
|
|
|
if (options.pid_file != NULL)
|
|
|
|
unlink(options.pid_file);
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -2165,6 +2221,9 @@ main(int ac, char **av)
|
|
|
|
do_authenticated(ssh, authctxt);
|
2013-04-08 15:17:10 +00:00
|
|
|
|
|
|
|
/* The connection has been terminated. */
|
|
|
|
+ packet_destroy_all(1, 1);
|
|
|
|
+ destroy_sensitive_data(1);
|
|
|
|
+
|
2015-03-20 13:56:04 +00:00
|
|
|
packet_get_bytes(&ibytes, &obytes);
|
2013-04-08 15:17:10 +00:00
|
|
|
verbose("Transferred: sent %llu, received %llu bytes",
|
2015-03-20 13:56:04 +00:00
|
|
|
(unsigned long long)obytes, (unsigned long long)ibytes);
|
2017-09-26 12:04:45 +00:00
|
|
|
@@ -2344,6 +2403,15 @@ void
|
2013-04-08 15:17:10 +00:00
|
|
|
cleanup_exit(int i)
|
|
|
|
{
|
2017-09-26 12:04:45 +00:00
|
|
|
struct ssh *ssh = active_state; /* XXX */
|
2013-04-08 15:17:10 +00:00
|
|
|
+ static int in_cleanup = 0;
|
|
|
|
+ int is_privsep_child;
|
|
|
|
+
|
|
|
|
+ /* cleanup_exit can be called at the very least from the privsep
|
|
|
|
+ wrappers used for auditing. Make sure we don't recurse
|
|
|
|
+ indefinitely. */
|
|
|
|
+ if (in_cleanup)
|
|
|
|
+ _exit(i);
|
|
|
|
+ in_cleanup = 1;
|
2017-09-26 12:04:45 +00:00
|
|
|
|
2013-04-08 15:17:10 +00:00
|
|
|
if (the_authctxt) {
|
2017-09-26 12:04:45 +00:00
|
|
|
do_cleanup(ssh, the_authctxt);
|
|
|
|
@@ -2356,9 +2424,14 @@ cleanup_exit(int i)
|
2013-04-08 15:17:10 +00:00
|
|
|
pmonitor->m_pid, strerror(errno));
|
|
|
|
}
|
|
|
|
}
|
2013-11-26 12:22:08 +00:00
|
|
|
+ is_privsep_child = use_privsep && pmonitor != NULL && pmonitor->m_pid == 0;
|
2013-04-08 15:17:10 +00:00
|
|
|
+ if (sensitive_data.host_keys != NULL)
|
|
|
|
+ destroy_sensitive_data(is_privsep_child);
|
|
|
|
+ packet_destroy_all(1, is_privsep_child);
|
|
|
|
#ifdef SSH_AUDIT_EVENTS
|
|
|
|
/* done after do_cleanup so it can cancel the PAM auth 'thread' */
|
|
|
|
- if (!use_privsep || mm_is_monitor())
|
|
|
|
+ if ((the_authctxt == NULL || !the_authctxt->authenticated) &&
|
|
|
|
+ (!use_privsep || mm_is_monitor()))
|
|
|
|
audit_event(SSH_CONNECTION_ABANDON);
|
|
|
|
#endif
|
|
|
|
_exit(i);
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/sshkey.c.audit openssh-7.6p1/sshkey.c
|
|
|
|
--- openssh-7.6p1/sshkey.c.audit 2017-10-04 17:18:32.758504660 +0200
|
|
|
|
+++ openssh-7.6p1/sshkey.c 2017-10-04 17:18:32.839505074 +0200
|
|
|
|
@@ -295,6 +295,32 @@ sshkey_type_is_valid_ca(int type)
|
2015-01-20 12:18:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
+sshkey_is_private(const struct sshkey *k)
|
|
|
|
+{
|
|
|
|
+ switch (k->type) {
|
2016-01-05 11:47:04 +00:00
|
|
|
+#ifdef WITH_OPENSSL
|
2015-01-20 12:18:45 +00:00
|
|
|
+ case KEY_RSA_CERT:
|
|
|
|
+ case KEY_RSA:
|
|
|
|
+ return k->rsa->d != NULL;
|
|
|
|
+ case KEY_DSA_CERT:
|
|
|
|
+ case KEY_DSA:
|
|
|
|
+ return k->dsa->priv_key != NULL;
|
|
|
|
+#ifdef OPENSSL_HAS_ECC
|
|
|
|
+ case KEY_ECDSA_CERT:
|
|
|
|
+ case KEY_ECDSA:
|
|
|
|
+ return EC_KEY_get0_private_key(k->ecdsa) != NULL;
|
2016-01-05 11:47:04 +00:00
|
|
|
+#endif /* OPENSSL_HAS_ECC */
|
|
|
|
+#endif /* WITH_OPENSSL */
|
2015-01-20 12:18:45 +00:00
|
|
|
+ case KEY_ED25519_CERT:
|
|
|
|
+ case KEY_ED25519:
|
|
|
|
+ return (k->ed25519_pk != NULL);
|
|
|
|
+ default:
|
|
|
|
+ /* fatal("key_is_private: bad key type %d", k->type); */
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
sshkey_is_cert(const struct sshkey *k)
|
|
|
|
{
|
|
|
|
if (k == NULL)
|
2017-09-26 12:04:45 +00:00
|
|
|
diff -up openssh-7.6p1/sshkey.h.audit openssh-7.6p1/sshkey.h
|
|
|
|
--- openssh-7.6p1/sshkey.h.audit 2017-10-04 17:18:32.758504660 +0200
|
|
|
|
+++ openssh-7.6p1/sshkey.h 2017-10-04 17:18:32.840505079 +0200
|
|
|
|
@@ -133,6 +133,7 @@ u_int sshkey_size(const struct sshkey
|
2015-01-20 12:18:45 +00:00
|
|
|
int sshkey_generate(int type, u_int bits, struct sshkey **keyp);
|
|
|
|
int sshkey_from_private(const struct sshkey *, struct sshkey **);
|
|
|
|
int sshkey_type_from_name(const char *);
|
|
|
|
+int sshkey_is_private(const struct sshkey *);
|
|
|
|
int sshkey_is_cert(const struct sshkey *);
|
|
|
|
int sshkey_type_is_cert(int);
|
|
|
|
int sshkey_type_plain(int);
|