Menu

#122 When referencing ${path} in Windows, an incorrect "Path to executable" command might be generated

All
closed-wont-fix
nobody
None
5
2016-09-02
2016-04-14
No

When referencing ${path} (for instance: wrapper.java.library.path.2=${path}), an incorrect command might be generated depending on the %PATH% configuration. More specifically, if %PATH% ends with \\, we will have something like this in the service's configuration:

C:\path\to\java.exe -classpath "C:\path\to\service-wrapper\wrapper.jar" -Xrs -Dwrapper.service=true -Dwrapper.working.dir="C:\somedir" -Djava.net.preferIPv4Stack=true -Dpath="some;paths;C:\problematic\path\" -Dwrapper.config="C:\path\to\service.conf" -Dwrapper.additional.1x=-Xrs -Djna_tmpdir=C:\Users\SomeUser\AppData\Local\Temp org.rzo.yajsw.boot.WrapperServiceBooter

This command is incorrect due to the \\" at the end of the -Dpath value, and the service won't start.

If we modify our %PATH% so it ends like C:\problematic\path or C:\problematic\path\; and we re-install the service, it will start just fine.

In addition, if the %PATH% value contains double quotes (which should not be used inside the %PATH% value, but nothing prevents users or some software from doing it), we'll have the same problem.

Maybe some processing should be applied to the %PATH% variable before applying its value to the final service's startup command, in order to avoid this kind of difficult-to-diagnose situations.

Discussion

  • Ismael Teijeiro

    Ismael Teijeiro - 2016-04-14

    Correction:

    ... if %PATH% ends with \\ ... ==> ... if %PATH% ends with \ ...
    ... incorrect due to the \\" at the end of the ... ==> ... incorrect due to the \" at the end of the ...

     

    Last edit: Ismael Teijeiro 2016-04-14
  • Ismael Teijeiro

    Ismael Teijeiro - 2016-06-15

    Any updates on this? Thanks!

     
  • rzo

    rzo - 2016-06-19

    hello,

    i do not think that it is a good idea to hard code handling of specific environment variables.
    you can easily do this in the configuration file using groovy:

    cleanPath=${/${path}/.replaceAll(~/\\;/,';')}.replaceAll(~/\$/,'')}

    wrapper.java.additional.7=-Dpath=${cleanPath}

    -- Ron

     
    • Ismael Teijeiro

      Ismael Teijeiro - 2016-06-20

      Ok, thanks!

       
  • rzo

    rzo - 2016-09-02
    • status: open --> closed-wont-fix
     

Log in to post a comment.