aboutsummaryrefslogtreecommitdiffstats
path: root/testing/pam-krb5/fix-tests_basic-t.patch
blob: d4b84769efb18ce3b5295e4427f1dbef59179841 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Fix pulled from upstream - https://github.com/rra/pam-krb5/commit/265870985e578a78a4112bd3f6c23c171b1097b8

--- a/tests/data/generate-krb5-conf
+++ b/tests/data/generate-krb5-conf
@@ -67,8 +67,17 @@
     { if (skip == 0) print }
 ' "$p" > tmp/krb5.conf.tmp
 if [ -n "$realm" ] ; then
-    sed -e "s/\\(default_realm.*=\\) .*/\\1 $realm/" \
-        tmp/krb5.conf.tmp > tmp/krb5.conf
+    pattern='^[ 	]*default_realm.*='
+    if grep "$pattern" tmp/krb5.conf.tmp >/dev/null 2>/dev/null; then
+        sed -e "s/\\(default_realm.*=\\) .*/\\1 $realm/" \
+            tmp/krb5.conf.tmp >tmp/krb5.conf
+    else
+        (
+            cat tmp/krb5.conf.tmp
+            echo "[libdefaults]"
+            echo "    default_realm = $realm"
+        ) >tmp/krb5.conf
+    fi
     rm tmp/krb5.conf.tmp
 else
     mv tmp/krb5.conf.tmp tmp/krb5.conf
--- a/tests/module/basic-t.c
+++ b/tests/module/basic-t.c
@@ -16,7 +16,7 @@
 
 #include <tests/fakepam/script.h>
 #include <tests/tap/basic.h>
-
+#include <tests/tap/kerberos.h>
 
 int
 main(void)
@@ -25,6 +25,12 @@
 
     plan_lazy();
 
+    /*
+     * Generate a testing krb5.conf file with a nonexistent default realm so
+     * that this test will run on any system.
+     */
+    kerberos_generate_conf("bogus.example.com");
+
     /* Attempt login as the root user to test ignore_root. */
     memset(&config, 0, sizeof(config));
     config.user = "root";