[Klone-users] Windows service : change and know the execution path

Steven Dorigotti dorigotti at koanlogic.com
Thu Nov 26 04:40:35 EST 2009


Dear Mickaël,

  what you are suggesting, to detect whether KLone is running in
service mode or not, is definitely feasible but shouldn't be necessary
for transparency. It's not usually the responsibility of an
application to know how it was launched, rather such job could be done
by a higher installation layer. It would also require more
windows-specific code.

  If you set a fixed chroot path in the configuration file and let
KLone change directory for you as with our last patch you have a
generic solution for knowing where KLone is being executed which works
under all environments.

  Or is your issue still out of sight?

let us know,
sd

2009/11/26 Mickael Auger <mickael.auger at gmail.com>:
> Hi,
>
> thank you for your patch.
>
> Hovewer, in Windows service mode I will search the
> "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\kloned\ImagePath" key in
> Windows registry to know the kloned.exe installation directory and call
> SetCurrentDirectory to it in "server_init" hook.
>
> So, I would like know the kloned execution mode (application or service).
> Have you a solution to distinct this execution mode (kloned launched with
> WinMain() or ServiceMain() functions in entry.c) ?
>
> Bye.
>
> 2009/11/25 Steven Dorigotti <dorigotti at koanlogic.com>
>>
>> Hi!
>>
>>  Ok, your problem is more clear to us now.
>>
>>  Please try the attached patch (using KLONE_TARGET_PATCH_FILE for
>> local build or KLONE_HOST_PATCH_FILE for cross-compilation) and setup
>> your base path in the kloned configuration file as follows:
>>
>>  chroot    c:/your/base/dir
>>
>>  The server will then do the SetCurrentDirectory() on MinGW as you
>> suggested.
>>
>> cheers,
>> sd
>>
>>
>> 2009/11/25 Mickael Auger <mickael.auger at gmail.com>:
>> > Hi Steven,
>> >
>> > thank you for response but it's my question (sorry :(  ).
>> > For example, I have an installation folder "C:\ProgramFiles\KLoneApp"
>> > what
>> > contains :
>> > - kloned.exe
>> > - config.ini (this file will be modify by another application)
>> >
>> > If I launch "kloned.exe" as standard application in MS-DOS console, the
>> > execution folder is "C:\ProgramFiles\KLoneApp".
>> > But if I install kloned as a Windows service and I launch "kloned.exe"
>> > with
>> > "net start kloned" command line, the execution folder is
>> > "C:\windows\system32".
>> >
>> > To read my "config.ini" file, I have this index.klx.
>> >
>> > ================================
>> > <html>
>> > <body>
>> > <%
>> > FILE *file;
>> > file = fopen("config.ini","r); //local file in
>> > "C:\ProgramFiles\KLoneApp"
>> > if(file)
>> > {
>> >   ...
>> >   fclose(file);
>> > }
>> > %>
>> > </body>
>> > </html>
>> > ================================
>> >
>> > I would be known this installation directory which contains "kloned.exe"
>> > to
>> > change the execution path by calling SetCurrentDirectory() Windows
>> > function.
>> > This installation directory is stored in Windows registry (in ImagePath
>> > key).
>> >
>> > This way, my KLone application could be execute regardless of standard
>> > application or service mode.
>> >
>> > Can you have a function (or a solution) to know this installation
>> > directory,
>> > please ?
>> >
>> > 2009/11/25 Steven Dorigotti <dorigotti at koanlogic.com>
>> >>
>> >> Hi Mickaël,
>> >>
>> >>  so you managed to cross-compile or in this case did you also compile
>> >> on
>> >> win?
>> >>
>> >>  The win service should point to the directory from which you ran
>> >> "kloned -i", so that should be your reference executable.
>> >>
>> >>  In order to access content on your local file system you need to
>> >> make sure the sup fs was setup correcly upon build, so:
>> >>
>> >> KLONE_CONF_ARGS += --enable_fs
>> >>
>> >>  and make sure the document root is setup correctly in your
>> >> configuration
>> >> file:
>> >>
>> >> dir_root        /path/to/dir/www
>> >>
>> >>  where the path should be relative to the msys installation  (in this
>> >> case for example c:\msys\1.0\path\to\dir\www)
>> >>
>> >>  Have you already done these steps and still have trouble?
>> >>
>> >> bye,
>> >> Steven
>> >>
>> >>
>> >> 2009/11/24 Mickael Auger <mickael.auger at gmail.com>:
>> >> > Hi,
>> >> >
>> >> > I compile and execute KLone as a Windows service, but I need to two
>> >> > informations.
>> >> >
>> >> > How can I know and / or change the run directory of kloned ?
>> >> >
>> >> > How can I know the folder containing the kloned binary ?
>> >> >
>> >> > Know this folders could me to manage a lot of personal file provided
>> >> > with
>> >> > kloned binary (in the install folder).
>> >> >
>> >> > Bye.
>> >> > --
>> >> > Mickaël AUGER
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > Klone-users mailing list
>> >> > Klone-users at koanlogic.com
>> >> > http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>> >> >
>> >> >
>> >>
>> >> _______________________________________________
>> >> Klone-users mailing list
>> >> Klone-users at koanlogic.com
>> >> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>> >
>> >
>> >
>> > --
>> > Mickaël AUGER
>> >
>> >
>> > _______________________________________________
>> > Klone-users mailing list
>> > Klone-users at koanlogic.com
>> > http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>> >
>> >
>>
>> _______________________________________________
>> Klone-users mailing list
>> Klone-users at koanlogic.com
>> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>>
>
>
>
> --
> Mickaël AUGER
>
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>
>




More information about the klone-users mailing list