summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/smb.h5
-rw-r--r--source3/smbd/globals.h1
-rw-r--r--source3/smbd/server.c22
3 files changed, 27 insertions, 1 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h
index de104a51eb..31ef910a70 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -407,6 +407,11 @@ typedef struct files_struct {
#include "ntquotas.h"
#include "sysquotas.h"
+struct client_address {
+ char addr[INET6_ADDRSTRLEN];
+ const char *name;
+};
+
struct vuid_cache_entry {
struct auth_serversupplied_info *server_info;
uint16_t vuid;
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index cf23509060..e4f4b79058 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -458,6 +458,7 @@ struct pending_auth_data;
struct smbd_server_connection {
int sock;
+ struct client_address client_id;
const struct tsocket_address *local_address;
const struct tsocket_address *remote_address;
struct messaging_context *msg_ctx;
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 8cb2f23e12..0f43022dd8 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -59,8 +59,28 @@ int smbd_server_fd(void)
static void smbd_set_server_fd(int fd)
{
- smbd_server_conn->sock = fd;
+ struct smbd_server_connection *sconn = smbd_server_conn;
+ const char *name;
+
server_fd = fd;
+
+ sconn->sock = fd;
+
+ /*
+ * Initialize sconn->client_id: If we can't find the client's
+ * name, default to its address.
+ */
+
+ client_addr(fd, sconn->client_id.addr, sizeof(sconn->client_id.addr));
+
+ name = client_name(sconn->sock);
+ if (strcmp(name, "UNKNOWN") != 0) {
+ name = talloc_strdup(sconn, name);
+ } else {
+ name = NULL;
+ }
+ sconn->client_id.name =
+ (name != NULL) ? name : sconn->client_id.addr;
}
struct event_context *smbd_event_context(void)