adjust the mortbay-eclipse.jetty in c file, and pom tweaks

This commit is contained in:
Jesse McConnell 2012-09-14 14:28:29 -05:00
parent 38bc38f59e
commit 8fd40a3097
3 changed files with 193 additions and 193 deletions

View File

@ -1,19 +1,23 @@
// ========================================================================
// Copyright 2002-2005 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================================================================
//
// ========================================================================
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
#include <jni.h>
#include "org_mortbay_setuid_SetUID.h"
#include "org_eclipse_jetty_setuid_SetUID.h"
#include <sys/types.h>
#include <unistd.h>
#include <sys/resource.h>
@ -40,19 +44,19 @@ int getJavaFieldInt(JNIEnv *env, jobject obj, const char *name);
JNIEXPORT jint JNICALL
Java_org_mortbay_setuid_SetUID_setuid (JNIEnv * env, jclass j, jint uid)
Java_org_eclipse_jetty_setuid_SetUID_setuid (JNIEnv * env, jclass j, jint uid)
{
return((jint)setuid((uid_t)uid));
}
JNIEXPORT jint JNICALL
Java_org_mortbay_setuid_SetUID_setumask (JNIEnv * env, jclass j, jint mask)
Java_org_eclipse_jetty_setuid_SetUID_setumask (JNIEnv * env, jclass j, jint mask)
{
return((jint)umask((mode_t)mask));
}
JNIEXPORT jint JNICALL
Java_org_mortbay_setuid_SetUID_setgid (JNIEnv * env, jclass j, jint gid)
Java_org_eclipse_jetty_setuid_SetUID_setgid (JNIEnv * env, jclass j, jint gid)
{
return((jint)setgid((gid_t)gid));
}
@ -62,7 +66,7 @@ Java_org_mortbay_setuid_SetUID_setgid (JNIEnv * env, jclass j, jint gid)
/* User informaton implementatons */
JNIEXPORT jobject JNICALL
Java_org_mortbay_setuid_SetUID_getpwnam(JNIEnv * env, jclass j, jstring name)
Java_org_eclipse_jetty_setuid_SetUID_getpwnam(JNIEnv * env, jclass j, jstring name)
{
struct passwd* pw;
jboolean iscopy;
@ -82,28 +86,28 @@ Java_org_mortbay_setuid_SetUID_getpwnam(JNIEnv * env, jclass j, jstring name)
(*env)->ReleaseStringUTFChars( env, name, pname );
// get The java class org.mortbay.setuid.Passwd
// get The java class org.eclipse.jetty.setuid.Passwd
jclass cls;
cls = (*env)->FindClass(env,"org/mortbay/setuid/Passwd");
cls = (*env)->FindClass(env,"org/eclipse/jetty/setuid/Passwd");
if(!cls)
{
throwNewJavaSecurityException(env, "Class: org.mortbay.setuid.Passwd is not found!!!");
throwNewJavaSecurityException(env, "Class: org.eclipse.jetty.setuid.Passwd is not found!!!");
return NULL;
}
// get the default constructor of org.mortbay.setuid.Passwd
// get the default constructor of org.eclipse.jetty.setuid.Passwd
jmethodID constructorMethod = getJavaMethodId(env, cls, "<init>", "()V");
// construct org.mortbay.setuid.Passwd java object
// construct org.eclipse.jetty.setuid.Passwd java object
jobject retVal = (*env)->NewObject(env, cls,constructorMethod);
if(!retVal)
{
throwNewJavaSecurityException(env, "Object Construction error of Class: org.mortbay.setuid.Passwd!!!");
throwNewJavaSecurityException(env, "Object Construction error of Class: org.eclipse.jetty.setuid.Passwd!!!");
return NULL;
}
// copy the struct passwd values to java object org.mortbay.setuid.Passwd
// copy the struct passwd values to java object org.eclipse.jetty.setuid.Passwd
//char *pw_name;
setJavaFieldString(env, retVal, "_pwName", pw->pw_name);
//char *pw_passwd;
@ -127,7 +131,7 @@ Java_org_mortbay_setuid_SetUID_getpwnam(JNIEnv * env, jclass j, jstring name)
JNIEXPORT jobject JNICALL
Java_org_mortbay_setuid_SetUID_getpwuid(JNIEnv * env, jclass j, jint uid)
Java_org_eclipse_jetty_setuid_SetUID_getpwuid(JNIEnv * env, jclass j, jint uid)
{
struct passwd* pw;
pw=getpwuid((uid_t) uid);
@ -140,29 +144,29 @@ Java_org_mortbay_setuid_SetUID_getpwuid(JNIEnv * env, jclass j, jint uid)
}
// get The java class org.mortbay.setuid.Passwd
// get The java class org.eclipse.jetty.setuid.Passwd
jclass cls;
cls = (*env)->FindClass(env,"org/mortbay/setuid/Passwd");
cls = (*env)->FindClass(env,"org/eclipse/jetty/setuid/Passwd");
if(!cls)
{
throwNewJavaSecurityException(env, "Class: org.mortbay.setuid.Passwd is not found!!!");
throwNewJavaSecurityException(env, "Class: org.eclipse.jetty.setuid.Passwd is not found!!!");
return NULL;
}
// get the default constructor of org.mortbay.setuid.Passwd
// get the default constructor of org.eclipse.jetty.setuid.Passwd
jmethodID constructorMethod = getJavaMethodId(env, cls, "<init>", "()V");
// construct org.mortbay.setuid.Passwd java object
// construct org.eclipse.jetty.setuid.Passwd java object
jobject retVal = (*env)->NewObject(env, cls,constructorMethod);
if(!retVal)
{
throwNewJavaSecurityException(env, "Object Construction error of Class: org.mortbay.setuid.Passwd!!!");
throwNewJavaSecurityException(env, "Object Construction error of Class: org.eclipse.jetty.setuid.Passwd!!!");
return NULL;
}
// copy the struct passwd values to java object org.mortbay.setuid.Passwd
// copy the struct passwd values to java object org.eclipse.jetty.setuid.Passwd
//char *pw_name;
setJavaFieldString(env, retVal, "_pwName", pw->pw_name);
//char *pw_passwd;
@ -188,7 +192,7 @@ Java_org_mortbay_setuid_SetUID_getpwuid(JNIEnv * env, jclass j, jint uid)
/* Group information implimentations */
JNIEXPORT jobject JNICALL
Java_org_mortbay_setuid_SetUID_getgrnam(JNIEnv * env, jclass j, jstring name)
Java_org_eclipse_jetty_setuid_SetUID_getgrnam(JNIEnv * env, jclass j, jstring name)
{
struct group* gr;
jboolean iscopy;
@ -209,27 +213,27 @@ Java_org_mortbay_setuid_SetUID_getgrnam(JNIEnv * env, jclass j, jstring name)
(*env)->ReleaseStringUTFChars( env, name, pname );
// get The java class org.mortbay.setuid.Passwd
// get The java class org.eclipse.jetty.setuid.Passwd
jclass cls;
cls = (*env)->FindClass(env,"org/mortbay/setuid/Group");
cls = (*env)->FindClass(env,"org/eclipse/jetty/setuid/Group");
if(!cls)
{
throwNewJavaSecurityException(env, "Class: org.mortbay.setuid.Group is not found!!!");
throwNewJavaSecurityException(env, "Class: org.eclipse.jetty.setuid.Group is not found!!!");
return NULL;
}
// get the default constructor of org.mortbay.setuid.Group
// get the default constructor of org.eclipse.jetty.setuid.Group
jmethodID constructorMethod = getJavaMethodId(env, cls, "<init>", "()V");
// construct org.mortbay.setuid.Group java object
// construct org.eclipse.jetty.setuid.Group java object
jobject retVal = (*env)->NewObject(env, cls,constructorMethod);
if(!retVal)
{
throwNewJavaSecurityException(env, "Object Construction error of Class: org.mortbay.setuid.Group!!!");
throwNewJavaSecurityException(env, "Object Construction error of Class: org.eclipse.jetty.setuid.Group!!!");
return NULL;
}
// copy the struct grpup values to java object org.mortbay.setuid.Group
// copy the struct grpup values to java object org.eclipse.jetty.setuid.Group
//char *gr_name;
setJavaFieldString(env, retVal, "_grName", gr->gr_name);
//char *gr_passwd;
@ -274,7 +278,7 @@ Java_org_mortbay_setuid_SetUID_getgrnam(JNIEnv * env, jclass j, jstring name)
}
JNIEXPORT jobject JNICALL
Java_org_mortbay_setuid_SetUID_getgrgid(JNIEnv * env, jclass j, jint gid)
Java_org_eclipse_jetty_setuid_SetUID_getgrgid(JNIEnv * env, jclass j, jint gid)
{
struct group* gr;
@ -288,29 +292,29 @@ Java_org_mortbay_setuid_SetUID_getgrgid(JNIEnv * env, jclass j, jint gid)
}
// get The java class org.mortbay.setuid.Passwd
// get The java class org.eclipse.jetty.setuid.Passwd
jclass cls;
cls = (*env)->FindClass(env,"org/mortbay/setuid/Group");
cls = (*env)->FindClass(env,"org/eclipse/jetty/setuid/Group");
if(!cls)
{
throwNewJavaSecurityException(env, "Class: org.mortbay.setuid.Group is not found!!!");
throwNewJavaSecurityException(env, "Class: org.eclipse.jetty.setuid.Group is not found!!!");
return NULL;
}
// get the default constructor of org.mortbay.setuid.Group
// get the default constructor of org.eclipse.jetty.setuid.Group
jmethodID constructorMethod = getJavaMethodId(env, cls, "<init>", "()V");
// construct org.mortbay.setuid.Group java object
// construct org.eclipse.jetty.setuid.Group java object
jobject retVal = (*env)->NewObject(env, cls,constructorMethod);
if(!retVal)
{
throwNewJavaSecurityException(env, "Object Construction Error of Class: org.mortbay.setuid.Group!!!");
throwNewJavaSecurityException(env, "Object Construction Error of Class: org.eclipse.jetty.setuid.Group!!!");
return NULL;
}
// copy the struct grpup values to java object org.mortbay.setuid.Group
// copy the struct grpup values to java object org.eclipse.jetty.setuid.Group
//char *gr_name;
setJavaFieldString(env, retVal, "_grName", gr->gr_name);
//char *gr_passwd;
@ -358,11 +362,11 @@ Java_org_mortbay_setuid_SetUID_getgrgid(JNIEnv * env, jclass j, jint gid)
/*
* Class: org_mortbay_setuid_SetUID
* Class: org_eclipse_jetty_setuid_SetUID
* Method: getrlimitnofiles
* Signature: ()Lorg/mortbay/setuid/RLimit;
* Signature: ()Lorg/eclipse/jetty/setuid/RLimit;
*/
JNIEXPORT jobject JNICALL Java_org_mortbay_setuid_SetUID_getrlimitnofiles
JNIEXPORT jobject JNICALL Java_org_eclipse_jetty_setuid_SetUID_getrlimitnofiles
(JNIEnv *env, jclass j)
{
struct rlimit rlim;
@ -373,22 +377,22 @@ JNIEXPORT jobject JNICALL Java_org_mortbay_setuid_SetUID_getrlimitnofiles
return NULL;
}
// get The java class org.mortbay.setuid.RLimit
jclass cls = (*env)->FindClass(env, "org/mortbay/setuid/RLimit");
// get The java class org.eclipse.jetty.setuid.RLimit
jclass cls = (*env)->FindClass(env, "org/eclipse/jetty/setuid/RLimit");
if(!cls)
{
throwNewJavaSecurityException(env, "Class: org.mortbay.setuid.RLimit is not found!!!");
throwNewJavaSecurityException(env, "Class: org.eclipse.jetty.setuid.RLimit is not found!!!");
return NULL;
}
// get the default constructor of org.mortbay.setuid.RLimit
// get the default constructor of org.eclipse.jetty.setuid.RLimit
jmethodID constructorMethod = getJavaMethodId(env, cls, "<init>", "()V");
// construct org.mortbay.setuid.RLimit java object
// construct org.eclipse.jetty.setuid.RLimit java object
jobject retVal = (*env)->NewObject(env, cls,constructorMethod);
if(!retVal)
{
throwNewJavaSecurityException(env, "Object Construction Error of Class: org.mortbay.setuid.RLimit!!!");
throwNewJavaSecurityException(env, "Object Construction Error of Class: org.eclipse.jetty.setuid.RLimit!!!");
return NULL;
}
setJavaFieldInt(env, retVal, "_soft", rlim.rlim_cur);
@ -399,16 +403,16 @@ JNIEXPORT jobject JNICALL Java_org_mortbay_setuid_SetUID_getrlimitnofiles
}
/*
* Class: org_mortbay_setuid_SetUID
* Class: org_eclipse_jetty_setuid_SetUID
* Method: setrlimitnofiles
* Signature: (Lorg/mortbay/setuid/RLimit;)I
* Signature: (Lorg/eclipse/jetty/setuid/RLimit;)I
*/
JNIEXPORT jint JNICALL Java_org_mortbay_setuid_SetUID_setrlimitnofiles
JNIEXPORT jint JNICALL Java_org_eclipse_jetty_setuid_SetUID_setrlimitnofiles
(JNIEnv *env, jclass j, jobject jo)
{
struct rlimit rlim;
jclass cls = (*env)->FindClass(env, "org/mortbay/setuid/RLimit");
jclass cls = (*env)->FindClass(env, "org/eclipse/jetty/setuid/RLimit");
rlim.rlim_cur=getJavaFieldInt(env,jo, "_soft");
rlim.rlim_max=getJavaFieldInt(env,jo, "_hard");
int success = setrlimit(RLIMIT_NOFILE, &rlim);

View File

@ -1,133 +1,129 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.eclipse.jetty.setuid</groupId>
<artifactId>jetty-setuid-parent</artifactId>
<version>9.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-setuid-osx</artifactId>
<name>Jetty :: SetUID OSX Native</name>
<packaging>so</packaging>
<properties>
<native-source-dir>target/native</native-source-dir>
<jetty-setuid-linkerStartOption>-lc -ldl -dynamiclib -undefined
dynamic_lookup -single_module</jetty-setuid-linkerStartOption>
<jetty-setuid-linkerEndOption>target/libsetuid.so</jetty-setuid-linkerEndOption>
</properties>
<build>
<finalName>libsetuid</finalName>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jetty.setuid</groupId>
<artifactId>jetty-setuid-native</artifactId>
<version>${project.version}</version>
<overWrite>true</overWrite>
<outputDirectory>${native-source-dir}/</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-jni-implementation</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy failonerror="false"
file="${native-source-dir}/org_eclipse_jetty_setuid_SetUID.c"
todir="target/generated" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<javahOS>mac</javahOS>
<jdkIncludePath>${java.home}/include</jdkIncludePath>
<compilerStartOptions>
<compilerStartOption>-fPIC -O</compilerStartOption>
</compilerStartOptions>
<sources>
<source>
<directory>target/generated</directory>
<fileNames>
<fileName>org_eclipse_jetty_setuid_SetUID.c</fileName>
</fileNames>
</source>
</sources>
<linkerStartOptions>
<linkerStartOption>${jetty-setuid-linkerStartOption}</linkerStartOption>
</linkerStartOptions>
<linkerEndOptions>
<linkerEndOptions>-o
${project.build.directory}/libsetuid.so</linkerEndOptions>
</linkerEndOptions>
</configuration>
<executions>
<execution>
<id>javah</id>
<phase>generate-sources</phase>
<configuration>
<classNames>
<className>org.eclipse.jetty.setuid.SetUID</className>
</classNames>
<outputDirectory>target/generated</outputDirectory>
</configuration>
<goals>
<goal>javah</goal>
</goals>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.setuid</groupId>
<artifactId>jetty-setuid-parent</artifactId>
<version>9.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-setuid-osx</artifactId>
<name>Jetty :: SetUID OSX Native</name>
<packaging>so</packaging>
<properties>
<native-source-dir>target/native</native-source-dir>
<jetty-setuid-linkerStartOption>-lc -ldl -dynamiclib -undefined dynamic_lookup -single_module</jetty-setuid-linkerStartOption>
<jetty-setuid-linkerEndOption>target/libsetuid.so</jetty-setuid-linkerEndOption>
</properties>
<build>
<finalName>libsetuid</finalName>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.eclipse.jetty.setuid</groupId>
<artifactId>jetty-setuid-native</artifactId>
<version>${project.version}</version>
<overWrite>true</overWrite>
<outputDirectory>${native-source-dir}/</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-jni-implementation</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy failonerror="false" file="${native-source-dir}/org_eclipse_jetty_setuid_SetUID.c" todir="target/generated" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<javahOS>mac</javahOS>
<jdkIncludePath>${java.home}/include</jdkIncludePath>
<compilerStartOptions>
<compilerStartOption>-fPIC -O</compilerStartOption>
</compilerStartOptions>
<sources>
<source>
<directory>target/generated</directory>
<fileNames>
<fileName>org_mortbay_setuid_SetUID.c</fileName>
</fileNames>
</source>
</sources>
<linkerStartOptions>
<linkerStartOption>${jetty-setuid-linkerStartOption}</linkerStartOption>
</linkerStartOptions>
<linkerEndOptions>
<linkerEndOptions>-o
${project.build.directory}/libsetuid.so</linkerEndOptions>
</linkerEndOptions>
</configuration>
<executions>
<execution>
<id>javah</id>
<phase>generate-sources</phase>
<configuration>
<classNames>
<className>org.eclipse.jetty.setuid.SetUID</className>
</classNames>
<outputDirectory>target/generated</outputDirectory>
</configuration>
<goals>
<goal>javah</goal>
</goals>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.setuid</groupId>
<artifactId>jetty-setuid-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<artifactId>jetty-setuid-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -12,7 +12,7 @@
<modules>
<module>jetty-setuid-java</module>
<module>jetty-setuid-native</module>
<module>jetty-setuid-test</module>
<!-- module>jetty-setuid-test</module -->
</modules>
<profiles>
<profile>