Kern Sibbald wrote:
> On Monday 16 May 2005 11:25, Russell Howe wrote:
> 
>>/servicehelper, which looks to mean "Display pretty system tray icon". 
> 
> No, see below.

OK, I had misconceptions about the /servicehelper switch.

> /servicehelper is an old artifact that should not be used, unless you want to 
> have all kinds of problems -- see below.

OK. I notice that the current code in src/filed/win32/winmain.cpp
doesn't even check for it as a commandline option.

> The bacula-fd runs both the daemon and the systray icon.  They are just two 
> different threads of the same program.

Ah, this I didn't realise - it explains some of my confusion :)

>>>>HKLM\Software\Microsoft\Windows\CurrentVersion\Run has this:
>>>>
>>>>Name: Bacula
>>>>Value: "c:\bacula\bin\bacula-fd.exe" /servicehelper
> 
> 
> If that is how you are starting Bacula, then you are starting it incorrectly. 

This was not set up by me - looking at the source, it is set up by the
InstallService() member function of bacService. Take a look around line
528 of src/bacula/filed/win32/winservice.cpp:

// Now install the servicehelper registry setting...
// Locate the RunService registry entry
HKEY runapps;
if (RegCreateKey(HKEY_LOCAL_MACHINE,
        "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
        &runapps) != ERROR_SUCCESS) {

It then looks like bacula-fd.exe goes on to add itself to this startup key.

So, when bacula-fd is run with the /install switch, it creates this
HKLM\Software\Windows\CurrentVersion\Run key, as well as doing things
like registering itself with the service manager (at least on NT and above).

I don't know if removing this key on Win9x/ME will have any adverse
effects, although the code seems to add an entry under RunServices on
those OSes, so I suspect the key under Run is just noise. Since the code
doesn't even seem to check for the option, I don't see that it can be
doing anything...

> This is probably just some other key that the original code setup that is not 
> used by Bacula.  Bacula should always be started as /service.  I have no idea 
> what the service helper code does. It is old original code that is not 
> functional as best I know, and I just didn't bother to rip it out.

Well, I have removed this startup key on one of our servers, so there is
no longer any copy of bacula running with the /servicehelper switch.
I'll let you know if it causes any weirdness. Removing the key certainly
stops the warning messages being logged when users log in via terminal
services.

>>>>strncmp("/servicehelper", "/service", 8) and is only matching on the 1st
>>>>8 characters of "/servicehelper".
>>>>
>>>>"/service" is then seen as equal to "/servicehelper"
>>>>
>>>>Should it not be strcmp(&szCmdLine[i], BaculaRunService)? Is
>>>>szCmdLine[i] trusted?
>>
>>Trusted to be null terminated, rather (otherwise it may be a potential
>>vulnerability?).
> 
> I could be wrong, but I think you are going in a completely wrong direction.
> As I previously stated, most likely it has something to do with interacting
> with the user.  If it is not that then it is some new requirement that
> Microsoft has added in the past few years to interact with the Service
> Manager that Bacula does not understand.

Well, from where I'm sitting it looks like a couple of things:

* The registry key is (presumably?) superfluous and should not be
created when the FD is installed as a service in Windows. This will also
be one less thing to run at bootup, which I'm sure is welcome :)

* The commandline option parsing sees the following two options as
identical:

        foo
        foobar

(but will also pick up the 'foobar' option if it checks for it). This
isn't a problem, as long as command line options are picked such that
none follow the above pattern.

Had the latter not been the case, I suspect bacula-fd.exe would simply
have terminated as soon as it had been called with /servicehelper, with
an error to the effect that it didn't know what '/servicehelper' meant.
Instead, it took it to mean /service and tried to register itself with
the service helper (which MS says an application started from the
console cannot do).

-- 
Russell Howe
[EMAIL PROTECTED]

Today's Nemi: http://www.metro.co.uk/img/pix/nemi_may17.jpg


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to