You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2019/08/08 12:19:12 UTC

[tomcat] branch master updated (e3a59c3 -> 7ac5fc8)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from e3a59c3  Update expiring test certs
     new 62da9b7  Align the comments with the usage message
     new 7ac5fc8  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bin/service.bat                        | 122 ++++++++++++++++++++++-----------
 webapps/docs/changelog.xml             |   9 +++
 webapps/docs/windows-service-howto.xml |  14 +++-
 3 files changed, 103 insertions(+), 42 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Align the comments with the usage message

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 62da9b70f775d55bfa517661e1442a739282ce72
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Aug 8 08:37:26 2019 +0100

    Align the comments with the usage message
---
 bin/service.bat | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/bin/service.bat b/bin/service.bat
index 221ef18..5d9e053 100755
--- a/bin/service.bat
+++ b/bin/service.bat
@@ -17,13 +17,19 @@ rem limitations under the License.
 rem ---------------------------------------------------------------------------
 rem NT Service Install/Uninstall script
 rem
+rem Usage: service.bat install/remove [service_name] [/user username]
+rem
 rem Options
-rem install                Install the service using Tomcat@VERSION_MAJOR@ as service name.
-rem                        Service is installed using default settings.
-rem remove                 Remove the service from the System.
+rem install                 Install the service using default settings.
+rem remove                  Remove the service from the system.
+rem
+rem service_name (optional) The name to use for the service. If not specified,
+rem                         Tomcat@VERSION_MAJOR@ is used as the service name.
 rem
-rem name        (optional) If the second argument is present it is considered
-rem                        to be new service name
+rem username (optional)     The name of the OS user to use to install/remove
+rem                         the service (not the name of the OS user the
+rem                         service will run as). If not specified, the current
+rem                         user is used.
 rem ---------------------------------------------------------------------------
 
 setlocal


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] 02/02: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285

Posted by Mark Thomas <ma...@apache.org>.
<snip/>

>> How about this as a modified approach:
> 
>> - Keep renaming back to Tomcat9[w].exe on remove. That won't
>> impact existing service.bat users but will help users that install
>> via the installer (e.g. they'll be able to change the service
>> name).
> 
> Aha. I'm sure that has something to do with the answer to "who is
> broken" question.
> 
>> - Change the option to --rename and only rename on install when 
>> explicitly requested. Current service.bat users would be
>> unaffected and installer users would need to use this option if
>> they used service.bat to uninstall and reinstall the service (e.g.
>> to rename it)
> 
> I think I like the --no-rename -> --rename option is the best because
> it makes the smallest change. Only currently-affected users will need
> to modify their behavior, instead of most users having to modify their
> behavior.
> 
>> That should fix the reported issue while removing the impact on
>> the existing service.bat users.
> 
>> Thoughts?
> 
>> Mark
> 
> 
>> P.S. I know the 9.0.x and 8.5.x tags are overdue but I'd rather
>> wait a few more days to make sure we are happy with this change
>> before tagging and committing us to an approach.
> 
> +1
> 
> I wouldn't want to put out a release where the rules are different
> from every other release if we are going to change --no-rename ->
> --rename.
> 
> In case it's not clear, I'm fully in favor of changing --no-rename ->
> --rename instead of the current patch.

Done.

I have a few bits and pieces I want to look at before the tag so I
probably won't tag until tomorrow / Wednesday.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] 02/02: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 8/9/19 09:46, Mark Thomas wrote:
>> Mark,
>> 
>> On 8/8/19 08:19, markt@apache.org wrote:
>>> This is an automated email from the ASF dual-hosted git 
>>> repository.
>> 
>>> markt pushed a commit to branch master in repository 
>>> https://gitbox.apache.org/repos/asf/tomcat.git
>> 
>>> commit 7ac5fc8a59c10e7de1ee6d4b85c1ee797942a1e7 Author: Mark
>>> Thomas <ma...@apache.org> AuthorDate: Thu Aug 8 13:17:29 2019
>>> +0100
>> 
>>> Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285
>> 
>>> Align the behaviour of service.bat with the Windows installer
>>> and rename the executables on installation (and restore on
>>> removal).
>> 
>> If I understand this patch, I might need to veto it for Tomcat
>> 9. Changing for TC 10 will be okay.
>> 
>> Re-naming the Tomcat .exe files on Windows will be a very
>> surprising change for a point-release. Every installation I've
>> ever worked on has multiple services running off the same Tomcat
>> installation. If any of them is upgraded without adding the
>> "--no-rename" option to an invocation of the service.bat script,
>> all automation will begin to fail.
> 
> As soon as a new service is installed, yes.
> 
>> That includes services which *are not* reconfigured because the 
>> TomcatX.exe file will be renamed and still referenced in various 
>> service definitions.
> 
> Yes.
> 
> This is one of those cases where something is going to be broken 
> whatever we do. Happy to discuss options to try and minimise how
> much gets broken.

