diff options
-rw-r--r-- | source/lib/util.c | 74 | ||||
-rw-r--r-- | source/libsmb/ntlmssp.c | 5 | ||||
-rw-r--r-- | source/nmbd/nmbd_processlogon.c | 2 | ||||
-rw-r--r-- | source/param/loadparm.c | 4 | ||||
-rw-r--r-- | source/printing/nt_printing.c | 2 | ||||
-rw-r--r-- | source/rpc_server/srv_lsa_ds_nt.c | 4 | ||||
-rw-r--r-- | source/rpc_server/srv_lsa_nt.c | 2 | ||||
-rw-r--r-- | source/rpc_server/srv_spoolss_nt.c | 2 |
8 files changed, 39 insertions, 56 deletions
diff --git a/source/lib/util.c b/source/lib/util.c index 4f4e0eb5d7b..3da4e536e02 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -932,26 +932,33 @@ BOOL get_myname(char *my_name) } /**************************************************************************** - Get my own name, including domain. + Get my own canonical name, including domain. ****************************************************************************/ -BOOL get_myfullname(char *my_name) +BOOL get_mydnsfullname(fstring my_dnsname) { - pstring hostname; + static fstring dnshostname; + struct hostent *hp; - *hostname = 0; + if (!*dnshostname) { + /* get my host name */ + if (gethostname(dnshostname, sizeof(dnshostname)) == -1) { + *dnshostname = '\0'; + DEBUG(0,("gethostname failed\n")); + return False; + } - /* get my host name */ - if (gethostname(hostname, sizeof(hostname)) == -1) { - DEBUG(0,("gethostname failed\n")); - return False; - } + /* Ensure null termination. */ + dnshostname[sizeof(dnshostname)-1] = '\0'; - /* Ensure null termination. */ - hostname[sizeof(hostname)-1] = '\0'; - - if (my_name) - fstrcpy(my_name, hostname); + /* Ensure we get the cannonical name. */ + if (!(hp = sys_gethostbyname(dnshostname))) { + *dnshostname = '\0'; + return False; + } + fstrcpy(dnshostname, hp->h_name); + } + fstrcpy(my_dnsname, dnshostname); return True; } @@ -959,44 +966,19 @@ BOOL get_myfullname(char *my_name) Get my own domain name. ****************************************************************************/ -BOOL get_mydomname(fstring my_domname) +BOOL get_mydnsdomname(fstring my_domname) { - pstring hostname; + fstring domname; char *p; - struct hostent *hp; - *hostname = 0; - /* get my host name */ - if (gethostname(hostname, sizeof(hostname)) == -1) { - DEBUG(0,("gethostname failed\n")); - return False; - } - - /* Ensure null termination. */ - hostname[sizeof(hostname)-1] = '\0'; - - - p = strchr_m(hostname, '.'); - - if (p) { - p++; - - if (my_domname) - fstrcpy(my_domname, p); - } - - if (!(hp = sys_gethostbyname(hostname))) { + *my_domname = '\0'; + if (!get_mydnsfullname(domname)) { return False; - } - - p = strchr_m(hp->h_name, '.'); - + } + p = strchr_m(domname, '.'); if (p) { p++; - - if (my_domname) - fstrcpy(my_domname, p); - return True; + fstrcpy(my_domname, p); } return False; diff --git a/source/libsmb/ntlmssp.c b/source/libsmb/ntlmssp.c index a80b4b66b0e..60523ddf9d0 100644 --- a/source/libsmb/ntlmssp.c +++ b/source/libsmb/ntlmssp.c @@ -433,12 +433,11 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, /* This should be a 'netbios domain -> DNS domain' mapping */ dnsdomname[0] = '\0'; - get_mydomname(dnsdomname); + get_mydnsdomname(dnsdomname); strlower_m(dnsdomname); dnsname[0] = '\0'; - get_myfullname(dnsname); - strlower_m(dnsname); + get_mydnsfullname(dnsname); /* This creates the 'blob' of names that appears at the end of the packet */ if (chal_flags & NTLMSSP_CHAL_TARGET_INFO) diff --git a/source/nmbd/nmbd_processlogon.c b/source/nmbd/nmbd_processlogon.c index 7819649b83e..7350d8237fe 100644 --- a/source/nmbd/nmbd_processlogon.c +++ b/source/nmbd/nmbd_processlogon.c @@ -321,7 +321,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", char *q_orig = q; int str_offset; - get_mydomname(domain); + get_mydnsdomname(domain); get_myname(hostname); if (SVAL(uniuser, 0) == 0) { diff --git a/source/param/loadparm.c b/source/param/loadparm.c index f921206610a..344002e6535 100644 --- a/source/param/loadparm.c +++ b/source/param/loadparm.c @@ -553,7 +553,6 @@ static int default_server_announce; /* prototypes for the special type handlers */ static BOOL handle_include(const char *pszParmValue, char **ptr); static BOOL handle_copy(const char *pszParmValue, char **ptr); -static BOOL handle_source_env(const char *pszParmValue, char **ptr); static BOOL handle_netbios_name(const char *pszParmValue, char **ptr); static BOOL handle_idmap_uid(const char *pszParmValue, char **ptr); static BOOL handle_idmap_gid(const char *pszParmValue, char **ptr); @@ -2790,6 +2789,8 @@ static BOOL source_env(char **lines) return (True); } +#if 0 +/* Doesn't seem to be used anymore. JRA */ /*************************************************************************** Handle the source environment operation. ***************************************************************************/ @@ -2829,6 +2830,7 @@ static BOOL handle_source_env(const char *pszParmValue, char **ptr) return (result); } +#endif /*************************************************************************** Handle the include operation. diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index 266a2efe1b7..43f8205c591 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -2537,7 +2537,7 @@ static BOOL map_nt_printer_info2_to_dsspooler(NT_PRINTER_INFO_LEVEL_2 *info2) map_sz_into_ctr(ctr, SPOOL_REG_PRINTERNAME, info2->sharename); map_sz_into_ctr(ctr, SPOOL_REG_SHORTSERVERNAME, global_myname()); - get_myfullname(longname); + get_mydnsfullname(longname); map_sz_into_ctr(ctr, SPOOL_REG_SERVERNAME, longname); asprintf(&allocated_string, "\\\\%s\\%s", longname, info2->sharename); diff --git a/source/rpc_server/srv_lsa_ds_nt.c b/source/rpc_server/srv_lsa_ds_nt.c index 97e9dc361d9..f6e8eed9a97 100644 --- a/source/rpc_server/srv_lsa_ds_nt.c +++ b/source/rpc_server/srv_lsa_ds_nt.c @@ -58,7 +58,7 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; - get_mydomname(dnsdomain); + get_mydnsdomname(dnsdomain); strlower_m(dnsdomain); break; case ROLE_DOMAIN_PDC: @@ -66,7 +66,7 @@ static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE; if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) ) basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT; - get_mydomname(dnsdomain); + get_mydnsdomname(dnsdomain); strlower_m(dnsdomain); break; } diff --git a/source/rpc_server/srv_lsa_nt.c b/source/rpc_server/srv_lsa_nt.c index 2b2cb919245..3300c252548 100644 --- a/source/rpc_server/srv_lsa_nt.c +++ b/source/rpc_server/srv_lsa_nt.c @@ -1250,7 +1250,7 @@ NTSTATUS _lsa_query_info2(pipes_struct *p, LSA_Q_QUERY_INFO2 *q_u, LSA_R_QUERY_I /* This should be a 'netbios domain -> DNS domain' mapping */ dnsdomname[0] = '\0'; - get_mydomname(dnsdomname); + get_mydnsdomname(dnsdomname); strlower_m(dnsdomname); dns_name = dnsdomname; diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index 15578f61482..61c908e474b 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -2431,7 +2431,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint if (!StrCaseCmp(value, "DNSMachineName")) { pstring hostname; - if (!get_myfullname(hostname)) + if (!get_mydnsfullname(hostname)) return WERR_BADFILE; *type = 0x1; *needed = 2*(strlen(hostname)+1); |