| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Generate a krb5.conf file with an [appdefault] krb5-sync 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 <[email protected]> |
| 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 |
# Pull over all of the template file up to the krb5-sync settings. |
| 28 |
sed '/^ *krb5-sync *= */q' <"$source" >"$tmpdir"/krb5.conf |
| 29 |
|
| 30 |
# Add the key-value pairs. |
| 31 |
while [ -n "$1" ] ; do |
| 32 |
echo " $1 = $2" >>"$tmpdir"/krb5.conf |
| 33 |
shift |
| 34 |
shift |
| 35 |
done |
| 36 |
|
| 37 |
# Add the rest of the file. |
| 38 |
sed '0,/^ *krb5-sync *= */d' <"$source" >>"$tmpdir"/krb5.conf |
| 39 |
|
| 40 |
# Done. |
| 41 |
exit 0 |