arturobernalg commented on PR #667:
URL: https://github.com/apache/jspwiki/pull/667#issuecomment-7270607433

   Reviewed the diff. The diagnosis looks right (user.home resolving to 
something like /nonexistent for locked-down service accounts), and getting the 
wiki to boot at all in that case is a legitimate goal. Found a few things worth 
looking at before merging, the first one more than a nit:
   
   1. The fallback can override an explicitly-configured pageDir, turning a 
loud failure into silent data loss. TextUtil.getCanonicalFilePathProperty 
returns the already-configured value (property/system property/env var) 
whenever one is set, ignoring the default argument. So if 
jspwiki.fileSystemProvider.pageDir is explicitly set to a path that can't be 
created (wrong permissions, a typo, a volume not yet mounted), the first two 
retry blocks just re-resolve to that same failing path -- they're no-ops, with 
a misleading "retrying using java.io.tmpdir" log -- and the Linux branch then 
assigns /tmp/jspwiki-files directly, bypassing the configured property 
entirely. Today that misconfiguration fails fast with a clear IOException; with 
this change it would silently boot empty out of /tmp instead, and whoever edits 
pages there loses them later. I'd scope the fallback so it only kicks in when 
the property was never set in the first place.
   2. System.getenv("TMPDIR") (and System.getenv("TEMP") in the Windows branch) 
can be null -- TMPDIR isn't reliably set on Linux, unlike the java.io.tmpdir 
system property. When it's null, the concatenation becomes the literal string 
"null/jspwiki-files", so if the working directory happens to be writable this 
silently creates a directory called null instead of falling back anywhere 
sensible.
   3. /tmp isn't a safe place to land persistent wiki content at all, not just 
"wiped on reboot": on several distros it's tmpfs, systemd-tmpfiles ages out 
files individually after some days regardless of reboot, and PrivateTmp=yes 
(set on some hardened Tomcat units) wipes the service's private /tmp on every 
restart, not just reboot. There's also a predictable-path concern in a 
world-writable directory.
   4. I'd drop using the ServletContext tempdir as an alternative (the 
mechanism PropertyReader.setWorkDir() already uses for jspwiki.workDir) -- it's 
the right call there since workDir is meant to be rebuildable, but Tomcat and 
Jetty both clear it on undeploy/redeploy, so it would trade one ephemeral 
location for another for something that's supposed to be durable.
   5. BasicAttachmentProvider has the same user.home-based default and isn't 
touched by this fix, so a wiki using it would still fail (or end up with pages 
fixed but attachments broken) in the same scenario.
   Given all that, maybe the cleanest fix is: keep the clear failure (with a 
better message naming the property, the resolved path, and user.home) when 
pageDir isn't configured and can't be created, and set a sane default at the 
packaging/deployment layer instead -- this is exactly what the JSPWIKI-1397 
installer work sets up, pointing at /var/lib/jspwiki. If a boot-anyway fallback 
is still wanted for the "get it running so Install.jsp can fix it" case, it'd 
need to apply only when the property was never set, and log loudly (WARN/ERROR) 
that pages are sitting in non-durable storage.
   
   Happy to help with any of this if useful.


-- 
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]

Reply via email to