summaryrefslogtreecommitdiff
path: root/audit-bsm.c
diff options
context:
space:
mode:
Diffstat (limited to 'audit-bsm.c')
-rw-r--r--audit-bsm.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/audit-bsm.c b/audit-bsm.c
index c26b4caed..2c417bc27 100644
--- a/audit-bsm.c
+++ b/audit-bsm.c
@@ -1,4 +1,4 @@
1/* $Id: audit-bsm.c,v 1.5 2006/09/30 22:09:50 dtucker Exp $ */ 1/* $Id: audit-bsm.c,v 1.6 2008/02/25 10:05:04 dtucker Exp $ */
2 2
3/* 3/*
4 * TODO 4 * TODO
@@ -40,7 +40,9 @@
40#include <sys/types.h> 40#include <sys/types.h>
41 41
42#include <errno.h> 42#include <errno.h>
43#include <netdb.h>
43#include <stdarg.h> 44#include <stdarg.h>
45#include <string.h>
44#include <unistd.h> 46#include <unistd.h>
45 47
46#include "ssh.h" 48#include "ssh.h"
@@ -62,8 +64,6 @@
62#if defined(HAVE_GETAUDIT_ADDR) 64#if defined(HAVE_GETAUDIT_ADDR)
63#define AuditInfoStruct auditinfo_addr 65#define AuditInfoStruct auditinfo_addr
64#define AuditInfoTermID au_tid_addr_t 66#define AuditInfoTermID au_tid_addr_t
65#define GetAuditFunc(a,b) getaudit_addr((a),(b))
66#define GetAuditFuncText "getaudit_addr"
67#define SetAuditFunc(a,b) setaudit_addr((a),(b)) 67#define SetAuditFunc(a,b) setaudit_addr((a),(b))
68#define SetAuditFuncText "setaudit_addr" 68#define SetAuditFuncText "setaudit_addr"
69#define AUToSubjectFunc au_to_subject_ex 69#define AUToSubjectFunc au_to_subject_ex
@@ -71,18 +71,16 @@
71#else 71#else
72#define AuditInfoStruct auditinfo 72#define AuditInfoStruct auditinfo
73#define AuditInfoTermID au_tid_t 73#define AuditInfoTermID au_tid_t
74#define GetAuditFunc(a,b) getaudit(a)
75#define GetAuditFuncText "getaudit"
76#define SetAuditFunc(a,b) setaudit(a) 74#define SetAuditFunc(a,b) setaudit(a)
77#define SetAuditFuncText "setaudit" 75#define SetAuditFuncText "setaudit"
78#define AUToSubjectFunc au_to_subject 76#define AUToSubjectFunc au_to_subject
79#define AUToReturnFunc(a,b) au_to_return((a), (u_int)(b)) 77#define AUToReturnFunc(a,b) au_to_return((a), (u_int)(b))
80#endif 78#endif
81 79
80#ifndef cannot_audit
82extern int cannot_audit(int); 81extern int cannot_audit(int);
82#endif
83extern void aug_init(void); 83extern void aug_init(void);
84extern dev_t aug_get_port(void);
85extern int aug_get_machine(char *, u_int32_t *, u_int32_t *);
86extern void aug_save_auid(au_id_t); 84extern void aug_save_auid(au_id_t);
87extern void aug_save_uid(uid_t); 85extern void aug_save_uid(uid_t);
88extern void aug_save_euid(uid_t); 86extern void aug_save_euid(uid_t);
@@ -119,6 +117,51 @@ static AuditInfoTermID ssh_bsm_tid;
119/* Below is the low-level BSM interface code */ 117/* Below is the low-level BSM interface code */
120 118
121/* 119/*
120 * aug_get_machine is only required on IPv6 capable machines, we use a
121 * different mechanism in audit_connection_from() for IPv4-only machines.
122 * getaudit_addr() is only present on IPv6 capable machines.
123 */
124#if defined(HAVE_AUG_GET_MACHINE) || !defined(HAVE_GETAUDIT_ADDR)
125extern int aug_get_machine(char *, u_int32_t *, u_int32_t *);
126#else
127static int
128aug_get_machine(char *host, u_int32_t *addr, u_int32_t *type)
129{
130 struct addrinfo *ai;
131 struct sockaddr_in *in4;
132 struct sockaddr_in6 *in6;
133 int ret = 0, r;
134
135 if ((r = getaddrinfo(host, NULL, NULL, &ai)) != 0) {
136 error("BSM audit: getaddrinfo failed for %.100s: %.100s", host,
137 r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r));
138 return -1;
139 }
140
141 switch (ai->ai_family) {
142 case AF_INET:
143 in4 = (struct sockaddr_in *)ai->ai_addr;
144 *type = AU_IPv4;
145 memcpy(addr, &in4->sin_addr, sizeof(struct in_addr));
146 break;
147#ifdef AU_IPv6
148 case AF_INET6:
149 in6 = (struct sockaddr_in6 *)ai->ai_addr;
150 *type = AU_IPv6;
151 memcpy(addr, &in6->sin6_addr, sizeof(struct in6_addr));
152 break;
153#endif
154 default:
155 error("BSM audit: unknown address family for %.100s: %d",
156 host, ai->ai_family);
157 ret = -1;
158 }
159 freeaddrinfo(ai);
160 return ret;
161}
162#endif
163
164/*
122 * Check if the specified event is selected (enabled) for auditing. 165 * Check if the specified event is selected (enabled) for auditing.
123 * Returns 1 if the event is selected, 0 if not and -1 on failure. 166 * Returns 1 if the event is selected, 0 if not and -1 on failure.
124 */ 167 */