Help me understand how "no change" is broken. Who is adversely
affected by not making any changes?

> How about this as a modified approach:
> 
> - Keep renaming back to Tomcat9[w].exe on remove. That won't
> impact existing service.bat users but will help users that install
> via the installer (e.g. they'll be able to change the service
> name).

Aha. I'm sure that has something to do with the answer to "who is
broken" question.

> - Change the option to --rename and only rename on install when 
> explicitly requested. Current service.bat users would be
> unaffected and installer users would need to use this option if
> they used service.bat to uninstall and reinstall the service (e.g.
> to rename it)

I think I like the --no-rename -> --rename option is the best because
it makes the smallest change. Only currently-affected users will need
to modify their behavior, instead of most users having to modify their
behavior.

> That should fix the reported issue while removing the impact on
> the existing service.bat users.
> 
> Thoughts?
> 
> Mark
> 
> 
> P.S. I know the 9.0.x and 8.5.x tags are overdue but I'd rather
> wait a few more days to make sure we are happy with this change
> before tagging and committing us to an approach.

+1

I wouldn't want to put out a release where the rules are different
from every other release if we are going to change --no-rename ->
- --rename.

In case it's not clear, I'm fully in favor of changing --no-rename ->
- --rename instead of the current patch.

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl1Ns4MACgkQHPApP6U8
pFj6NA//ZkKtLWvNF3sByWLijbdtQlw8fTScLgWfrN2WmcJc5Y3gO+xfi89mfaPc
5We7o7F0pNmyYAF1ndyk4myKXju7tg6RPYEnfEm2sOv1UajOD7PIeFKC5WCnp4hn
A6npiA4uXzDeEm8hTbdV9e1bIvZnx2xtivzD1tYvJpuctvjmb7ktK+hGw0SVNWxI
zXept1kg4O8zHOp6XvGkcV7kCLitW9v0TeOwJmuIYUpjBB2J+wSnRNQZyZliUd+6
vQhrvGFzptcLE7j6ek24yKCRkCNXnBipoFnNT5GMBmjerd9w3QHvcrGefU4L1Zqk
DgY1lDYaCBaAaBnPFMXPobmLhT/PbI6wVdl6s6b2sBk+fj9FZIS0bgVrb6hlBEVS
GfBZPITR/HG+Bz1s4gLndNqbOZ1z/c7NpTM7smpcEnlaWSnjxQE/V90Kc4Y0cTXp
+CudLWhxrqXFOEXuvngFCi1gXsvSbDqjMckcvgKfW764L1vOyNrWP4pgd/xSUJaq
0cq4q/Xw8Dhl3yBDxkG0ZLrvT9lNh9S4XKUW0WqXRSbiMmofAhSJS7bjEWnRS1sy
nmxdG62EZyYaGs/8VUWz3eceUU3DqOgCtxO5nnfKC8h42bpSKJboQ1FvOO4dd5uV
bkoQJrIkGopOzyGzxq5xHBVkJCxT9r/1+CRX0hJ31FNI6lJA1Bk=
=02Pa
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] 02/02: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285

Posted by Mark Thomas <ma...@apache.org>.
> Mark,
> 
> On 8/8/19 08:19, markt@apache.org wrote:
>> This is an automated email from the ASF dual-hosted git
>> repository.
> 
>> markt pushed a commit to branch master in repository
>> https://gitbox.apache.org/repos/asf/tomcat.git
> 
>> commit 7ac5fc8a59c10e7de1ee6d4b85c1ee797942a1e7 Author: Mark Thomas
>> <ma...@apache.org> AuthorDate: Thu Aug 8 13:17:29 2019 +0100
> 
>> Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285
> 
>> Align the behaviour of service.bat with the Windows installer and
>> rename the executables on installation (and restore on removal).
> 
> If I understand this patch, I might need to veto it for Tomcat 9.
> Changing for TC 10 will be okay.
> 
> Re-naming the Tomcat .exe files on Windows will be a very surprising
> change for a point-release. Every installation I've ever worked on has
> multiple services running off the same Tomcat installation. If any of
> them is upgraded without adding the "--no-rename" option to an
> invocation of the service.bat script, all automation will begin to
> fail.

