mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
Always pass a TALLOC_CTX to str_list_make and str_list_copy
This commit is contained in:
parent
d471dd4adb
commit
e2c9fc4cf5
@ -458,7 +458,9 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context)
|
|||||||
char **auth_method_list = NULL;
|
char **auth_method_list = NULL;
|
||||||
NTSTATUS nt_status;
|
NTSTATUS nt_status;
|
||||||
|
|
||||||
if (lp_auth_methods() && !str_list_copy(&auth_method_list, lp_auth_methods())) {
|
if (lp_auth_methods()
|
||||||
|
&& !str_list_copy(talloc_tos(), &auth_method_list,
|
||||||
|
lp_auth_methods())) {
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,38 +469,52 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context)
|
|||||||
{
|
{
|
||||||
case SEC_DOMAIN:
|
case SEC_DOMAIN:
|
||||||
DEBUG(5,("Making default auth method list for security=domain\n"));
|
DEBUG(5,("Making default auth method list for security=domain\n"));
|
||||||
auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(), "guest sam winbind:ntdomain",
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
case SEC_SERVER:
|
case SEC_SERVER:
|
||||||
DEBUG(5,("Making default auth method list for security=server\n"));
|
DEBUG(5,("Making default auth method list for security=server\n"));
|
||||||
auth_method_list = str_list_make("guest sam smbserver", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(), "guest sam smbserver",
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
case SEC_USER:
|
case SEC_USER:
|
||||||
if (lp_encrypted_passwords()) {
|
if (lp_encrypted_passwords()) {
|
||||||
if ((lp_server_role() == ROLE_DOMAIN_PDC) || (lp_server_role() == ROLE_DOMAIN_BDC)) {
|
if ((lp_server_role() == ROLE_DOMAIN_PDC) || (lp_server_role() == ROLE_DOMAIN_BDC)) {
|
||||||
DEBUG(5,("Making default auth method list for DC, security=user, encrypt passwords = yes\n"));
|
DEBUG(5,("Making default auth method list for DC, security=user, encrypt passwords = yes\n"));
|
||||||
auth_method_list = str_list_make("guest sam winbind:trustdomain", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(),
|
||||||
|
"guest sam winbind:trustdomain",
|
||||||
|
NULL);
|
||||||
} else {
|
} else {
|
||||||
DEBUG(5,("Making default auth method list for standalone security=user, encrypt passwords = yes\n"));
|
DEBUG(5,("Making default auth method list for standalone security=user, encrypt passwords = yes\n"));
|
||||||
auth_method_list = str_list_make("guest sam", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(), "guest sam",
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG(5,("Making default auth method list for security=user, encrypt passwords = no\n"));
|
DEBUG(5,("Making default auth method list for security=user, encrypt passwords = no\n"));
|
||||||
auth_method_list = str_list_make("guest unix", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(), "guest unix", NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SEC_SHARE:
|
case SEC_SHARE:
|
||||||
if (lp_encrypted_passwords()) {
|
if (lp_encrypted_passwords()) {
|
||||||
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = yes\n"));
|
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = yes\n"));
|
||||||
auth_method_list = str_list_make("guest sam", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(), "guest sam", NULL);
|
||||||
} else {
|
} else {
|
||||||
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = no\n"));
|
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = no\n"));
|
||||||
auth_method_list = str_list_make("guest unix", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(), "guest unix", NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SEC_ADS:
|
case SEC_ADS:
|
||||||
DEBUG(5,("Making default auth method list for security=ADS\n"));
|
DEBUG(5,("Making default auth method list for security=ADS\n"));
|
||||||
auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL);
|
auth_method_list = str_list_make(
|
||||||
|
talloc_tos(), "guest sam winbind:ntdomain",
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUG(5,("Unknown auth method!\n"));
|
DEBUG(5,("Unknown auth method!\n"));
|
||||||
@ -511,7 +527,7 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context)
|
|||||||
nt_status = make_auth_context_text_list(auth_context,
|
nt_status = make_auth_context_text_list(auth_context,
|
||||||
auth_method_list);
|
auth_method_list);
|
||||||
|
|
||||||
str_list_free(&auth_method_list);
|
TALLOC_FREE(auth_method_list);
|
||||||
return nt_status;
|
return nt_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,14 +460,14 @@ bool debug_parse_levels(const char *params_str)
|
|||||||
if (AllowDebugChange == False)
|
if (AllowDebugChange == False)
|
||||||
return True;
|
return True;
|
||||||
|
|
||||||
params = str_list_make(params_str, NULL);
|
params = str_list_make(talloc_tos(), params_str, NULL);
|
||||||
|
|
||||||
if (debug_parse_params(params)) {
|
if (debug_parse_params(params)) {
|
||||||
debug_dump_status(5);
|
debug_dump_status(5);
|
||||||
str_list_free(¶ms);
|
TALLOC_FREE(params);
|
||||||
return True;
|
return True;
|
||||||
} else {
|
} else {
|
||||||
str_list_free(¶ms);
|
TALLOC_FREE(params);
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1902,19 +1902,12 @@ static char **str_list_make_internal(TALLOC_CTX *mem_ctx, const char *string,
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **str_list_make_talloc(TALLOC_CTX *mem_ctx,
|
char **str_list_make(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
|
||||||
const char *string,
|
|
||||||
const char *sep)
|
|
||||||
{
|
{
|
||||||
return str_list_make_internal(mem_ctx, string, sep);
|
return str_list_make_internal(mem_ctx, string, sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
char **str_list_make(const char *string, const char *sep)
|
bool str_list_copy(TALLOC_CTX *mem_ctx, char ***dest, const char **src)
|
||||||
{
|
|
||||||
return str_list_make_internal(NULL, string, sep);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool str_list_copy(char ***dest, const char **src)
|
|
||||||
{
|
{
|
||||||
char **list;
|
char **list;
|
||||||
int i, num;
|
int i, num;
|
||||||
@ -1928,7 +1921,7 @@ bool str_list_copy(char ***dest, const char **src)
|
|||||||
num += 1;
|
num += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = TALLOC_ARRAY(NULL, char *, num+1);
|
list = TALLOC_ARRAY(mem_ctx, char *, num+1);
|
||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -664,7 +664,7 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads,
|
|||||||
else {
|
else {
|
||||||
/* This would be the utf8-encoded version...*/
|
/* This would be the utf8-encoded version...*/
|
||||||
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
|
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
|
||||||
if (!(str_list_copy(&search_attrs, attrs))) {
|
if (!(str_list_copy(talloc_tos(), &search_attrs, attrs))) {
|
||||||
rc = LDAP_NO_MEMORY;
|
rc = LDAP_NO_MEMORY;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -974,7 +974,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
|
|||||||
else {
|
else {
|
||||||
/* This would be the utf8-encoded version...*/
|
/* This would be the utf8-encoded version...*/
|
||||||
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
|
/* if (!(search_attrs = ads_push_strvals(ctx, attrs))) */
|
||||||
if (!(str_list_copy(&search_attrs, attrs)))
|
if (!(str_list_copy(talloc_tos(), &search_attrs, attrs)))
|
||||||
{
|
{
|
||||||
DEBUG(1,("ads_do_search: str_list_copy() failed!"));
|
DEBUG(1,("ads_do_search: str_list_copy() failed!"));
|
||||||
rc = LDAP_NO_MEMORY;
|
rc = LDAP_NO_MEMORY;
|
||||||
|
@ -44,7 +44,7 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
|||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
ext_list = str_list_make_talloc(mem_ctx, extension_raw, "]");
|
ext_list = str_list_make(mem_ctx, extension_raw, "]");
|
||||||
if (!ext_list) {
|
if (!ext_list) {
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
|
|||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ext_strings = str_list_make_talloc(mem_ctx, p, "}");
|
ext_strings = str_list_make(mem_ctx, p, "}");
|
||||||
if (ext_strings == NULL) {
|
if (ext_strings == NULL) {
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ static ADS_STATUS gpo_parse_gplink(TALLOC_CTX *mem_ctx,
|
|||||||
|
|
||||||
DEBUG(10,("gpo_parse_gplink: gPLink: %s\n", gp_link_raw));
|
DEBUG(10,("gpo_parse_gplink: gPLink: %s\n", gp_link_raw));
|
||||||
|
|
||||||
link_list = str_list_make_talloc(mem_ctx, gp_link_raw, "]");
|
link_list = str_list_make(mem_ctx, gp_link_raw, "]");
|
||||||
if (!link_list) {
|
if (!link_list) {
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
|
@ -1691,7 +1691,7 @@ static void init_globals(bool first_time_only)
|
|||||||
Globals.bWinbindTrustedDomainsOnly = False;
|
Globals.bWinbindTrustedDomainsOnly = False;
|
||||||
Globals.bWinbindNestedGroups = True;
|
Globals.bWinbindNestedGroups = True;
|
||||||
Globals.winbind_expand_groups = 1;
|
Globals.winbind_expand_groups = 1;
|
||||||
Globals.szWinbindNssInfo = str_list_make("template", NULL);
|
Globals.szWinbindNssInfo = str_list_make(NULL, "template", NULL);
|
||||||
Globals.bWinbindRefreshTickets = False;
|
Globals.bWinbindRefreshTickets = False;
|
||||||
Globals.bWinbindOfflineLogon = False;
|
Globals.bWinbindOfflineLogon = False;
|
||||||
|
|
||||||
@ -2397,7 +2397,7 @@ const char **lp_parm_string_list(int snum, const char *type, const char *option,
|
|||||||
return (const char **)def;
|
return (const char **)def;
|
||||||
|
|
||||||
if (data->list==NULL) {
|
if (data->list==NULL) {
|
||||||
data->list = str_list_make(data->value, NULL);
|
data->list = str_list_make(NULL, data->value, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (const char **)data->list;
|
return (const char **)data->list;
|
||||||
@ -3276,7 +3276,8 @@ static void copy_service(service * pserviceDest, service * pserviceSource,
|
|||||||
break;
|
break;
|
||||||
case P_LIST:
|
case P_LIST:
|
||||||
str_list_free((char ***)dest_ptr);
|
str_list_free((char ***)dest_ptr);
|
||||||
str_list_copy((char ***)dest_ptr, *(const char ***)src_ptr);
|
str_list_copy(NULL, (char ***)dest_ptr,
|
||||||
|
*(const char ***)src_ptr);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -3775,7 +3776,7 @@ static bool handle_netbios_scope(int snum, const char *pszParmValue, char **ptr)
|
|||||||
static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
|
static bool handle_netbios_aliases(int snum, const char *pszParmValue, char **ptr)
|
||||||
{
|
{
|
||||||
str_list_free(&Globals.szNetbiosAliases);
|
str_list_free(&Globals.szNetbiosAliases);
|
||||||
Globals.szNetbiosAliases = str_list_make(pszParmValue, NULL);
|
Globals.szNetbiosAliases = str_list_make(NULL, pszParmValue, NULL);
|
||||||
return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
|
return set_netbios_aliases((const char **)Globals.szNetbiosAliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4193,7 +4194,8 @@ bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue
|
|||||||
|
|
||||||
case P_LIST:
|
case P_LIST:
|
||||||
str_list_free((char ***)parm_ptr);
|
str_list_free((char ***)parm_ptr);
|
||||||
*(char ***)parm_ptr = str_list_make(pszParmValue, NULL);
|
*(char ***)parm_ptr = str_list_make(
|
||||||
|
NULL, pszParmValue, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case P_STRING:
|
case P_STRING:
|
||||||
@ -4812,8 +4814,9 @@ static void lp_save_defaults(void)
|
|||||||
continue;
|
continue;
|
||||||
switch (parm_table[i].type) {
|
switch (parm_table[i].type) {
|
||||||
case P_LIST:
|
case P_LIST:
|
||||||
str_list_copy(&(parm_table[i].def.lvalue),
|
str_list_copy(
|
||||||
*(const char ***)parm_table[i].ptr);
|
NULL, &(parm_table[i].def.lvalue),
|
||||||
|
*(const char ***)parm_table[i].ptr);
|
||||||
break;
|
break;
|
||||||
case P_STRING:
|
case P_STRING:
|
||||||
case P_USTRING:
|
case P_USTRING:
|
||||||
|
@ -178,7 +178,7 @@ bool map_username(fstring user)
|
|||||||
|
|
||||||
/* skip lines like 'user = ' */
|
/* skip lines like 'user = ' */
|
||||||
|
|
||||||
dosuserlist = str_list_make(dosname, NULL);
|
dosuserlist = str_list_make(talloc_tos(), dosname, NULL);
|
||||||
if (!dosuserlist) {
|
if (!dosuserlist) {
|
||||||
DEBUG(0,("Bad username map entry. Unable to build user list. Ignoring.\n"));
|
DEBUG(0,("Bad username map entry. Unable to build user list. Ignoring.\n"));
|
||||||
continue;
|
continue;
|
||||||
@ -193,13 +193,13 @@ bool map_username(fstring user)
|
|||||||
fstrcpy( user, unixname );
|
fstrcpy( user, unixname );
|
||||||
|
|
||||||
if ( return_if_mapped ) {
|
if ( return_if_mapped ) {
|
||||||
str_list_free (&dosuserlist);
|
TALLOC_FREE(dosuserlist);
|
||||||
x_fclose(f);
|
x_fclose(f);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str_list_free (&dosuserlist);
|
TALLOC_FREE(dosuserlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
x_fclose(f);
|
x_fclose(f);
|
||||||
|
@ -582,7 +582,7 @@ static bool user_ok(const char *user, int snum)
|
|||||||
ret = True;
|
ret = True;
|
||||||
|
|
||||||
if (lp_invalid_users(snum)) {
|
if (lp_invalid_users(snum)) {
|
||||||
str_list_copy(&invalid, lp_invalid_users(snum));
|
str_list_copy(talloc_tos(), &invalid, lp_invalid_users(snum));
|
||||||
if (invalid &&
|
if (invalid &&
|
||||||
str_list_substitute(invalid, "%S", lp_servicename(snum))) {
|
str_list_substitute(invalid, "%S", lp_servicename(snum))) {
|
||||||
|
|
||||||
@ -599,7 +599,7 @@ static bool user_ok(const char *user, int snum)
|
|||||||
str_list_free (&invalid);
|
str_list_free (&invalid);
|
||||||
|
|
||||||
if (ret && lp_valid_users(snum)) {
|
if (ret && lp_valid_users(snum)) {
|
||||||
str_list_copy(&valid, lp_valid_users(snum));
|
str_list_copy(talloc_tos(), &valid, lp_valid_users(snum));
|
||||||
if ( valid &&
|
if ( valid &&
|
||||||
str_list_substitute(valid, "%S", lp_servicename(snum)) ) {
|
str_list_substitute(valid, "%S", lp_servicename(snum)) ) {
|
||||||
|
|
||||||
@ -615,13 +615,14 @@ static bool user_ok(const char *user, int snum)
|
|||||||
str_list_free (&valid);
|
str_list_free (&valid);
|
||||||
|
|
||||||
if (ret && lp_onlyuser(snum)) {
|
if (ret && lp_onlyuser(snum)) {
|
||||||
char **user_list = str_list_make (lp_username(snum), NULL);
|
char **user_list = str_list_make(
|
||||||
|
talloc_tos(), lp_username(snum), NULL);
|
||||||
if (user_list &&
|
if (user_list &&
|
||||||
str_list_substitute(user_list, "%S",
|
str_list_substitute(user_list, "%S",
|
||||||
lp_servicename(snum))) {
|
lp_servicename(snum))) {
|
||||||
ret = user_in_list(user, (const char **)user_list);
|
ret = user_in_list(user, (const char **)user_list);
|
||||||
}
|
}
|
||||||
if (user_list) str_list_free (&user_list);
|
TALLOC_FREE(user_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
|
@ -74,7 +74,7 @@ void web_set_lang(const char *lang_string)
|
|||||||
int lang_num, i;
|
int lang_num, i;
|
||||||
|
|
||||||
/* build the lang list */
|
/* build the lang list */
|
||||||
lang_list = str_list_make(lang_string, ", \t\r\n");
|
lang_list = str_list_make(talloc_tos(), lang_string, ", \t\r\n");
|
||||||
if (!lang_list) return;
|
if (!lang_list) return;
|
||||||
|
|
||||||
/* sort the list by priority */
|
/* sort the list by priority */
|
||||||
@ -100,7 +100,7 @@ void web_set_lang(const char *lang_string)
|
|||||||
}
|
}
|
||||||
pl[i].string = SMB_STRDUP(lang_list[i]);
|
pl[i].string = SMB_STRDUP(lang_list[i]);
|
||||||
}
|
}
|
||||||
str_list_free(&lang_list);
|
TALLOC_FREE(lang_list);
|
||||||
|
|
||||||
qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list);
|
qsort(pl, lang_num, sizeof(struct pri_list), &qsort_cmp_list);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user