From f32486d2918ef3bcc45d09a980219393eae5201c Mon Sep 17 00:00:00 2001
From: Robert Ricci <ricci@cs.utah.edu>
Date: Tue, 6 Jan 2004 22:58:19 +0000
Subject: [PATCH] Make OURDOMAIN default to boss's domain name, so that we
 don't expose it to the user - it was a source of confusion.

---
 configure     | 11 ++++++++++-
 configure.in  | 11 +++++++++++
 defs-example  |  3 ---
 doc/setup.txt |  3 ++-
 4 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 03b3f204bd..c3651d28fc 100755
--- a/configure
+++ b/configure
@@ -1051,6 +1051,15 @@ else
     TBUSERSARCHIVE="$TBOPSEMAIL"
 fi
 
+# Default OURDOMAIN to the domain name of the boss node
+# This is gross beyond all description - autoconf changes m4's quote characters
+# to '[' and ']', which prevents them from working in the sed expression below.
+# So, we temporarily change them to something else then change them back.
+# Note: In newer versions of autoconf, this can be done with 'quadrigraphs'
+if test -z "$OURDOMAIN"; then
+    OURDOMAIN="`echo $BOSSNODE | sed -E -e 's/^[a-zA-Z0-9\-]+\.//'`"
+fi
+
 if test -z "$TBAUTHDOMAIN"; then
     TBAUTHDOMAIN=".$OURDOMAIN"
 fi
@@ -1298,7 +1307,7 @@ fi
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1302: checking for a BSD compatible install" >&5
+echo "configure:1311: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
diff --git a/configure.in b/configure.in
index d26d1e3a80..e28d77d7ec 100755
--- a/configure.in
+++ b/configure.in
@@ -196,6 +196,17 @@ else
     TBUSERSARCHIVE="$TBOPSEMAIL"
 fi
 
+# Default OURDOMAIN to the domain name of the boss node
+# This is gross beyond all description - autoconf changes m4's quote characters
+# to '[' and ']', which prevents them from working in the sed expression below.
+# So, we temporarily change them to something else then change them back.
+# Note: In newer versions of autoconf, this can be done with 'quadrigraphs'
+changequote(START, END)dnl
+if test -z "$OURDOMAIN"; then
+    OURDOMAIN="`echo $BOSSNODE | sed -E -e 's/^[a-zA-Z0-9\-]+\.//'`"
+fi
+changequote([, ])dnl
+
 if test -z "$TBAUTHDOMAIN"; then
     TBAUTHDOMAIN=".$OURDOMAIN"
 fi
diff --git a/defs-example b/defs-example
index d28bd9ba85..a0f1cec3c1 100644
--- a/defs-example
+++ b/defs-example
@@ -12,9 +12,6 @@ THISHOMEBASE=Example.Emulab.Net
 # Various domain and host names
 #
 
-# Domain this testbed resides in
-OURDOMAIN=example.emulab.net
-
 # Host name of our web server (or host:port)
 WWWHOST=www.example.emulab.net
 
diff --git a/doc/setup.txt b/doc/setup.txt
index 0fbec7fe22..f9e9a34420 100644
--- a/doc/setup.txt
+++ b/doc/setup.txt
@@ -119,7 +119,8 @@ and is generally helpful if things go wrong with the nameserver.
 SSL certificates - Our apache config file expects to find SSL certificates in:
 /usr/local/etc/apache/ssl.crt/www.<sitename>.crt and
 /usr/local/etc/apache/ssl.key/www.<sitename>.key
-(where <sitename> is OURDOMAIN from the configure defs file.) 
+(where <sitename> is OURDOMAIN from the configure defs file, which defaults to
+boss's domain name.) 
 Generate a passwordless certificate (up to you if you want to get a 'real' one
 from Verisign, etc., or sign your own), and place the files from it in the
 above locations.
-- 
GitLab