summaryrefslogtreecommitdiff
path: root/source3/auth/auth_server.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-12-07 17:32:32 -0800
committerJeremy Allison <jra@samba.org>2007-12-07 17:32:32 -0800
commit42cfffae80480eae4381902fff3f7c61f858a933 (patch)
tree2fc1bc486fa988a4f2854310bcf91943db1aa566 /source3/auth/auth_server.c
parent25288b0e4472c728fc5a3a70c6c3e1f621ffae5f (diff)
downloadsamba-42cfffae80480eae4381902fff3f7c61f858a933.tar.gz
samba-42cfffae80480eae4381902fff3f7c61f858a933.tar.bz2
samba-42cfffae80480eae4381902fff3f7c61f858a933.zip
Remove next_token - all uses must now be next_token_talloc.
No more temptations to use static length strings. Jeremy. (This used to be commit ec003f39369910dee852b7cafb883ddaa321c2de)
Diffstat (limited to 'source3/auth/auth_server.c')
-rw-r--r--source3/auth/auth_server.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index 8b10be93fc..7c99848612 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -32,10 +32,10 @@ extern userdom_struct current_user_info;
static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
{
struct cli_state *cli = NULL;
- fstring desthost;
+ char *desthost = NULL;
struct sockaddr_storage dest_ss;
const char *p;
- char *pserver;
+ char *pserver = NULL;
bool connected_ok = False;
if (!(cli = cli_initialise()))
@@ -47,11 +47,16 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
pserver = talloc_strdup(mem_ctx, lp_passwordserver());
p = pserver;
- while(next_token( &p, desthost, LIST_SEP, sizeof(desthost))) {
+ while(next_token_talloc(mem_ctx, &p, &desthost, LIST_SEP)) {
NTSTATUS status;
- standard_sub_basic(current_user_info.smb_name, current_user_info.domain,
- desthost, sizeof(desthost));
+ desthost = talloc_sub_basic(mem_ctx,
+ current_user_info.smb_name,
+ current_user_info.domain,
+ desthost);
+ if (!desthost) {
+ return NULL;
+ }
strupper_m(desthost);
if(!resolve_name( desthost, &dest_ss, 0x20)) {
@@ -64,9 +69,9 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
continue;
}
- /* we use a mutex to prevent two connections at once - when a
- Win2k PDC get two connections where one hasn't completed a
- session setup yet it will send a TCP reset to the first
+ /* we use a mutex to prevent two connections at once - when a
+ Win2k PDC get two connections where one hasn't completed a
+ session setup yet it will send a TCP reset to the first
connection (tridge) */
if (!grab_server_mutex(desthost)) {
@@ -81,27 +86,27 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
}
DEBUG(10,("server_cryptkey: failed to connect to server %s. Error %s\n",
desthost, nt_errstr(status) ));
+ release_server_mutex();
}
if (!connected_ok) {
- release_server_mutex();
DEBUG(0,("password server not available\n"));
cli_shutdown(cli);
return NULL;
}
-
- if (!attempt_netbios_session_request(&cli, global_myname(),
+
+ if (!attempt_netbios_session_request(&cli, global_myname(),
desthost, &dest_ss)) {
release_server_mutex();
DEBUG(1,("password server fails session request\n"));
cli_shutdown(cli);
return NULL;
}
-
+
if (strequal(desthost,myhostname())) {
exit_server_cleanly("Password server loop!");
}
-
+
DEBUG(3,("got session\n"));
if (!cli_negprot(cli)) {
@@ -119,9 +124,9 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
return NULL;
}
- /* Get the first session setup done quickly, to avoid silly
+ /* Get the first session setup done quickly, to avoid silly
Win2k bugs. (The next connection to the server will kill
- this one...
+ this one...
*/
if (!NT_STATUS_IS_OK(cli_session_setup(cli, "", "", 0, "", 0,
@@ -132,11 +137,11 @@ static struct cli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
cli_shutdown(cli);
return NULL;
}
-
+
release_server_mutex();
DEBUG(3,("password server OK\n"));
-
+
return cli;
}