]> eyrie.org Git - kerberos/krb5-strength.git/blob - tests/data/make-krb5-conf
Declare fast forward from 3.1-2
[kerberos/krb5-strength.git] / tests / data / make-krb5-conf
1 #!/bin/sh
2 #
3 # Generate a krb5.conf file with an [appdefault] krb5-strength section that
4 # contains all the key/value pairs given on the command line.  This script is
5 # used by C tests to set up the environment.
6 #
7 # Written by Russ Allbery <eagle@eyrie.org>
8 # Copyright 2009, 2013
9 #     The Board of Trustees of the Leland Stanford Junior University
10 #
11 # SPDX-License-Identifier: MIT
12
13 set -e
14
15 # Command-line arguments are the source krb5.conf template, the directory into
16 # which to write the resulting krb5.conf file, and then any number of key and
17 # value pairs to put into krb5.conf.
18 source="$1"
19 tmpdir="$2"
20 if [ -z "$tmpdir" ] ; then
21     echo 'Syntax: make-krb5-conf <source> <tmpdir> <key> <value> ...' >&2
22     exit 1
23 fi
24 shift
25 shift
26
27 # Copy over the template and ensure it's writable.
28 cp "$source" "$tmpdir"/krb5.conf
29 chmod 644 "$tmpdir"/krb5.conf
30
31 # Add the appdefaults section.
32 cat <<EOF >>"$tmpdir"/krb5.conf
33
34 [appdefaults]
35     krb5-strength = {
36 EOF
37
38 # Add the key-value pairs.
39 while [ -n "$1" ] ; do
40     echo "        $1 = $2" >>"$tmpdir"/krb5.conf
41     shift
42     shift
43 done
44
45 # End the appdefaults section.
46 echo '    }' >>"$tmpdir"/krb5.conf
47
48 # Done.
49 exit 0