You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xmlgraphics.apache.org by "Simon Steiner (Jira)" <ji...@apache.org> on 2023/08/31 11:27:00 UTC

[jira] [Commented] (XGC-137) FOP Default font cache file mishandled when user has no home directory

    [ https://issues.apache.org/jira/browse/XGC-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17760873#comment-17760873 ] 

Simon Steiner commented on XGC-137:
-----------------------------------

this bug was created on xgc project not fop

> 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.8, 2.9, main
>         Environment: Ubuntu 22.04
>            Reporter: Paul Robinson
>            Priority: Minor
>
> 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: general-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: general-help@xmlgraphics.apache.org