summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/client/client.c2
-rw-r--r--source3/include/proto.h5
-rw-r--r--source3/libsmb/dsgetdcname.c3
-rw-r--r--source3/libsmb/namequery.c44
-rw-r--r--source3/param/loadparm.c15
-rw-r--r--source3/utils/smbpasswd.c2
6 files changed, 31 insertions, 40 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 821bd0a32e..28fc30aeb4 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -5540,7 +5540,7 @@ static int do_message_op(struct user_auth_info *a_info)
}
if(new_name_resolve_order)
- lp_set_name_resolve_order(new_name_resolve_order);
+ lp_set_cmdline("name resolve order", new_name_resolve_order);
if (!tar_type && !query_host && !service && !message) {
poptPrintUsage(pc, stderr, 0);
diff --git a/source3/include/proto.h b/source3/include/proto.h
index f551c25590..769a300403 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -900,7 +900,7 @@ NTSTATUS internal_resolve_name(const char *name,
const char *sitename,
struct ip_service **return_iplist,
int *return_count,
- const char *resolve_order);
+ const char **resolve_order);
bool resolve_name(const char *name,
struct sockaddr_storage *return_ss,
int name_type,
@@ -1034,7 +1034,7 @@ char *lp_auto_services(TALLOC_CTX *ctx);
char *lp_passwd_program(TALLOC_CTX *ctx);
char *lp_passwd_chat(TALLOC_CTX *ctx);
const char *lp_passwordserver(void);
-const char *lp_name_resolve_order(void);
+const char **lp_name_resolve_order(void);
const char *lp_netbios_scope(void);
const char *lp_netbios_name(void);
const char *lp_workgroup(void);
@@ -1472,7 +1472,6 @@ bool lp_preferred_master(void);
void lp_remove_service(int snum);
void lp_copy_service(int snum, const char *new_name);
int lp_default_server_announce(void);
-void lp_set_name_resolve_order(const char *new_order);
const char *lp_printername(TALLOC_CTX *ctx, int snum);
void lp_set_logfile(const char *name);
int lp_maxprintjobs(int snum);
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 02f4bc928d..028a31b617 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -478,6 +478,7 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
int i;
struct ip_service_name *dclist = NULL;
int count;
+ static const char *resolve_order[] = { "lmhosts", "wins", "bcast", NULL };
*returned_dclist = NULL;
*returned_count = 0;
@@ -492,7 +493,7 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
status = internal_resolve_name(domain_name, name_type, NULL,
&iplist, &count,
- "lmhosts wins bcast");
+ resolve_order);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10,("discover_dc_netbios: failed to find DC\n"));
return status;
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 4c05e4f418..e4dda16659 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -2584,10 +2584,9 @@ NTSTATUS internal_resolve_name(const char *name,
const char *sitename,
struct ip_service **return_iplist,
int *return_count,
- const char *resolve_order)
+ const char **resolve_order)
{
- char *tok;
- const char *ptr;
+ const char *tok;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
int i;
TALLOC_CTX *frame = NULL;
@@ -2640,21 +2639,22 @@ NTSTATUS internal_resolve_name(const char *name,
/* set the name resolution order */
- if (strcmp( resolve_order, "NULL") == 0) {
+ if (resolve_order && strcmp(resolve_order[0], "NULL") == 0) {
DEBUG(8,("internal_resolve_name: all lookups disabled\n"));
return NT_STATUS_INVALID_PARAMETER;
}
- if (!resolve_order[0]) {
- ptr = "host";
- } else {
- ptr = resolve_order;
+ if (!resolve_order || !resolve_order[0]) {
+ static const char *host_order[] = { "host", NULL };
+ resolve_order = host_order;
}
/* iterate through the name resolution backends */
frame = talloc_stackframe();
- while (next_token_talloc(frame, &ptr, &tok, LIST_SEP)) {
+ for (i=0; resolve_order[i]; i++) {
+ tok = resolve_order[i];
+
if((strequal(tok, "host") || strequal(tok, "hosts"))) {
status = resolve_hosts(name, name_type, return_iplist,
return_count);
@@ -2963,12 +2963,12 @@ bool get_pdc_ip(const char *domain, struct sockaddr_storage *pss)
struct ip_service *ip_list = NULL;
int count = 0;
NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
-
+ static const char *ads_order[] = { "ads", NULL };
/* Look up #1B name */
if (lp_security() == SEC_ADS) {
status = internal_resolve_name(domain, 0x1b, NULL, &ip_list,
- &count, "ads");
+ &count, ads_order);
}
if (!NT_STATUS_IS_OK(status) || count == 0) {
@@ -3009,7 +3009,7 @@ static NTSTATUS get_dc_list(const char *domain,
enum dc_lookup_type lookup_type,
bool *ordered)
{
- char *resolve_order = NULL;
+ const char **resolve_order = NULL;
char *saf_servername = NULL;
char *pserver = NULL;
const char *p;
@@ -3040,27 +3040,30 @@ static NTSTATUS get_dc_list(const char *domain,
are disabled and ads_only is True, then set the string to
NULL. */
- resolve_order = talloc_strdup(ctx, lp_name_resolve_order());
+ resolve_order = lp_name_resolve_order();
if (!resolve_order) {
status = NT_STATUS_NO_MEMORY;
goto out;
}
- strlower_m(resolve_order);
if (lookup_type == DC_ADS_ONLY) {
- if (strstr( resolve_order, "host")) {
- resolve_order = talloc_strdup(ctx, "ads");
+ if (str_list_check_ci(resolve_order, "host")) {
+ static const char *ads_order[] = { "ads", NULL };
+ resolve_order = ads_order;
/* DNS SRV lookups used by the ads resolver
are already sorted by priority and weight */
*ordered = true;
} else {
- resolve_order = talloc_strdup(ctx, "NULL");
+ /* this is quite bizarre! */
+ static const char *null_order[] = { "NULL", NULL };
+ resolve_order = null_order;
}
} else if (lookup_type == DC_KDC_ONLY) {
+ static const char *kdc_order[] = { "kdc", NULL };
/* DNS SRV lookups used by the ads/kdc resolver
are already sorted by priority and weight */
*ordered = true;
- resolve_order = talloc_strdup(ctx, "kdc");
+ resolve_order = kdc_order;
}
if (!resolve_order) {
status = NT_STATUS_NO_MEMORY;
@@ -3281,10 +3284,9 @@ NTSTATUS get_sorted_dc_list( const char *domain,
*count = 0;
DEBUG(8,("get_sorted_dc_list: attempting lookup "
- "for name %s (sitename %s) using [%s]\n",
+ "for name %s (sitename %s)\n",
domain,
- sitename ? sitename : "NULL",
- (ads_only ? "ads" : lp_name_resolve_order())));
+ sitename ? sitename : "NULL"));
if (ads_only) {
lookup_type = DC_ADS_ONLY;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 5486b0a92f..4c21d5032f 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1749,7 +1749,7 @@ static struct parm_struct parm_table[] = {
},
{
.label = "name resolve order",
- .type = P_STRING,
+ .type = P_LIST,
.p_class = P_GLOBAL,
.offset = GLOBAL_VAR(szNameResolveOrder),
.special = NULL,
@@ -4730,7 +4730,7 @@ static void init_globals(bool reinit_globals)
string_set(&Globals.szLogonHome, "\\\\%N\\%U");
string_set(&Globals.szLogonPath, "\\\\%N\\%U\\profile");
- string_set(&Globals.szNameResolveOrder, "lmhosts wins host bcast");
+ Globals.szNameResolveOrder = (const char **)str_list_make_v3(NULL, "lmhosts wins host bcast", NULL);
string_set(&Globals.szPasswordServer, "*");
Globals.AlgorithmicRidBase = BASE_RID;
@@ -5109,7 +5109,6 @@ int lp_cups_encrypt(void)
/* These functions remain in source3/param for now */
-FN_GLOBAL_CONST_STRING(name_resolve_order, szNameResolveOrder)
FN_GLOBAL_CONST_STRING(smb_ports, smb_ports)
FN_GLOBAL_INTEGER(security, security)
FN_GLOBAL_INTEGER(usershare_max_shares, iUsershareMaxShares)
@@ -9149,16 +9148,6 @@ void lp_copy_service(int snum, const char *new_name)
}
}
-
-/***********************************************************
- Set the global name resolution order (used in smbclient).
-************************************************************/
-
-void lp_set_name_resolve_order(const char *new_order)
-{
- string_set(&Globals.szNameResolveOrder, new_order);
-}
-
const char *lp_printername(TALLOC_CTX *ctx, int snum)
{
const char *ret = lp__printername(talloc_tos(), snum);
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 43edab24ee..f845147da4 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -153,7 +153,7 @@ static int process_options(int argc, char **argv, int local_flags)
fstrcpy(ldap_secret, optarg);
break;
case 'R':
- lp_set_name_resolve_order(optarg);
+ lp_set_cmdline("name resolve order", optarg);
break;
case 'D':
lp_set_cmdline("log level", optarg);