Windows: Use 32-bit time_t on 32-bit builds
[heimdal.git] / tests / db / loaddump-db.in
blob03520207912a76c309ebfea55c395fee82f1b056
1 #!/bin/sh
3 # Copyright (c) 2005 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden).
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # 3. Neither the name of the Institute nor the names of its contributors
19 # may be used to endorse or promote products derived from this software
20 # without specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 # SUCH DAMAGE.
34 # $Id$
37 srcdir="@srcdir@"
38 objdir="@objdir@"
40 # If there is no useful db support compile in, disable test
41 ./have-db || exit 77
43 R=EXAMPLE.ORG
45 kadmin="../../kadmin/kadmin -l -r $R"
46 kstash="../../kdc/kstash"
47 hprop="../../kdc/hprop"
48 hpropd="../../kdc/hpropd"
50 type="${1}"
51 typesep="${type:+:}"
52 typeconf="${type:+-}"
55 propdb="${hprop} --database=${type}${typesep}./current-db -n"
56 propddb="${hpropd} --database=${type}${typesep}./current-db -n"
58 KRB5_CONFIG="${objdir}/krb5.conf${typeconf}${type}"
59 export KRB5_CONFIG
61 rm -f current-db*
62 rm -f out-*
63 rm -f mkey.file*
65 ${kadmin} \
66 init \
67 --realm-max-ticket-life=1day \
68 --realm-max-renewable-life=1month \
69 EXAMPLE.ORG || exit 1
71 # check that we can dump and load ourself
72 ${kadmin} dump out-current-db || exit 1
73 sort out-current-db > out-current-db-sort
74 ${kadmin} load out-current-db || exit 1
75 ${kadmin} dump out-current-db2 || exit 1
76 sort out-current-db2 > out-current-db2-sort
77 cmp out-current-db-sort out-current-db2-sort || exit 1
79 rm -f current-db*
81 # check with no extentions
82 ${kadmin} load ${srcdir}/text-dump-0.7 || exit 1
83 ${propdb} > db-dump.tmp|| exit 1
84 rm -f current-db*
85 ${propddb} < db-dump.tmp || exit 1
86 ${kadmin} dump | sort | sed 's/[0-9]* -$//' > out-text-dump-0.7 || exit 1
87 sort < ${srcdir}/text-dump-0.7 | \
88 sed 's/[0-9]*$//' > out-text-dump-0.7-orig || exit 1
89 cmp out-text-dump-0.7-orig out-text-dump-0.7 || exit 1
91 # check with no extentions
92 ${kadmin} load ${srcdir}/text-dump-no-ext || exit 1
93 ${propdb} > db-dump.tmp || exit 1
94 ${propddb} < db-dump.tmp || exit 1
95 ${kadmin} dump | sort | \
96 awk '{$11=""; print;}' > out-text-dump-no-ext || exit 1
97 sort < ${srcdir}/text-dump-no-ext | \
98 awk '{$11=""; print;}' > out-text-dump-no-ext-orig || exit 1
99 cmp out-text-dump-no-ext-orig out-text-dump-no-ext || exit 1
101 # check with known extentions
102 ${kadmin} load ${srcdir}/text-dump-known-ext || exit 1
103 ${propdb} > db-dump.tmp || exit 1
104 ${propddb} < db-dump.tmp || exit 1
105 ${kadmin} dump | sort | \
106 awk '{$11=""; print;}' > out-text-dump-known-ext || exit 1
107 sort < ${srcdir}/text-dump-known-ext | \
108 awk '{$11=""; print;}' > out-text-dump-known-ext-orig || exit 1
109 cmp out-text-dump-known-ext-orig out-text-dump-known-ext || exit 1
111 # check with unknown extentions
112 ${kadmin} load ${srcdir}/text-dump-unknown-ext || exit 1
113 ${propdb} > db-dump.tmp || exit 1
114 ${propddb} < db-dump.tmp || exit 1
115 ${kadmin} dump | sort | \
116 awk '{$11=""; print;}' > out-text-dump-unknown-ext || exit 1
117 sort < ${srcdir}/text-dump-unknown-ext | \
118 awk '{$11=""; print;}' > out-text-dump-unknown-ext-orig || exit 1
119 cmp out-text-dump-unknown-ext-orig out-text-dump-unknown-ext || exit 1
121 ${kstash} -e aes256-cts-hmac-sha1-96 --random-key -k ./mkey.file >/dev/null 2>/dev/null || exit 1
123 # remove masterkey
124 ${kadmin} load ${srcdir}/text-dump-0.7 || exit 1
125 ${propdb} > db-dump.tmp|| exit 1
126 ${propddb} < db-dump.tmp || exit 1
127 ${propdb} -m mkey.file -D > db-dump.tmp || exit 1
128 mv mkey.file mkey.file.no || exit 1
129 ${propddb} < db-dump.tmp || exit 1
130 ${kadmin} dump | sort | \
131 awk '{$11=""; print;}' > out-text-dump-0.7 || exit 1
132 sort < ${srcdir}/text-dump-unknown-ext | \
133 awk '{$11=""; print;}' > out-text-dump-0.7-orig || exit 1
134 cmp out-text-dump-0.7 out-text-dump-0.7-orig || exit 1
136 exit 0