>-----Original Message-----
>From: Mark Thomas [mailto:ma...@apache.org]
>Sent: Tuesday, March 12, 2019 12:51 AM
>To: users@tomcat.apache.org
>Subject: Re: Followup2: Changed behaviour of Tomcat 
>Deployment/Context/Lifecycle Manager concerning symbolic links

>Looking at the code in ContextConfig.fixDocBase() it looks like it
>should be possible to switch lines 585 and 587 to use getAbsolutePath()
>without having too much impact on any performance improvements we may
>want to consider. That should address the regression. @Guido can you
>confirm that please?


Using  getAbsolutePath()  instead of  getPath()  ...

                File file = new File(docBase);
                if (!file.isAbsolute()) {
        -            docBase = (new File(appBase, docBase)).getCanonicalPath();
        +            docBase = (new File(appBase, docBase)).getAbsolutePath();
                } else {
        -            docBase = file.getCanonicalPath();
        +            docBase = file.getAbsolutePath();
                }

also still solve the issue for me.


Here my minimal test set:

* At some auto-deploying location, create the empty WAR 'dst.war.' 

        (You may use the following, if you like)

        # cat /opt/bin/mkemptyzip 
        #!/bin/bash
        #
        # 20180516/gj
        
        if [ -z "$1" ]; then
          cat >&2 <<-EOT
                syntax : $0 <file>...
                purpose: generate empty zip file
                EOT
          exit -1
        fi
        for FILE; do
          [ -f "$FILE" ] && echo "file \"$FILE\" exists, skipping" && continue
          echo -en      
'\x50\x4b\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 >$FILE
        done

* Set up some different styled symlinks to it:

        root@testbcs0 /home/tomcatT-8/webapps/localhost # ll ???.*              
                                                                                
                                 
        lrwxrwxrwx 1 root root 41 Mar 12 12:32 abs.war -> 
/data/srv/test/webapps/localhost/dst.war.
        lrwxrwxrwx 1 root root  8 Mar 12 12:33 chn.war. -> dst.war.
        -rw-r--r-- 1 root root 22 Mar 12 12:32 dst.war.
        lrwxrwxrwx 1 root root  8 Mar 12 12:35 dsy.war -> chn.war.
        lrwxrwxrwx 1 root root  8 Mar 12 12:40 p#s.war -> chn.war.
        lrwxrwxrwx 1 root root  8 Mar 12 11:51 lnk.war -> dst.war.
        lrwxrwxrwx 1 root root 21 Mar 12 11:51 rel.war -> ../localhost/dst.war.


This will proper deploy the Contexts named '/abs'  '/dsy'  '/p/s'  '/lnk'  and  
'/rel' . All this breaks while using getCanonical, but works with getPath() or 
getAbsolutePath(). Notice also, that the "final destination" is still proper 
watched, i.e. touching the 'dst.war.' will redeploy all contexts.




>I can run the unit tests and if they pass and the correction of the
>regression is confirmed it should be possible to get the fix into the
>next set of releases.
>
>The next release is almost certainly too soon for completing the
>performance review. That is probably going to need to wait until the
>following set of releases.

To remove the regression, IMHO you fist should revert the change for the next 
release and do your wider code cleaning and performance after that.


with greetings

Guido

Reply via email to