diff options
Diffstat (limited to 'src/client.c')
| -rw-r--r-- | src/client.c | 16 |
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 | ||
