Results 1 to 10 of 10

Thread: Shared lib template broken under linux ???

  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry Shared lib template broken under linux ???

    Hi,

    A project of mine is splitted in two components : an executable and a shared lib. It compiles and run fine under window$ (mingw3.4.2, win ME) but when I tried to compile it under my linux distro (Kanotix 2005-4, GCC 4.0.1) the .so occured to cause troubles...

    Firts of all I believed that any shared lib neede an import lib (.a in my case) but none was created... Thus I had to change my project file but it finally compiled fine. Second step : running the app. My executable is in the same directory as my .so, the makefile created 3 symlinks to it to make sure it can't get lost...
    And the executable doesn't find the library!!!
    Quote Originally Posted by it
    error while loading shared libraries: libdevqt.so.1: cannot open shared object file: No such file or directory
    I tried changing the name of the real shared library to avoid troubles with symlinks but it didn't change anyhting!
    Help me!!!
    Current Qt projects : QCodeEdit, RotiDeCode

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    52
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Shared lib template broken under linux ???

    hmm... would it help if you provide the .pro files?

    I use the QPluginLoader class for my project and so far have no problems with main app loading the plugin on Windows or Linux.

    Mike

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Shared lib template broken under linux ???

    Quote Originally Posted by fullmetalcoder
    Firts of all I believed that any shared lib neede an import lib (.a in my case) but none was created...
    Only crappy OSes need it.

    Second step : running the app. My executable is in the same directory as my .so, the makefile created 3 symlinks to it to make sure it can't get lost...
    And the executable doesn't find the library!!!

    I tried changing the name of the real shared library to avoid troubles with symlinks but it didn't change anyhting!
    Linux doesn't look for libraries in the "current directory". You have to tell it where to look for the lib. For example by issuing:
    Qt Code:
    1. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
    To copy to clipboard, switch view to plain text mode 

    or simply:

    Qt Code:
    1. LD_LIBRARY_PATH=. ./devqt
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Shared lib template broken under linux ???

    Maybe only crap OSes need import lib but then only crap OSes forget to look in the current dir to find shared libs!!!
    Is there a way to do that programmatically because I don't wanna force each user of my app to do that stupid trick on its own... I think there some QApplication static functions that deals with library paths but will they work from the application itself or will loading fail before the static function is called???
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #5
    Join Date
    Jan 2006
    Posts
    24
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Shared lib template broken under linux ???

    Quote Originally Posted by fullmetalcoder
    Maybe only crap OSes need import lib but then only crap OSes forget to look in the current dir to find shared libs!!!
    Is there a way to do that programmatically because I don't wanna force each user of my app to do that stupid trick on its own... I think there some QApplication static functions that deals with library paths but will they work from the application itself or will loading fail before the static function is called???
    Predefined library path avoid security problems, for launch application write a simple script:

    Qt Code:
    1. #!/bin/bash
    2. export DEVQT_HOME=/path/to/data/files/
    3. export LD_LIBRARY_PATH=${DEVQT_HOME}/lib
    4.  
    5. #and launch app
    6. ${DEVQT_HOME}/bin/devqt
    To copy to clipboard, switch view to plain text mode 

    in MacOsX LD_LIBRARY_PATH is DYLD_LIBRARY_PATH

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Shared lib template broken under linux ???

    Quote Originally Posted by fullmetalcoder
    Maybe only crap OSes need import lib but then only crap OSes forget to look in the current dir to find shared libs!!!
    If the loader was looking in the current dir for libraries, it would be trivial to poison any application by using a "modified" version of a library it uses. There are even viri/rootkits for Linux that use this and ld_preload mechanism to infect the system. If a user wants to alter the library path, it has to be her/his own decision.

  7. #7
    Join Date
    Jan 2006
    Posts
    109
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Shared lib template broken under linux ???

    Quote Originally Posted by wysota
    If the loader was looking in the current dir for libraries, it would be trivial to poison any application by using a "modified" version of a library it uses.
    Actually isn't this a misundesrtanding? As far as I know, on Windows the loader looks for DLLs in the application directory, not the current directory. This looks like a good idea and I don't think there are related security issues.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Shared lib template broken under linux ???

    What if you make a link to the application and somehow force the directory containing the link to be in the path before the directory containing the proper binary (without a poisoned lib in the same directory) or even execute the link yourself on purpose? Making a hard link (I don't know what about a symbolic one) will surely change the "application directory" which opens the security hole again.

  9. #9
    Join Date
    Jan 2006
    Posts
    24
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Shared lib template broken under linux ???

    Quote Originally Posted by dimitri
    Actually isn't this a misundesrtanding? As far as I know, on Windows the loader looks for DLLs in the application directory, not the current directory. This looks like a good idea and I don't think there are related security issues.
    Windows? ...

  10. #10
    Join Date
    Jan 2006
    Posts
    109
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Shared lib template broken under linux ???

    Quote Originally Posted by wysota
    What if you make a link to the application and somehow force the directory containing the link to be in the path before the directory containing the proper binary (without a poisoned lib in the same directory) or even execute the link yourself on purpose? Making a hard link (I don't know what about a symbolic one) will surely change the "application directory" which opens the security hole again.
    This cannot happen on Windows, can it?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.