|
Lines 37-42
Link Here
|
| 37 |
#include "audit.h" |
37 |
#include "audit.h" |
| 38 |
#include "canohost.h" |
38 |
#include "canohost.h" |
| 39 |
|
39 |
|
|
|
40 |
#define AUDIT_LOG_SIZE 128 |
| 41 |
|
| 40 |
const char* audit_username(void); |
42 |
const char* audit_username(void); |
| 41 |
|
43 |
|
| 42 |
int |
44 |
int |
|
Lines 63-68
linux_audit_record_event(int uid, const
Link Here
|
| 63 |
return (rc >= 0) || ((rc == -EPERM) && (getuid() != 0)); |
65 |
return (rc >= 0) || ((rc == -EPERM) && (getuid() != 0)); |
| 64 |
} |
66 |
} |
| 65 |
|
67 |
|
|
|
68 |
int |
| 69 |
audit_keyusage(int host_user, const char *type, unsigned len, char *fp, int rv) |
| 70 |
{ |
| 71 |
char buf[AUDIT_LOG_SIZE]; |
| 72 |
int audit_fd, rc, saved_errno; |
| 73 |
|
| 74 |
audit_fd = audit_open(); |
| 75 |
if (audit_fd < 0) { |
| 76 |
if (errno == EINVAL || errno == EPROTONOSUPPORT || |
| 77 |
errno == EAFNOSUPPORT) |
| 78 |
return 1; /* No audit support in kernel */ |
| 79 |
else |
| 80 |
return 0; /* Must prevent login */ |
| 81 |
} |
| 82 |
snprintf(buf, sizeof(buf), "%s_auth rport=%d", host_user ? "hostbased" : "pubkey", get_remote_port()); |
| 83 |
rc = audit_log_acct_message(audit_fd, AUDIT_USER_AUTH, NULL, |
| 84 |
buf, audit_username(), -1, NULL, get_remote_ipaddr(), NULL, rv); |
| 85 |
if ((rc < 0) && ((rc != -1) || (getuid() == 0))) |
| 86 |
goto out; |
| 87 |
snprintf(buf, sizeof(buf), "key algo=%s size=%d fp=%s rport=%d", |
| 88 |
type, 8 * len, fp, get_remote_port()); |
| 89 |
rc = audit_log_acct_message(audit_fd, AUDIT_USER_AUTH, NULL, |
| 90 |
buf, audit_username(), -1, NULL, get_remote_ipaddr(), NULL, rv); |
| 91 |
out: |
| 92 |
saved_errno = errno; |
| 93 |
audit_close(audit_fd); |
| 94 |
errno = saved_errno; |
| 95 |
/* do not report error if the error is EPERM and sshd is run as non root user */ |
| 96 |
return (rc >= 0) || ((rc == -EPERM) && (getuid() != 0)); |
| 97 |
} |
| 98 |
|
| 66 |
/* Below is the sshd audit API code */ |
99 |
/* Below is the sshd audit API code */ |
| 67 |
|
100 |
|
| 68 |
void |
101 |
void |