mirror of
https://github.com/samba-team/samba.git
synced 2025-12-06 16:23:49 +03:00
r2542: I really don't like the 'substitute' code, and I particularly don't
like it in the mainline code (outside the smb.conf magic). We will need to have a more useful 'helper' routine for this, but for now we at least get a reliable IP address. Also remove the unused 'socket' structure in the smb server - it seems to have been replaced by the socket library. Andrew Bartlett
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
cd2f97530b
commit
d8fd19a202
@@ -52,18 +52,6 @@ static void setup_string(char **dest, const char *str)
|
|||||||
(*dest) = s;
|
(*dest) = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sub_set_local_machine(const char *local_machine)
|
|
||||||
{
|
|
||||||
if (!sub) return;
|
|
||||||
setup_string(&sub->local_machine, local_machine);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sub_set_remote_machine(const char *remote_machine)
|
|
||||||
{
|
|
||||||
if (!sub) return;
|
|
||||||
setup_string(&sub->remote_machine, remote_machine);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sub_set_remote_proto(const char *str)
|
void sub_set_remote_proto(const char *str)
|
||||||
{
|
{
|
||||||
if (!sub) return;
|
if (!sub) return;
|
||||||
@@ -76,19 +64,6 @@ void sub_set_remote_arch(const char *str)
|
|||||||
setup_string(&sub->remote_arch, str);
|
setup_string(&sub->remote_arch, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *sub_get_remote_machine(void)
|
|
||||||
{
|
|
||||||
if (!sub) return "UNKNOWN";
|
|
||||||
return sub->remote_machine;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *sub_get_local_machine(void)
|
|
||||||
{
|
|
||||||
if (!sub) return "UNKNOWN";
|
|
||||||
return sub->local_machine;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
setup the string used by %U substitution
|
setup the string used by %U substitution
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -218,8 +218,7 @@ static NTSTATUS make_connection(struct smbsrv_request *req,
|
|||||||
snum = find_service(service);
|
snum = find_service(service);
|
||||||
|
|
||||||
if (snum == -1) {
|
if (snum == -1) {
|
||||||
DEBUG(0,("%s couldn't find service %s\n",
|
DEBUG(0,("couldn't find service %s\n", service));
|
||||||
sub_get_remote_machine(), service));
|
|
||||||
return NT_STATUS_BAD_NETWORK_NAME;
|
return NT_STATUS_BAD_NETWORK_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,14 +45,23 @@ static NTSTATUS sesssetup_old(struct smbsrv_request *req, union smb_sesssetup *s
|
|||||||
struct auth_serversupplied_info *server_info = NULL;
|
struct auth_serversupplied_info *server_info = NULL;
|
||||||
struct auth_session_info *session_info;
|
struct auth_session_info *session_info;
|
||||||
|
|
||||||
|
TALLOC_CTX *mem_ctx = talloc_init("NT1 session setup");
|
||||||
|
char *remote_machine;
|
||||||
|
if (!mem_ctx) {
|
||||||
|
return NT_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
if (!req->smb_conn->negotiate.done_sesssetup) {
|
if (!req->smb_conn->negotiate.done_sesssetup) {
|
||||||
req->smb_conn->negotiate.max_send = sess->old.in.bufsize;
|
req->smb_conn->negotiate.max_send = sess->old.in.bufsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remote_machine = socket_get_peer_addr(req->smb_conn->connection->socket, mem_ctx);
|
||||||
status = make_user_info_for_reply_enc(&user_info,
|
status = make_user_info_for_reply_enc(&user_info,
|
||||||
sess->old.in.user, sess->old.in.domain,
|
sess->old.in.user, sess->old.in.domain,
|
||||||
|
remote_machine,
|
||||||
sess->old.in.password,
|
sess->old.in.password,
|
||||||
data_blob(NULL, 0));
|
data_blob(NULL, 0));
|
||||||
|
talloc_free(mem_ctx);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return NT_STATUS_ACCESS_DENIED;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
@@ -122,10 +131,18 @@ static NTSTATUS sesssetup_nt1(struct smbsrv_request *req, union smb_sesssetup *s
|
|||||||
free_auth_context(&auth_context);
|
free_auth_context(&auth_context);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
TALLOC_CTX *mem_ctx = talloc_init("NT1 session setup");
|
||||||
|
char *remote_machine;
|
||||||
|
if (!mem_ctx) {
|
||||||
|
return NT_STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
remote_machine = socket_get_peer_addr(req->smb_conn->connection->socket, mem_ctx);
|
||||||
status = make_user_info_for_reply_enc(&user_info,
|
status = make_user_info_for_reply_enc(&user_info,
|
||||||
sess->nt1.in.user, sess->nt1.in.domain,
|
sess->nt1.in.user, sess->nt1.in.domain,
|
||||||
|
remote_machine,
|
||||||
sess->nt1.in.password1,
|
sess->nt1.in.password1,
|
||||||
sess->nt1.in.password2);
|
sess->nt1.in.password2);
|
||||||
|
talloc_free(mem_ctx);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
return NT_STATUS_ACCESS_DENIED;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -838,13 +838,6 @@ void smbsrv_accept(struct server_connection *conn)
|
|||||||
|
|
||||||
sub_set_context(&smb_conn->substitute);
|
sub_set_context(&smb_conn->substitute);
|
||||||
|
|
||||||
/* set an initial client name based on its IP address. This will be replaced with
|
|
||||||
the netbios name later if it gives us one */
|
|
||||||
socket_addr = socket_get_peer_addr(conn->socket, smb_conn);
|
|
||||||
if (socket_addr) {
|
|
||||||
sub_set_remote_machine(socket_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now initialise a few default values associated with this smb socket */
|
/* now initialise a few default values associated with this smb socket */
|
||||||
smb_conn->negotiate.max_send = 0xFFFF;
|
smb_conn->negotiate.max_send = 0xFFFF;
|
||||||
|
|
||||||
|
|||||||
@@ -168,22 +168,10 @@ struct substitute_context {
|
|||||||
* information associated with a SMB server connection
|
* information associated with a SMB server connection
|
||||||
*/
|
*/
|
||||||
struct smbsrv_connection {
|
struct smbsrv_connection {
|
||||||
/* this is the context for a SMB socket associated with the socket itself */
|
|
||||||
struct {
|
|
||||||
/* the open file descriptor */
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
/* the last read error on the socket, if any (replaces smb_read_error global) */
|
|
||||||
int read_error;
|
|
||||||
|
|
||||||
/* a count of the number of packets we have received. We
|
/* a count of the number of packets we have received. We
|
||||||
* actually only care about zero/non-zero at this stage */
|
* actually only care about zero/non-zero at this stage */
|
||||||
unsigned pkt_count;
|
unsigned pkt_count;
|
||||||
|
|
||||||
/* the network address of the client */
|
|
||||||
char *client_addr;
|
|
||||||
} socket;
|
|
||||||
|
|
||||||
/* context that has been negotiated between the client and server */
|
/* context that has been negotiated between the client and server */
|
||||||
struct {
|
struct {
|
||||||
/* have we already done the NBT session establishment? */
|
/* have we already done the NBT session establishment? */
|
||||||
|
|||||||
Reference in New Issue
Block a user