summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2013-10-01 22:42:12 -0700
committerJay Sorg <jay.sorg@gmail.com>2013-10-01 22:42:12 -0700
commitb598e258a43dc3ca6f3dcc37ceb6a2a6c18227d1 (patch)
tree8860215afea0ca3c35e03fb9b86d33a1e3b83187 /common
parentcd93db2c98425645c9c79fece04617c4d82184c3 (diff)
downloadxrdp-proprietary-b598e258a43dc3ca6f3dcc37ceb6a2a6c18227d1.tar.gz
xrdp-proprietary-b598e258a43dc3ca6f3dcc37ceb6a2a6c18227d1.zip
add pid logging
Diffstat (limited to 'common')
-rw-r--r--common/os_calls.c32
-rw-r--r--common/os_calls.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/common/os_calls.c b/common/os_calls.c
index c5a15bb0..a26a180f 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -504,6 +504,38 @@ g_tcp_local_socket(void)
}
/*****************************************************************************/
+int APP_CC
+g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid)
+{
+ int ucred_length;
+ struct myucred
+ {
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
+ } credentials;
+
+ ucred_length = sizeof(credentials);
+ if (getsockopt(sck, SOL_SOCKET, SO_PEERCRED, &credentials, &ucred_length))
+ {
+ return 1;
+ }
+ if (pid != 0)
+ {
+ *pid = credentials.pid;
+ }
+ if (uid != 0)
+ {
+ *uid = credentials.uid;
+ }
+ if (gid != 0)
+ {
+ *gid = credentials.gid;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
void APP_CC
g_tcp_close(int sck)
{
diff --git a/common/os_calls.h b/common/os_calls.h
index 443a1840..b68dd4bf 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -46,6 +46,7 @@ int APP_CC g_tcp_set_no_delay(int sck);
int APP_CC g_tcp_set_keepalive(int sck);
int APP_CC g_tcp_socket(void);
int APP_CC g_tcp_local_socket(void);
+int APP_CC g_sck_get_peer_cred(int sck, int *pid, int *uid, int *gid);
void APP_CC g_tcp_close(int sck);
int APP_CC g_tcp_connect(int sck, const char* address, const char* port);
int APP_CC g_tcp_local_connect(int sck, const char* port);