diff options
author | Jim McDonough <jmcd@samba.org> | 2002-12-03 19:35:46 +0000 |
---|---|---|
committer | Jim McDonough <jmcd@samba.org> | 2002-12-03 19:35:46 +0000 |
commit | ce397dbf04312d5f15e25da8e83e3ba1da273d45 (patch) | |
tree | 372f592dbacfa5e4d2473a0d5baaea41c220927f | |
parent | d9f51cd143d142bfa0f581f98cb1c2e889f3e8ef (diff) | |
download | samba-ce397dbf04312d5f15e25da8e83e3ba1da273d45.tar.gz samba-ce397dbf04312d5f15e25da8e83e3ba1da273d45.tar.bz2 samba-ce397dbf04312d5f15e25da8e83e3ba1da273d45.zip |
fns for retrieving dns host name and domain name (get rid of lp_realm hacks).
(This used to be commit 456813308d8542211183f9655b7fe598144f7bfc)
-rw-r--r-- | source3/lib/util.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 2dbd732cd8..2e43281a88 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -975,6 +975,62 @@ BOOL get_myname(char *my_name) } /**************************************************************************** + Get my own name, including domain. +****************************************************************************/ + +BOOL get_myfullname(char *my_name) +{ + pstring hostname; + + *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'; + + if (my_name) + fstrcpy(my_name, hostname); + return True; +} + +/**************************************************************************** + Get my own domain name. +****************************************************************************/ + +BOOL get_mydomname(char *my_domname) +{ + pstring hostname; + char *p; + + *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) + return False; + + p++; + + if (my_domname) + fstrcpy(my_domname, p); + + return True; +} + +/**************************************************************************** Interpret a protocol description string, with a default. ****************************************************************************/ |