diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2017-02-15 14:42:48 +0000 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-03-21 10:33:30 +0100 |
commit | 8996f80a5e3b205cb580aba34aa21d165ef78cfb (patch) | |
tree | 63247f1c738a59600e2a437054d18826db4dc2d2 /nx-X11/programs/Xserver/os/connection.c | |
parent | 6bc37b980515995b0944632e5a062246683f1d97 (diff) | |
download | nx-libs-8996f80a5e3b205cb580aba34aa21d165ef78cfb.tar.gz nx-libs-8996f80a5e3b205cb580aba34aa21d165ef78cfb.tar.bz2 nx-libs-8996f80a5e3b205cb580aba34aa21d165ef78cfb.zip |
Rework local client id finding code to be more uniform
Backport of X.org commit:
commit 2d93e69690d2c5d4a89a795ede6423796528e5df
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Thu Sep 27 16:47:06 2007 -0700
Rework local client id finding code to be more uniform
Backported-to-NX-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
Note: This commit also switches client_uid_string's size from 32 to 64 chars,
as found in this X.org commit (spotted by Mihai Moldovan during code review):
commit a7b944f0d96c3e0e15e75378a04def1ac96089fb
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Wed Nov 1 16:17:49 2006 -0800
If getpeerucred() is available, include pid & zoneid in audit messages too
Diffstat (limited to 'nx-X11/programs/Xserver/os/connection.c')
-rw-r--r-- | nx-X11/programs/Xserver/os/connection.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/nx-X11/programs/Xserver/os/connection.c b/nx-X11/programs/Xserver/os/connection.c index 151605cfb..538996198 100644 --- a/nx-X11/programs/Xserver/os/connection.c +++ b/nx-X11/programs/Xserver/os/connection.c @@ -534,8 +534,8 @@ AuthAudit (ClientPtr client, Bool letin, char addr[128]; char *out = addr; - int client_uid; - char client_uid_string[32]; + char client_uid_string[64]; + LocalClientCredRec *lcc; if (!len) strcpy(out, "local host"); @@ -567,10 +567,44 @@ AuthAudit (ClientPtr client, Bool letin, strcpy(out, "unknown address"); } - if (LocalClientCred(client, &client_uid, NULL) != -1) { - snprintf(client_uid_string, sizeof(client_uid_string), - " (uid %d)", client_uid); - } else { + 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) { + 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) { + 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'; } |