diff options
-rw-r--r-- | source3/lib/util.c | 74 | ||||
-rw-r--r-- | source3/libsmb/ntlmssp.c | 5 | ||||
-rw-r--r-- | source3/nmbd/nmbd_processlogon.c | 2 | ||||
-rw-r--r-- | source3/param/loadparm.c | 4 | ||||
-rw-r--r-- | source3/printing/nt_printing.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_lsa_ds_nt.c | 4 | ||||
-rw-r--r-- | source3/rpc_server/srv_lsa_nt.c | 2 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 2 |
8 files changed, 39 insertions, 56 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 4f4e0eb5d7..3da4e536e0 100644 --- a/source3/lib/util.c +++ b/source3/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/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index a80b4b66b0..60523ddf9d 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/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/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c index 6b806f2a05..13aefabd26 100644 --- a/source3/nmbd/nmbd_processlogon.c +++ b/source3/nmbd/nmbd_processlogon.c @@ -322,7 +322,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/source3/param/loadparm.c b/source3/param/loadparm.c index 4b6c51045e..1fa3efabf8 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -556,7 +556,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); @@ -2803,6 +2802,8 @@ static BOOL source_env(char **lines) return (True); } +#if 0 +/* Doesn't seem to be used anymore. JRA */ /*************************************************************************** Handle the source environment operation. ***************************************************************************/ @@ -2842,6 +2843,7 @@ static BOOL handle_source_env(const char *pszParmValue, char **ptr) return (result); } +#endif /*************************************************************************** Handle the include operation. diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 34274d1831..8aa02b57b6 100644 --- a/source3/printing/nt_printing.c +++ b/source3/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/source3/rpc_server/srv_lsa_ds_nt.c b/source3/rpc_server/srv_lsa_ds_nt.c index 97e9dc361d..f6e8eed9a9 100644 --- a/source3/rpc_server/srv_lsa_ds_nt.c +++ b/source3/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/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c index 01a31dcfe5..4a3f6ddbf1 100644 --- a/source3/rpc_server/srv_lsa_nt.c +++ b/source3/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/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index ad8f5af432..b5f5bffbb4 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/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); |