Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 27181 invoked from network); 21 Feb 2006 22:15:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Feb 2006 22:15:58 -0000 Received: (qmail 61419 invoked by uid 500); 21 Feb 2006 22:15:58 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 61344 invoked by uid 500); 21 Feb 2006 22:15:57 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 61333 invoked by uid 99); 21 Feb 2006 22:15:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Feb 2006 14:15:57 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 21 Feb 2006 14:15:56 -0800 Received: (qmail 26985 invoked by uid 65534); 21 Feb 2006 22:15:36 -0000 Message-ID: <20060221221536.26983.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: harmony-commits@incubator.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.6 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + return TRUE; +} + + + #include "nixemu.h" +#else + #include + #include + #include +#endif // ifdef _WINDOWS + +#include +#include + +#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; igr_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 ..)