Howto create a shared library with self-restrict loading?

Howto create a shared library with self-restrict loading?

Post by Le » Thu, 03 Jul 2003 17:56:47



Hi

Is it possible on Unix to create a shared library that will allow/deny
load to specified proceses (executables) ?

I mean the same thing than in DLLs' is done by something like that:

BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
{
    if(dwReason == DLL_PROCESS_ATTACH){
        /* Check who's loading us.
         * and return FALSE to deny load or return TRUE to permit load */
    }

Quote:}

I'd be grateful for any help.

RL

 
 
 

Howto create a shared library with self-restrict loading?

Post by M?ns Rullg? » Thu, 03 Jul 2003 18:11:04



> Is it possible on Unix to create a shared library that will allow/deny
> load to specified proceses (executables) ?

> I mean the same thing than in DLLs' is done by something like that:

> BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
> {
>     if(dwReason == DLL_PROCESS_ATTACH){
>    /* Check who's loading us.
>     * and return FALSE to deny load or return TRUE to permit load */
>     }
> }

> I'd be grateful for any help.

In Unix, such things are usually achieved by setting appropriate file
permissions.  If you can't read the file, you can't use it.

--
M?ns Rullg?rd


 
 
 

Howto create a shared library with self-restrict loading?

Post by David Schwart » Thu, 03 Jul 2003 21:54:05



Quote:> Is it possible on Unix to create a shared library that will allow/deny
> load to specified proceses (executables) ?

    You could write an appropriate _init function.

    DS

 
 
 

1. Shared library loading shared library.

  I was wondering if someone could tell me how(if possible) this can be done.

  I am writing a shared library that an executable will load int at runtime.  The
shared library I wrote needs to use symbols and functions from another shared
library that was not part of the link line of the executable.  Is there a way for
a shared library to tell the executable that it needs other library loaded that the
executable didn't link in.

  Is there a command line option to ld when creating a shareed library to use
other libraries?

  Is there a link option for the executable to shared libraries to link in other
shared libraries not in the link line?

Illustration
----------
Executable:
CC -o myProgram *.o -lmyLib

My shared library:
ld -G -b -o libmyLib.so
  ** myLib needs another library libotherLib.so

PS.  I am using SUNWspro CC4.1 compiler.

Thanks for any help,
Greg.

--
Gregory Gee
Nortel ISPN
Phone: (613)763-6175 ESN 393


2. Linux Xwindows setup problem.

3. How to create shared load library for java to put native methods??

4. advice needed on new system to run Linux

5. error in loading shared libraries: libXmu.so.6: cannot open shared object

6. When to get tcl7.6 and tk4.2 ?

7. Shared variable between main() and loaded shared library - dlopen()

8. System copy to new harddisk

9. Self-initializing shared library?

10. Howto create a user w/ restricted commands

11. Will strip(debug shared library) == nodebug shared library ?

12. Help with building shared libraries with dependencies on other shared libraries

13. Question: Inclusion of shared libraries during linking of shared libraries