summaryrefslogtreecommitdiff
path: root/source3/smbd/globals.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-05-03 09:32:01 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-05-08 12:01:13 +0200
commit45e26fdeec4c6d3c4e75d648399ce2a8b3e26364 (patch)
treea3c978965ceb727463a9355b7825787b87c87b9e /source3/smbd/globals.c
parent2c569cd8ba70e1aba30019618e759866c55eff30 (diff)
downloadsamba-45e26fdeec4c6d3c4e75d648399ce2a8b3e26364.tar.gz
samba-45e26fdeec4c6d3c4e75d648399ce2a8b3e26364.tar.bz2
samba-45e26fdeec4c6d3c4e75d648399ce2a8b3e26364.zip
s3-smbd: expose smbd_set_server_fd()
this allows the fd to be setup by subsystems that want to use the s3 server core code Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Sun May 8 12:01:13 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3/smbd/globals.c')
-rw-r--r--source3/smbd/globals.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 8e6f46fe5c..6f7f200b01 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -160,3 +160,32 @@ void smbd_init_globals(void)
smbd_server_conn->smb1.echo_handler.trusted_fd = -1;
smbd_server_conn->smb1.echo_handler.socket_lock_fd = -1;
}
+
+void smbd_set_server_fd(int fd)
+{
+ struct smbd_server_connection *sconn = smbd_server_conn;
+ char addr[INET6_ADDRSTRLEN];
+ const char *name;
+
+ 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;
+
+ sub_set_socket_ids(sconn->client_id.addr, sconn->client_id.name,
+ client_socket_addr(sconn->sock, addr,
+ sizeof(addr)));
+}