You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Schreibman, David" <DS...@eTranslate.com> on 2001/12/20 17:02:16 UTC

PATCH: NT Service display name should not be used as service name

Hi,

We've encountered a problem with the way jk_nt_service.c creates nt
services.

Specifically, the call to CreateService uses the name passed in for the
service as both the service name and the service display name.  This is a
problem because there are restrictions on the service name that do not apply
to the display name.  The MS documentation states that neither forward nor
back slashes are allowed but in practice I have found that other characters
cause problems as well.

For example, if you create a service via jk_nt_service -i "My Service"
wrapper.properties the service creates just fine but it fails to start.

Since the MS source is not readily available we can't check on what the REAL
rules are for the internal service name.

To be safe, a solution I have used in the past is to treat the name passed
in via the command line as the display name, and then remove all
non-alphanumeric characters to generate the internal service name.

This is cheap, but might cause trouble if you are unlucky enough to have
multiple service display names mapping to a single internal name as in "My
Service 1.1" and "My Service 11".

An alternative that fixes this is to convert non alphanumerics to their hex
representation.

I've attached a patch using the first approach since I've used in in the
past without any problems.  I'll be happy to rework it to hex encode non
alphanumerics if there is interest.

-David