Paul Robinson created XGC-137:
---------------------------------
Summary: FOP Default font cache file mishandled when user has no
home directory
Key: XGC-137
URL: https://issues.apache.org/jira/browse/XGC-137
Project: XMLGraphicsCommons
Issue Type: Bug
Components: general
Affects Versions: 2.9, 2.8, main
Environment: Ubuntu 22.04
Reporter: Paul Robinson
Fix For: main
FontCache.getDefaultCacheFile(boolean forWriting) tries to choose and (if
necessary) create a .fop directory. It checks to make sure that is writable,
and if not, users a temporary directory instead. Finally, it then returns a
File pointing inside the .fop directory.
This all works, but only when FontCache.getUserHome() returns non-null.
getUserHome() returns null if a user is configured with a non-existent home
directory (which just happens to be the default when installing Apache Tomcat 9
on Ubuntu, where the home directory is /var/lib/tomcat but it doesn't exist,
whereas /var/lib/tomcat9 does).
In this case, it simply returns a new file called ".fop". This means the
default cache file will be called ".fop" in the current working directory. This
avoids the check to see whether the directory is writable, and it uses a file
called .fop instead of a directory called .fop.
If (as can be the case in Tomcat) the current working directory is not
writable, then the default cache file cannot be written to leading to an
exception.
I think this can be fixed with simple change from this:
{code:java}
File userHome = getUserHome();
if (userHome != null) {
File fopUserDir = new File(userHome, FOP_USER_DIR);
{code}
to this:
{code:java}
File userHome = getUserHome();
File fopUserDir = userHome == null ? new File(FOP_USER_DIR) : new
File(userHome, FOP_USER_DIR);
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]