3 Commits (66861c12e7d515f4d0e779102780d89e3fcd2a12)

Author SHA1 Message Date
Iain Patterson fb96938cf9 Use nssm_imagepath().
We were calling GetModuleFileName() in a number of places.  Use
nssm_imagepath() instead.

Ensure that a quoted path is used for the service image path when
creating the service, thus avoiding a theoretical security vulnerability
whereby the service manager could be tricked into launching the wrong
program.

When setting the path to NSSM in the environment for event hooks we
still use the unquoted path, as environment variables are typically
unquoted.

Thanks Gerald Haider.
10 years ago
Iain Patterson f124b07b52 Save the environment.
Before the previous two commits we used to read the environment from the
registry and set it using an optimisation which modified the retrieved
block in-place.

Now we need to set the environment twice after querying the registry -
once in get_parameters() and once just before CreateProcess(), which
means we can't use the in-place optimisation and must copy the block
before operating on it.

Additionally, nssm_hook() cleans the environment so we have to reinstate
it immediately prior to launching the application.
10 years ago
Iain Patterson 2f2f64b076 Run hooks in response to certain events.
User-configurable hooks will be run before and/or after certain events,
eg after the application starts successfully.

Hooks will run with the environment of the application, with additional
environment variables providing information about the service status and
the hook which has been called.
10 years ago