Repository navigation
LINDAT/Fix dspace-customers 1083 finding 6: keep the backend application files owned by root - #1707
Open
milanmajchrak wants to merge 6 commits into
Open
milanmajchrak wants to merge 6 commits into
milanmajchrak wants to merge 6 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> (cherry picked from commit a20e448)
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> (cherry picked from commit a796f8c)
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 directory permissions cause stats-util -s and stats-util -b cleanup to fail when deleting /dspace/temp, including in documented cron usage, so both cleanup calls need to preserve the directory.
1 open issue
What changed in this PR
Backports the backend image hardening from #1706: DSpace and Tomcat application files remain root-owned while Tomcat runs as dspace.
Changes:
- Restricts writable paths to runtime data directories and selected configuration and deployment paths.
- Preserves script execution permissions and prepares required directories.
- Moves the debug flag to
/home/dspace, outside Tomcat’s protected installation.
| File | Description |
|---|---|
scripts/restart_debug/undebug.sh |
Removes the debug flag from its new location. |
scripts/restart_debug/redebug.sh |
Creates the debug flag in /home/dspace. |
scripts/restart_debug/custom_run.sh |
Reads the relocated flag when selecting debug mode. |
Dockerfile |
Keeps application files root-owned and grants targeted runtime write 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; \ |
stats-util -s and -b delete /dspace/temp when they finish, and solr-reindex-statistics creates and deletes /dspace/solr-export. Both need write access to /dspace. With the sticky bit dspace can add and remove its own entries there, but not the root-owned ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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. Same change as #1706 on dtq-dev.
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
The diff is the same as #1706 on dtq-dev and was tested there.
/dspaceand Tomcat stay root-owned;dspaceowns only the data folders,solr/search/conf, Tomcat'swebappsandconfig/item-submission.xml. Thedo_debug.txtflag of the debug scripts moves 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.Codex review (gpt-6.2-sol, high): it flagged only the changes listed above. The 2 findings fixed on dtq-dev are in this PR too.
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