|
Tomáš Mráz |
c9833c |
diff -up openssh-4.7p1/auth.c.audit openssh-4.7p1/auth.c
|
|
Tomáš Mráz |
c9833c |
--- openssh-4.7p1/auth.c.audit 2007-03-26 18:35:28.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
+++ openssh-4.7p1/auth.c 2007-09-06 17:07:44.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
@@ -286,6 +286,12 @@ auth_log(Authctxt *authctxt, int authent
|
|
Tomáš Mráz |
c9833c |
get_canonical_hostname(options.use_dns), "ssh", &loginmsg);
|
|
Tomáš Mráz |
c9833c |
# endif
|
|
Tomáš Mráz |
c9833c |
#endif
|
|
Tomáš Mráz |
c9833c |
+#if HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
c9833c |
+ if (authenticated == 0 && !authctxt->postponed) {
|
|
Tomáš Mráz |
c9833c |
+ linux_audit_record_event(-1, authctxt->user, NULL,
|
|
Tomáš Mráz |
c9833c |
+ get_remote_ipaddr(), "sshd", 0);
|
|
Tomáš Mráz |
c9833c |
+ }
|
|
Tomáš Mráz |
c9833c |
+#endif
|
|
Tomáš Mráz |
c9833c |
#ifdef SSH_AUDIT_EVENTS
|
|
Tomáš Mráz |
c9833c |
if (authenticated == 0 && !authctxt->postponed)
|
|
Tomáš Mráz |
c9833c |
audit_event(audit_classify_auth(method));
|
|
Tomáš Mráz |
c9833c |
@@ -492,6 +498,10 @@ getpwnamallow(const char *user)
|
|
Tomáš Mráz |
c9833c |
record_failed_login(user,
|
|
Tomáš Mráz |
c9833c |
get_canonical_hostname(options.use_dns), "ssh");
|
|
Tomáš Mráz |
c9833c |
#endif
|
|
Tomáš Mráz |
c9833c |
+#ifdef HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
c9833c |
+ linux_audit_record_event(-1, user, NULL, get_remote_ipaddr(),
|
|
Tomáš Mráz |
c9833c |
+ "sshd", 0);
|
|
Tomáš Mráz |
c9833c |
+#endif
|
|
Tomáš Mráz |
c9833c |
#ifdef SSH_AUDIT_EVENTS
|
|
Tomáš Mráz |
c9833c |
audit_event(SSH_INVALID_USER);
|
|
Tomáš Mráz |
c9833c |
#endif /* SSH_AUDIT_EVENTS */
|
|
Tomáš Mráz |
c9833c |
diff -up openssh-4.7p1/loginrec.c.audit openssh-4.7p1/loginrec.c
|
|
Tomáš Mráz |
c9833c |
--- openssh-4.7p1/loginrec.c.audit 2007-04-29 04:10:58.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
+++ openssh-4.7p1/loginrec.c 2007-09-06 17:07:44.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
@@ -176,6 +176,10 @@
|
|
Tomáš Mráz |
ad07b9 |
#include "auth.h"
|
|
Tomáš Mráz |
ad07b9 |
#include "buffer.h"
|
|
Tomáš Mráz |
ad07b9 |
|
|
Tomáš Mráz |
ad07b9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
ad07b9 |
+# include <libaudit.h>
|
|
Tomáš Mráz |
ad07b9 |
+#endif
|
|
Tomáš Mráz |
ad07b9 |
+
|
|
Tomáš Mráz |
ad07b9 |
#ifdef HAVE_UTIL_H
|
|
Tomáš Mráz |
ad07b9 |
# include <util.h>
|
|
Tomáš Mráz |
ad07b9 |
#endif
|
|
Tomáš Mráz |
c9833c |
@@ -202,6 +206,9 @@ int utmp_write_entry(struct logininfo *l
|
|
Tomáš Mráz |
ad07b9 |
int utmpx_write_entry(struct logininfo *li);
|
|
Tomáš Mráz |
ad07b9 |
int wtmp_write_entry(struct logininfo *li);
|
|
Tomáš Mráz |
ad07b9 |
int wtmpx_write_entry(struct logininfo *li);
|
|
Tomáš Mráz |
ad07b9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
ad07b9 |
+int linux_audit_write_entry(struct logininfo *li);
|
|
Tomáš Mráz |
ad07b9 |
+#endif
|
|
Tomáš Mráz |
ad07b9 |
int lastlog_write_entry(struct logininfo *li);
|
|
Tomáš Mráz |
ad07b9 |
int syslogin_write_entry(struct logininfo *li);
|
|
Tomáš Mráz |
ad07b9 |
|
|
Tomáš Mráz |
c9833c |
@@ -440,6 +447,10 @@ login_write(struct logininfo *li)
|
|
Tomáš Mráz |
ad07b9 |
|
|
Tomáš Mráz |
ad07b9 |
/* set the timestamp */
|
|
Tomáš Mráz |
ad07b9 |
login_set_current_time(li);
|
|
Tomáš Mráz |
ad07b9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
ad07b9 |
+ if (linux_audit_write_entry(li) == 0)
|
|
Tomáš Mráz |
ad07b9 |
+ fatal("linux_audit_write_entry failed: %s", strerror(errno));
|
|
Tomáš Mráz |
ad07b9 |
+#endif
|
|
Tomáš Mráz |
ad07b9 |
#ifdef USE_LOGIN
|
|
Tomáš Mráz |
ad07b9 |
syslogin_write_entry(li);
|
|
Tomáš Mráz |
ad07b9 |
#endif
|
|
Tomáš Mráz |
c9833c |
@@ -1394,6 +1405,51 @@ wtmpx_get_entry(struct logininfo *li)
|
|
Tomáš Mráz |
ad07b9 |
}
|
|
Tomáš Mráz |
ad07b9 |
#endif /* USE_WTMPX */
|
|
Tomáš Mráz |
ad07b9 |
|
|
Tomáš Mráz |
ad07b9 |
+#ifdef HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
ad07b9 |
+int
|
|
Tomáš Mráz |
ad07b9 |
+linux_audit_record_event(int uid, const char *username,
|
|
Tomáš Mráz |
ad07b9 |
+ const char *hostname, const char *ip, const char *ttyn, int success)
|
|
Tomáš Mráz |
ad07b9 |
+{
|
|
Tomáš Mráz |
ad07b9 |
+ char buf[64];
|
|
Tomáš Mráz |
ad07b9 |
+ int audit_fd, rc;
|
|
Tomáš Mráz |
ad07b9 |
+
|
|
Tomáš Mráz |
ad07b9 |
+ audit_fd = audit_open();
|
|
Tomáš Mráz |
ad07b9 |
+ if (audit_fd < 0) {
|
|
Tomáš Mráz |
ad07b9 |
+ if (errno == EINVAL || errno == EPROTONOSUPPORT ||
|
|
Tomáš Mráz |
ad07b9 |
+ errno == EAFNOSUPPORT)
|
|
Tomáš Mráz |
ad07b9 |
+ return 1; /* No audit support in kernel */
|
|
Tomáš Mráz |
ad07b9 |
+ else
|
|
Tomáš Mráz |
ad07b9 |
+ return 0; /* Must prevent login */
|
|
Tomáš Mráz |
ad07b9 |
+ }
|
|
Tomáš Mráz |
ad07b9 |
+ if (username == NULL)
|
|
Tomáš Mráz |
ad07b9 |
+ snprintf(buf, sizeof(buf), "uid=%d", uid);
|
|
Tomáš Mráz |
ad07b9 |
+ else
|
|
Tomáš Mráz |
ad07b9 |
+ snprintf(buf, sizeof(buf), "acct=%s", username);
|
|
Tomáš Mráz |
ad07b9 |
+ rc = audit_log_user_message(audit_fd, AUDIT_USER_LOGIN,
|
|
Tomáš Mráz |
ad07b9 |
+ buf, hostname, ip, ttyn, success);
|
|
Tomáš Mráz |
ad07b9 |
+ close(audit_fd);
|
|
Tomáš Mráz |
ad07b9 |
+ if (rc >= 0)
|
|
Tomáš Mráz |
ad07b9 |
+ return 1;
|
|
Tomáš Mráz |
ad07b9 |
+ else
|
|
Tomáš Mráz |
ad07b9 |
+ return 0;
|
|
Tomáš Mráz |
ad07b9 |
+}
|
|
Tomáš Mráz |
ad07b9 |
+
|
|
Tomáš Mráz |
ad07b9 |
+int
|
|
Tomáš Mráz |
ad07b9 |
+linux_audit_write_entry(struct logininfo *li)
|
|
Tomáš Mráz |
ad07b9 |
+{
|
|
Tomáš Mráz |
ad07b9 |
+ switch(li->type) {
|
|
Tomáš Mráz |
ad07b9 |
+ case LTYPE_LOGIN:
|
|
Tomáš Mráz |
ad07b9 |
+ return (linux_audit_record_event(li->uid, NULL, li->hostname,
|
|
Tomáš Mráz |
ad07b9 |
+ NULL, li->line, 1));
|
|
Tomáš Mráz |
ad07b9 |
+ case LTYPE_LOGOUT:
|
|
Tomáš Mráz |
ad07b9 |
+ return (1); /* We only care about logins */
|
|
Tomáš Mráz |
ad07b9 |
+ default:
|
|
Tomáš Mráz |
ad07b9 |
+ logit("%s: invalid type field", __func__);
|
|
Tomáš Mráz |
ad07b9 |
+ return (0);
|
|
Tomáš Mráz |
ad07b9 |
+ }
|
|
Tomáš Mráz |
ad07b9 |
+}
|
|
Tomáš Mráz |
ad07b9 |
+#endif /* HAVE_LINUX_AUDIT */
|
|
Tomáš Mráz |
ad07b9 |
+
|
|
Tomáš Mráz |
ad07b9 |
/**
|
|
Tomáš Mráz |
ad07b9 |
** Low-level libutil login() functions
|
|
Tomáš Mráz |
ad07b9 |
**/
|
|
Tomáš Mráz |
c9833c |
diff -up openssh-4.7p1/config.h.in.audit openssh-4.7p1/config.h.in
|
|
Tomáš Mráz |
c9833c |
--- openssh-4.7p1/config.h.in.audit 2007-09-04 08:50:04.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
+++ openssh-4.7p1/config.h.in 2007-09-06 17:07:44.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
@@ -1334,6 +1334,9 @@
|
|
Tomáš Mráz |
ad07b9 |
/* Define if you want SELinux support. */
|
|
Tomáš Mráz |
ad07b9 |
#undef WITH_SELINUX
|
|
Tomáš Mráz |
ad07b9 |
|
|
Tomáš Mráz |
ad07b9 |
+/* Define if you want Linux audit support. */
|
|
Tomáš Mráz |
ad07b9 |
+#undef HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
ad07b9 |
+
|
|
Tomáš Mráz |
ad07b9 |
/* Define to 1 if your processor stores words with the most significant byte
|
|
Tomáš Mráz |
ad07b9 |
first (like Motorola and SPARC, unlike Intel and VAX). */
|
|
Tomáš Mráz |
ad07b9 |
#undef WORDS_BIGENDIAN
|
|
Tomáš Mráz |
c9833c |
diff -up openssh-4.7p1/loginrec.h.audit openssh-4.7p1/loginrec.h
|
|
Tomáš Mráz |
c9833c |
--- openssh-4.7p1/loginrec.h.audit 2006-08-05 04:39:40.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
+++ openssh-4.7p1/loginrec.h 2007-09-06 17:07:44.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
@@ -127,5 +127,9 @@ char *line_stripname(char *dst, const ch
|
|
Tomáš Mráz |
c9833c |
char *line_abbrevname(char *dst, const char *src, int dstsize);
|
|
Tomáš Mráz |
c9833c |
|
|
Tomáš Mráz |
c9833c |
void record_failed_login(const char *, const char *, const char *);
|
|
Tomáš Mráz |
c9833c |
+#ifdef HAVE_LINUX_AUDIT
|
|
Tomáš Mráz |
c9833c |
+int linux_audit_record_event(int uid, const char *username,
|
|
Tomáš Mráz |
c9833c |
+ const char *hostname, const char *ip, const char *ttyn, int success);
|
|
Tomáš Mráz |
c9833c |
+#endif /* HAVE_LINUX_AUDIT */
|
|
Tomáš Mráz |
c9833c |
|
|
Tomáš Mráz |
c9833c |
#endif /* _HAVE_LOGINREC_H_ */
|
|
Tomáš Mráz |
c9833c |
diff -up openssh-4.7p1/configure.ac.audit openssh-4.7p1/configure.ac
|
|
Tomáš Mráz |
c9833c |
--- openssh-4.7p1/configure.ac.audit 2007-09-06 17:07:44.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
+++ openssh-4.7p1/configure.ac 2007-09-06 17:15:23.000000000 +0200
|
|
Tomáš Mráz |
c9833c |
@@ -3216,6 +3216,18 @@ AC_ARG_WITH(selinux,
|
|
Tomáš Mráz |
c9833c |
fi ]
|
|
Tomáš Mráz |
ad07b9 |
)
|
|
Tomáš Mráz |
ad07b9 |
|
|
Tomáš Mráz |
ad07b9 |
+# Check whether user wants Linux audit support
|
|
Tomáš Mráz |
ad07b9 |
+LINUX_AUDIT_MSG="no"
|
|
Tomáš Mráz |
ad07b9 |
+AC_ARG_WITH(linux-audit,
|
|
Tomáš Mráz |
ad07b9 |
+ [ --with-linux-audit Enable Linux audit support],
|
|
Tomáš Mráz |
ad07b9 |
+ [ if test "x$withval" != "xno" ; then
|
|
Tomáš Mráz |
ad07b9 |
+ AC_DEFINE(HAVE_LINUX_AUDIT,1,[Define if you want Linux audit support.])
|
|
Tomáš Mráz |
ad07b9 |
+ LINUX_AUDIT_MSG="yes"
|
|
Tomáš Mráz |
ad07b9 |
+ AC_CHECK_HEADERS(libaudit.h)
|
|
Tomáš Mráz |
c9833c |
+ SSHDLIBS="$SSHDLIBS -laudit"
|
|
Tomáš Mráz |
c9833c |
+ fi ]
|
|
Tomáš Mráz |
c9833c |
+)
|
|
Tomáš Mráz |
ad07b9 |
+
|
|
Tomáš Mráz |
ad07b9 |
# Check whether user wants Kerberos 5 support
|
|
Tomáš Mráz |
ad07b9 |
KRB5_MSG="no"
|
|
Tomáš Mráz |
ad07b9 |
AC_ARG_WITH(kerberos5,
|
|
Tomáš Mráz |
c9833c |
@@ -4037,6 +4049,7 @@ echo " PAM support
|
|
Tomáš Mráz |
ad07b9 |
echo " OSF SIA support: $SIA_MSG"
|
|
Tomáš Mráz |
ad07b9 |
echo " KerberosV support: $KRB5_MSG"
|
|
Tomáš Mráz |
ad07b9 |
echo " SELinux support: $SELINUX_MSG"
|
|
Tomáš Mráz |
ad07b9 |
+echo " Linux audit support: $LINUX_AUDIT_MSG"
|
|
Tomáš Mráz |
ad07b9 |
echo " Smartcard support: $SCARD_MSG"
|
|
Tomáš Mráz |
ad07b9 |
echo " S/KEY support: $SKEY_MSG"
|
|
Tomáš Mráz |
ad07b9 |
echo " TCP Wrappers support: $TCPW_MSG"
|