As soon as a new service is installed, yes.

> That includes services which *are not* reconfigured because the
> TomcatX.exe file will be renamed and still referenced in various
> service definitions.

Yes.

This is one of those cases where something is going to be broken
whatever we do. Happy to discuss options to try and minimise how much
gets broken.

How about this as a modified approach:

- Keep renaming back to Tomcat9[w].exe on remove. That won't impact
  existing service.bat users but will help users that install via the
  installer (e.g. they'll be able to change the service name).

- Change the option to --rename and only rename on install when
  explicitly requested. Current service.bat users would be unaffected
  and installer users would need to use this option if they used
  service.bat to uninstall and reinstall the service (e.g. to rename it)

That should fix the reported issue while removing the impact on the
existing service.bat users.

Thoughts?

Mark


P.S. I know the 9.0.x and 8.5.x tags are overdue but I'd rather wait a
few more days to make sure we are happy with this change before tagging
and committing us to an approach.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] 02/02: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 8/8/19 08:19, markt@apache.org wrote:
> This is an automated email from the ASF dual-hosted git
> repository.
> 
> markt pushed a commit to branch master in repository
> https://gitbox.apache.org/repos/asf/tomcat.git
> 
> commit 7ac5fc8a59c10e7de1ee6d4b85c1ee797942a1e7 Author: Mark Thomas
> <ma...@apache.org> AuthorDate: Thu Aug 8 13:17:29 2019 +0100
> 
> Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285
> 
> Align the behaviour of service.bat with the Windows installer and
> rename the executables on installation (and restore on removal).

If I understand this patch, I might need to veto it for Tomcat 9.
Changing for TC 10 will be okay.

Re-naming the Tomcat .exe files on Windows will be a very surprising
change for a point-release. Every installation I've ever worked on has
multiple services running off the same Tomcat installation. If any of
them is upgraded without adding the "--no-rename" option to an
invocation of the service.bat script, all automation will begin to
fail. That includes services which *are not* reconfigured because the
TomcatX.exe file will be renamed and still referenced in various
service definitions.

Thanks,
- -chris

