From 7b6835ec1da127713d0a412edcbe0a3c1bcc6192 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 16 Aug 2010 08:30:36 +0200 Subject: s3: Add smbd_server_connection->client_id --- source3/smbd/globals.h | 1 + source3/smbd/server.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'source3/smbd') 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) -- cgit