Update for SQLite for Linux

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
mmvisual
Senior Boarder
Senior Boarder
Posts: 51
Joined: 13.10.2010, 14:55

Update for SQLite for Linux

Post 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
marcov
Senior Boarder
Senior Boarder
Posts: 95
Joined: 24.06.2010, 09:17

Post 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.
mmvisual
Senior Boarder
Senior Boarder
Posts: 51
Joined: 13.10.2010, 14:55

Post 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.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
mmvisual
Senior Boarder
Senior Boarder
Posts: 51
Joined: 13.10.2010, 14:55

Post 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
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Locked