> --- bin/service.bat                        | 110
> ++++++++++++++++++++++----------- webapps/docs/changelog.xml
> |   9 +++ webapps/docs/windows-service-howto.xml |  14 ++++- 3
> files changed, 94 insertions(+), 39 deletions(-)
> 
> diff --git a/bin/service.bat b/bin/service.bat index
> 5d9e053..6105b15 100755 --- a/bin/service.bat +++
> b/bin/service.bat @@ -17,7 +17,7 @@ rem limitations under the
> License. rem
> ----------------------------------------------------------------------
- -----
>
> 
rem NT Service Install/Uninstall script
> rem -rem Usage: service.bat install/remove [service_name] [/user
> username] +rem Usage: service.bat install/remove [service_name
> [--no-rename]] [--user username] rem rem Options rem install
> Install the service using default settings. @@ -26,7 +26,10 @@ rem 
> rem service_name (optional) The name to use for the service. If not
> specified, rem                         Tomcat@VERSION_MAJOR@ is
> used as the service name. rem -rem username (optional)     The name
> of the OS user to use to install/remove +rem --no-rename
> (optional) Don't rename tomcat@VERSION_MAJOR@.exe and
> tomcat@VERSION_MAJOR@w.exe to match +rem
> the non-default service name. +rem +rem username     (optional) The
> name of the OS user to use to install/remove rem
> the service (not the name of the OS user the rem
> service will run as). If not specified, the current rem
> user is used. @@ -35,21 +38,70 @@ rem
> ----------------------------------------------------------------------
- -----
>
> 
setlocal
> 
> set "SELF=%~dp0%service.bat" -rem Guess CATALINA_HOME if not
> defined + +set DEFAULT_SERVICE_NAME=Tomcat@VERSION_MAJOR@ +set
> SERVICE_NAME=%DEFAULT_SERVICE_NAME% + set "CURRENT_DIR=%cd%" + +rem
> Parse the arguments +if "x%1x" == "xx" goto displayUsage +set
> SERVICE_CMD=%1 +shift +if "x%1x" == "xx" goto checkEnv +:checkUser 
> +if "x%1x" == "x/userx" goto runAsUser +if "x%1x" == "x--userx"
> goto runAsUser +set SERVICE_NAME=%1 +shift +if "x%1x" == "xx" goto
> checkEnv +if "x%1x" == "x--no-renamex" ( +    set NO_RENAME=%1 +
> shift +) +if "x%1x" == "xx" goto checkEnv +goto checkUser 
> +:runAsUser +shift +if "x%1x" == "xx" goto displayUsage +set
> SERVICE_USER=%1 +shift +runas /env /savecred /user:%SERVICE_USER%
> "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%" +goto end + 
> +rem Check the environment +:checkEnv + +rem Guess CATALINA_HOME if
> not defined if not "%CATALINA_HOME%" == "" goto gotHome set
> "CATALINA_HOME=%cd%" -if exist
> "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome +if
> exist "%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe" goto okHome 
> +if exist "%CATALINA_HOME%\bin\%SERVICE_NAME%.exe" goto okHome rem
> CD to the upper dir cd .. set "CATALINA_HOME=%cd%" :gotHome -if
> exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome 
> -echo The tomcat@VERSION_MAJOR@.exe was not found... -echo The
> CATALINA_HOME environment variable is not defined correctly. -echo
> This environment variable is needed to run this program +if exist
> "%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe" ( +    set
> "EXECUTABLE=%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe" +
> goto okHome +) +if exist "%CATALINA_HOME%\bin\%SERVICE_NAME%.exe"
> ( +    set "EXECUTABLE=%CATALINA_HOME%\bin\%SERVICE_NAME%.exe" +
> goto okHome +) +if "%DEFAULT_SERVICE_NAME%"== "%SERVICE_NAME%" ( +
> echo The file %DEFAULT_SERVICE_NAME%.exe was not found... +) else
> ( +    echo Neither the %DEFAULT_SERVICE_NAME%.exe file nor the
> %SERVICE_NAME%.exe file was found... +) +echo Either the
> CATALINA_HOME environment variable is not defined correctly or 
> +echo the incorrect service name has been used. +echo Both the
> CATALINA_HOME environment variable and the correct service name 
> +echo are required to run this program. goto end :okHome +cd
> "%CURRENT_DIR%" + rem Make sure prerequisite environment variables
> are set if not "%JAVA_HOME%" == "" goto gotJdkHome if not
> "%JRE_HOME%" == "" goto gotJreHome @@ -81,12 +133,6 @@ if not
> "%CATALINA_BASE%" == "" goto gotBase set
> "CATALINA_BASE=%CATALINA_HOME%" :gotBase
> 
> -set "EXECUTABLE=%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" - 
> -rem Set default Service name -set
> SERVICE_NAME=Tomcat@VERSION_MAJOR@ -set DISPLAYNAME=Apache Tomcat
> @VERSION_MAJOR_MINOR@ %SERVICE_NAME% - rem Java 9 no longer
> supports the java.endorsed.dirs rem system property. Only try to
> use it if rem JAVA_ENDORSED_DIRS was explicitly set @@ -100,33
> +146,14 @@ if not exist "%CATALINA_HOME%\endorsed" goto
> doneEndorsed set ENDORSED_PROP=java.endorsed.dirs :doneEndorsed
> 
> -if "x%1x" == "xx" goto displayUsage -set SERVICE_CMD=%1 -shift -if
> "x%1x" == "xx" goto checkServiceCmd -:checkUser -if "x%1x" ==
> "x/userx" goto runAsUser -if "x%1x" == "x--userx" goto runAsUser 
> -set SERVICE_NAME=%1 -set DISPLAYNAME=Apache Tomcat
> @VERSION_MAJOR_MINOR@ %1 -shift -if "x%1x" == "xx" goto
> checkServiceCmd -goto checkUser -:runAsUser -shift -if "x%1x" ==
> "xx" goto displayUsage -set SERVICE_USER=%1 -shift -runas /env
> /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\"
> %SERVICE_CMD% %SERVICE_NAME%" -goto end -:checkServiceCmd +rem
> Process the requested command if /i %SERVICE_CMD% == install goto
> doInstall if /i %SERVICE_CMD% == remove goto doRemove if /i
> %SERVICE_CMD% == uninstall goto doRemove echo Unknown parameter
> "%SERVICE_CMD%" :displayUsage echo. -echo Usage: service.bat
> install/remove [service_name] [/user username] +echo Usage:
> service.bat install/remove [service_name [--no-rename]] [--user
> username] goto end
> 
> :doRemove @@ -141,6 +168,10 @@ echo Failed removing
> '%SERVICE_NAME%' service goto end :removed echo The service
> '%SERVICE_NAME%' has been removed +if exist
> "%CATALINA_HOME%\bin\%SERVICE_NAME%.exe" ( +    rename
> "%SERVICE_NAME%.exe" "%DEFAULT_SERVICE_NAME%.exe" +    rename
> "%SERVICE_NAME%w.exe" "%DEFAULT_SERVICE_NAME%w.exe" +) goto end
> 
> :doInstall @@ -169,6 +200,14 @@ if "%SERVICE_STARTUP_MODE%" == ""
> set SERVICE_STARTUP_MODE=manual if "%JvmMs%" == "" set JvmMs=128 if
> "%JvmMx%" == "" set JvmMx=256
> 
> +if exist "%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe" ( +
> if "x%NO_RENAME%x" == "xx" ( +        rename
> "%DEFAULT_SERVICE_NAME%.exe" "%SERVICE_NAME%.exe" +        rename
> "%DEFAULT_SERVICE_NAME%w.exe" "%SERVICE_NAME%w.exe" +        set
> "EXECUTABLE=%CATALINA_HOME%\bin\%SERVICE_NAME%.exe" +    ) +) + 
> "%EXECUTABLE%" //IS//%SERVICE_NAME% ^ --Description "Apache Tomcat
> @VERSION@ Server - https://tomcat.apache.org/" ^ --DisplayName
> "%DISPLAYNAME%" ^ @@ -198,4 +237,3 @@ goto end echo The service
> '%SERVICE_NAME%' has been installed.
> 
> :end -cd "%CURRENT_DIR%" diff --git a/webapps/docs/changelog.xml
> b/webapps/docs/changelog.xml index d81703c..c2419a7 100644 ---
> a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@
> -203,6 +203,15 @@ with Apache Tomcat. (remm) </add> <fix> +
> <bug>63285</bug>: Modify <code>service.bat</code> so that when +
> installing a Windows service, by default, it changes the name of
> the +        executables used by the Windows service to match the
> service name. This +        makes the installation behaviour
> consistent with the Windows installer. +        The original
> executable names will be restored when the Windows service +
> is removed. The renaming can be disabled by using the new +
> <code>--no-rename</code> option after the service name. (markt) +
> </fix> +      <fix> <bug>63567</bug>: Restore the passing of
> <code>$LOGGING_MANAGER</code> to the jvm in
> <code>catalina.sh</code> when calling <code>stop</code>. (markt) 
> diff --git a/webapps/docs/windows-service-howto.xml
> b/webapps/docs/windows-service-howto.xml index d3c69b9..b9215f7
> 100644 --- a/webapps/docs/windows-service-howto.xml +++
> b/webapps/docs/windows-service-howto.xml @@ -346,9 +346,9 @@
> script. If necessary, you can use the <code>/user</code> switch to
> specify a user to use for the installation of the service. </p> 
> <p> -<strong>NOTE:</strong> On Windows Vista or any later operating
> system with User -Account Control (UAC) enabled you will be asked
> for additional privileges -when 'Tomcat<version-major/>.exe' is
> launched by the script.<br/> +<strong>NOTE:</strong> If User
> Account Control (UAC) is enabled you will be +asked for additional
> privileges when 'Tomcat<version-major/>.exe' is launched by +the
> script.<br/> If you want to pass additional options to service
> installer as <code>PR_*</code> environment variables, you have to
> either configure them globally in OS, or launch the program that
> sets them with elevated privileges @@ -367,6 +367,14 @@ service, as
> displayed in Windows services.</p> <source>Install the service
> named 'MyService' C:\> service.bat install MyService</source>
> 
> +<p>When installing the service with a non-default name, 
> +tomcat<version-major/>.exe and tomcat<version-major/>w.exe will be
> renamed to +match the chosen service name. To prevent this, use the
> <code>--no-rename</code> +option.</p> + +<source>Install the
> service named 'MyService' without renaming +C:\> service.bat
> install MyService --no-rename</source> + <p> If using
> tomcat<version-major/>.exe, you need to use the <b>//IS//</b>
> parameter.</p>
> 
> 
> 
> ---------------------------------------------------------------------
>
> 
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl1Ndf8ACgkQHPApP6U8
pFjA+BAAooRuMfdmMiuQdScqlLVnT428drU6Z0X9IPqDYh6v4mjsYygLusYmn7wt
XH1zoIV3q3JsVFbH6KaEIL3L4nOLfYQwoywcpHVYUxntmG/YjDCyFVzZOdwqzwJy
jk52PdQFRFknaDJRU8uVH9mLJTrpljxOxC8Y48fIQ7JZ83B+jMMu+ZbO2qd31IZR
KGaDtGLlhy+G8TvH7uWaf0ZZ0YXLnvAjU+mAbJ0qimuTJ94DX3Jn/D87p/ZcoQJL
hG24nm2T9kF41LdmX2tULTkZjgeQIHwDhfSfDhMlgnQ27gsdDEk4cV6kzFdaWdIU
+2XfR+bkJxgwfOw59XBAbyYosiCRI+lhNU/q3563GV5jMDdse5VUzXV1JW7Bi+mS
0QxEPyLXE85Ld5eXSA6IDQg1reUuT6LkU+SbjpEGgTe7uMYhRXvJPzxZqMJWuVHK
U5uPJGiwaxE5MCoNY20Eja9wJOYZlGk7c+K4Ph3ybLjo9BGJSEwKX6MNDeOQKoPD
+X9y8re/tigE+vkp80D5V1cilbIciL3Ux+64QTwL4v385JGHsz4MX1zCtYj4EQwq
CQrIcqT3GPAFegmu3b6pIe1ua/IXHulAZpOetbcT4f+jwaSLIh/qq4UfaBqrZJrP
kHg+JMLmri64Hm0EmLBYFlSqjyxoPNXMvCj+tEYzyc1gCl/bZm4=
=PkEs
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 7ac5fc8a59c10e7de1ee6d4b85c1ee797942a1e7
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Aug 8 13:17:29 2019 +0100

    Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63285
    
    Align the behaviour of service.bat with the Windows installer and rename
    the executables on installation (and restore on removal).
