Skip to content

Commit 543e079

Browse files
committed
More cleanup on fixture image
- do not use sudo - keep docker image small - simplify installkdc.sh script
1 parent 32360d8 commit 543e079

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

test/fixtures/krb5kdc-fixture/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
FROM ubuntu:24.04
22

33
ADD . /fixture
4-
# Update the package listing
5-
RUN apt-get update
4+
RUN apt-get update && apt-get install -y --no-install-recommends python3 krb5-kdc krb5-admin-server && apt-get clean && rm -rf /var/lib/apt/lists/*
65

7-
# Install sudo
8-
RUN apt-get install -y sudo python3
96
RUN echo kerberos.build.elastic.co > /etc/hostname
107
RUN bash /fixture/src/main/resources/provision/installkdc.sh
118

test/fixtures/krb5kdc-fixture/src/main/resources/provision/addprinc.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ USER_KTAB=$LOCALSTATEDIR/$USER.keytab
4545

4646
if [ -f $USER_KTAB ] && [ -z "$PASSWD" ]; then
4747
echo "Principal '${PRINC}@${REALM}' already exists. Re-copying keytab..."
48-
sudo cp $USER_KTAB $KEYTAB_DIR/$USER.keytab
48+
cp $USER_KTAB $KEYTAB_DIR/$USER.keytab
4949
else
5050
if [ -z "$PASSWD" ]; then
5151
echo "Provisioning '${PRINC}@${REALM}' principal and keytab..."
52-
sudo kadmin -p $ADMIN_PRIN -kt $ADMIN_KTAB -q "addprinc -randkey $USER_PRIN"
53-
sudo kadmin -p $ADMIN_PRIN -kt $ADMIN_KTAB -q "ktadd -k $USER_KTAB $USER_PRIN"
54-
sudo cp $USER_KTAB $KEYTAB_DIR/$USER.keytab
52+
kadmin -p $ADMIN_PRIN -kt $ADMIN_KTAB -q "addprinc -randkey $USER_PRIN"
53+
kadmin -p $ADMIN_PRIN -kt $ADMIN_KTAB -q "ktadd -k $USER_KTAB $USER_PRIN"
54+
cp $USER_KTAB $KEYTAB_DIR/$USER.keytab
5555
else
5656
echo "Provisioning '${PRINC}@${REALM}' principal with password..."
57-
sudo kadmin -p $ADMIN_PRIN -kt $ADMIN_KTAB -q "addprinc -pw $PASSWD $PRINC"
57+
kadmin -p $ADMIN_PRIN -kt $ADMIN_KTAB -q "addprinc -pw $PASSWD $PRINC"
5858
fi
5959
fi
6060

test/fixtures/krb5kdc-fixture/src/main/resources/provision/installkdc.sh

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,6 @@ touch $LOGDIR/kadmin.log
4949
touch $LOGDIR/krb5kdc.log
5050
touch $LOGDIR/krb5lib.log
5151

52-
# Update package manager
53-
apt-get update -qqy
54-
55-
# Installation asks a bunch of questions via debconf. Set the answers ahead of time
56-
debconf-set-selections <<< "krb5-config krb5-config/read_conf boolean true"
57-
debconf-set-selections <<< "krb5-config krb5-config/kerberos_servers string $KDC_NAME"
58-
debconf-set-selections <<< "krb5-config krb5-config/add_servers boolean true"
59-
debconf-set-selections <<< "krb5-config krb5-config/admin_server string $KDC_NAME"
60-
debconf-set-selections <<< "krb5-config krb5-config/add_servers_realm string $REALM_NAME"
61-
debconf-set-selections <<< "krb5-config krb5-config/default_realm string $REALM_NAME"
62-
debconf-set-selections <<< "krb5-admin-server krb5-admin-server/kadmind boolean true"
63-
debconf-set-selections <<< "krb5-admin-server krb5-admin-server/newrealm note"
64-
debconf-set-selections <<< "krb5-kdc krb5-kdc/debconf boolean true"
65-
debconf-set-selections <<< "krb5-kdc krb5-kdc/purge_data_too boolean false"
66-
67-
# Install krb5 packages
68-
apt-get install -qqy krb5-{admin-server,kdc}
69-
70-
# /dev/random produces output very slowly on Ubuntu VM's. Install haveged to increase entropy.
71-
apt-get install -qqy haveged
72-
haveged
73-
7452
# Create kerberos database with stash file and garbage password
7553
kdb5_util create -s -r $REALM_NAME -P zyxwvutsrpqonmlk9876
7654

0 commit comments

Comments
 (0)