From efa8da48ffc46e18ac231358c6a51362b6c401ba Mon Sep 17 00:00:00 2001
From: David Byers <byers@lysator.liu.se>
Date: Fri, 12 Apr 2002 10:36:01 +0000
Subject: [PATCH] Fixed bug 331: localhost or localhost.localdomain

---
 ChangeLog                             | 19 ++++++++++++++++
 src/server/testsuite/config/unix.exp  |  9 ++++++++
 src/server/testsuite/lyskomd.0/00.exp |  2 +-
 src/server/testsuite/lyskomd.0/01.exp |  2 +-
 src/server/testsuite/lyskomd.0/03.exp | 32 +++++++++++++--------------
 src/server/testsuite/lyskomd.0/16.exp | 12 +++++-----
 6 files changed, 52 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 23f833741..641ba3aa1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2002-04-12  David Byers  <david.byers@swipnet.se>
+
+	Fix bug 331:
+	* src/server/testsuite/lyskomd.0/03.exp: Use idholl and
+	lyskomd_host for hostname-dependend strings.
+
+	* src/server/testsuite/lyskomd.0/16.exp: Use idholl and
+	lyskomd_host for hostname-dependend strings.
+
+	* src/server/testsuite/lyskomd.0/01.exp: Use idholl and
+	lyskomd_host for hostname-dependend strings.
+
+	* src/server/testsuite/lyskomd.0/00.exp: Use idholl and
+	lyskomd_host for hostname-dependend strings.
+
+	* src/server/testsuite/config/unix.exp (idholl): New function to
+	create hollerith with at sign and name of localhost appended.
+	(lyskomd_server): New variable containing the name of this host.
+
 2002-04-11  David Byers  <david.byers@swipnet.se>
 
 	* configure.in: Added AC_PREREQ.
diff --git a/src/server/testsuite/config/unix.exp b/src/server/testsuite/config/unix.exp
index 1265468ce..889508b69 100644
--- a/src/server/testsuite/config/unix.exp
+++ b/src/server/testsuite/config/unix.exp
@@ -64,6 +64,10 @@ set stty_init "-echo -onlcr -istrip -isig erase '^-' kill '^-' werase '^-'"
 set line_leader ""
 set meta_line_leader ""
 