---
 bin/service.bat                        | 110 ++++++++++++++++++++++-----------
 webapps/docs/changelog.xml             |   9 +++
 webapps/docs/windows-service-howto.xml |  14 ++++-
 3 files changed, 94 insertions(+), 39 deletions(-)

diff --git a/bin/service.bat b/bin/service.bat
index 5d9e053..6105b15 100755
--- a/bin/service.bat
+++ b/bin/service.bat
@@ -17,7 +17,7 @@ rem limitations under the License.
 rem ---------------------------------------------------------------------------
 rem NT Service Install/Uninstall script
 rem
-rem Usage: service.bat install/remove [service_name] [/user username]
+rem Usage: service.bat install/remove [service_name [--no-rename]] [--user username]
 rem
 rem Options
 rem install                 Install the service using default settings.
@@ -26,7 +26,10 @@ rem
 rem service_name (optional) The name to use for the service. If not specified,
 rem                         Tomcat@VERSION_MAJOR@ is used as the service name.
 rem
-rem username (optional)     The name of the OS user to use to install/remove
+rem --no-rename  (optional) Don't rename tomcat@VERSION_MAJOR@.exe and tomcat@VERSION_MAJOR@w.exe to match
+rem                         the non-default service name.
+rem
+rem username     (optional) The name of the OS user to use to install/remove
 rem                         the service (not the name of the OS user the
 rem                         service will run as). If not specified, the current
 rem                         user is used.
