summaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2014-11-11 13:49:03 +0100
committerGravatar Nikias Bassen2014-11-11 13:49:03 +0100
commit5e017fbb36d4ccafb9be6859d90f2c04b20b3d06 (patch)
tree80737aaa0fdd6d212a3f5c814c7e5f9591d56c26 /src/client.c
parent04e07442bbc8a5d8515fa1eea52cb15ebd2cc992 (diff)
downloadusbmuxd-5e017fbb36d4ccafb9be6859d90f2c04b20b3d06.tar.gz
usbmuxd-5e017fbb36d4ccafb9be6859d90f2c04b20b3d06.tar.bz2
client: Log pid of connecting clients (if supported)
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/client.c b/src/client.c
index 67a29e8..d5f31e4 100644
--- a/src/client.c
+++ b/src/client.c
@@ -22,6 +22,8 @@
#include <config.h>
#endif
+#define _GNU_SOURCE 1
+
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@@ -166,7 +168,21 @@ int client_accept(int listenfd)
collection_add(&client_list, client);
pthread_mutex_unlock(&client_list_mutex);
+#ifdef SO_PEERCRED
+ if (log_level >= LL_INFO) {
+ struct ucred cr;
+ len = sizeof(struct ucred);
+ getsockopt(cfd, SOL_SOCKET, SO_PEERCRED, &cr, &len);
+
+ if (getpid() == cr.pid) {
+ usbmuxd_log(LL_INFO, "New client on fd %d (self)", client->fd);
+ } else {
+ usbmuxd_log(LL_INFO, "New client on fd %d (pid %d)", client->fd, cr.pid);
+ }
+ }
+#else
usbmuxd_log(LL_INFO, "New client on fd %d", client->fd);
+#endif
return client->fd;
}