Pier, Pier Fumagalli wrote: > > Patrick... System.loadlibrary (or however is called), does the exact > opposite of what we need... We ship a binary that will load the JVM library, > we don't rely on the JVM binary to load a library...
Maybe I should clarify what I am trying to do. I am trying to enable the use of setuid() within the existing Tomcat startup process (i.e. shell scripts). I definitely like your native launcher and the more I look at it, the more I like its sophisticated function. I just want to make the setuid() call available even if I haven't startup Tomcat using your native launcher. The way to do that is to use the Java->JNI method of creating a shared library that contains a function with a name that matches a demangled version of a "public native" Java method. Then, when Tomcat is started via a script (as it does now), the StandardServer class can do the following: - Invoke System.loadLibrary() - Bind all of the ports (if you are root, you can bind to ports <= 1024) - If we are root, invoke a "public native" method that Java maps to the C function contained in the shared library. The C function would contain the setuid() C call to change the Java process to a non-root user The above method effectively does the same thing as your native launcher. The only difference is that I thought it might be a may to get your setuid code into the standard Tomcat installations much sooner since my proposed approach is compatible with the existing Tomcat configuration and startup. I think the only changes to support my proposed approach in your native code are the following: - Add a "public static native" method in DaemonLoader.java - Create a DaemonLoader.h file using javah - Implement the setuid() calls for the function defined in DaemonLoader.h in DaemonLoader.c. Specifically, I could just move the child process' code in the checkuser function here so that there is not duplication of code. - Add compiling and linking of DaemonLoader.c into a shared library that the Java System.loadLibrary() call can handle. - Add calling of this "public static native" method from Tomcat's StandardService.initialize() method (i.e. after all ports have been bound). > > Also, if you need to do some callbacks from Java into our native C code, the > easiest thing is to register those right after invoking CreateJavaVM in JNI > (and it works), rather than relying on an external library... > I was thinking that once we have the above method implemented, we could try replacing the existing scripts with the native launchers. At that point, the System.loadLibrary() call in Tomcat could be removed since the native launcher could register the JNI C function that the "public native" method maps to. What do you think of the above approach? Thanks, Patrick -- _____________________________________________________________________ Patrick Luby Email: [EMAIL PROTECTED] Sun Microsystems Phone: 408-276-7471 901 San Antonio Road, USCA14-303 Palo Alto, CA 94303-4900 _____________________________________________________________________ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>