|
Jan F |
1732b0 |
diff -up openssh-5.8p1/audit-bsm.c.audit1 openssh-5.8p1/audit-bsm.c
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/audit-bsm.c.audit1 2011-01-17 11:15:29.000000000 +0100
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/audit-bsm.c 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -305,6 +305,12 @@ audit_run_command(const char *command)
|
|
Jan F |
1732b0 |
}
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
void
|
|
Jan F |
1732b0 |
+audit_end_command(const char *command)
|
|
Jan F |
1732b0 |
+{
|
|
Jan F |
1732b0 |
+ /* not implemented */
|
|
Jan F |
1732b0 |
+}
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+void
|
|
Jan F |
1732b0 |
audit_session_open(struct logininfo *li)
|
|
Jan F |
1732b0 |
{
|
|
Jan F |
1732b0 |
/* not implemented */
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/audit.c.audit1 openssh-5.8p1/audit.c
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/audit.c.audit1 2011-01-17 11:15:30.000000000 +0100
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/audit.c 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -182,5 +182,18 @@ audit_run_command(const char *command)
|
|
Jan F |
1732b0 |
debug("audit run command euid %d user %s command '%.200s'", geteuid(),
|
|
Jan F |
1732b0 |
audit_username(), command);
|
|
Jan F |
1732b0 |
}
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+/*
|
|
Jan F |
1732b0 |
+ * This will be called when the non-interactive command finishes. Note that
|
|
Jan F |
1732b0 |
+ * it may be called multiple times for a single connection since SSH2 allows
|
|
Jan F |
1732b0 |
+ * multiple sessions within a single connection.
|
|
Jan F |
1732b0 |
+ */
|
|
Jan F |
1732b0 |
+void
|
|
Jan F |
1732b0 |
+audit_end_command(const char *command)
|
|
Jan F |
1732b0 |
+{
|
|
Jan F |
1732b0 |
+ debug("audit end nopty exec euid %d user %s command '%.200s'", geteuid(),
|
|
Jan F |
1732b0 |
+ audit_username(), command);
|
|
Jan F |
1732b0 |
+}
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
# endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */
|
|
Jan F |
1732b0 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/audit.h.audit1 openssh-5.8p1/audit.h
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/audit.h.audit1 2011-01-17 11:15:30.000000000 +0100
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/audit.h 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -52,6 +52,7 @@ void audit_event(ssh_audit_event_t);
|
|
Jan F |
1732b0 |
void audit_session_open(struct logininfo *);
|
|
Jan F |
1732b0 |
void audit_session_close(struct logininfo *);
|
|
Jan F |
1732b0 |
void audit_run_command(const char *);
|
|
Jan F |
1732b0 |
+void audit_end_command(const char *);
|
|
Jan F |
1732b0 |
ssh_audit_event_t audit_classify_auth(const char *);
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
#endif /* _SSH_AUDIT_H */
|
|
Jan F |
483c73 |
diff -up openssh-5.8p1/audit-linux.c.audit1 openssh-5.8p1/audit-linux.c
|
|
Jan F |
b9127e |
--- openssh-5.8p1/audit-linux.c.audit1 2011-01-17 11:15:30.000000000 +0100
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/audit-linux.c 2011-02-23 09:46:43.000000000 +0100
|
|
Jan F |
c2b009 |
@@ -35,13 +35,20 @@
|
|
Jan F |
483c73 |
|
|
Jan F |
c2b009 |
#include "log.h"
|
|
Jan F |
c2b009 |
#include "audit.h"
|
|
Jan F |
c2b009 |
+#include "key.h"
|
|
Jan F |
c2b009 |
+#include "hostfile.h"
|
|
Jan F |
c2b009 |
+#include "auth.h"
|
|
Jan F |
c2b009 |
+#include "servconf.h"
|
|
Jan F |
c2b009 |
#include "canohost.h"
|
|
Jan F |
c2b009 |
|
|
Jan F |
c2b009 |
+extern ServerOptions options;
|
|
Jan F |
c2b009 |
+extern Authctxt *the_authctxt;
|
|
Jan F |
c2b009 |
+extern u_int utmp_len;
|
|
Jan F |
483c73 |
const char* audit_username(void);
|
|
Jan F |
483c73 |
|
|
Jan F |
483c73 |
-int
|
|
Jan F |
483c73 |
-linux_audit_record_event(int uid, const char *username,
|
|
Jan F |
c2b009 |
- const char *hostname, const char *ip, const char *ttyn, int success)
|
|
Jan F |
b9127e |
+static void
|
|
Jan F |
c2b009 |
+linux_audit_user_logxxx(int uid, const char *username,
|
|
Jan F |
c2b009 |
+ const char *hostname, const char *ip, const char *ttyn, int success, int event)
|
|
Jan F |
483c73 |
{
|
|
Jan F |
483c73 |
int audit_fd, rc, saved_errno;
|
|
Jan F |
c2b009 |
|
|
Jan F |
c2b009 |
@@ -49,11 +56,11 @@ linux_audit_record_event(int uid, const
|
|
Jan F |
b9127e |
if (audit_fd < 0) {
|
|
Jan F |
b9127e |
if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
Jan F |
b9127e |
errno == EAFNOSUPPORT)
|
|
Jan F |
b9127e |
- return 1; /* No audit support in kernel */
|
|
Jan F |
b9127e |
+ return; /* No audit support in kernel */
|
|
Jan F |
b9127e |
else
|
|
Jan F |
b9127e |
- return 0; /* Must prevent login */
|
|
Jan F |
b9127e |
+ goto fatal_report; /* Must prevent login */
|
|
Jan F |
b9127e |
}
|
|
Jan F |
c2b009 |
- rc = audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN,
|
|
Jan F |
c2b009 |
+ rc = audit_log_acct_message(audit_fd, event,
|
|
Jan F |
b9127e |
NULL, "login", username ? username : "(unknown)",
|
|
Jan F |
c2b009 |
username == NULL ? uid : -1, hostname, ip, ttyn, success);
|
|
Jan F |
c2b009 |
saved_errno = errno;
|
|
Jan F |
1732b0 |
@@ -65,35 +72,112 @@ linux_audit_record_event(int uid, const
|
|
Jan F |
b9127e |
if ((rc == -EPERM) && (geteuid() != 0))
|
|
Jan F |
b9127e |
rc = 0;
|
|
Jan F |
b9127e |
errno = saved_errno;
|
|
Jan F |
b9127e |
- return (rc >= 0);
|
|
Jan F |
b9127e |
+ if (rc < 0) {
|
|
Jan F |
b9127e |
+fatal_report:
|
|
Jan F |
b9127e |
+ fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
|
Jan F |
b9127e |
+ }
|
|
Jan F |
b9127e |
+}
|
|
Jan F |
b9127e |
+
|
|
Jan F |
b9127e |
+static void
|
|
Jan F |
483c73 |
+linux_audit_user_auth(int uid, const char *username,
|
|
Jan F |
483c73 |
+ const char *hostname, const char *ip, const char *ttyn, int success, int event)
|
|
Jan F |
483c73 |
+{
|
|
Jan F |
483c73 |
+ int audit_fd, rc, saved_errno;
|
|
Jan F |
483c73 |
+ static const char *event_name[] = {
|
|
Jan F |
c2b009 |
+ "maxtries exceeded",
|
|
Jan F |
483c73 |
+ "root denied",
|
|
Jan F |
483c73 |
+ "success",
|
|
Jan F |
483c73 |
+ "none",
|
|
Jan F |
c2b009 |
+ "password",
|
|
Jan F |
c2b009 |
+ "challenge-response",
|
|
Jan F |
483c73 |
+ "pubkey",
|
|
Jan F |
483c73 |
+ "hostbased",
|
|
Jan F |
483c73 |
+ "gssapi",
|
|
Jan F |
483c73 |
+ "invalid user",
|
|
Jan F |
483c73 |
+ "nologin",
|
|
Jan F |
c2b009 |
+ "connection closed",
|
|
Jan F |
c2b009 |
+ "connection abandoned",
|
|
Jan F |
483c73 |
+ "unknown"
|
|
Jan F |
483c73 |
+ };
|
|
Jan F |
483c73 |
+
|
|
Jan F |
483c73 |
+ audit_fd = audit_open();
|
|
Jan F |
483c73 |
+ if (audit_fd < 0) {
|
|
Jan F |
483c73 |
+ if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
Jan F |
483c73 |
+ errno == EAFNOSUPPORT)
|
|
Jan F |
b9127e |
+ return; /* No audit support in kernel */
|
|
Jan F |
483c73 |
+ else
|
|
Jan F |
b9127e |
+ goto fatal_report; /* Must prevent login */
|
|
Jan F |
483c73 |
+ }
|
|
Jan F |
483c73 |
+
|
|
Jan F |
483c73 |
+ if ((event < 0) || (event > SSH_AUDIT_UNKNOWN))
|
|
Jan F |
483c73 |
+ event = SSH_AUDIT_UNKNOWN;
|
|
Jan F |
483c73 |
+
|
|
Jan F |
483c73 |
+ rc = audit_log_acct_message(audit_fd, AUDIT_USER_AUTH,
|
|
Jan F |
483c73 |
+ NULL, event_name[event], username ? username : "(unknown)",
|
|
Jan F |
483c73 |
+ username == NULL ? uid : -1, hostname, ip, ttyn, success);
|
|
Jan F |
483c73 |
+ saved_errno = errno;
|
|
Jan F |
483c73 |
+ close(audit_fd);
|
|
Jan F |
483c73 |
+ /*
|
|
Jan F |
483c73 |
+ * Do not report error if the error is EPERM and sshd is run as non
|
|
Jan F |
483c73 |
+ * root user.
|
|
Jan F |
483c73 |
+ */
|
|
Jan F |
483c73 |
+ if ((rc == -EPERM) && (geteuid() != 0))
|
|
Jan F |
483c73 |
+ rc = 0;
|
|
Jan F |
483c73 |
+ errno = saved_errno;
|
|
Jan F |
b9127e |
+ if (rc < 0) {
|
|
Jan F |
b9127e |
+fatal_report:
|
|
Jan F |
b9127e |
+ fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
|
Jan F |
b9127e |
+ }
|
|
Jan F |
b9127e |
}
|
|
Jan F |
483c73 |
|
|
Jan F |
c2b009 |
+static int user_login_count = 0;
|
|
Jan F |
c2b009 |
+
|
|
Jan F |
b9127e |
/* Below is the sshd audit API code */
|
|
Jan F |
c2b009 |
|
|
Jan F |
483c73 |
void
|
|
Jan F |
483c73 |
audit_connection_from(const char *host, int port)
|
|
Jan F |
483c73 |
{
|
|
Jan F |
483c73 |
-}
|
|
Jan F |
483c73 |
/* not implemented */
|
|
Jan F |
483c73 |
+}
|
|
Jan F |
483c73 |
|
|
Jan F |
483c73 |
void
|
|
Jan F |
483c73 |
audit_run_command(const char *command)
|
|
Jan F |
c2b009 |
{
|
|
Jan F |
c2b009 |
- /* not implemented */
|
|
Jan F |
c2b009 |
+ if (!user_login_count++)
|
|
Jan F |
c2b009 |
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL, get_remote_name_or_ip(utmp_len, options.use_dns),
|
|
Jan F |
c2b009 |
+ NULL, "ssh", 1, AUDIT_USER_LOGIN);
|
|
Jan F |
1732b0 |
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL, get_remote_name_or_ip(utmp_len, options.use_dns),
|
|
Jan F |
1732b0 |
+ NULL, "ssh", 1, AUDIT_USER_START);
|
|
Jan F |
1732b0 |
+}
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+void
|
|
Jan F |
1732b0 |
+audit_end_command(const char *command)
|
|
Jan F |
1732b0 |
+{
|
|
Jan F |
1732b0 |
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL, get_remote_name_or_ip(utmp_len, options.use_dns),
|
|
Jan F |
1732b0 |
+ NULL, "ssh", 1, AUDIT_USER_END);
|
|
Jan F |
1732b0 |
+ if (!--user_login_count)
|
|
Jan F |
1732b0 |
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL, get_remote_name_or_ip(utmp_len, options.use_dns),
|
|
Jan F |
1732b0 |
+ NULL, "ssh", 1, AUDIT_USER_LOGOUT);
|
|
Jan F |
c2b009 |
}
|
|
Jan F |
c2b009 |
|
|
Jan F |
483c73 |
void
|
|
Jan F |
483c73 |
audit_session_open(struct logininfo *li)
|
|
Jan F |
483c73 |
{
|
|
Jan F |
483c73 |
- if (linux_audit_record_event(li->uid, NULL, li->hostname,
|
|
Jan F |
b9127e |
- NULL, li->line, 1) == 0)
|
|
Jan F |
b9127e |
- fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
|
Jan F |
c2b009 |
+ if (!user_login_count++)
|
|
Jan F |
c2b009 |
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
|
Jan F |
c2b009 |
+ NULL, li->line, 1, AUDIT_USER_LOGIN);
|
|
Jan F |
1732b0 |
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
|
Jan F |
1732b0 |
+ NULL, li->line, 1, AUDIT_USER_START);
|
|
Jan F |
c2b009 |
}
|
|
Jan F |
c2b009 |
|
|
Jan F |
c2b009 |
void
|
|
Jan F |
c2b009 |
audit_session_close(struct logininfo *li)
|
|
Jan F |
c2b009 |
{
|
|
Jan F |
c2b009 |
- /* not implemented */
|
|
Jan F |
c2b009 |
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
|
Jan F |
c2b009 |
+ NULL, li->line, 1, AUDIT_USER_END);
|
|
Jan F |
c2b009 |
+ if (!--user_login_count)
|
|
Jan F |
c2b009 |
+ linux_audit_user_logxxx(li->uid, NULL, li->hostname,
|
|
Jan F |
c2b009 |
+ NULL, li->line, 1, AUDIT_USER_LOGOUT);
|
|
Jan F |
483c73 |
}
|
|
Jan F |
b9127e |
|
|
Jan F |
b9127e |
void
|
|
Jan F |
1732b0 |
@@ -101,21 +185,43 @@ audit_event(ssh_audit_event_t event)
|
|
Jan F |
483c73 |
{
|
|
Jan F |
483c73 |
switch(event) {
|
|
Jan F |
483c73 |
case SSH_AUTH_SUCCESS:
|
|
Jan F |
483c73 |
- case SSH_CONNECTION_CLOSE:
|
|
Jan F |
b9127e |
+ linux_audit_user_auth(-1, audit_username(), NULL,
|
|
Jan F |
b9127e |
+ get_remote_ipaddr(), "sshd", 1, event);
|
|
Jan F |
483c73 |
+ break;
|
|
Jan F |
483c73 |
+
|
|
Jan F |
483c73 |
case SSH_NOLOGIN:
|
|
Jan F |
b9127e |
- case SSH_LOGIN_EXCEED_MAXTRIES:
|
|
Jan F |
483c73 |
case SSH_LOGIN_ROOT_DENIED:
|
|
Jan F |
483c73 |
+ linux_audit_user_auth(-1, audit_username(), NULL,
|
|
Jan F |
483c73 |
+ get_remote_ipaddr(), "sshd", 0, event);
|
|
Jan F |
c2b009 |
+ linux_audit_user_logxxx(-1, audit_username(), NULL,
|
|
Jan F |
c2b009 |
+ get_remote_ipaddr(), "sshd", 0, AUDIT_USER_LOGIN);
|
|
Jan F |
483c73 |
break;
|
|
Jan F |
483c73 |
|
|
Jan F |
b9127e |
+ case SSH_LOGIN_EXCEED_MAXTRIES:
|
|
Jan F |
483c73 |
case SSH_AUTH_FAIL_NONE:
|
|
Jan F |
b9127e |
case SSH_AUTH_FAIL_PASSWD:
|
|
Jan F |
b9127e |
case SSH_AUTH_FAIL_KBDINT:
|
|
Jan F |
483c73 |
case SSH_AUTH_FAIL_PUBKEY:
|
|
Jan F |
483c73 |
case SSH_AUTH_FAIL_HOSTBASED:
|
|
Jan F |
483c73 |
case SSH_AUTH_FAIL_GSSAPI:
|
|
Jan F |
483c73 |
+ linux_audit_user_auth(-1, audit_username(), NULL,
|
|
Jan F |
483c73 |
+ get_remote_ipaddr(), "sshd", 0, event);
|
|
Jan F |
483c73 |
+ break;
|
|
Jan F |
483c73 |
+
|
|
Jan F |
483c73 |
+ case SSH_CONNECTION_CLOSE:
|
|
Jan F |
1732b0 |
+ if (user_login_count) {
|
|
Jan F |
1732b0 |
+ while (user_login_count--)
|
|
Jan F |
1732b0 |
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL, get_remote_name_or_ip(utmp_len, options.use_dns),
|
|
Jan F |
1732b0 |
+ NULL, "ssh", 1, AUDIT_USER_END);
|
|
Jan F |
1732b0 |
+ linux_audit_user_logxxx(the_authctxt->pw->pw_uid, NULL, get_remote_name_or_ip(utmp_len, options.use_dns),
|
|
Jan F |
1732b0 |
+ NULL, "ssh", 1, AUDIT_USER_LOGOUT);
|
|
Jan F |
1732b0 |
+ }
|
|
Jan F |
1732b0 |
+ break;
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
483c73 |
+ case SSH_CONNECTION_ABANDON:
|
|
Jan F |
483c73 |
case SSH_INVALID_USER:
|
|
Jan F |
483c73 |
- linux_audit_record_event(-1, audit_username(), NULL,
|
|
Jan F |
c2b009 |
- get_remote_ipaddr(), "sshd", 0);
|
|
Jan F |
c2b009 |
+ linux_audit_user_logxxx(-1, audit_username(), NULL,
|
|
Jan F |
c2b009 |
+ get_remote_ipaddr(), "sshd", 0, AUDIT_USER_LOGIN);
|
|
Jan F |
483c73 |
break;
|
|
Jan F |
483c73 |
|
|
Jan F |
c2b009 |
default:
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/monitor.c.audit1 openssh-5.8p1/monitor.c
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/monitor.c.audit1 2010-09-10 03:23:34.000000000 +0200
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/monitor.c 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -177,6 +177,7 @@ int mm_answer_gss_checkmic(int, Buffer *
|
|
Jan F |
1732b0 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F |
1732b0 |
int mm_answer_audit_event(int, Buffer *);
|
|
Jan F |
1732b0 |
int mm_answer_audit_command(int, Buffer *);
|
|
Jan F |
1732b0 |
+int mm_answer_audit_end_command(int, Buffer *);
|
|
Jan F |
1732b0 |
#endif
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
static Authctxt *authctxt;
|
|
Jan F |
1732b0 |
@@ -261,6 +262,7 @@ struct mon_table mon_dispatch_postauth20
|
|
Jan F |
1732b0 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F |
1732b0 |
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
Jan F |
1732b0 |
{MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command},
|
|
Jan F |
1732b0 |
+ {MONITOR_REQ_AUDIT_END_COMMAND, MON_PERMIT, mm_answer_audit_end_command},
|
|
Jan F |
1732b0 |
#endif
|
|
Jan F |
1732b0 |
{0, 0, NULL}
|
|
Jan F |
1732b0 |
};
|
|
Jan F |
1732b0 |
@@ -303,6 +305,7 @@ struct mon_table mon_dispatch_postauth15
|
|
Jan F |
1732b0 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F |
1732b0 |
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
Jan F |
1732b0 |
{MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command},
|
|
Jan F |
1732b0 |
+ {MONITOR_REQ_AUDIT_END_COMMAND, MON_PERMIT, mm_answer_audit_end_command},
|
|
Jan F |
1732b0 |
#endif
|
|
Jan F |
1732b0 |
{0, 0, NULL}
|
|
Jan F |
1732b0 |
};
|
|
Jan F |
1732b0 |
@@ -1618,6 +1621,20 @@ mm_answer_audit_command(int socket, Buff
|
|
Jan F |
1732b0 |
xfree(cmd);
|
|
Jan F |
1732b0 |
return (0);
|
|
Jan F |
1732b0 |
}
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+int
|
|
Jan F |
1732b0 |
+mm_answer_audit_end_command(int socket, Buffer *m)
|
|
Jan F |
1732b0 |
+{
|
|
Jan F |
1732b0 |
+ u_int len;
|
|
Jan F |
1732b0 |
+ char *cmd;
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+ debug3("%s entering", __func__);
|
|
Jan F |
1732b0 |
+ cmd = buffer_get_string(m, &len;;
|
|
Jan F |
1732b0 |
+ /* sanity check command, if so how? */
|
|
Jan F |
1732b0 |
+ audit_end_command(cmd);
|
|
Jan F |
1732b0 |
+ xfree(cmd);
|
|
Jan F |
1732b0 |
+ return (0);
|
|
Jan F |
1732b0 |
+}
|
|
Jan F |
1732b0 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
void
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/monitor.h.audit1 openssh-5.8p1/monitor.h
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/monitor.h.audit1 2008-11-05 06:20:46.000000000 +0100
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/monitor.h 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -60,6 +60,7 @@ enum monitor_reqtype {
|
|
Jan F |
1732b0 |
MONITOR_REQ_PAM_RESPOND, MONITOR_ANS_PAM_RESPOND,
|
|
Jan F |
1732b0 |
MONITOR_REQ_PAM_FREE_CTX, MONITOR_ANS_PAM_FREE_CTX,
|
|
Jan F |
1732b0 |
MONITOR_REQ_AUDIT_EVENT, MONITOR_REQ_AUDIT_COMMAND,
|
|
Jan F |
1732b0 |
+ MONITOR_REQ_AUDIT_END_COMMAND,
|
|
Jan F |
1732b0 |
MONITOR_REQ_TERM,
|
|
Jan F |
1732b0 |
MONITOR_REQ_JPAKE_STEP1, MONITOR_ANS_JPAKE_STEP1,
|
|
Jan F |
1732b0 |
MONITOR_REQ_JPAKE_GET_PWDATA, MONITOR_ANS_JPAKE_GET_PWDATA,
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/monitor_wrap.c.audit1 openssh-5.8p1/monitor_wrap.c
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/monitor_wrap.c.audit1 2010-08-31 14:41:14.000000000 +0200
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/monitor_wrap.c 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -1163,6 +1163,20 @@ mm_audit_run_command(const char *command
|
|
Jan F |
1732b0 |
mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_COMMAND, &m);
|
|
Jan F |
1732b0 |
buffer_free(&m);
|
|
Jan F |
1732b0 |
}
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+void
|
|
Jan F |
1732b0 |
+mm_audit_end_command(const char *command)
|
|
Jan F |
1732b0 |
+{
|
|
Jan F |
1732b0 |
+ Buffer m;
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+ debug3("%s entering command %s", __func__, command);
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+ buffer_init(&m);
|
|
Jan F |
1732b0 |
+ buffer_put_cstring(&m, command);
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_END_COMMAND, &m);
|
|
Jan F |
1732b0 |
+ buffer_free(&m);
|
|
Jan F |
1732b0 |
+}
|
|
Jan F |
1732b0 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
#ifdef GSSAPI
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/monitor_wrap.h.audit1 openssh-5.8p1/monitor_wrap.h
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/monitor_wrap.h.audit1 2009-03-05 14:58:22.000000000 +0100
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/monitor_wrap.h 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -74,6 +74,7 @@ void mm_sshpam_free_ctx(void *);
|
|
Jan F |
1732b0 |
#include "audit.h"
|
|
Jan F |
1732b0 |
void mm_audit_event(ssh_audit_event_t);
|
|
Jan F |
1732b0 |
void mm_audit_run_command(const char *);
|
|
Jan F |
1732b0 |
+void mm_audit_end_command(const char *);
|
|
Jan F |
1732b0 |
#endif
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
struct Session;
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/session.c.audit1 openssh-5.8p1/session.c
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/session.c.audit1 2010-12-01 02:02:59.000000000 +0100
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/session.c 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -809,14 +809,16 @@ do_exec(Session *s, const char *command)
|
|
Jan F |
1732b0 |
}
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F |
1732b0 |
- if (command != NULL)
|
|
Jan F |
1732b0 |
+ if (command != NULL) {
|
|
Jan F |
1732b0 |
PRIVSEP(audit_run_command(command));
|
|
Jan F |
1732b0 |
- else if (s->ttyfd == -1) {
|
|
Jan F |
1732b0 |
+ command = xstrdup(command);
|
|
Jan F |
1732b0 |
+ } else if (s->ttyfd == -1) {
|
|
Jan F |
1732b0 |
char *shell = s->pw->pw_shell;
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
if (shell[0] == '\0') /* empty shell means /bin/sh */
|
|
Jan F |
1732b0 |
shell =_PATH_BSHELL;
|
|
Jan F |
1732b0 |
PRIVSEP(audit_run_command(shell));
|
|
Jan F |
1732b0 |
+ command = xstrdup(shell);
|
|
Jan F |
1732b0 |
}
|
|
Jan F |
1732b0 |
#endif
|
|
Jan F |
1732b0 |
if (s->ttyfd != -1)
|
|
Jan F |
1732b0 |
@@ -2456,6 +2458,12 @@ session_close(Session *s)
|
|
Jan F |
1732b0 |
debug("session_close: session %d pid %ld", s->self, (long)s->pid);
|
|
Jan F |
1732b0 |
if (s->ttyfd != -1)
|
|
Jan F |
1732b0 |
session_pty_cleanup(s);
|
|
Jan F |
1732b0 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F |
1732b0 |
+ if (s->command) {
|
|
Jan F |
1732b0 |
+ PRIVSEP(audit_end_command(s->command));
|
|
Jan F |
1732b0 |
+ xfree(s->command);
|
|
Jan F |
1732b0 |
+ }
|
|
Jan F |
1732b0 |
+#endif
|
|
Jan F |
1732b0 |
if (s->term)
|
|
Jan F |
1732b0 |
xfree(s->term);
|
|
Jan F |
1732b0 |
if (s->display)
|
|
Jan F |
1732b0 |
diff -up openssh-5.8p1/session.h.audit1 openssh-5.8p1/session.h
|
|
Jan F |
1732b0 |
--- openssh-5.8p1/session.h.audit1 2008-05-19 07:34:50.000000000 +0200
|
|
Jan F |
1732b0 |
+++ openssh-5.8p1/session.h 2011-02-23 09:45:05.000000000 +0100
|
|
Jan F |
1732b0 |
@@ -60,6 +60,11 @@ struct Session {
|
|
Jan F |
1732b0 |
char *name;
|
|
Jan F |
1732b0 |
char *val;
|
|
Jan F |
1732b0 |
} *env;
|
|
Jan F |
1732b0 |
+
|
|
Jan F |
1732b0 |
+ /* exec */
|
|
Jan F |
1732b0 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F |
1732b0 |
+ char *command;
|
|
Jan F |
1732b0 |
+#endif
|
|
Jan F |
1732b0 |
};
|
|
Jan F |
1732b0 |
|
|
Jan F |
1732b0 |
void do_authenticated(Authctxt *);
|