Skip to content

Commit b0e2bb6

Browse files
committed
Run keystone services using keystone user
This patch represents an improvment of the existing code to make sure we run keystone services using the keystone user instead of root. Jira: https://issues.redhat.com/browse/OSPRH-15198 Signed-off-by: Francesco Pantano <[email protected]>
1 parent dbb5120 commit b0e2bb6

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

pkg/keystone/const.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const (
2828
KeystonePublicPort int32 = 5000
2929
// KeystoneInternalPort -
3030
KeystoneInternalPort int32 = 5000
31-
31+
// Keystone UID based on kolla
32+
// https://github.com/openstack/kolla/blob/master/kolla/common/users.py
33+
KeystoneUID = 42425
3234
// DefaultFernetMaxActiveKeys -
3335
DefaultFernetMaxActiveKeys = 5
3436
// DefaultFernetRotationDays -

pkg/keystone/deployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232

3333
const (
3434
// ServiceCommand -
35-
ServiceCommand = "/usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start"
35+
ServiceCommand = "/usr/local/bin/kolla_start"
3636
)
3737

3838
// Deployment func
@@ -43,7 +43,7 @@ func Deployment(
4343
annotations map[string]string,
4444
topology *topologyv1.Topology,
4545
) (*appsv1.Deployment, error) {
46-
runAsUser := int64(0)
46+
runAsUser := int64(KeystoneUID)
4747

4848
livenessProbe := &corev1.Probe{
4949
// TODO might need tuning

templates/keystoneapi/config/keystone-api-config.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@
1616
{
1717
"source": "/var/lib/config-data/default/httpd.conf",
1818
"dest": "/etc/httpd/conf/httpd.conf",
19-
"owner": "apache",
19+
"owner": "keystone:apache",
2020
"perm": "0644"
2121
},
2222
{
2323
"source": "/var/lib/config-data/default/ssl.conf",
2424
"dest": "/etc/httpd/conf.d/ssl.conf",
25-
"owner": "apache",
25+
"owner": "keystone:apache",
2626
"perm": "0644"
2727
},
2828
{
2929
"source": "/var/lib/config-data/tls/certs/*",
3030
"dest": "/etc/pki/tls/certs/",
31-
"owner": "root",
31+
"owner": "keystone:apache",
3232
"perm": "0640",
3333
"optional": true,
3434
"merge": true
3535
},
3636
{
3737
"source": "/var/lib/config-data/tls/private/*",
3838
"dest": "/etc/pki/tls/private/",
39-
"owner": "root",
39+
"owner": "keystone:apache",
4040
"perm": "0600",
4141
"optional": true,
4242
"merge": true
@@ -62,9 +62,21 @@
6262
{
6363
"source": "/var/lib/config-data/default/httpd_custom_*",
6464
"dest": "/etc/httpd/conf/",
65-
"owner": "apache",
65+
"owner": "keystone:apache",
6666
"perm": "0444",
6767
"optional": true
6868
}
69+
],
70+
"permissions": [
71+
{
72+
"path": "/etc/httpd",
73+
"owner": "keystone:apache",
74+
"recurse": true
75+
},
76+
{
77+
"path": "/var/log/keystone",
78+
"owner": "keystone:apache",
79+
"recurse": true
80+
}
6981
]
7082
}

tests/kuttl/common/assert_sample_deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spec:
6161
containers:
6262
- args:
6363
- -c
64-
- /usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start
64+
- /usr/local/bin/kolla_start
6565
command:
6666
- /bin/bash
6767
imagePullPolicy: IfNotPresent

tests/kuttl/tests/keystone_tls/01-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ spec:
3434
containers:
3535
- args:
3636
- -c
37-
- /usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start
37+
- /usr/local/bin/kolla_start
3838
volumeMounts:
3939
- mountPath: /usr/local/bin/container-scripts
4040
name: scripts

0 commit comments

Comments
 (0)