+# Values that show up in protocol messages
+set lyskomd_host [exec python -c "import socket\nprint socket.gethostbyaddr(\"127.0.0.1\")\[0\]"]
+
+
 proc efence_blurb {} {
     global efence
 
@@ -708,6 +712,11 @@ proc holl {str} {
     return "[string length $str]H$str"
 }
 
+proc idholl {str} {
+    global lyskomd_host;
+    return [holl "$str@$lyskomd_host"]
+}
+
 proc read_versions {} {
     # Read $top_srcdir/versions and store the versions in global variables.
     global top_srcdir
diff --git a/src/server/testsuite/lyskomd.0/00.exp b/src/server/testsuite/lyskomd.0/00.exp
index bb9b2721b..7c6b7951e 100644
--- a/src/server/testsuite/lyskomd.0/00.exp
+++ b/src/server/testsuite/lyskomd.0/00.exp
@@ -207,7 +207,7 @@ send "1040 100 1 6 100 0 00000000\n"
 simple_expect "=1040" "Eskil joins ok"
 
 send "1041 2 1\n"
-simple_expect ":5 6 6 1 2 [holl ""] [holl "bar@localhost"]" "Eskil changed conference"
+simple_expect ":5 6 6 1 2 [holl ""] [idholl "bar"]" "Eskil changed conference"
 simple_expect "=1041" "Eskil member; thus can change conference"
 
 send "1042 86 [holl "text0004"] 1 { 0 1 } 0 { }\n"
diff --git a/src/server/testsuite/lyskomd.0/01.exp b/src/server/testsuite/lyskomd.0/01.exp
index 6a977fd74..de73297b1 100644
--- a/src/server/testsuite/lyskomd.0/01.exp
+++ b/src/server/testsuite/lyskomd.0/01.exp
@@ -443,7 +443,7 @@ send "30004 9 5 5\n"
 simple_expect "=30004 $any_time 5 255 0 0 \\*"
 
 send "30005 6 6 1\n"
-simple_expect "=30005 [holl "DejaGnu test suite.unknown.@localhost"] 0000010000000000 00000000 $any_time 0 $any_num 1 0 0 0 0 0 0 1 0 0 1"
+simple_expect "=30005 [idholl "DejaGnu test suite.unknown."] 0000010000000000 00000000 $any_time 0 $any_num 1 0 0 0 0 0 0 1 0 0 1"
 send "30006 6 6 0\n"
 simple_expect "=30006 0H 0000010000000000 00000000 $any_time 0 $any_num 1 0 0 0 0 0 0 1 0 0 1"
 
diff --git a/src/server/testsuite/lyskomd.0/03.exp b/src/server/testsuite/lyskomd.0/03.exp
index 7892cae24..028b565bf 100644
--- a/src/server/testsuite/lyskomd.0/03.exp
+++ b/src/server/testsuite/lyskomd.0/03.exp
@@ -310,7 +310,7 @@ simple_expect "=1045 2 { 2 8 0 $any_num 01000000 0H 1 6 7 $any_num 00000000 0H }
 send "1046 2 0\n"
 simple_expect "=1046"
 talk_to client 1
-simple_expect ":5 6 6 0 1 [holl ""] [holl "ceder@gratia@localhost"]"
+simple_expect ":5 6 6 0 1 [holl ""] [idholl "ceder@gratia"]"
 talk_to client 0
 send "1047 83 1 0 0\n"
 simple_expect "=1047 2 { 2 8 0 $any_num 01000000 0H 1 6 0 $any_num 00000000 0H }"
@@ -318,7 +318,7 @@ simple_expect "=1047 2 { 2 8 0 $any_num 01000000 0H 1 6 0 $any_num 00000000 0H }
 send "1048 2 6\n"
 simple_expect "=1048"
 talk_to client 1
-simple_expect ":5 6 6 6 1 [holl ""] [holl "ceder@gratia@localhost"]"
+simple_expect ":5 6 6 6 1 [holl ""] [idholl "ceder@gratia"]"
 talk_to client 0
 send "1049 83 1 0 0\n"
 simple_expect "=1049 2 { 2 8 0 $any_num 01000000 0H 1 6 6 $any_num 00000000 0H }"
@@ -341,9 +341,9 @@ talk_to client 0
 send "1052 4 [holl "Running a test suite"]\n"
 simple_expect "=1052"
 talk_to client 1
-simple_expect ":5 6 6 6 1 [holl "Running a test suite"] [holl "ceder@gratia@localhost"]"
+simple_expect ":5 6 6 6 1 [holl "Running a test suite"] [idholl "ceder@gratia"]"
 send "1053 4 [holl "Accepting i-am-on"]\n"
-simple_expect ":5 6 8 0 2 [holl "Accepting i-am-on"] [holl "ic@gratia@localhost"]"
+simple_expect ":5 6 8 0 2 [holl "Accepting i-am-on"] [idholl "ic@gratia"]"
 simple_expect "=1053"
 
 # call 5 (create-person-old) is tested above.
@@ -357,15 +357,15 @@ simple_expect "%1056 10 10"
 send "1057 6 6 0\n"
 simple_expect "=1057 [holl ""] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
 send "1058 6 6 1\n"
-simple_expect "=1058 [holl "ceder@gratia.unknown.@localhost"] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
+simple_expect "=1058 [idholl "ceder@gratia.unknown."] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
 send "1059 6 6 2\n"
 simple_expect "=1059 [holl ""] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
 send "1060 6 6 3\n"
-simple_expect "=1060 [holl "ceder@gratia.unknown.@localhost"] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
+simple_expect "=1060 [idholl "ceder@gratia.unknown."] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
 send "1061 6 6 32770\n"
 simple_expect "=1061 [holl ""] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
 send "1062 6 6 32771\n"
-simple_expect "=1062 [holl "ceder@gratia.unknown.@localhost"] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
+simple_expect "=1062 [idholl "ceder@gratia.unknown."] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 1 1 3 0 2"
 
 # test call 7 (set-priv-bits)
 send "1063 7 8 0000000000000000\n"
@@ -829,14 +829,14 @@ simple_expect "=1211 2 { 6 8 }"
 
 # test call 49 (get-person-stat)
 send "1212 49 6\n"
-simple_expect "=1212 [holl "ceder@gratia.unknown.@localhost"] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 2 1 3 0 2"
+simple_expect "=1212 [idholl "ceder@gratia.unknown."] 0000010000000000 00000000 $any_time 0 0 1 0 48 0 0 0 2 1 3 0 2"
 
 # test call 50 (get-conf-stat-old)
 send "1213 50 7\n"
 simple_expect "=1213 [holl "PRIMa musik"] 0100 $any_time $any_time 6 3 7 8 4 2 144 2 1 6"
 # test call 51 (who-is-on)
 send "1214 51\n"
-simple_expect "=1214 2 { 8 0 2 [holl "Accepting i-am-on"] [holl "ic@gratia@localhost"] 6 6 1 [holl "Running a test suite"] [holl "ceder@gratia@localhost"] }"
+simple_expect "=1214 2 { 8 0 2 [holl "Accepting i-am-on"] [idholl "ic@gratia"] 6 6 1 [holl "Running a test suite"] [idholl "ceder@gratia"] }"
 
 # test call 52 (get-unread-confs)
 send "1215 52 6\n"
@@ -865,7 +865,7 @@ talk_to client 0
 
 # test call 54 (get-session-info)
 send "1219 54 2\n"
-simple_expect "=1219 8 0 2 [holl "Accepting i-am-on"] [holl "ic@gratia@localhost"] $any_num $any_time"
+simple_expect "=1219 8 0 2 [holl "Accepting i-am-on"] [idholl "ic@gratia"] $any_num $any_time"
 
 # test call 55 (disconnect)
 talk_to client 2
@@ -882,7 +882,7 @@ simple_expect "=1221 1"
 send "1222 57 6 3\n"
 simple_expect "=1222"
 send "1223 49 6\n"
-simple_expect "=1223 [holl "ceder@gratia.unknown.@localhost"] 0000010000000000 00000000 $any_time 3 0 1 0 48 0 0 0 2 1 3 0 2"
+simple_expect "=1223 [idholl "ceder@gratia.unknown."] 0000010000000000 00000000 $any_time 3 0 1 0 48 0 0 0 2 1 3 0 2"
 
 # test call 58 (get-last-text)
 send "1224 58 0 0 0 1 0 98 0 0 0\n"
@@ -910,7 +910,7 @@ send "1230 59 [holl "Anon text 8"] 1 { 0 2 }\n"
 simple_expect "=1230 8"
 # check that the number of created texts/bytes does not increase
 send "1231 49 6\n"
-simple_expect "=1231 [holl "ceder@gratia.unknown.@localhost"] 0000010000000000 00000000 $any_time 3 0 1 0 48 0 0 0 2 1 3 0 2"
+simple_expect "=1231 [idholl "ceder@gratia.unknown."] 0000010000000000 00000000 $any_time 3 0 1 0 48 0 0 0 2 1 3 0 2"
 
 # test call 60 (find-next-text-no)
 send "1232 60 0\n"
@@ -962,11 +962,11 @@ simple_expect "=1252 8"
 
 # test call 63 (who-is-on-ident)
 send "1253 63\n"
-simple_expect "=1253 2 { 8 0 2 [holl "Accepting i-am-on"] [holl "ic@gratia"] [holl "localhost"] [holl "unknown"] 6 6 1 [holl "Running a test suite"] [holl "ceder@gratia"] [holl "localhost"] [holl "unknown"] }"
+simple_expect "=1253 2 { 8 0 2 [holl "Accepting i-am-on"] [holl "ic@gratia"] [holl "$lyskomd_host"] [holl "unknown"] 6 6 1 [holl "Running a test suite"] [holl "ceder@gratia"] [holl "$lyskomd_host"] [holl "unknown"] }"
 
 # test call 64 (get-session-info-ident)
 send "1254 64 2\n"
-simple_expect "=1254 8 0 2 [holl "Accepting i-am-on"] [holl "ic@gratia"] [holl "localhost"] [holl "unknown"] $any_num $any_time"
+simple_expect "=1254 8 0 2 [holl "Accepting i-am-on"] [holl "ic@gratia"] [holl "$lyskomd_host"] [holl "unknown"] $any_num $any_time"
 
 # test call 65 (re-lookup-person)
 send "1255 65 [holl "nya"]\n"
@@ -1170,7 +1170,7 @@ simple_expect "=1322 2 { 2 8 0 $any_num 01000000 [holl "Accepting i-am-on"] 1 6
 
 # test call 84 (get-static-session-info)
 send "1323 84 2\n"
-simple_expect "=1323 [holl "ic@gratia"] [holl "localhost"] [holl "unknown"] $any_time"
+simple_expect "=1323 [holl "ic@gratia"] [holl "$lyskomd_host"] [holl "unknown"] $any_time"
 
 # test call 85 (get-collate-table)
 send "1324 85\n"
@@ -1380,7 +1380,7 @@ send "1370 106 8 01011010\n"
 simple_expect "=1370"
 
 send "1371 49 8\n"
-simple_expect "=1371 [holl "ic@gratia.unknown.@localhost"] 0000010000000000 01011010 $any_time 0 $any_num 3 0 80 0 0 1 2 1 5 0 2"
+simple_expect "=1371 [idholl "ic@gratia.unknown."] 0000010000000000 01011010 $any_time 0 $any_num 3 0 80 0 0 1 2 1 5 0 2"
 
 # There is no call 107--yet.
 send "1372 107\n"
diff --git a/src/server/testsuite/lyskomd.0/16.exp b/src/server/testsuite/lyskomd.0/16.exp
index 57c530dc6..e554cadc4 100644
--- a/src/server/testsuite/lyskomd.0/16.exp
+++ b/src/server/testsuite/lyskomd.0/16.exp
@@ -72,12 +72,12 @@ simple_expect "=1001"
 
 # Person 7 goes to the secret conference.
 send "1002 2 8\n"
-simple_expect ":5 6 7 8 2 0H [holl "foo@localhost"]"
+simple_expect ":5 6 7 8 2 0H [idholl "foo"]"
 simple_expect "=1002"
 talk_to client 0
 # Should this even be sent?  Seen from the view-point of person 6,
 # person 7 goes from conference 0 to conference 0.
-extracting_expect ":5 6 7 (\[08\]) 2 0H [holl "foo@localhost"]" conf 1
+extracting_expect ":5 6 7 (\[08\]) 2 0H [idholl "foo"]" conf 1
 assert_0 $conf "async-i-am-on leaks secret info"
 
 
@@ -92,19 +92,19 @@ extracting_expect "=1004 2 { 7 (\[08\]) 0H 6 0 0H }" conf 1
 assert_0 $conf "who-is-on-old leaks secret info"
 
 send "1005 51\n"
-extracting_expect "=1005 2 { 7 (\[08\]) 2 0H [holl "foo@localhost"] 6 0 1 0H [holl "foo@localhost"] }" conf 1
+extracting_expect "=1005 2 { 7 (\[08\]) 2 0H [idholl "foo"] 6 0 1 0H [idholl "foo"] }" conf 1
 assert_0 $conf "who-is-on leaks secret info"
 
 send "1007 54 2\n"
-extracting_expect "=1007 7 (\[08\]) 2 0H [holl "foo@localhost"] $any_num $any_time" conf 1
+extracting_expect "=1007 7 (\[08\]) 2 0H [idholl "foo"] $any_num $any_time" conf 1
 assert_0 $conf "get-session-info leaks secret info"
 
 send "1006 63\n"
-extracting_expect "=1006 2 { 7 (\[08\]) 2 0H 3Hfoo [holl "localhost"] [holl "unknown"] 6 0 1 0H 3Hfoo [holl "localhost"] [holl "unknown"] }" conf 1
+extracting_expect "=1006 2 { 7 (\[08\]) 2 0H 3Hfoo [holl "$lyskomd_host"] [holl "unknown"] 6 0 1 0H 3Hfoo [holl "$lyskomd_host"] [holl "unknown"] }" conf 1
 assert_0 $conf "who-is-on-ident leaks secret info"
 
 send "1007 64 2\n"
-extracting_expect "=1007 7 (\[08\]) 2 0H 3Hfoo [holl "localhost"] [holl "unknown"] $any_num $any_time" conf 1
+extracting_expect "=1007 7 (\[08\]) 2 0H 3Hfoo [holl "$lyskomd_host"] [holl "unknown"] $any_num $any_time" conf 1
 assert_0 $conf "get-session-info-ident leaks secret info"
 
 send "1 83 1 1 0\n"
-- 
GitLab