|
Jan F. Chadima |
2ed3f9 |
diff -up openssh-5.3p1/auth.c.audit openssh-5.3p1/auth.c
|
|
Jan F. Chadima |
2ed3f9 |
--- openssh-5.3p1/auth.c.audit 2008-11-05 06:12:54.000000000 +0100
|
|
Jan F. Chadima |
ecd50f |
+++ openssh-5.3p1/auth.c 2009-12-21 08:50:12.000000000 +0100
|
|
Jan F. Chadima |
2ed3f9 |
@@ -287,6 +287,12 @@ auth_log(Authctxt *authctxt, int authent
|
|
Jan F. Chadima |
2ed3f9 |
get_canonical_hostname(options.use_dns), "ssh", &loginmsg);
|
|
Jan F. Chadima |
2ed3f9 |
# endif
|
|
Jan F. Chadima |
2ed3f9 |
#endif
|
|
Jan F. Chadima |
2ed3f9 |
+#if HAVE_LINUX_AUDIT
|
|
Jan F. Chadima |
ecd50f |
+ if (authenticated == 0 && !authctxt->postponed) {
|
|
Jan F. Chadima |
ecd50f |
+ linux_audit_record_event(-1, authctxt->user, NULL,
|
|
Jan F. Chadima |
ecd50f |
+ get_remote_ipaddr(), "sshd", 0);
|
|
Jan F. Chadima |
ecd50f |
+ }
|
|
Jan F. Chadima |
2ed3f9 |
+#endif
|
|
Jan F. Chadima |
2ed3f9 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
2ed3f9 |
if (authenticated == 0 && !authctxt->postponed)
|
|
Jan F. Chadima |
2ed3f9 |
audit_event(audit_classify_auth(method));
|
|
Jan F. Chadima |
2ed3f9 |
@@ -533,6 +539,10 @@ getpwnamallow(const char *user)
|
|
Jan F. Chadima |
2ed3f9 |
record_failed_login(user,
|
|
Jan F. Chadima |
2ed3f9 |
get_canonical_hostname(options.use_dns), "ssh");
|
|
Jan F. Chadima |
2ed3f9 |
#endif
|
|
Jan F. Chadima |
2ed3f9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Jan F. Chadima |
ecd50f |
+ linux_audit_record_event(-1, user, NULL, get_remote_ipaddr(),
|
|
Jan F. Chadima |
ecd50f |
+ "sshd", 0);
|
|
Jan F. Chadima |
2ed3f9 |
+#endif
|
|
Jan F. Chadima |
2ed3f9 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
2ed3f9 |
audit_event(SSH_INVALID_USER);
|
|
Jan F. Chadima |
2ed3f9 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F. Chadima |
2ed3f9 |
diff -up openssh-5.3p1/configure.ac.audit openssh-5.3p1/configure.ac
|
|
Jan F. Chadima |
ecd50f |
--- openssh-5.3p1/configure.ac.audit 2009-12-21 08:48:59.000000000 +0100
|
|
Jan F. Chadima |
ecd50f |
+++ openssh-5.3p1/configure.ac 2009-12-21 08:51:47.000000000 +0100
|
|
Jan F. Chadima |
ecd50f |
@@ -3409,6 +3409,18 @@ AC_ARG_WITH(selinux,
|
|
Jan F. Chadima |
2ed3f9 |
fi ]
|
|
Jan F. Chadima |
2ed3f9 |
)
|
|
Jan F. Chadima |
2ed3f9 |
|
|
Jan F. Chadima |
2ed3f9 |
+# Check whether user wants Linux audit support
|
|
Jan F. Chadima |
2ed3f9 |
+LINUX_AUDIT_MSG="no"
|
|
Jan F. Chadima |
2ed3f9 |
+AC_ARG_WITH(linux-audit,
|
|
Jan F. Chadima |
ecd50f |
+ [ --with-linux-audit Enable Linux audit support],
|
|
Jan F. Chadima |
ecd50f |
+ [ if test "x$withval" != "xno" ; then
|
|
Jan F. Chadima |
ecd50f |
+ AC_DEFINE(HAVE_LINUX_AUDIT,1,[Define if you want Linux audit support.])
|
|
Jan F. Chadima |
ecd50f |
+ LINUX_AUDIT_MSG="yes"
|
|
Jan F. Chadima |
ecd50f |
+ AC_CHECK_HEADERS(libaudit.h)
|
|
Jan F. Chadima |
ecd50f |
+ SSHDLIBS="$SSHDLIBS -laudit"
|
|
Jan F. Chadima |
ecd50f |
+ fi ]
|
|
Jan F. Chadima |
2ed3f9 |
+)
|
|
Jan F. Chadima |
2ed3f9 |
+
|
|
Jan F. Chadima |
2ed3f9 |
# Check whether user wants Kerberos 5 support
|
|
Jan F. Chadima |
2ed3f9 |
KRB5_MSG="no"
|
|
Jan F. Chadima |
2ed3f9 |
AC_ARG_WITH(kerberos5,
|
|
Jan F. Chadima |
ecd50f |
@@ -4234,6 +4246,7 @@ echo " PAM support
|
|
Jan F. Chadima |
2ed3f9 |
echo " OSF SIA support: $SIA_MSG"
|
|
Jan F. Chadima |
2ed3f9 |
echo " KerberosV support: $KRB5_MSG"
|
|
Jan F. Chadima |
2ed3f9 |
echo " SELinux support: $SELINUX_MSG"
|
|
Jan F. Chadima |
2ed3f9 |
+echo " Linux audit support: $LINUX_AUDIT_MSG"
|
|
Jan F. Chadima |
2ed3f9 |
echo " Smartcard support: $SCARD_MSG"
|
|
Jan F. Chadima |
2ed3f9 |
echo " S/KEY support: $SKEY_MSG"
|
|
Jan F. Chadima |
2ed3f9 |
echo " TCP Wrappers support: $TCPW_MSG"
|
|
Jan F. Chadima |
2ed3f9 |
diff -up openssh-5.3p1/loginrec.c.audit openssh-5.3p1/loginrec.c
|
|
Jan F. Chadima |
2ed3f9 |
--- openssh-5.3p1/loginrec.c.audit 2009-02-12 03:12:22.000000000 +0100
|
|
Jan F. Chadima |
ecd50f |
+++ openssh-5.3p1/loginrec.c 2009-12-21 08:54:17.000000000 +0100
|
|
Jan F. Chadima |
2ed3f9 |
@@ -176,6 +176,10 @@
|
|
Jan F. Chadima |
2ed3f9 |
#include "auth.h"
|
|
Jan F. Chadima |
2ed3f9 |
#include "buffer.h"
|
|
Jan F. Chadima |
2ed3f9 |
|
|
Jan F. Chadima |
2ed3f9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Jan F. Chadima |
2ed3f9 |
+# include <libaudit.h>
|
|
Jan F. Chadima |
2ed3f9 |
+#endif
|
|
Jan F. Chadima |
2ed3f9 |
+
|
|
Jan F. Chadima |
2ed3f9 |
#ifdef HAVE_UTIL_H
|
|
Jan F. Chadima |
2ed3f9 |
# include <util.h>
|
|
Jan F. Chadima |
2ed3f9 |
#endif
|
|
Jan F. Chadima |
2ed3f9 |
@@ -202,6 +206,9 @@ int utmp_write_entry(struct logininfo *l
|
|
Jan F. Chadima |
2ed3f9 |
int utmpx_write_entry(struct logininfo *li);
|
|
Jan F. Chadima |
2ed3f9 |
int wtmp_write_entry(struct logininfo *li);
|
|
Jan F. Chadima |
2ed3f9 |
int wtmpx_write_entry(struct logininfo *li);
|
|
Jan F. Chadima |
2ed3f9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Jan F. Chadima |
2ed3f9 |
+int linux_audit_write_entry(struct logininfo *li);
|
|
Jan F. Chadima |
2ed3f9 |
+#endif
|
|
Jan F. Chadima |
2ed3f9 |
int lastlog_write_entry(struct logininfo *li);
|
|
Jan F. Chadima |
2ed3f9 |
int syslogin_write_entry(struct logininfo *li);
|
|
Jan F. Chadima |
2ed3f9 |
|
|
Jan F. Chadima |
2ed3f9 |
@@ -440,6 +447,10 @@ login_write(struct logininfo *li)
|
|
Jan F. Chadima |
2ed3f9 |
|
|
Jan F. Chadima |
2ed3f9 |
/* set the timestamp */
|
|
Jan F. Chadima |
2ed3f9 |
login_set_current_time(li);
|
|
Jan F. Chadima |
2ed3f9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Jan F. Chadima |
ecd50f |
+ if (linux_audit_write_entry(li) == 0)
|
|
Jan F. Chadima |
ecd50f |
+ fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
|
Jan F. Chadima |
2ed3f9 |
+#endif
|
|
Jan F. Chadima |
2ed3f9 |
#ifdef USE_LOGIN
|
|
Jan F. Chadima |
2ed3f9 |
syslogin_write_entry(li);
|
|
Jan F. Chadima |
2ed3f9 |
#endif
|
|
Jan F. Chadima |
ecd50f |
@@ -1394,6 +1405,47 @@ wtmpx_get_entry(struct logininfo *li)
|
|
Jan F. Chadima |
2ed3f9 |
}
|
|
Jan F. Chadima |
2ed3f9 |
#endif /* USE_WTMPX */
|
|
Jan F. Chadima |
2ed3f9 |
|
|
Jan F. Chadima |
2ed3f9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Jan F. Chadima |
2ed3f9 |
+int
|
|
Jan F. Chadima |
2ed3f9 |
+linux_audit_record_event(int uid, const char *username,
|
|
Jan F. Chadima |
ecd50f |
+ const char *hostname, const char *ip, const char *ttyn, int success)
|
|
Jan F. Chadima |
2ed3f9 |
+{
|
|
Jan F. Chadima |
ecd50f |
+ int audit_fd, rc;
|
|
Jan F. Chadima |
2ed3f9 |
+
|
|
Jan F. Chadima |
ecd50f |
+ audit_fd = audit_open();
|
|
Jan F. Chadima |
ecd50f |
+ if (audit_fd < 0) {
|
|
Jan F. Chadima |
ecd50f |
+ if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
Jan F. Chadima |
ecd50f |
+ errno == EAFNOSUPPORT)
|
|
Jan F. Chadima |
ecd50f |
+ return 1; /* No audit support in kernel */
|
|
Jan F. Chadima |
ecd50f |
+ else
|
|
Jan F. Chadima |
ecd50f |
+ return 0; /* Must prevent login */
|
|
Jan F. Chadima |
ecd50f |
+ }
|
|
Jan F. Chadima |
ecd50f |
+ rc = audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN,
|
|
Jan F. Chadima |
ecd50f |
+ NULL, "login", username ? username : "(unknown)",
|
|
Jan F. Chadima |
ecd50f |
+ username == NULL ? uid : -1, hostname, ip, ttyn, success);
|
|
Jan F. Chadima |
ecd50f |
+ close(audit_fd);
|
|
Jan F. Chadima |
ecd50f |
+ if (rc >= 0)
|
|
Jan F. Chadima |
ecd50f |
+ return 1;
|
|
Jan F. Chadima |
ecd50f |
+ else
|
|
Jan F. Chadima |
ecd50f |
+ return 0;
|
|
Jan F. Chadima |
2ed3f9 |
+}
|
|
Jan F. Chadima |
2ed3f9 |
+
|
|
Jan F. Chadima |
2ed3f9 |
+int
|
|
Jan F. Chadima |
2ed3f9 |
+linux_audit_write_entry(struct logininfo *li)
|
|
Jan F. Chadima |
2ed3f9 |
+{
|
|
Jan F. Chadima |
ecd50f |
+ switch(li->type) {
|
|
Jan F. Chadima |
ecd50f |
+ case LTYPE_LOGIN:
|
|
Jan F. Chadima |
ecd50f |
+ return (linux_audit_record_event(li->uid, NULL, li->hostname,
|
|
Jan F. Chadima |
ecd50f |
+ NULL, li->line, 1));
|
|
Jan F. Chadima |
ecd50f |
+ case LTYPE_LOGOUT:
|
|
Jan F. Chadima |
ecd50f |
+ return (1); /* We only care about logins */
|
|
Jan F. Chadima |
ecd50f |
+ default:
|
|
Jan F. Chadima |
ecd50f |
+ logit("%s: invalid type field", __func__);
|
|
Jan F. Chadima |
ecd50f |
+ return (0);
|
|
Jan F. Chadima |
ecd50f |
+ }
|
|
Jan F. Chadima |
2ed3f9 |
+}
|
|
Jan F. Chadima |
2ed3f9 |
+#endif /* HAVE_LINUX_AUDIT */
|
|
Jan F. Chadima |
2ed3f9 |
+
|
|
Jan F. Chadima |
2ed3f9 |
/**
|
|
Jan F. Chadima |
2ed3f9 |
** Low-level libutil login() functions
|
|
Jan F. Chadima |
2ed3f9 |
**/
|
|
Jan F. Chadima |
2ed3f9 |
diff -up openssh-5.3p1/loginrec.h.audit openssh-5.3p1/loginrec.h
|
|
Jan F. Chadima |
2ed3f9 |
--- openssh-5.3p1/loginrec.h.audit 2006-08-05 04:39:40.000000000 +0200
|
|
Jan F. Chadima |
ecd50f |
+++ openssh-5.3p1/loginrec.h 2009-12-21 08:48:59.000000000 +0100
|
|
Jan F. Chadima |
2ed3f9 |
@@ -127,5 +127,9 @@ char *line_stripname(char *dst, const ch
|
|
Jan F. Chadima |
2ed3f9 |
char *line_abbrevname(char *dst, const char *src, int dstsize);
|
|
Jan F. Chadima |
2ed3f9 |
|
|
Jan F. Chadima |
2ed3f9 |
void record_failed_login(const char *, const char *, const char *);
|
|
Jan F. Chadima |
2ed3f9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Jan F. Chadima |
2ed3f9 |
+int linux_audit_record_event(int uid, const char *username,
|
|
Jan F. Chadima |
ecd50f |
+ const char *hostname, const char *ip, const char *ttyn, int success);
|
|
Jan F. Chadima |
2ed3f9 |
+#endif /* HAVE_LINUX_AUDIT */
|
|
Jan F. Chadima |
2ed3f9 |
|
|
Jan F. Chadima |
2ed3f9 |
#endif /* _HAVE_LOGINREC_H_ */
|