summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim McDonough <jmcd@samba.org>2002-12-03 19:36:53 +0000
committerJim McDonough <jmcd@samba.org>2002-12-03 19:36:53 +0000
commit4225a857c9f2470c056a2ceee6d873f589b5f117 (patch)
tree9a66335024e12ef9ab8cd113f1895ea50a5fc8d3
parentb95056499bbb4adfc587ca1a33ef9cb6e5cf656f (diff)
downloadsamba-4225a857c9f2470c056a2ceee6d873f589b5f117.tar.gz
samba-4225a857c9f2470c056a2ceee6d873f589b5f117.tar.bz2
samba-4225a857c9f2470c056a2ceee6d873f589b5f117.zip
fns for retrieving dns host name and domain name (get rid of lp_realm hacks).
(This used to be commit eda83b6d13f5f73136363d165e9396725b923873)
-rw-r--r--source3/lib/util.c56
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.
****************************************************************************/