summaryrefslogtreecommitdiffstats
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
parent04e07442bbc8a5d8515fa1eea52cb15ebd2cc992 (diff)
downloadusbmuxd-5e017fbb36d4ccafb9be6859d90f2c04b20b3d06.tar.gz
usbmuxd-5e017fbb36d4ccafb9be6859d90f2c04b20b3d06.tar.bz2
client: Log pid of connecting clients (if supported)
-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 @@
22#include <config.h> 22#include <config.h>
23#endif 23#endif
24 24
25#define _GNU_SOURCE 1
26
25#include <stdlib.h> 27#include <stdlib.h>
26#include <string.h> 28#include <string.h>
27#include <errno.h> 29#include <errno.h>
@@ -166,7 +168,21 @@ int client_accept(int listenfd)
166 collection_add(&client_list, client); 168 collection_add(&client_list, client);
167 pthread_mutex_unlock(&client_list_mutex); 169 pthread_mutex_unlock(&client_list_mutex);
168 170
171#ifdef SO_PEERCRED
172 if (log_level >= LL_INFO) {
173 struct ucred cr;
174 len = sizeof(struct ucred);
175 getsockopt(cfd, SOL_SOCKET, SO_PEERCRED, &cr, &len);
176
177 if (getpid() == cr.pid) {
178 usbmuxd_log(LL_INFO, "New client on fd %d (self)", client->fd);
179 } else {
180 usbmuxd_log(LL_INFO, "New client on fd %d (pid %d)", client->fd, cr.pid);
181 }
182 }
183#else
169 usbmuxd_log(LL_INFO, "New client on fd %d", client->fd); 184 usbmuxd_log(LL_INFO, "New client on fd %d", client->fd);
185#endif
170 return client->fd; 186 return client->fd;
171} 187}
172 188