summaryrefslogtreecommitdiffstats
path: root/source/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-03 18:15:45 -0700
committerJeremy Allison <jra@samba.org>2007-11-03 18:15:45 -0700
commite848506c858bd16706c1d7f6b4b032005512b8ac (patch)
tree5e3ac1ad96e052b4c042c584a43620859031bdda /source/smbd
parentd50d14c300abc83b7015718ec48acc8b3227a273 (diff)
downloadsamba-e848506c858bd16706c1d7f6b4b032005512b8ac.tar.gz
samba-e848506c858bd16706c1d7f6b4b032005512b8ac.tar.xz
samba-e848506c858bd16706c1d7f6b4b032005512b8ac.zip
Stop get_peer_addr() and client_addr() from using global
statics. Part of my library cleanups. Jeremy.
Diffstat (limited to 'source/smbd')
-rw-r--r--source/smbd/connection.c3
-rw-r--r--source/smbd/process.c5
-rw-r--r--source/smbd/server.c4
-rw-r--r--source/smbd/service.c6
-rw-r--r--source/smbd/session.c5
-rw-r--r--source/smbd/sesssetup.c4
6 files changed, 19 insertions, 8 deletions
diff --git a/source/smbd/connection.c b/source/smbd/connection.c
index e9f1b82fbfe..4b896686400 100644
--- a/source/smbd/connection.c
+++ b/source/smbd/connection.c
@@ -128,6 +128,7 @@ bool claim_connection(connection_struct *conn, const char *name,
struct connections_data crec;
TDB_DATA dbuf;
NTSTATUS status;
+ char addr[INET6_ADDRSTRLEN];
DEBUG(5,("claiming [%s]\n", name));
@@ -151,7 +152,7 @@ bool claim_connection(connection_struct *conn, const char *name,
crec.bcast_msg_flags = msg_flags;
strlcpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine));
- strlcpy(crec.addr,conn?conn->client_address:client_addr(),
+ strlcpy(crec.addr,conn?conn->client_address:client_addr(addr),
sizeof(crec.addr));
dbuf.dptr = (uint8 *)&crec;
diff --git a/source/smbd/process.c b/source/smbd/process.c
index 11fdb03d72a..f35e7054d77 100644
--- a/source/smbd/process.c
+++ b/source/smbd/process.c
@@ -1460,15 +1460,18 @@ static void process_smb(char *inbuf, size_t nread, size_t unread_bytes)
DO_PROFILE_INC(smb_count);
if (trans_num == 0) {
+ char addr[INET6_ADDRSTRLEN];
+
/* on the first packet, check the global hosts allow/ hosts
deny parameters before doing any parsing of the packet
passed to us by the client. This prevents attacks on our
parsing code from hosts not in the hosts allow list */
+
if (!check_access(smbd_server_fd(), lp_hostsallow(-1),
lp_hostsdeny(-1))) {
/* send a negative session response "not listening on calling name" */
static unsigned char buf[5] = {0x83, 0, 0, 1, 0x81};
- DEBUG( 1, ( "Connection denied from %s\n", client_addr() ) );
+ DEBUG( 1, ( "Connection denied from %s\n", client_addr(addr) ) );
(void)send_smb(smbd_server_fd(),(char *)buf);
exit_server_cleanly("connection denied");
}
diff --git a/source/smbd/server.c b/source/smbd/server.c
index fa8e1630817..34b3d4a32a8 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -602,6 +602,8 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
if (allowable_number_of_smbd_processes() &&
smbd_server_fd() != -1 &&
((child = sys_fork())==0)) {
+ char remaddr[INET6_ADDRSTRLEN];
+
/* Child code ... */
/* Stop zombies, the parent explicitly handles
@@ -622,7 +624,7 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_
/* this is needed so that we get decent entries
in smbstatus for port 445 connects */
- set_remote_machine_name(get_peer_addr(smbd_server_fd()),
+ set_remote_machine_name(get_peer_addr(smbd_server_fd(),remaddr),
False);
/* Reset the state of the random
diff --git a/source/smbd/service.c b/source/smbd/service.c
index bb279b701fd..2901cd3417c 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -642,6 +642,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
fstring user;
fstring dev;
int ret;
+ char addr[INET6_ADDRSTRLEN];
*user = 0;
fstrcpy(dev, pdev);
@@ -757,7 +758,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
add_session_user(user);
- safe_strcpy(conn->client_address, client_addr(),
+ safe_strcpy(conn->client_address, client_addr(addr),
sizeof(conn->client_address)-1);
conn->num_files_open = 0;
conn->lastused = conn->lastused_count = time(NULL);
@@ -1204,6 +1205,7 @@ connection_struct *make_connection(const char *service_in, DATA_BLOB password,
fstring service;
fstring dev;
int snum = -1;
+ char addr[INET6_ADDRSTRLEN];
fstrcpy(dev, pdev);
@@ -1300,7 +1302,7 @@ connection_struct *make_connection(const char *service_in, DATA_BLOB password,
}
DEBUG(0,("%s (%s) couldn't find service %s\n",
- get_remote_machine_name(), client_addr(), service));
+ get_remote_machine_name(), client_addr(addr), service));
*status = NT_STATUS_BAD_NETWORK_NAME;
return NULL;
}
diff --git a/source/smbd/session.c b/source/smbd/session.c
index ebbb40eb5ad..15154162b95 100644
--- a/source/smbd/session.c
+++ b/source/smbd/session.c
@@ -69,6 +69,7 @@ bool session_claim(user_struct *vuser)
struct db_context *ctx;
struct db_record *rec;
NTSTATUS status;
+ char addr[INET6_ADDRSTRLEN];
vuser->session_keystr = NULL;
@@ -160,7 +161,7 @@ bool session_claim(user_struct *vuser)
hostname = client_name();
if (strcmp(hostname, "UNKNOWN") == 0) {
- hostname = client_addr();
+ hostname = client_addr(addr);
}
fstrcpy(sessionid.username, vuser->user.unix_name);
@@ -170,7 +171,7 @@ bool session_claim(user_struct *vuser)
sessionid.uid = vuser->uid;
sessionid.gid = vuser->gid;
fstrcpy(sessionid.remote_machine, get_remote_machine_name());
- fstrcpy(sessionid.ip_addr_str, client_addr());
+ fstrcpy(sessionid.ip_addr_str, client_addr(addr));
sessionid.connect_start = time(NULL);
if (!smb_pam_claim_session(sessionid.username, sessionid.id_str,
diff --git a/source/smbd/sesssetup.c b/source/smbd/sesssetup.c
index bc298d11f73..35efbc009f9 100644
--- a/source/smbd/sesssetup.c
+++ b/source/smbd/sesssetup.c
@@ -1307,6 +1307,8 @@ static int shutdown_other_smbds(struct db_record *rec,
static void setup_new_vc_session(void)
{
+ char addr[INET6_ADDRSTRLEN];
+
DEBUG(2,("setup_new_vc_session: New VC == 0, if NT4.x "
"compatible we would close all old resources.\n"));
#if 0
@@ -1315,7 +1317,7 @@ static void setup_new_vc_session(void)
#endif
if (lp_reset_on_zero_vc()) {
connections_forall(shutdown_other_smbds,
- CONST_DISCARD(void *,client_addr()));
+ CONST_DISCARD(void *,client_addr(addr)));
}
}