summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-01-30 18:38:48 +0000
committerJeremy Allison <jra@samba.org>2004-01-30 18:38:48 +0000
commit2f2e5b01919fe4daf60f97430959ebc98e31ce92 (patch)
tree4d1ed0030a4bbfb6fdc84c764841ce74c683986f /source3/lib
parentbff6c1384950e97d723828cb0de579226abc7807 (diff)
downloadsamba-2f2e5b01919fe4daf60f97430959ebc98e31ce92.tar.gz
samba-2f2e5b01919fe4daf60f97430959ebc98e31ce92.tar.bz2
samba-2f2e5b01919fe4daf60f97430959ebc98e31ce92.zip
Fix up name canonicalization (needed for krb5 keytab support later).
Remove source_env handler (no longer used in any codepath). Jeremy. (This used to be commit 3a3e33603084048e647af86a9badaaf49433c789)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c74
1 files changed, 28 insertions, 46 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;