Skip to content

Commit edcb8e1

Browse files
committed
Restore cert-cache ownership to root after configure_tomcat
configure_tomcat transfers ownership of /var/vcap/data/uaa/ to vcap, which includes cert-cache and the Java truststore within it. Add resecure_cert_cache() to run after configure_tomcat and configure_spring_boot. It restores cert-cache to root:root with mode 0711 and all enclosed files to root:root 0644, so the vcap process retains read access to the truststore without write access.
1 parent fb3d29f commit edcb8e1

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

jobs/uaa/templates/bin/pre-start.erb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ function configure_tomcat {
176176
chown -R vcap:vcap /var/vcap/data/uaa/
177177
}
178178

179+
function resecure_cert_cache {
180+
# configure_tomcat hands all of /var/vcap/data/uaa/ to vcap via chown -R.
181+
# Re-secure cert-cache so that the vcap process cannot tamper with the
182+
# truststore between deploys. vcap retains read-only access via the
183+
# execute bit on the directory and world-readable mode on the files.
184+
chown root:root "${PERSISTENT_CERTS_DIR}"
185+
chmod 0711 "${PERSISTENT_CERTS_DIR}"
186+
find "${PERSISTENT_CERTS_DIR}" -maxdepth 1 -type f -exec chown root:root {} +
187+
find "${PERSISTENT_CERTS_DIR}" -maxdepth 1 -type f -exec chmod 0644 {} +
188+
}
189+
179190
function configure_spring_boot {
180191
# When run with bpm, the vcap user does not have permissions to read
181192
# files in the jobs and packages directories. Consequently, we move
@@ -213,6 +224,8 @@ configure_tomcat
213224

214225
configure_spring_boot
215226

227+
resecure_cert_cache
228+
216229
rm -rf $TMP_DIR
217230

218231
log "Completed"

0 commit comments

Comments
 (0)