Repository navigation
Fix dspace-customers 1083 finding 6: keep the backend application files owned by root - #1706
Open
milanmajchrak wants to merge 5 commits into
Open
milanmajchrak wants to merge 5 commits into
milanmajchrak wants to merge 5 commits into
Conversation
Tomcat still runs as the dspace user. The user can write only to the data folders DSpace uses at runtime, Tomcat's webapps folder and item-submission.xml. The do_debug.txt flag of redebug.sh moves to Tomcat's temp folder, because the bin folder is no longer writable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Branches whose installation lacks one of the folders would otherwise fail at chown. Tomcat's conf/Catalina/localhost is created root-owned, so Tomcat does not log an error at start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The database migration writes solr/search/conf/reindex.flag as dspace, and solr-export-statistics defaults to /dspace/solr-export. The image also ships an empty root-owned local.cfg, and the debug scripts get read rights for all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tomcat's temp folder is writable by every user, so the flag now lives in /home/dspace. solr-reindex-statistics removes its export folder only when it created it, so the image no longer creates /dspace/solr-export. The solr-*-statistics commands take -d instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new permissions prevent stats-util -s and -b from deleting /dspace/temp, causing cleanup IOExceptions after Solr updates and affecting documented cron usage.
1 open issue
What changed in this PR
Hardens the backend image by keeping DSpace and Tomcat application files root-owned while retaining targeted write access for the dspace runtime user.
Changes:
- Restricts runtime ownership to data directories and specific writable paths, including the newly created
/dspace/sitemaps. - Preserves configuration backups, administrative submission-file edits, and script execution under the tighter permissions.
- Moves the debug flag from Tomcat’s
bindirectory to/home/dspace.
| File | Description |
|---|---|
scripts/restart_debug/undebug.sh |
Removes the debug flag from its new home-directory location. |
scripts/restart_debug/redebug.sh |
Creates the debug flag in the writable home directory. |
scripts/restart_debug/custom_run.sh |
Reads the relocated flag when selecting debug startup. |
Dockerfile |
Keeps application files root-owned and grants targeted runtime access. |
Review effort: Balanced
Comment on lines
+91
to
+92
| temp triplestore upload var; do \ | ||
| mkdir -p /dspace/$dir && chown -R dspace:dspace /dspace/$dir; \ |
This was referenced Nov 18, 2026
Open
Open
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

References
dspace-customers issue 1083, finding 6. This PR also creates
/dspace/sitemaps, which is all that the open PR 1496 does.Description
The backend image now keeps the DSpace and Tomcat files owned by root. Tomcat still runs as
dspace, which owns only the data folders and the few paths listed below.Instructions for Reviewers
List of changes in this PR:
Dockerfile:/dspaceand/usr/local/tomcatare no longer owned bydspace. It owns only these:assetstore,ctqueues,exports,handle-server,imports,log,matomo_reports,reports,sitemaps,temp,triplestore,uploadandvar(missing ones are created);solr/search/conf, wheredatabase migratewritesreindex.flagso the webapp reindexes Discovery;webappsfolder. The compose entrypoint relinks the namespace there at every start, so it stays writable;config/item-submission.xml, which admins can edit through/api/admin/configfiles(config.admin.updateable.files)./dspace/configisroot:dspacewith the sticky bit. DSpace can write its backup files there, but it cannot replace other files. The image ships an empty root-ownedlocal.cfg; a mountedlocal.cfgreplaces it./dspace/bingetsa+rX, sodspacecan still run the installed scripts (the installer makes them744).conf/Catalina/localhostis created up front, because Tomcat logs an error when it cannot create it.redebug.sh,undebug.sh,custom_run.sh: thedo_debug.txtflag moves from Tomcat'sbinfolder to/home/dspace.Named volumes that already exist keep their owner, so deployments need no migration. Three things change:
item-submission.xmlinconfig.admin.updateable.files, the API can no longer save those files unless they are mounted writable.dspace metadata-export -f out.csv) now fails, because the working folder is root-owned. So do thesolr-*-statisticscommands without-d(the export one only prints an error and exits with 0), because they cannot create/dspace/solr-export. Give them a path in a writable folder such as/dspace/exports.dspace stats-util -ucan no longer download spider lists intoconfig/spiders. Our cron jobs use only-f,-iand-s.How to test:
All three
touchcommands fail withPermission denied.Also tested with a full build on a stack set up like our deployments, once with the current dtq-dev image and once with this one. Both pass the same checks (start, reindex after the first migration, login, config API save, upload, sitemaps, OAI import, index-discovery, debug restart). Only this one refuses writes to
config/dspace.cfg,lib,WEB-INF/lib,binand Tomcat'sbin,confandlib. The last commit (debug flag,solr-export) was tested on that build with the changed files swapped in.Codex review (gpt-6.2-sol, high): 2 findings fixed, 1 noted in the list of changes above. The last round flagged only the
solr-*-statisticsandstats-util -uchanges.AI Disclosure (REQUIRED)
Were AI tools used in the creation of this PR?
Claude Code wrote the change and tested it in Docker as described above.
Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.🤖 Generated with Claude Code