]> eyrie.org Git - kerberos/krb5-strength.git/blob - tests/data/make-krb5-conf
Add support for enforcing a minimum password length
[kerberos/krb5-strength.git] / tests / data / make-krb5-conf
1 #!/bin/sh
2 #
3 # Generate a krb5.conf file with an [appdefault] password_dictionary setting
4 # pointing to the password dictionary we generated for the build.  This script
5 # is used by C tests to set up the environment.
6 #
7 # Written by Russ Allbery <rra@stanford.edu>
8 # Copyright 2009, 2013
9 #     The Board of Trustees of the Leland Stanford Junior University
10 #
11 # See LICENSE for licensing terms.
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.
28 cp "$source" "$tmpdir"/krb5.conf
29
30 # Add the appdefaults section.
31 cat <<EOF >>"$tmpdir"/krb5.conf
32
33 [appdefaults]
34     krb5-strength = {
35 EOF
36
37 # Add the key-value pairs.
38 while [ -n "$1" ] ; do
39     echo "        $1 = $2" >>"$tmpdir"/krb5.conf
40     shift
41     shift
42 done
43
44 # End the appdefaults section.
45 echo '    }' >>"$tmpdir"/krb5.conf
46
47 # Done.
48 exit 0