Skip to content

Commit f0b80fd

Browse files
authored
[8.17] [Build] Update krb5kdc test fixture base image and krb5 library (elastic#119403) (elastic#119489)
* [Build] Update krb5kdc test fixture base image and krb5 library (elastic#119403) (cherry picked from commit 957064b) # Conflicts: # muted-tests.yml * Unmute KerberosAuthenticationIT
1 parent ed903cd commit f0b80fd

File tree

9 files changed

+28
-49
lines changed

9 files changed

+28
-49
lines changed

muted-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,6 @@ tests:
356356
- class: org.elasticsearch.xpack.esql.plugin.ClusterRequestTests
357357
method: testFallbackIndicesOptions
358358
issue: https://github.com/elastic/elasticsearch/issues/117937
359-
- class: org.elasticsearch.xpack.security.authc.kerberos.KerberosAuthenticationIT
360-
issue: https://github.com/elastic/elasticsearch/issues/118414
361359
- class: org.elasticsearch.gradle.internal.InternalDistributionBwcSetupPluginFuncTest
362360
method: "builds distribution from branches via archives extractedAssemble [bwcDistVersion: 8.1.3, bwcProject: bugfix2, expectedAssembleTaskName:
363361
extractedAssemble, #3]"
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
FROM ubuntu:14.04
2-
ADD . /fixture
1+
FROM alpine:3.21.0
2+
3+
ADD src/main/resources /fixture
4+
RUN apk update && apk add -y --no-cache python3 krb5 krb5-server
5+
36
RUN echo kerberos.build.elastic.co > /etc/hostname
4-
RUN bash /fixture/src/main/resources/provision/installkdc.sh
7+
RUN sh /fixture/provision/installkdc.sh
58

69
EXPOSE 88
710
EXPOSE 88/udp
811

9-
CMD sleep infinity
12+
CMD ["sleep", "infinity"]

test/fixtures/krb5kdc-fixture/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ apply plugin: 'elasticsearch.deploy-test-fixtures'
1616
dockerFixtures {
1717
krb5dc {
1818
dockerContext = projectDir
19-
version = "1.0"
20-
baseImages = ["ubuntu:14.04"]
19+
version = "1.1"
20+
baseImages = ["alpine:3.21.0"]
2121
}
2222
}
2323

test/fixtures/krb5kdc-fixture/src/main/java/org/elasticsearch/test/fixtures/krb5kdc/Krb5kDcContainer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.List;
3030

3131
public final class Krb5kDcContainer extends DockerEnvironmentAwareTestContainer {
32-
public static final String DOCKER_BASE_IMAGE = "docker.elastic.co/elasticsearch-dev/krb5dc-fixture:1.0";
32+
public static final String DOCKER_BASE_IMAGE = "docker.elastic.co/elasticsearch-dev/krb5dc-fixture:1.1";
3333
private final TemporaryFolder temporaryFolder = new TemporaryFolder();
3434
private final ProvisioningId provisioningId;
3535
private Path krb5ConfFile;
@@ -39,14 +39,14 @@ public final class Krb5kDcContainer extends DockerEnvironmentAwareTestContainer
3939
public enum ProvisioningId {
4040
HDFS(
4141
"hdfs",
42-
"/fixture/src/main/resources/provision/hdfs.sh",
42+
"/fixture/provision/hdfs.sh",
4343
"/fixture/build/keytabs/hdfs_hdfs.build.elastic.co.keytab",
4444
"/fixture/build/keytabs/elasticsearch.keytab",
4545
4646
),
4747
PEPPA(
4848
"peppa",
49-
"/fixture/src/main/resources/provision/peppa.sh",
49+
"/fixture/provision/peppa.sh",
5050
"/fixture/build/keytabs/peppa.keytab",
5151
"/fixture/build/keytabs/HTTP_localhost.keytab",
5252
@@ -94,7 +94,7 @@ public Krb5kDcContainer(ProvisioningId provisioningId) {
9494
withNetworkAliases("kerberos.build.elastic.co", "build.elastic.co");
9595
withCopyFileToContainer(MountableFile.forHostPath("/dev/urandom"), "/dev/random");
9696
withExtraHost("kerberos.build.elastic.co", "127.0.0.1");
97-
withCommand("bash", provisioningId.scriptPath);
97+
withCommand("sh", provisioningId.scriptPath);
9898
}
9999

100100
@Override
@@ -122,7 +122,7 @@ public String getConf() {
122122
.findFirst();
123123
String hostPortSpec = bindings.get().getHostPortSpec();
124124
String s = copyFileFromContainer("/fixture/build/krb5.conf.template", i -> IOUtils.toString(i, StandardCharsets.UTF_8));
125-
return s.replace("${MAPPED_PORT}", hostPortSpec);
125+
return s.replace("#KDC_DOCKER_HOST", "kdc = 127.0.0.1:" + hostPortSpec);
126126
}
127127

128128
public Path getKeytab() {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
44
# or more contributor license agreements. Licensed under the "Elastic License
@@ -24,7 +24,7 @@ PASSWD="$2"
2424
USER=$(echo $PRINC | tr "/" "_")
2525

2626
VDIR=/fixture
27-
RESOURCES=$VDIR/src/main/resources
27+
RESOURCES=$VDIR
2828
PROV_DIR=$RESOURCES/provision
2929
ENVPROP_FILE=$RESOURCES/env.properties
3030
BUILD_DIR=$VDIR/build
@@ -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/hdfs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
set -e
44

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

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
44
# or more contributor license agreements. Licensed under the "Elastic License
@@ -12,8 +12,7 @@ set -e
1212
# KDC installation steps and considerations based on https://web.mit.edu/kerberos/krb5-latest/doc/admin/install_kdc.html
1313
# and helpful input from https://help.ubuntu.com/community/Kerberos
1414

15-
VDIR=/fixture
16-
RESOURCES=$VDIR/src/main/resources
15+
RESOURCES=/fixture
1716
PROV_DIR=$RESOURCES/provision
1817
ENVPROP_FILE=$RESOURCES/env.properties
1918
LOCALSTATEDIR=/etc
@@ -49,33 +48,11 @@ touch $LOGDIR/kadmin.log
4948
touch $LOGDIR/krb5kdc.log
5049
touch $LOGDIR/krb5lib.log
5150

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-
7451
# Create kerberos database with stash file and garbage password
7552
kdb5_util create -s -r $REALM_NAME -P zyxwvutsrpqonmlk9876
7653

7754
# Set up admin acls
78-
cat << EOF > /etc/krb5kdc/kadm5.acl
55+
cat << EOF > /var/lib/krb5kdc/kadm5.acl
7956
*/admin@$REALM_NAME *
8057
*/*@$REALM_NAME i
8158
EOF

test/fixtures/krb5kdc-fixture/src/main/resources/provision/krb5.conf.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# License v3.0 only", or the "Server Side Public License, v 1".
77

88
[libdefaults]
9+
spake_preauth_groups = edwards25519
910
default_realm = ${REALM_NAME}
1011
dns_canonicalize_hostname = false
1112
dns_lookup_kdc = false
@@ -25,7 +26,7 @@
2526
[realms]
2627
${REALM_NAME} = {
2728
kdc = 127.0.0.1:88
28-
kdc = 127.0.0.1:${MAPPED_PORT}
29+
#KDC_DOCKER_HOST
2930
admin_server = ${KDC_NAME}:749
3031
default_domain = ${BUILD_ZONE}
3132
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
set -e
44

0 commit comments

Comments
 (0)