diff options
author | Jeremy Allison <jra@samba.org> | 2007-12-07 17:32:32 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-12-07 17:32:32 -0800 |
commit | 42cfffae80480eae4381902fff3f7c61f858a933 (patch) | |
tree | 2fc1bc486fa988a4f2854310bcf91943db1aa566 /source3/auth | |
parent | 25288b0e4472c728fc5a3a70c6c3e1f621ffae5f (diff) | |
download | samba-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')
-rw-r--r-- | source3/auth/auth_sam.c | 15 | ||||
-rw-r--r-- | source3/auth/auth_server.c | 39 | ||||
-rw-r--r-- | source3/auth/pampass.c | 21 |
3 files changed, 44 insertions, 31 deletions
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c index 13fc968b88..1ab0c8b3eb 100644 --- a/source3/auth/auth_sam.c +++ b/source3/auth/auth_sam.c @@ -188,15 +188,14 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx, if (*workstation_list) { bool invalid_ws = True; - fstring tok; + char *tok; const char *s = workstation_list; const char *machine_name = talloc_asprintf(mem_ctx, "%s$", user_info->wksta_name); if (machine_name == NULL) return NT_STATUS_NO_MEMORY; - - - while (next_token(&s, tok, ",", sizeof(tok))) { + + while (next_token_talloc(mem_ctx, &s, &tok, ",")) { DEBUG(10,("sam_account_ok: checking for workstation match %s and %s\n", tok, user_info->wksta_name)); if(strequal(tok, user_info->wksta_name)) { @@ -211,9 +210,11 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx, break; } } + TALLOC_FREE(tok); } - - if (invalid_ws) + TALLOC_FREE(tok); + + if (invalid_ws) return NT_STATUS_INVALID_WORKSTATION; } @@ -221,7 +222,7 @@ static NTSTATUS sam_account_ok(TALLOC_CTX *mem_ctx, DEBUG(2,("sam_account_ok: Domain trust account %s denied by server\n", pdb_get_username(sampass))); return NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT; } - + if (acct_ctrl & ACB_SVRTRUST) { if (!(user_info->logon_parameters & MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT)) { DEBUG(2,("sam_account_ok: Server trust account %s denied by server\n", pdb_get_username(sampass))); 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; } diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c index 739e0a78fd..554df3c157 100644 --- a/source3/auth/pampass.c +++ b/source3/auth/pampass.c @@ -207,15 +207,17 @@ struct chat_struct { static struct chat_struct *make_pw_chat(const char *p) { - fstring prompt; - fstring reply; + char *prompt; + char *reply; struct chat_struct *list = NULL; struct chat_struct *t; + TALLOC_CTX *frame = talloc_stackframe(); while (1) { t = SMB_MALLOC_P(struct chat_struct); if (!t) { DEBUG(0,("make_pw_chat: malloc failed!\n")); + TALLOC_FREE(frame); return NULL; } @@ -223,22 +225,26 @@ static struct chat_struct *make_pw_chat(const char *p) DLIST_ADD_END(list, t, struct chat_struct*); - if (!next_token(&p, prompt, NULL, sizeof(fstring))) + if (!next_token_talloc(frame, &p, &prompt, NULL)) { break; + } - if (strequal(prompt,".")) + if (strequal(prompt,".")) { fstrcpy(prompt,"*"); + } special_char_sub(prompt); fstrcpy(t->prompt, prompt); strlower_m(t->prompt); trim_char(t->prompt, ' ', ' '); - if (!next_token(&p, reply, NULL, sizeof(fstring))) + if (!next_token_talloc(frame, &p, reply, NULL)) { break; + } - if (strequal(reply,".")) - fstrcpy(reply,""); + if (strequal(reply,".")) { + fstrcpy(reply,""); + } special_char_sub(reply); fstrcpy(t->reply, reply); @@ -246,6 +252,7 @@ static struct chat_struct *make_pw_chat(const char *p) trim_char(t->reply, ' ', ' '); } + TALLOC_FREE(frame); return list; } |