@@ -35,21 +38,70 @@ rem ---------------------------------------------------------------------------
 setlocal
 
 set "SELF=%~dp0%service.bat"
-rem Guess CATALINA_HOME if not defined
+
+set DEFAULT_SERVICE_NAME=Tomcat@VERSION_MAJOR@
+set SERVICE_NAME=%DEFAULT_SERVICE_NAME%
+
 set "CURRENT_DIR=%cd%"
+
+rem Parse the arguments
+if "x%1x" == "xx" goto displayUsage
+set SERVICE_CMD=%1
+shift
+if "x%1x" == "xx" goto checkEnv
+:checkUser
+if "x%1x" == "x/userx" goto runAsUser
+if "x%1x" == "x--userx" goto runAsUser
+set SERVICE_NAME=%1
+shift
+if "x%1x" == "xx" goto checkEnv
+if "x%1x" == "x--no-renamex" (
+    set NO_RENAME=%1
+    shift
+)
+if "x%1x" == "xx" goto checkEnv
+goto checkUser
+:runAsUser
+shift
+if "x%1x" == "xx" goto displayUsage
+set SERVICE_USER=%1
+shift
+runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%"
+goto end
+
+rem Check the environment
+:checkEnv
+
+rem Guess CATALINA_HOME if not defined
 if not "%CATALINA_HOME%" == "" goto gotHome
 set "CATALINA_HOME=%cd%"
