[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-549-gec003f3
Jeremy Allison
jra at samba.org
Sat Dec 8 01:33:11 GMT 2007
The branch, v3-2-test has been updated
via ec003f39369910dee852b7cafb883ddaa321c2de (commit)
from bca371bff8e1dd5099eda1774e5bb0fdbd6a1a77 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit ec003f39369910dee852b7cafb883ddaa321c2de
Author: Jeremy Allison <jra at samba.org>
Date: Fri Dec 7 17:32:32 2007 -0800
Remove next_token - all uses must now be next_token_talloc.
No more temptations to use static length strings.
Jeremy.
-----------------------------------------------------------------------
Summary of changes:
source/auth/auth_sam.c | 15 ++--
source/auth/auth_server.c | 39 +++++----
source/auth/pampass.c | 21 +++--
source/groupdb/mapping_ldb.c | 9 ++-
source/groupdb/mapping_tdb.c | 22 +++--
source/lib/sharesec.c | 4 +-
source/lib/util_sock.c | 6 +-
source/lib/util_str.c | 110 ++++-------------------
source/libgpo/gpo_fetch.c | 21 +----
source/libsmb/clikrb5.c | 17 ++--
source/libsmb/libsmbclient.c | 55 ++++++++----
source/libsmb/namequery.c | 30 ++++---
source/nmbd/nmbd_sendannounce.c | 14 ++-
source/nmbd/nmbd_synclists.c | 18 +++--
source/nmbd/nmbd_winsserver.c | 49 ++++++----
source/nsswitch/wbinfo.c | 33 +++++---
source/nsswitch/winbind_nss_linux.c | 89 ++++++++++++------
source/passdb/pdb_ldap.c | 4 +-
source/printing/lpq_parse.c | 168 +++++++++++++++++++++++-----------
source/registry/reg_db.c | 19 +++--
source/rpc_parse/parse_net.c | 14 ++-
source/smbd/chgpasswd.c | 42 ++++++---
source/smbd/lanman.c | 51 +++++++----
source/smbd/server.c | 26 ++++--
source/utils/net_rpc.c | 14 ++--
source/utils/net_rpc_printer.c | 12 ++--
source/utils/sharesec.c | 20 ++++-
source/utils/smbcacls.c | 31 +++++--
source/winbindd/winbindd_pam.c | 16 +++-
29 files changed, 563 insertions(+), 406 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/auth/auth_sam.c b/source/auth/auth_sam.c
index 13fc968..1ab0c8b 100644
--- a/source/auth/auth_sam.c
+++ b/source/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/source/auth/auth_server.c b/source/auth/auth_server.c
index 8b10be9..7c99848 100644
--- a/source/auth/auth_server.c
+++ b/source/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/source/auth/pampass.c b/source/auth/pampass.c
index 739e0a7..554df3c 100644
--- a/source/auth/pampass.c
+++ b/source/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;
}
diff --git a/source/groupdb/mapping_ldb.c b/source/groupdb/mapping_ldb.c
index ab7ac0b..205111e 100644
--- a/source/groupdb/mapping_ldb.c
+++ b/source/groupdb/mapping_ldb.c
@@ -578,8 +578,9 @@ static int upgrade_alias_record(TDB_CONTEXT *tdb_ctx, TDB_DATA key,
TDB_DATA data, void *state)
{
const char *p = (const char *)data.dptr;
- fstring string_sid;
+ char *string_sid;
DOM_SID member;
+ TALLOC_CTX *frame;
if (strncmp((char *)key.dptr, MEMBEROF_PREFIX,
MIN(key.dsize, strlen(MEMBEROF_PREFIX))) != 0) {
@@ -592,7 +593,8 @@ static int upgrade_alias_record(TDB_CONTEXT *tdb_ctx, TDB_DATA key,
*(int *)state = -1;
}
- while (next_token(&p, string_sid, " ", sizeof(string_sid))) {
+ frame = talloc_stackframe();
+ while (next_token_talloc(frame,&p, &string_sid, " ")) {
DOM_SID alias;
NTSTATUS status;
string_to_sid(&alias, string_sid);
@@ -604,10 +606,11 @@ static int upgrade_alias_record(TDB_CONTEXT *tdb_ctx, TDB_DATA key,
DEBUG(0,("Failed to add alias member during upgrade - %s\n",
nt_errstr(status)));
*(int *)state = -1;
+ TALLOC_FREE(frame);
return -1;
}
}
-
+ TALLOC_FREE(frame);
return 0;
}
diff --git a/source/groupdb/mapping_tdb.c b/source/groupdb/mapping_tdb.c
index 539b02e..2e4ed46 100644
--- a/source/groupdb/mapping_tdb.c
+++ b/source/groupdb/mapping_tdb.c
@@ -388,9 +388,11 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_
static NTSTATUS one_alias_membership(const DOM_SID *member,
DOM_SID **sids, size_t *num)
{
- fstring key, string_sid;
+ fstring key;
+ char *string_sid;
TDB_DATA dbuf;
const char *p;
+ TALLOC_CTX *frame;
sid_to_string(string_sid, member);
slprintf(key, sizeof(key), "%s%s", MEMBEROF_PREFIX, string_sid);
@@ -402,19 +404,20 @@ static NTSTATUS one_alias_membership(const DOM_SID *member,
}
p = (const char *)dbuf.dptr;
-
- while (next_token(&p, string_sid, " ", sizeof(string_sid))) {
-
+ frame = talloc_stackframe();
+ while (next_token_talloc(frame, &p, &string_sid, " ")) {
DOM_SID alias;
if (!string_to_sid(&alias, string_sid))
continue;
if (!add_sid_to_array_unique(NULL, &alias, sids, num)) {
+ TALLOC_FREE(frame);
return NT_STATUS_NO_MEMORY;
}
}
+ TALLOC_FREE(frame);
SAFE_FREE(dbuf.dptr);
return NT_STATUS_OK;
}
@@ -518,7 +521,8 @@ static int collect_aliasmem(TDB_CONTEXT *tdb_ctx, TDB_DATA key, TDB_DATA data,
{
struct aliasmem_closure *closure = (struct aliasmem_closure *)state;
const char *p;
- fstring alias_string;
+ char *alias_string;
+ TALLOC_CTX *frame;
if (strncmp((const char *)key.dptr, MEMBEROF_PREFIX,
strlen(MEMBEROF_PREFIX)) != 0)
@@ -526,11 +530,10 @@ static int collect_aliasmem(TDB_CONTEXT *tdb_ctx, TDB_DATA key, TDB_DATA data,
p = (const char *)data.dptr;
- while (next_token(&p, alias_string, " ", sizeof(alias_string))) {
-
+ frame = talloc_stackframe();
+ while (next_token_talloc(frame, &p, &alias_string, " ")) {
DOM_SID alias, member;
const char *member_string;
-
if (!string_to_sid(&alias, alias_string))
continue;
@@ -552,13 +555,14 @@ static int collect_aliasmem(TDB_CONTEXT *tdb_ctx, TDB_DATA key, TDB_DATA data,
if (!string_to_sid(&member, member_string))
continue;
-
+
if (!add_sid_to_array(NULL, &member, closure->sids, closure->num)) {
/* talloc fail. */
break;
}
}
+ TALLOC_FREE(frame);
return 0;
}
diff --git a/source/lib/sharesec.c b/source/lib/sharesec.c
index 4b1ec55..b3b0005 100644
--- a/source/lib/sharesec.c
+++ b/source/lib/sharesec.c
@@ -290,10 +290,10 @@ bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, SEC_DESC **ppsd)
uint32 g_access;
uint32 s_access;
DOM_SID sid;
- fstring sidstr;
+ char *sidstr;
uint8 type = SEC_ACE_TYPE_ACCESS_ALLOWED;
- if (!next_token(&pacl, sidstr, ":", sizeof(sidstr))) {
+ if (!next_token_talloc(ctx, &pacl, &sidstr, ":")) {
DEBUG(0,("parse_usershare_acl: malformed usershare acl looking "
"for ':' in string '%s'\n", pacl));
return False;
diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c
index e49db34..e919cc5 100644
--- a/source/lib/util_sock.c
+++ b/source/lib/util_sock.c
@@ -785,9 +785,10 @@ static void print_socket_options(int s)
void set_socket_options(int fd, const char *options)
{
- fstring tok;
+ TALLOC_CTX *ctx = talloc_stackframe();
+ char *tok;
- while (next_token(&options,tok," \t,", sizeof(tok))) {
+ while (next_token_talloc(ctx, &options, &tok," \t,")) {
int ret=0,i;
int value = 1;
char *p;
@@ -836,6 +837,7 @@ void set_socket_options(int fd, const char *options)
}
}
+ TALLOC_FREE(ctx);
print_socket_options(fd);
}
diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index 2c0d86e..ee76e33 100644
--- a/source/lib/util_str.c
+++ b/source/lib/util_str.c
@@ -29,62 +29,6 @@
* @brief String utilities.
**/
-/**
- * Internal function to get the next token from a string, return false if none
- * found. Handles double-quotes. This is the work horse function called by
- * next_token() and next_token_no_ltrim().
- *
- * Based on a routine by GJC at VILLAGE.COM.
- * Extensively modified by Andrew.Tridgell at anu.edu.au
- */
-static bool next_token_internal(const char **ptr,
- char *buff,
- const char *sep,
- size_t bufsize,
- bool ltrim)
-{
- char *s;
- char *pbuf;
- bool quoted;
- size_t len=1;
-
- if (!ptr)
- return(false);
-
- s = (char *)*ptr;
-
- /* default to simple separators */
- if (!sep)
- sep = " \t\n\r";
-
- /* find the first non sep char, if left-trimming is requested */
- if (ltrim) {
- while (*s && strchr_m(sep,*s))
- s++;
- }
-
- /* nothing left? */
- if (! *s)
- return(false);
-
- /* copy over the token */
- pbuf = buff;
- for (quoted = false; len < bufsize && *s &&
- (quoted || !strchr_m(sep,*s)); s++) {
- if ( *s == '\"' ) {
- quoted = !quoted;
- } else {
- len++;
- *pbuf++ = *s;
- }
- }
-
- *ptr = (*s) ? s+1 : s;
- *pbuf = 0;
-
- return(true);
-}
-
static bool next_token_internal_talloc(TALLOC_CTX *ctx,
const char **ptr,
char **pp_buff,
@@ -111,8 +55,9 @@ static bool next_token_internal_talloc(TALLOC_CTX *ctx,
/* find the first non sep char, if left-trimming is requested */
if (ltrim) {
- while (*s && strchr_m(sep,*s))
+ while (*s && strchr_m(sep,*s)) {
s++;
+ }
}
/* nothing left? */
@@ -157,6 +102,7 @@ static bool next_token_internal_talloc(TALLOC_CTX *ctx,
return true;
}
+#if 0
/*
* Get the next token from a string, return false if none found. Handles
* double-quotes. This version trims leading separator characters before
@@ -166,6 +112,7 @@ bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize)
{
return next_token_internal(ptr, buff, sep, bufsize, true);
}
+#endif
bool next_token_talloc(TALLOC_CTX *ctx,
const char **ptr,
@@ -180,13 +127,6 @@ bool next_token_talloc(TALLOC_CTX *ctx,
* double-quotes. This version does not trim leading separator characters
* before looking for a token.
*/
-bool next_token_no_ltrim(const char **ptr,
- char *buff,
- const char *sep,
- size_t bufsize)
-{
- return next_token_internal(ptr, buff, sep, bufsize, false);
-}
bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
const char **ptr,
@@ -204,18 +144,6 @@ but beware the fact that it is not re-entrant!
static const char *last_ptr=NULL;
-bool next_token_nr(const char **ptr,char *buff, const char *sep, size_t bufsize)
-{
- bool ret;
- if (!ptr) {
- ptr = &last_ptr;
- }
-
- ret = next_token(ptr, buff, sep, bufsize);
--
Samba Shared Repository
More information about the samba-cvs
mailing list