Jefiya-MJ opened a new pull request, #544:
URL: https://github.com/apache/felix-dev/pull/544
### Problem
When `felix.fileinstall.subdir.mode = recurse` is active, FileInstall scans
all subdirectories under the watched root and registers every matching file as
an OSGi Configuration object.
Both `setConfig()` and `deleteConfig()` derive the ConfigurationAdmin PID
from the filename alone via `parsePid(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's
`felix.fileinstall.filename` property with the duplicate file's URI, silently
stealing ownership.
- When the duplicate file is later deleted, `deleteConfig()` resolves the
same PID and calls `config.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()`and
`deleteConfig()` now compare the absolute URI of the file under operation
against the `felix.fileinstall.filename` property already stored in that
Configuration.
```java
String registeredFileName = (String) props.get(DirectoryWatcher.FILENAME);
if (registeredFileName != null &&
!registeredFileName.equals(toConfigKey(f))) {
return false;
}
## Reproduction Scenario
1. Configure `felix.fileinstall.subdir.mode = recurse` (default).
2. Let FileInstall register `/watched/etc/app.cfg` as PID `app`.
3. Copy `/watched/etc/app.cfg` to `/watched/backup/etc/app.cfg`.
4. Delete `/watched/backup/etc/app.cfg`.
5. **Before this patch:** `deleteConfig()` resolves PID `app` and removes
the live configuration from ConfigurationAdmin. The service stops.
6. **After this patch:** `deleteConfig()` detects the URI mismatch and
returns `false` without touching ConfigurationAdmin.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]