-if exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome
+if exist "%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe" goto okHome
+if exist "%CATALINA_HOME%\bin\%SERVICE_NAME%.exe" goto okHome
 rem CD to the upper dir
 cd ..
 set "CATALINA_HOME=%cd%"
 :gotHome
-if exist "%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe" goto okHome
-echo The tomcat@VERSION_MAJOR@.exe was not found...
-echo The CATALINA_HOME environment variable is not defined correctly.
-echo This environment variable is needed to run this program
+if exist "%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe" (
+    set "EXECUTABLE=%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe"
+    goto okHome
+)
+if exist "%CATALINA_HOME%\bin\%SERVICE_NAME%.exe" (
+    set "EXECUTABLE=%CATALINA_HOME%\bin\%SERVICE_NAME%.exe"
+    goto okHome
+)
+if "%DEFAULT_SERVICE_NAME%"== "%SERVICE_NAME%" (
+    echo The file %DEFAULT_SERVICE_NAME%.exe was not found...
+) else (
+    echo Neither the %DEFAULT_SERVICE_NAME%.exe file nor the %SERVICE_NAME%.exe file was found...
+)
+echo Either the CATALINA_HOME environment variable is not defined correctly or
+echo the incorrect service name has been used.
+echo Both the CATALINA_HOME environment variable and the correct service name
+echo are required to run this program.
 goto end
 :okHome
+cd "%CURRENT_DIR%"
+
 rem Make sure prerequisite environment variables are set
 if not "%JAVA_HOME%" == "" goto gotJdkHome
 if not "%JRE_HOME%" == "" goto gotJreHome
@@ -81,12 +133,6 @@ if not "%CATALINA_BASE%" == "" goto gotBase
 set "CATALINA_BASE=%CATALINA_HOME%"
 :gotBase
 
-set "EXECUTABLE=%CATALINA_HOME%\bin\tomcat@VERSION_MAJOR@.exe"
-
-rem Set default Service name
-set SERVICE_NAME=Tomcat@VERSION_MAJOR@
-set DISPLAYNAME=Apache Tomcat @VERSION_MAJOR_MINOR@ %SERVICE_NAME%
-
 rem Java 9 no longer supports the java.endorsed.dirs
 rem system property. Only try to use it if
 rem JAVA_ENDORSED_DIRS was explicitly set
@@ -100,33 +146,14 @@ if not exist "%CATALINA_HOME%\endorsed" goto doneEndorsed
 set ENDORSED_PROP=java.endorsed.dirs
 :doneEndorsed
 
-if "x%1x" == "xx" goto displayUsage
-set SERVICE_CMD=%1
-shift
-if "x%1x" == "xx" goto checkServiceCmd
-:checkUser
-if "x%1x" == "x/userx" goto runAsUser
-if "x%1x" == "x--userx" goto runAsUser
-set SERVICE_NAME=%1
-set DISPLAYNAME=Apache Tomcat @VERSION_MAJOR_MINOR@ %1
-shift
-if "x%1x" == "xx" goto checkServiceCmd
-goto checkUser
-:runAsUser
-shift
-if "x%1x" == "xx" goto displayUsage
-set SERVICE_USER=%1
-shift
-runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%"
-goto end
-:checkServiceCmd
+rem Process the requested command
 if /i %SERVICE_CMD% == install goto doInstall
 if /i %SERVICE_CMD% == remove goto doRemove
 if /i %SERVICE_CMD% == uninstall goto doRemove
 echo Unknown parameter "%SERVICE_CMD%"
 :displayUsage
 echo.
