[FELIX-6855] FileInstall prevent duplicate *.cfg files in subdirectories from corrupting live OSGi configurations - #544
Open
Jefiya-MJ wants to merge 2 commits into
Open
Conversation
…does not match registered source
…OSGi configurations
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.
Problem
When
felix.fileinstall.subdir.mode = recurseis active, FileInstall scans all subdirectories under the watched root and registers every matching file as an OSGi Configuration object.Both
setConfig()anddeleteConfig()derive the ConfigurationAdmin PID from the filename alone viaparsePid(f.getName()), discarding the directory path entirely. This means any two files with the same name —regardless of where they sit in the directory tree — resolve to the same PID.
Consequences:
If a file with the same name as a live configuration is copied into a subdirectory,
setConfig()overwrites the live configuration'sfelix.fileinstall.filenameproperty with the duplicate file's URI, silently stealing ownership.When the duplicate file is later deleted,
deleteConfig()resolves the same PID and callsconfig.delete()on the live Configuration object — removing it from ConfigurationAdmin even though the original physical file was never touched. Dependent OSGi services stop immediately and cannot restart.Fix
Before acting on a resolved Configuration object, both
setConfig()anddeleteConfig()now compare the absolute URI of the file under operation against thefelix.fileinstall.filenameproperty already stored in that Configuration.Reproduction Scenario
felix.fileinstall.subdir.mode = recurse(default)./watched/etc/app.cfgas PIDapp./watched/etc/app.cfgto/watched/backup/etc/app.cfg./watched/backup/etc/app.cfg.deleteConfig()resolves PIDappand removes the live configuration from ConfigurationAdmin. The service stops.deleteConfig()detects the URI mismatch and returnsfalsewithout touching ConfigurationAdmin.