summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-03-05 16:56:53 +0100
committerVolker Lendecke <vl@samba.org>2012-03-06 14:29:50 +0100
commit1f62df52aaafc4f777fed4541625a92f15c8e12c (patch)
tree2b0a0118b646951145c11375cb4d331c92a6e163
parentb709589445820ae8b30e9554c08ca205c3b946f1 (diff)
downloadsamba-1f62df52aaafc4f777fed4541625a92f15c8e12c.tar.gz
samba-1f62df52aaafc4f777fed4541625a92f15c8e12c.tar.bz2
samba-1f62df52aaafc4f777fed4541625a92f15c8e12c.zip
s3: Move a talloc_strdup out of the main code path
This is only used for AS_GUEST requests Autobuild-User: Volker Lendecke <vl@samba.org> Autobuild-Date: Tue Mar 6 14:29:50 CET 2012 on sn-devel-104
-rw-r--r--source3/smbd/process.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index f61ad5d247..113131828f 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1351,7 +1351,6 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req)
uint16 session_tag;
connection_struct *conn = NULL;
struct smbd_server_connection *sconn = req->sconn;
- char *raddr;
errno = 0;
@@ -1466,21 +1465,38 @@ static connection_struct *switch_message(uint8 type, struct smb_request *req)
conn->num_smb_operations++;
}
- raddr = tsocket_address_inet_addr_string(sconn->remote_address,
- talloc_tos());
- if (raddr == NULL) {
- reply_nterror(req, NT_STATUS_NO_MEMORY);
- return conn;
- }
+ /*
+ * Does this protocol need to be run as guest? (Only archane
+ * messenger service requests have this...)
+ */
+ if (flags & AS_GUEST) {
+ char *raddr;
+ bool ok;
+
+ if (!change_to_guest()) {
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+ return conn;
+ }
+
+ raddr = tsocket_address_inet_addr_string(sconn->remote_address,
+ talloc_tos());
+ if (raddr == NULL) {
+ reply_nterror(req, NT_STATUS_NO_MEMORY);
+ return conn;
+ }
+
+ /*
+ * Haven't we checked this in smbd_process already???
+ */
+
+ ok = allow_access(lp_hostsdeny(-1), lp_hostsallow(-1),
+ sconn->remote_hostname, raddr);
+ TALLOC_FREE(raddr);
- /* does this protocol need to be run as guest? */
- if ((flags & AS_GUEST)
- && (!change_to_guest() ||
- !allow_access(lp_hostsdeny(-1), lp_hostsallow(-1),
- sconn->remote_hostname,
- raddr))) {
- reply_nterror(req, NT_STATUS_ACCESS_DENIED);
- return conn;
+ if (!ok) {
+ reply_nterror(req, NT_STATUS_ACCESS_DENIED);
+ return conn;
+ }
}
smb_messages[type].fn(req);