-echo Usage: service.bat install/remove [service_name] [/user username]
+echo Usage: service.bat install/remove [service_name [--no-rename]] [--user username]
 goto end
 
 :doRemove
@@ -141,6 +168,10 @@ echo Failed removing '%SERVICE_NAME%' service
 goto end
 :removed
 echo The service '%SERVICE_NAME%' has been removed
+if exist "%CATALINA_HOME%\bin\%SERVICE_NAME%.exe" (
+    rename "%SERVICE_NAME%.exe" "%DEFAULT_SERVICE_NAME%.exe"
+    rename "%SERVICE_NAME%w.exe" "%DEFAULT_SERVICE_NAME%w.exe"
+)
 goto end
 
 :doInstall
@@ -169,6 +200,14 @@ if "%SERVICE_STARTUP_MODE%" == "" set SERVICE_STARTUP_MODE=manual
 if "%JvmMs%" == "" set JvmMs=128
 if "%JvmMx%" == "" set JvmMx=256
 
+if exist "%CATALINA_HOME%\bin\%DEFAULT_SERVICE_NAME%.exe" (
+    if "x%NO_RENAME%x" == "xx" (
+        rename "%DEFAULT_SERVICE_NAME%.exe" "%SERVICE_NAME%.exe"
+        rename "%DEFAULT_SERVICE_NAME%w.exe" "%SERVICE_NAME%w.exe"
+        set "EXECUTABLE=%CATALINA_HOME%\bin\%SERVICE_NAME%.exe"
+    )
+)
+
 "%EXECUTABLE%" //IS//%SERVICE_NAME% ^
     --Description "Apache Tomcat @VERSION@ Server - https://tomcat.apache.org/" ^
     --DisplayName "%DISPLAYNAME%" ^
@@ -198,4 +237,3 @@ goto end
 echo The service '%SERVICE_NAME%' has been installed.
 
 :end
-cd "%CURRENT_DIR%"
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index d81703c..c2419a7 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -203,6 +203,15 @@
         with Apache Tomcat. (remm)
       </add>
       <fix>
+        <bug>63285</bug>: Modify <code>service.bat</code> so that when
+        installing a Windows service, by default, it changes the name of the
+        executables used by the Windows service to match the service name. This
+        makes the installation behaviour consistent with the Windows installer.
+        The original executable names will be restored when the Windows service
+        is removed. The renaming can be disabled by using the new
+        <code>--no-rename</code> option after the service name. (markt)
+      </fix>
+      <fix>
         <bug>63567</bug>: Restore the passing of <code>$LOGGING_MANAGER</code>
         to the jvm in <code>catalina.sh</code> when calling <code>stop</code>.
         (markt)
diff --git a/webapps/docs/windows-service-howto.xml b/webapps/docs/windows-service-howto.xml
index d3c69b9..b9215f7 100644
--- a/webapps/docs/windows-service-howto.xml
+++ b/webapps/docs/windows-service-howto.xml
@@ -346,9 +346,9 @@ script. If necessary, you can use the <code>/user</code> switch to specify
 a user to use for the installation of the service.
 </p>
 <p>
-<strong>NOTE:</strong> On Windows Vista or any later operating system with User
-Account Control (UAC) enabled you will be asked for additional privileges
-when 'Tomcat<version-major/>.exe' is launched by the script.<br/>
+<strong>NOTE:</strong> If User Account Control (UAC) is enabled you will be
+asked for additional privileges when 'Tomcat<version-major/>.exe' is launched by
+the script.<br/>
 If you want to pass additional options to service installer as
 <code>PR_*</code> environment variables, you have to either configure them
 globally in OS, or launch the program that sets them with elevated privileges
@@ -367,6 +367,14 @@ service, as displayed in Windows services.</p>
 <source>Install the service named 'MyService'
 C:\> service.bat install MyService</source>
 
+<p>When installing the service with a non-default name,
+tomcat<version-major/>.exe and tomcat<version-major/>w.exe will be renamed to
+match the chosen service name. To prevent this, use the <code>--no-rename</code>
+option.</p>
+
+<source>Install the service named 'MyService' without renaming
+C:\> service.bat install MyService --no-rename</source>
+
 <p>
 If using tomcat<version-major/>.exe, you need to use the <b>//IS//</b> parameter.</p>
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org