summaryrefslogtreecommitdiff
path: root/os/connection.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2006-11-01 16:17:49 -0800
committerAlan Coopersmith <alan.coopersmith@sun.com>2006-11-01 16:17:49 -0800
commita7b944f0d96c3e0e15e75378a04def1ac96089fb (patch)
tree04f18cdcd1c76b2f75e0a42f2c8677cb8bf48c69 /os/connection.c
parentfbfb35189ef6666707097704b43e052cb2f919ae (diff)
If getpeerucred() is available, include pid & zoneid in audit messages too
Diffstat (limited to 'os/connection.c')
-rw-r--r--os/connection.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/os/connection.c b/os/connection.c
index 60f3b9f51..6ca4010e2 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -165,6 +165,11 @@ extern __const__ int _nfiles;
#include <netdnet/dn.h>
#endif /* DNETCONN */
+#ifdef HAS_GETPEERUCRED
+# include <ucred.h>
+# include <zone.h>
+#endif
+
int lastfdesc; /* maximum file descriptor */
fd_set WellKnownConnections; /* Listener mask */
@@ -550,8 +555,13 @@ AuthAudit (ClientPtr client, Bool letin,
char addr[128];
char *out = addr;
int client_uid;
- char client_uid_string[32];
-
+ char client_uid_string[64];
+#ifdef HAS_GETPEERUCRED
+ ucred_t *peercred = NULL;
+ pid_t client_pid = -1;
+ zoneid_t client_zid = -1;
+#endif
+
if (!len)
strcpy(out, "local host");
else
@@ -588,10 +598,24 @@ AuthAudit (ClientPtr client, Bool letin,
strcpy(out, "unknown address");
}
+#ifdef HAS_GETPEERUCRED
+ if (getpeerucred(((OsCommPtr)client->osPrivate)->fd, &peercred) >= 0) {
+ client_uid = ucred_geteuid(peercred);
+ client_pid = ucred_getpid(peercred);
+ client_zid = ucred_getzoneid(peercred);
+
+ ucred_free(peercred);
+ snprintf(client_uid_string, sizeof(client_uid_string),
+ " (uid %ld, pid %ld, zone %ld)",
+ (long) client_uid, (long) client_pid, (long) client_zid);
+ }
+#else
if (LocalClientCred(client, &client_uid, NULL) != -1) {
snprintf(client_uid_string, sizeof(client_uid_string),
" (uid %d)", client_uid);
- } else {
+ }
+#endif
+ else {
client_uid_string[0] = '\0';
}