Page 1 of 1

Update for SQLite for Linux

Posted: 24.10.2010, 18:10
by mmvisual
Hello,

I have the problem, when file "libsqlite3.so" is not installed in the folder /lib then the database would not work.
I have copy this SO into the same folder from the application, but it does not work.

I want make a application where can run with a simple USB Stick without installation. In Windows, it works fine. But in Linux the system seek only in the folder /lib.

Can I do alter the file ZPlainSqlLiteDriver.pas:

constructor TZSQLite3PlainDriver.Create;
begin
inherited Create;
{$IFNDEF UNIX}
FLoader.AddLocation(WINDOWS_DLL3_LOCATION);
{$ELSE}
if FileExists('./' + LINUX_DLL3_LOCATION) then
FLoader.AddLocation('./' + LINUX_DLL3_LOCATION)
else
FLoader.AddLocation(LINUX_DLL3_LOCATION);
{$ENDIF}
end;

What think you about this?
Is it possible include it into V7.0.1 ?

Thanks for answer, regards Markus

Posted: 25.10.2010, 08:01
by marcov
I think this is a very bad security hazard.

Search for LD_LIBRARY_PATH for a more UNIX way to solve your problem.

Posted: 25.10.2010, 16:27
by mmvisual
Why is it a security risc?

For exaple, there gives a lot of other tools who want running on USB Stick without installation and use SQLite. I want build so an application.

One customer have an problem with the SQLite SO file, I have write him to do:
sudo apt-get install sqlite3
but the install said, all are allready existing, but zeos said, the libsqlite3.so file is not found.

When Zeos find the so file in the same folder as the application is, then there where no Problem. I'm not a linux expert, the costomer have need 3 days to find out the mistake.

I want make more easy my application. I have change my ZEOS code and it works fine.

Posted: 07.11.2010, 23:21
by mdaems
mmvisual,
I'm not sure it's a security hazard either. But if somebody can help us with the real 'UNIX/LINUX way' we should use that method, I believe.
You can make your code easier:

Code: Select all

{$IFNDEF UNIX} 
FLoader.AddLocation(WINDOWS_DLL3_LOCATION); 
{$ELSE} 
FLoader.AddLocation('./' + LINUX_DLL3_LOCATION) 
FLoader.AddLocation(LINUX_DLL3_LOCATION); 
{$ENDIF} 
Testing for existance is done automatically.
BTW : I'm looking for someone who can help me making 'Adding locations' possible from outside the zeoslib code. If you can find a way to implement this I hope you can share this with us.

Mark

Posted: 08.11.2010, 21:28
by mmvisual
I have change the code to your example and test it.

It works fine, you can include it into your sourcecode.

Thank you very much.

Best regards, Markus

Posted: 10.11.2010, 21:29
by mdaems
Markus,

I'm not trying to make it more difficult for you, but I'm not adding this code without some more background information on how LINUX loads a library when no full or relative path is passed to the call dlopen(Modulename, RTLD_GLOBAL) with RTLD_GLOBAL=$101
In windows the search order is clear : current dir of application exe and then the system path is checked.
How does this work in LINUX?
If the answer turns out the only way to have Windows-like behaviour is adding the './' location, I'll do so. But some more reading has to be done now...

Mark