harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r379605 - in /incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32: auth/ auth/auth_copyright.c auth/authnix.c auth/hyauth.exp auth/makefile makefile
Date Tue, 21 Feb 2006 22:15:33 GMT
Author: tellison
Date: Tue Feb 21 14:15:31 2006
New Revision: 379605

URL: http://svn.apache.org/viewcvs?rev=379605&view=rev
Log:
Adding linux version of auth natives

Added:
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/auth_copyright.c
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/authnix.c
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/hyauth.exp
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/makefile
Modified:
    incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/makefile

Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/auth_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/auth_copyright.c?rev=379605&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/auth_copyright.c
(added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/auth_copyright.c
Tue Feb 21 14:15:31 2006
@@ -0,0 +1,19 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * 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.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+  "(c) Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable.";

Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/authnix.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/authnix.c?rev=379605&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/authnix.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/authnix.c Tue Feb
21 14:15:31 2006
@@ -0,0 +1,150 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  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.
+ */
+
+/**
+ * @author Alexander V. Astapchuk
+ * @version $Revision$
+ */
+#if defined( _WINDOWS)
+#include <windows.h>
+BOOL APIENTRY DllMain( HANDLE hModule, 
+                       DWORD  ul_reason_for_call, 
+                       LPVOID lpReserved
+                     )
+{
+    return TRUE;
+}
+
+
+    #include "nixemu.h"
+#else
+    #include <unistd.h>
+    #include <pwd.h>
+    #include <grp.h>
+#endif // ifdef _WINDOWS
+
+#include <stdlib.h>
+#include <assert.h>
+
+#include "harmony.h"
+#include "jni.h"
+
+jfieldID jf_uid = NULL;
+jfieldID jf_username = NULL;
+jfieldID jf_gid = NULL;
+jfieldID jf_groupname = NULL;
+
+jfieldID jf_groups = NULL;
+jfieldID jf_groupsNames = NULL;
+
+jclass jclassString = NULL;
+
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_security_x_security_auth_module_UnixSystem_load
+  (JNIEnv * jenv, jobject thiz)
+{
+	PORT_ACCESS_FROM_ENV(jenv);
+
+    if( NULL == jf_uid ) {
+        jclass klass = (*jenv)->GetObjectClass (jenv, thiz);
+        if( NULL == klass ) {
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not obtain object's Class");
+            return;
+        }
+
+        if( NULL == (jf_uid = (*jenv)->GetFieldID (jenv, klass, "uid", "J"))) {
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"uid\" of type long");
+            return;
+        }
+        if( NULL == (jf_username = (*jenv)->GetFieldID (jenv, klass, "username", "Ljava/lang/String;")))
{
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"username\" of type
String");
+            return;
+        }
+        if( NULL == (jf_gid = (*jenv)->GetFieldID (jenv, klass, "gid", "J"))) {
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"gid\" of type long");
+            return;
+        }
+        if( NULL == (jf_groupname = (*jenv)->GetFieldID (jenv, klass, "groupname", "Ljava/lang/String;")))
{
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"groupname\" of
type String");
+            return;
+        }
+
+        if( NULL == (jf_groups = (*jenv)->GetFieldID (jenv, klass, "groups", "[J"))) {
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"groups\" of type
long[]");
+            return;
+        }
+        if( NULL == (jf_groupsNames = (*jenv)->GetFieldID (jenv, klass, "groupsNames",
"[Ljava/lang/String;"))) {
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not find field \"groupsNames\" of
type String[]");
+            return;
+        }
+        if( NULL == (jclassString = (*jenv)->FindClass (jenv, "java/lang/String")) ) {
+            jclass klassErr = (*jenv)->FindClass (jenv, "java/lang/Error");
+            assert(klassErr);
+            (*jenv)->ThrowNew (jenv, klassErr, "Could not find class java/lang/String");
+            return;
+        }
+        jclassString = (jclass)(*jenv)->NewGlobalRef (jenv, jclassString);
+    }
+
+    //
+    uid_t uid = getuid();
+    (*jenv)->SetLongField (jenv, thiz, jf_uid, (jlong)uid);
+    gid_t gid = getgid();
+    (*jenv)->SetLongField (jenv, thiz, jf_gid, (jlong)gid);
+    //
+    struct passwd * pp = getpwuid(uid);
+    (*jenv)->SetObjectField (jenv, thiz, jf_username, (*jenv)->NewStringUTF (jenv,
pp->pw_name));
+    //
+    struct group * pg = getgrgid(gid);
+    (*jenv)->SetObjectField (jenv, thiz, jf_groupname, (*jenv)->NewStringUTF (jenv,
pg->gr_name));
+    //
+    int gcount = getgroups(0, NULL);
+    if( 0 != gcount ) {
+        //
+        gid_t * gids = (gid_t*)hymem_allocate_memory(gcount*sizeof(gid_t));
+        //
+        getgroups(gcount, gids);
+        jlongArray jgs = (*jenv)->NewLongArray (jenv, gcount);
+        jlong * jgs_raw = (*jenv)->GetLongArrayElements (jenv, jgs, NULL);
+        jobjectArray jgsnames = (*jenv)->NewObjectArray (jenv, gcount, jclassString, NULL);
+        int i; 
+        for(i=0; i<gcount; i++ ) {
+            struct group * g = getgrgid(gids[i]);
+            jgs_raw[i] = g->gr_gid;
+            (*jenv)->SetObjectArrayElement (jenv, jgsnames, i, (*jenv)->NewStringUTF
(jenv, g->gr_name));
+        }
+        (*jenv)->ReleaseLongArrayElements (jenv, jgs, jgs_raw, 0); // here: 0='update
java array with the passed values'
+        (*jenv)->SetObjectField (jenv, thiz, jf_groups, jgs);
+        (*jenv)->SetObjectField (jenv, thiz, jf_groupsNames, jgsnames);
+        //
+        hymem_free_memory(gids);
+        //
+    };
+};

Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/hyauth.exp
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/hyauth.exp?rev=379605&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/hyauth.exp (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/hyauth.exp Tue Feb
21 14:15:31 2006
@@ -0,0 +1,7 @@
+HYAUTH_0.1 {
+	global :
+		Java_org_apache_harmony_security_x_security_auth_module_UnixSystem_load;
+		JNI_OnLoad;
+		JNI_OnUnload;
+	local : *;
+};

Added: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/makefile
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/makefile?rev=379605&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/makefile (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/auth/makefile Tue Feb
21 14:15:31 2006
@@ -0,0 +1,44 @@
+# Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+# 
+# 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.
+
+#
+# Makefile for module 'auth'
+#
+
+include ../makefile.include
+
+DLLFILENAME=libhyauth.so# declaration
+
+DLLNAME=../libhyauth.so# declaration
+
+LIBNAME=hyauth# declaration
+
+LIBPATH=../lib/# declaration
+
+CFLAGS= -fpic -DLINUX -D_REENTRANT -O1 -march=pentium3 -DIPv6_FUNCTION_SUPPORT  -DHYX86 -I../include
$(VMDEBUG)
+
+BUILDFILES = \
+	auth_copyright.o authnix.o
+
+all: $(DLLNAME)
+
+$(DLLNAME): $(BUILDFILES) $(MDLLIBFILES)
+	$(DLL_LD) -shared -Wl,--version-script,$(LIBNAME).exp \
+	-Wl,-soname=$(DLLFILENAME) $(VMLINK) -L.  -L../lib -L.. -o $(DLLNAME) \
+	$(BUILDFILES) -Xlinker --start-group \
+	-Xlinker --end-group  -lc -lm -ldl
+
+clean:
+	-rm -f *.o
+	-rm -f $(DLLNAME)

Modified: incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/makefile
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/makefile?rev=379605&r1=379604&r2=379605&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/makefile (original)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/linux.IA32/makefile Tue Feb 21 14:15:31
2006
@@ -18,9 +18,12 @@
 
 all: \
 	_sig _common _pool _thread _port _fdlibm _zip \
-	_zlib _vmi _luni _nio _archive \
+	_zlib _vmi _luni _nio _archive _auth \
 	_math _text _launcher
 
+_auth:
+	(cd auth && $(MAKE) & cd ..)
+
 _pool: 
 	(cd pool && $(MAKE) && cd ..)
 
@@ -67,6 +70,7 @@
 	(cd launcher && $(MAKE) && cd ..)	
 
 clean:
+	(cd auth && $(MAKE) clean && cd ..)
 	(cd sig && $(MAKE) clean && cd ..)
 	(cd pool  && $(MAKE) clean && cd ..)
 	(cd thread && $(MAKE) clean && cd ..)



Mime
View raw message