summaryrefslogtreecommitdiff
path: root/os/connection.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2007-09-27 16:47:06 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2007-09-27 16:47:32 -0700
commit2d93e69690d2c5d4a89a795ede6423796528e5df (patch)
tree1d775db95b52b13fd92508232aec7c894b4c8630 /os/connection.c
parentc7ead3a68e5839cb92129e35b21f55007fba8445 (diff)
Rework local client id finding code to be more uniform
Diffstat (limited to 'os/connection.c')
-rw-r--r--os/connection.c65
1 files changed, 45 insertions, 20 deletions
diff --git a/os/connection.c b/os/connection.c
index d1bc4d04e..70551a844 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -539,10 +539,8 @@ AuthAudit (ClientPtr client, Bool letin,
char *out = addr;
int client_uid;
char client_uid_string[64];
-#ifdef HAS_GETPEERUCRED
- ucred_t *peercred = NULL;
-#endif
-#if defined(HAS_GETPEERUCRED) || defined(XSERVER_DTRACE)
+ LocalClientCredRec *lcc;
+#ifdef XSERVER_DTRACE
pid_t client_pid = -1;
zoneid_t client_zid = -1;
#endif
@@ -583,23 +581,50 @@ 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);
- }
+ if (GetLocalClientCreds(client, &lcc) != -1) {
+ int slen; /* length written to client_uid_string */
+
+ strcpy(client_uid_string, " ( ");
+ slen = 3;
+
+ if (lcc->fieldsSet & LCC_UID_SET) {
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "uid=%ld ", (long) lcc->euid);
+ slen = strlen(client_uid_string);
+ }
+
+ if (lcc->fieldsSet & LCC_GID_SET) {
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "gid=%ld ", (long) lcc->egid);
+ slen = strlen(client_uid_string);
+ }
+
+ if (lcc->fieldsSet & LCC_PID_SET) {
+#ifdef XSERVER_DTRACE
+ client_pid = lcc->pid;
#endif
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "pid=%ld ", (long) lcc->pid);
+ slen = strlen(client_uid_string);
+ }
+
+ if (lcc->fieldsSet & LCC_ZID_SET) {
+#ifdef XSERVER_DTRACE
+ client_zid = lcc->zoneid;
+#endif
+ snprintf(client_uid_string + slen,
+ sizeof(client_uid_string) - slen,
+ "zoneid=%ld ", (long) lcc->zoneid);
+ slen = strlen(client_uid_string);
+ }
+
+ snprintf(client_uid_string + slen, sizeof(client_uid_string) - slen,
+ ")");
+ FreeLocalClientCreds(lcc);
+ }
else {
client_uid_string[0] = '\0';
}