svn commit: r769674 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/ main/native/ main/native/os/darwin/ main/native/os/linux/ main/native/os/solaris/ test/org/apache/com
Author: mturk Date: Wed Apr 29 06:20:38 2009 New Revision: 769674 URL: http://svn.apache.org/viewvc?rev=769674view=rev Log: Add users enum Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/linux/puser.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/solaris/puser.c (with props) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java commons/sandbox/runtime/trunk/src/main/native/Makefile.in commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestUser.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java?rev=769674r1=769673r2=769674view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Wed Apr 29 06:20:38 2009 @@ -39,8 +39,11 @@ Id = id; } -private static native Userget0(String name); +private static native Userget0(String name) +throws IOException, SecurityException; private static native boolean equals0(Descriptor a, Descriptor b); +private static native User[] enum0() +throws IOException, SecurityException, UnsupportedOperationException; /** * Create the {...@code User} object from the {...@code name}. @@ -60,6 +63,12 @@ return u; } +public static User[] getUsers() +throws IOException, SecurityException, UnsupportedOperationException +{ +return enum0(); +} + /** * String that specifies the name of the user account. */ Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=769674r1=769673r2=769674view=diff == --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Wed Apr 29 06:20:38 2009 @@ -87,6 +87,7 @@ $(SRCDIR)/os/unix/uutils.$(OBJ) \ $(SRCDIR)/os/linux/platform.$(OBJ) \ $(SRCDIR)/os/linux/pgroup.$(OBJ) \ + $(SRCDIR)/os/linux/puser.$(OBJ) \ $(SRCDIR)/os/linux/os.$(OBJ) SOLARIS_OBJS= \ @@ -99,6 +100,7 @@ $(SRCDIR)/os/unix/uutils.$(OBJ) \ $(SRCDIR)/os/solaris/platform.$(OBJ) \ $(SRCDIR)/os/solaris/pgroup.$(OBJ) \ + $(SRCDIR)/os/solaris/puser.$(OBJ) \ $(SRCDIR)/os/solaris/os.$(OBJ) DARWIN_OBJS= \ @@ -111,6 +113,7 @@ $(SRCDIR)/os/unix/uutils.$(OBJ) \ $(SRCDIR)/os/darwin/platform.$(OBJ) \ $(SRCDIR)/os/darwin/pgroup.$(OBJ) \ + $(SRCDIR)/os/darwin/puser.$(OBJ) \ $(SRCDIR)/os/darwin/os.$(OBJ) HPUX_OBJS= \ Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c?rev=769674view=auto == --- commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c Wed Apr 29 06:20:38 2009 @@ -0,0 +1,106 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +#include acr.h +#include acr_private.h +#include acr_arch.h +#include acr_clazz.h +#include acr_error.h +#include acr_memory.h +#include acr_string.h +#include acr_descriptor.h +#include acr_users.h + +#include pwd.h +#include grp.h + + +ACR_JNI_EXPORT_DECLARE(jobjectArray, Group, enum0)(ACR_JNISTDARGS) +{ +jobjectArray usrs = NULL; +struct passwd *pw; +jsize i, n = 0; +char **unames; + +UNREFERENCED_O; + +/* 1. stage - get the number of groups */ +setpwent(); +while (1) {
svn commit: r769676 - /commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c
Author: mturk Date: Wed Apr 29 06:23:05 2009 New Revision: 769676 URL: http://svn.apache.org/viewvc?rev=769676view=rev Log: Fix typos Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c?rev=769676r1=769675r2=769676view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/puser.c Wed Apr 29 06:23:05 2009 @@ -28,7 +28,7 @@ #include grp.h -ACR_JNI_EXPORT_DECLARE(jobjectArray, Group, enum0)(ACR_JNISTDARGS) +ACR_JNI_EXPORT_DECLARE(jobjectArray, User, enum0)(ACR_JNISTDARGS) { jobjectArray usrs = NULL; struct passwd *pw; @@ -72,7 +72,7 @@ setpwent(); for (i = 0; i n; i++) { pw = getpwent(); -if (gr) { +if (pw) { unames[i] = ACR_StrdupA(_E, THROW_FMARK, pw-pw_name); if (!unames[i]) { usrs = NULL; @@ -86,7 +86,7 @@ for (i = 0; i n; i++) { if (unames[i]) { jobject uid = ACR_UserObjectCreate(_E, unames[i]); -if ((*_E)-ExceptionCheck(_E) || gid == NULL) { +if ((*_E)-ExceptionCheck(_E) || uid == NULL) { /* Object creation failed */ break; }
svn commit: r769681 - in /commons/sandbox/runtime/trunk/src: main/native/os/win32/group.c main/native/os/win32/user.c test/org/apache/commons/runtime/TestGroup.java
Author: mturk Date: Wed Apr 29 06:49:17 2009 New Revision: 769681 URL: http://svn.apache.org/viewvc?rev=769681view=rev Log: Implement group and user lists on win32 Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c?rev=769681r1=769680r2=769681view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c Wed Apr 29 06:49:17 2009 @@ -142,7 +142,7 @@ rc = NetGroupGetInfo(NULL, name, 1, (LPBYTE *)pb); if (rc == ERROR_SUCCESS) { SET_IFIELD_W(, grp, pb-lgrpi1_name); -SET_IFIELD_C(0001, grp, pb-lgrpi1_comment); +SET_IFIELD_C(0001, grp, pb-lgrpi1_comment); NetApiBufferFree(pb); } else { @@ -180,3 +180,103 @@ return V2Z(EqualSid(gida, gidb)); } + +ACR_JNI_EXPORT_DECLARE(jobjectArray, Group, enum0)(ACR_JNISTDARGS) +{ + +DWORD resumehandle = 0, total; +PGROUP_INFO_0 pb; +DWORD res, dwRec, n, i = 0; +jsize j = 0, ngroups = 0; +jobjectArray grps = NULL; + +UNREFERENCED_O; +do { +res = NetLocalGroupEnum(NULL, 0, (LPBYTE *)pb, MAX_PREFERRED_LENGTH, +dwRec, total, (LPDWORD)resumehandle ); +if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) { +ngroups += dwRec; +NetApiBufferFree(pb); +} +} while (res == ERROR_MORE_DATA); +if (ngroups) +grps = (*_E)-NewObjectArray(_E, ngroups, _clazzn.i, NULL); +if (!grps) +return NULL; +resumehandle = 0; +do { +res = NetLocalGroupEnum(NULL, 0, (LPBYTE *)pb, MAX_PREFERRED_LENGTH, +dwRec, total, (LPDWORD)resumehandle ); +if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) { +for (n = 0; n dwRec; n++) { +if (j ngroups) { +jobject gid = ACR_GroupObjectCreate(_E, pb[n].grpi0_name); +if ((*_E)-ExceptionCheck(_E) || gid == NULL) { +NetApiBufferFree(pb); +grps = NULL; +goto cleanup; +} +(*_E)-SetObjectArrayElement(_E, grps, j, gid); +(*_E)-DeleteLocalRef(_E, gid); +} +j++; +} +NetApiBufferFree(pb); +} +} while (res == ERROR_MORE_DATA); + + +cleanup: +return grps; + +} + +ACR_JNI_EXPORT_DECLARE(jobjectArray, Group, enum1)(ACR_JNISTDARGS) +{ + +DWORD resumehandle = 0, total; +PGROUP_INFO_0 pb; +DWORD res, dwRec, n, i = 0; +jsize j = 0, ngroups = 0; +jobjectArray grps = NULL; + +UNREFERENCED_O; +do { +res = NetGroupEnum(NULL, 0, (LPBYTE *)pb, MAX_PREFERRED_LENGTH, + dwRec, total, (LPDWORD)resumehandle ); +if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) { +ngroups += dwRec; +NetApiBufferFree(pb); +} +} while (res == ERROR_MORE_DATA); +if (ngroups) +grps = (*_E)-NewObjectArray(_E, ngroups, _clazzn.i, NULL); +if (!grps) +return NULL; +resumehandle = 0; +do { +res = NetGroupEnum(NULL, 0, (LPBYTE *)pb, MAX_PREFERRED_LENGTH, + dwRec, total, (LPDWORD)resumehandle ); +if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) { +for (n = 0; n dwRec; n++) { +if (j ngroups) { +jobject gid = ACR_GroupObjectCreate(_E, pb[n].grpi0_name); +if ((*_E)-ExceptionCheck(_E) || gid == NULL) { +NetApiBufferFree(pb); +grps = NULL; +goto cleanup; +} +(*_E)-SetObjectArrayElement(_E, grps, j, gid); +(*_E)-DeleteLocalRef(_E, gid); +} +j++; +} +NetApiBufferFree(pb); +} +} while (res == ERROR_MORE_DATA); + + +cleanup: +return grps; + +} Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c?rev=769681r1=769680r2=769681view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Wed Apr 29 06:49:17 2009 @@ -284,3 +284,53 @@ return
svn commit: r769694 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/ test/org/apache/commons/runtime/
Author: mturk Date: Wed Apr 29 07:47:05 2009 New Revision: 769694 URL: http://svn.apache.org/viewvc?rev=769694view=rev Log: Use iterators Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIterator.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIteratorImpl.java (with props) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestUser.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java?rev=769694r1=769693r2=769694view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java Wed Apr 29 07:47:05 2009 @@ -48,7 +48,7 @@ /** - * Create the {...@code Group object from the {...@code name}. + * Create the {...@code Group} object from the {...@code name}. * * @return {...@code Group} obect. * @throws SecurityException if access to an internal group database @@ -65,16 +65,16 @@ return g; } -public static Group[] getLocalGroups() +public static GroupIterator getLocalGroups() throws IOException, SecurityException, UnsupportedOperationException { -return enum0(); +return new GroupIteratorImpl(enum0()); } -public static Group[] getGlobalGroups() +public static GroupIterator getGlobalGroups() throws IOException, SecurityException, UnsupportedOperationException { -return enum1(); +return new GroupIteratorImpl(enum1()); } /** Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java?rev=769694view=auto == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java Wed Apr 29 07:47:05 2009 @@ -0,0 +1,55 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.commons.runtime; + +import java.util.Iterator; + +/** + * Group Iterator + * + * @since Runtime 1.0 + */ +public abstract class GroupIterator +implements IteratorGroup, IterableGroup +{ +/** + * + */ +public abstract boolean hasNext(); + +/** + * + */ +public IteratorGroup iterator() +{ + return this; +} + +/** + * + */ +public abstract Group next(); + +/** + * + */ +public void remove() +{ +throw new UnsupportedOperationException(); +} + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java -- svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java?rev=769694view=auto == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java (added) +++
svn commit: r769704 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: Group.java GroupIterator.java GroupIteratorImpl.java User.java UserIterator.java UserIteratorImpl.java
Author: mturk Date: Wed Apr 29 08:17:21 2009 New Revision: 769704 URL: http://svn.apache.org/viewvc?rev=769704view=rev Log: Add javadocs and missing exceptions Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIteratorImpl.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIterator.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/UserIteratorImpl.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java?rev=769704r1=769703r2=769704view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java Wed Apr 29 08:17:21 2009 @@ -42,7 +42,7 @@ throws IOException, SecurityException; private static native boolean equals0(Descriptor a, Descriptor b); private static native Group[] enum0() -throws IOException, SecurityException, UnsupportedOperationException; +throws IOException, SecurityException; private static native Group[] enum1() throws IOException, SecurityException, UnsupportedOperationException; @@ -65,12 +65,32 @@ return g; } +/** + * Get the {...@link GroupIterator} of all {...@code local} groups defined + * on this system. + * + * @return GroupIterator containing all {...@code local} groups. + * @throws IOException in case of I/O error. + * @throws SecurityException if the current user is not allowed to + * access the system group database. + */ public static GroupIterator getLocalGroups() -throws IOException, SecurityException, UnsupportedOperationException +throws IOException, SecurityException { return new GroupIteratorImpl(enum0()); } +/** + * Get the {...@link GroupIterator} of all {...@code local} groups defined + * on this system. + * + * @return GroupIterator containing all {...@code local} groups. + * @throws IOException in case of I/O error. + * @throws SecurityException if the current user is not allowed to + * access the system group database. + * @throws UnsupportedOperationException if the operating system does not + * support the global groups concept. + */ public static GroupIterator getGlobalGroups() throws IOException, SecurityException, UnsupportedOperationException { @@ -121,13 +141,14 @@ public final Descriptor Id; /** - * Compares this {...@code Group} to the specified object. + * Compares {...@code this} Group to the specified object. * * @param other a {...@code Group} * @return true if the class of this {...@code Group} object and the * class of {...@code other} are exactly equal, and they point * to the same system group id. */ +@Override public boolean equals(Object other) { if (other == null) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java?rev=769704r1=769703r2=769704view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/GroupIterator.java Wed Apr 29 08:17:21 2009 @@ -17,6 +17,7 @@ package org.apache.commons.runtime; import java.util.Iterator; +import java.util.NoSuchElementException; /** * Group Iterator @@ -26,13 +27,20 @@ public abstract class GroupIterator implements IteratorGroup, IterableGroup { + /** + * Returns {...@code true} if the iteration has more elements. + * It returns {...@code true} if the {...@code next} would return + * an group rather then throwing and exception. * + * @return {...@code true} if the iteration has more elements. */ public abstract boolean hasNext(); /** + * Returns an iterator over a set of {...@link Group} elements. * + * return Iterator of type {...@code Group}. */ public IteratorGroup iterator() { @@ -40,14 +48,23 @@ } /** + * Returns the next {...@link Group} in the iteration. * + *
svn commit: r769708 - /commons/sandbox/runtime/trunk/src/main/native/Makefile.in
Author: mturk Date: Wed Apr 29 08:34:44 2009 New Revision: 769708 URL: http://svn.apache.org/viewvc?rev=769708view=rev Log: Add hpux private files Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=769708r1=769707r2=769708view=diff == --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Wed Apr 29 08:34:44 2009 @@ -123,6 +123,8 @@ $(SRCDIR)/os/unix/uuid.$(OBJ) \ $(SRCDIR)/os/unix/uutils.$(OBJ) \ $(SRCDIR)/os/hpux/platform.$(OBJ) \ + $(SRCDIR)/os/hpux/pgroup.$(OBJ) \ + $(SRCDIR)/os/hpux/puser.$(OBJ) \ $(SRCDIR)/os/hpux/os.$(OBJ) TEST_OBJS= \
svn commit: r769709 - /commons/sandbox/runtime/trunk/src/main/native/Makefile.in
Author: mturk Date: Wed Apr 29 08:37:27 2009 New Revision: 769709 URL: http://svn.apache.org/viewvc?rev=769709view=rev Log: hpux cc uses __inline keyword Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=769709r1=769708r2=769709view=diff == --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Wed Apr 29 08:37:27 2009 @@ -119,6 +119,8 @@ HPUX_OBJS= \ $(SRCDIR)/os/unix/file.$(OBJ) \ $(SRCDIR)/os/unix/main.$(OBJ) \ + $(SRCDIR)/os/unix/group.$(OBJ) \ + $(SRCDIR)/os/unix/user.$(OBJ) \ $(SRCDIR)/os/unix/syslog.$(OBJ) \ $(SRCDIR)/os/unix/uuid.$(OBJ) \ $(SRCDIR)/os/unix/uutils.$(OBJ) \
svn commit: r769714 - in /commons/sandbox/runtime/trunk/src/main/native/os/hpux: pgroup.c puser.c
Author: mturk Date: Wed Apr 29 08:43:07 2009 New Revision: 769714 URL: http://svn.apache.org/viewvc?rev=769714view=rev Log: Add hpux private files Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c (with props) commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c (with props) Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c?rev=769714view=auto == --- commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c Wed Apr 29 08:43:07 2009 @@ -0,0 +1,106 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +#include acr.h +#include acr_private.h +#include acr_arch.h +#include acr_clazz.h +#include acr_error.h +#include acr_memory.h +#include acr_string.h +#include acr_descriptor.h +#include acr_users.h + +#include pwd.h +#include grp.h + + +ACR_JNI_EXPORT_DECLARE(jobjectArray, Group, enum0)(ACR_JNISTDARGS) +{ +jobjectArray grps = NULL; +struct group *gr; +jsize i, n = 0; +char **gnames; + +UNREFERENCED_O; + +/* 1. stage - get the number of groups */ +setgrent(); +while (1) { +errno = 0; +gr = getgrent(); +if (gr == NULL n == 0) { +if (ACR_STATUS_IS_EACCES(ACR_GET_OS_ERROR())) +ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); +else +ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, + ACR_GET_OS_ERROR()); +return NULL; +} +if (gr == NULL) +break; +else +n++; +} +endgrent(); +if (n == 0) { +/* No groups defined */ +return NULL; +} +gnames = (char **)ACR_Calloc(_E, THROW_FMARK, n * sizeof(char *)); +if (!gnames) { +return NULL; +} +grps = ACR_NewGroupArray(_E, n); +if (grps == NULL) { +return NULL; +} +/* 2. stage - get the group names */ +setgrent(); +for (i = 0; i n; i++) { +gr = getgrent(); +if (gr) { +gnames[i] = ACR_StrdupA(_E, THROW_FMARK, gr-gr_name); +if (!gnames[i]) { +grps = NULL; +endgrent(); +goto cleanup; +} +} +} +endgrent(); +/* 3. stage - create the groups */ +for (i = 0; i n; i++) { +if (gnames[i]) { +jobject gid = ACR_GroupObjectCreate(_E, gnames[i]); +if ((*_E)-ExceptionCheck(_E) || gid == NULL) { +/* Object creation failed */ +break; +} +(*_E)-SetObjectArrayElement(_E, grps, i, gid); +(*_E)-DeleteLocalRef(_E, gid); +} +} +cleanup: +/* 4. stage - free the temp storage */ +for (i = 0; i n; i++) { +if (gnames[i]) +free(gnames[i]); +} +free(gnames); +return grps; +} + Propchange: commons/sandbox/runtime/trunk/src/main/native/os/hpux/pgroup.c -- svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c?rev=769714view=auto == --- commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c (added) +++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/puser.c Wed Apr 29 08:43:07 2009 @@ -0,0 +1,106 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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
svn commit: r769723 - in /commons/sandbox/runtime/trunk/src/main/native/os/unix: group.c user.c
Author: mturk Date: Wed Apr 29 09:02:20 2009 New Revision: 769723 URL: http://svn.apache.org/viewvc?rev=769723view=rev Log: Check for ENOENT Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c?rev=769723r1=769722r2=769723view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c Wed Apr 29 09:02:20 2009 @@ -104,7 +104,9 @@ rc = getgrnam_r(name, grb, buffer, sizeof(buffer), gr); if (rc) { -if (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc))) +if (ACR_STATUS_IS_ENOENT(ACR_FROM_OS_ERROR(rc))) +return NULL; +else if (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc))) ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); else ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c?rev=769723r1=769722r2=769723view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c Wed Apr 29 09:02:20 2009 @@ -117,7 +117,9 @@ rc = getpwnam_r(name, pwb, buffer, sizeof(buffer), pw); if (rc) { -if (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc))) +if (ACR_STATUS_IS_ENOENT(ACR_FROM_OS_ERROR(rc))) +return NULL; +else if (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc))) ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); else ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
svn commit: r769725 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: Group.java User.java
Author: mturk Date: Wed Apr 29 09:11:54 2009 New Revision: 769725 URL: http://svn.apache.org/viewvc?rev=769725view=rev Log: Make singleton access to user and group databases. Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java?rev=769725r1=769724r2=769725view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java Wed Apr 29 09:11:54 2009 @@ -27,6 +27,13 @@ public final class Group { +// Singleton access to users database +private static Object singleton; +static { + +singleton = new Object(); +} + private Group() { // No instance. @@ -77,7 +84,11 @@ public static GroupIterator getLocalGroups() throws IOException, SecurityException { -return new GroupIteratorImpl(enum0()); +GroupIterator iter; +synchronized(singleton) { +iter = new GroupIteratorImpl(enum0()); +} +return iter; } /** Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java?rev=769725r1=769724r2=769725view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Wed Apr 29 09:11:54 2009 @@ -28,6 +28,13 @@ public final class User { +// Singleton access to users database +private static Object singleton; +static { + +singleton = new Object(); +} + private User() { // No instance. @@ -74,7 +81,11 @@ public static UserIterator getUsers() throws IOException, SecurityException { -return new UserIteratorImpl(enum0()); +UserIterator iter; +synchronized(singleton) { +iter = new UserIteratorImpl(enum0()); +} +return iter; } /**
svn commit: r769726 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: Group.java User.java
Author: mturk Date: Wed Apr 29 09:14:33 2009 New Revision: 769726 URL: http://svn.apache.org/viewvc?rev=769726view=rev Log: Singleton is not a proper name. It's basically a lock Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java?rev=769726r1=769725r2=769726view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java Wed Apr 29 09:14:33 2009 @@ -27,11 +27,11 @@ public final class Group { -// Singleton access to users database -private static Object singleton; +// Serialize access to group database +private static Object lock; static { -singleton = new Object(); +lock = new Object(); } private Group() @@ -85,7 +85,7 @@ throws IOException, SecurityException { GroupIterator iter; -synchronized(singleton) { +synchronized(lock) { iter = new GroupIteratorImpl(enum0()); } return iter; Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java?rev=769726r1=769725r2=769726view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Wed Apr 29 09:14:33 2009 @@ -29,10 +29,10 @@ { // Singleton access to users database -private static Object singleton; +private static Object lock; static { -singleton = new Object(); +lock = new Object(); } private User() @@ -82,7 +82,7 @@ throws IOException, SecurityException { UserIterator iter; -synchronized(singleton) { +synchronized(lock) { iter = new UserIteratorImpl(enum0()); } return iter;
svn commit: r769737 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/ main/native/include/ main/native/os/unix/ main/native/shared/ main/native/test/ test/org/apache/commo
Author: mturk Date: Wed Apr 29 10:32:18 2009 New Revision: 769737 URL: http://svn.apache.org/viewvc?rev=769737view=rev Log: Add logged users Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java commons/sandbox/runtime/trunk/src/main/native/include/acr_tables.h commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c commons/sandbox/runtime/trunk/src/main/native/shared/tables.c commons/sandbox/runtime/trunk/src/main/native/test/testcase.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestUser.java Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java?rev=769737r1=769736r2=769737view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java Wed Apr 29 10:32:18 2009 @@ -51,6 +51,8 @@ private static native boolean equals0(Descriptor a, Descriptor b); private static native User[] enum0() throws IOException, SecurityException; +private static native User[] enum1() +throws IOException, SecurityException; /** * Create the {...@code User} object from the {...@code name}. @@ -89,6 +91,24 @@ } /** + * Get the {...@link UserIterator} of all users defined on the system. + * + * @return UserIterator containing all users. + * @throws IOException in case of I/O error. + * @throws SecurityException if the current user is not allowed to + * access the system user database. + */ +public static UserIterator getLoggedUsers() +throws IOException, SecurityException +{ +UserIterator iter; +synchronized(lock) { +iter = new UserIteratorImpl(enum1()); +} +return iter; +} + +/** * String that specifies the name of the user account. */ public String getName() Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_tables.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_tables.h?rev=769737r1=769736r2=769737view=diff == --- commons/sandbox/runtime/trunk/src/main/native/include/acr_tables.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_tables.h Wed Apr 29 10:32:18 2009 @@ -186,7 +186,7 @@ * @param dlen Pointer where to store the data length. Can be NULL * @return ACR_EOF on end. */ -ACR_DECLARE(int) ACR_TableIndex(acr_table_t *t, int idx, +ACR_DECLARE(int) ACR_TableIndex(acr_table_t *t, int idx, char **key, void **data, acr_size_t *dlen); /** @@ -203,7 +203,7 @@ * @param dlen Pointer where to store the data length. Can be NULL * @return ACR_EOF on end. */ -ACR_DECLARE(int) ACR_TableNext(acr_table_t *t, +ACR_DECLARE(int) ACR_TableNext(acr_table_t *t, char **key, void **data, acr_size_t *dlen); /** @@ -216,14 +216,15 @@ /** Callback function used in ACR_TableForEach. * If the function returns non zero the for each loop will break. */ -typedef int (acr_table_callback_fn_t)(char *key, void *data, acr_size_t dlen); +typedef int (acr_table_callback_fn_t)(void *opaque, char *key, void *data, + acr_size_t dlen); /** * Execute callback for each table entry. * @param t Table to use. * @param callback Callback function */ -ACR_DECLARE(void) ACR_TableForEach(acr_table_t *t, +ACR_DECLARE(void) ACR_TableForEach(acr_table_t *t, void *opaque, acr_table_callback_fn_t *callback); #ifdef __cplusplus Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c?rev=769737r1=769736r2=769737view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c Wed Apr 29 10:32:18 2009 @@ -21,11 +21,13 @@ #include acr_error.h #include acr_memory.h #include acr_string.h +#include acr_tables.h #include acr_descriptor.h #include acr_users.h #include pwd.h #include grp.h +#include utmpx.h J_DECLARE_CLAZZ = { NULL, @@ -142,7 +144,7 @@ SET_IFIELD_S(, usr, pw-pw_name); SET_IFIELD_S(0001, usr, pw-pw_gecos); -#ifdef DARWIN +#ifdef DARWIN /* Use user class name for comment */ SET_IFIELD_N(0002, usr, pw-pw_class); #endif @@ -177,3 +179,66
svn commit: r769829 - in /commons/sandbox/runtime/trunk/src: main/native/os/win32/group.c main/native/os/win32/user.c test/org/apache/commons/runtime/TestGroup.java
Author: mturk Date: Wed Apr 29 17:04:46 2009 New Revision: 769829 URL: http://svn.apache.org/viewvc?rev=769829view=rev Log: Add groupMembers for windows Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c?rev=769829r1=769828r2=769829view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c Wed Apr 29 17:04:46 2009 @@ -280,3 +280,74 @@ return grps; } + +ACR_JNI_EXPORT_DECLARE(jobjectArray, Group, enum2)(ACR_JNISTDARGS, + jobject gdd) +{ + +DWORD resumehandle = 0, total; +PLOCALGROUP_MEMBERS_INFO_1 pb; +DWORD res, dwRec, n, i = 0; +jsize j = 0, nusers = 0; +jobjectArray usrs = NULL; +PSID gid; +SID_NAME_USE gidt; +WCHAR gname[MAX_PATH]; + +UNREFERENCED_O; +gid = (PSID)ACR_DescriptorGetPtr(_E, gdd); +if (gid == NULL) { +return NULL; +} +gidt = ACR_GetAccountNameFromSid(gname, MAX_PATH, gid); +if (gidt == -1) { +return NULL; +} +do { +res = NetLocalGroupGetMembers(NULL, gname, 1, (LPBYTE *)pb, + MAX_PREFERRED_LENGTH, + dwRec, total, (LPDWORD)resumehandle ); +if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) { +for (n = 0; n dwRec; n++) { +if (pb[i].lgrmi1_sidusage == SidTypeUser) { +/* Only count in the User accounts */ +nusers++; +} +} +NetApiBufferFree(pb); +} +} while (res == ERROR_MORE_DATA); +if (nusers) +usrs = ACR_NewUserArray(_E, n); +if (!usrs) +return NULL; +resumehandle = 0; +do { +res = NetLocalGroupGetMembers(NULL, gname, 1, (LPBYTE *)pb, + MAX_PREFERRED_LENGTH, + dwRec, total, (LPDWORD)resumehandle ); +if ((res == ERROR_SUCCESS) || (res == ERROR_MORE_DATA)) { +for (n = 0; n dwRec; n++) { +if (pb[n].lgrmi1_sidusage != SidTypeUser) +continue; +if (j nusers) { +jobject uid = ACR_UserObjectCreate(_E, pb[n].lgrmi1_name); +if ((*_E)-ExceptionCheck(_E) || gid == NULL) { +NetApiBufferFree(pb); +usrs = NULL; +goto cleanup; +} +(*_E)-SetObjectArrayElement(_E, usrs, j, uid); +(*_E)-DeleteLocalRef(_E, uid); +} +j++; +} +NetApiBufferFree(pb); +} +} while (res == ERROR_MORE_DATA); + + +cleanup: +return usrs; + +} Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c?rev=769829r1=769828r2=769829view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Wed Apr 29 17:04:46 2009 @@ -134,10 +134,6 @@ DWORD acclen = (DWORD)blen; SID_NAME_USE sidtype; -if (IsWellKnownSid(psid, WinBuiltinAdministratorsSid)) { -wcscpy(buf, LSYSTEM); -return SidTypeWellKnownGroup; -} if (!LookupAccountSidW(NULL, psid, buf, acclen, domain, domlen, Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java?rev=769829r1=769828r2=769829view=diff == --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.java Wed Apr 29 17:04:46 2009 @@ -103,7 +103,7 @@ Group g; if (OS.TYPE.contains(OsType.WINDOWS)) -g = Group.get(Users); +g = Group.get(Administrators); else g = Group.get(sys); assertNotNull(Group, g);
svn commit: r769830 - /commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java
Author: mturk Date: Wed Apr 29 17:07:35 2009 New Revision: 769830 URL: http://svn.apache.org/viewvc?rev=769830view=rev Log: Use less restrictive check Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java?rev=769830r1=769829r2=769830view=diff == --- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java (original) +++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.java Wed Apr 29 17:07:35 2009 @@ -174,7 +174,7 @@ f.createNewFile(); EnumSet FileProtection fp = f.getFileProtection(); System.out.println(Protection + fp); -assertTrue(GWRITE, fp.contains(FileProtection.GREAD)); +assertTrue(UWRITE, fp.contains(FileProtection.UWRITE)); f.delete(); } }
svn commit: r769851 - in /commons/sandbox/runtime/trunk/src/main/native/os/win32: file.c main.c platform.c
Author: mturk Date: Wed Apr 29 17:50:57 2009 New Revision: 769851 URL: http://svn.apache.org/viewvc?rev=769851view=rev Log: Use XP functions for well known sids Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c?rev=769851r1=769850r2=769851view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/file.c Wed Apr 29 17:50:57 2009 @@ -248,7 +248,7 @@ return rv; } -extern PSID dll_worldid; +extern PSID acr_everyone_sid; /* Left bit shifts from World scope to given scope */ typedef enum prot_scope_e { @@ -282,12 +282,6 @@ * This function is only invoked for WinNT, * there is no reason for os_level testing here. */ -if (!dll_worldid) { -SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_WORLD_SID_AUTHORITY; -if (!AllocateAndInitializeSid(SIDAuth, 1, SECURITY_WORLD_RID, - 0, 0, 0, 0, 0, 0, 0, dll_worldid)) -dll_worldid = NULL; -} if (user) { ident.TrusteeType = TRUSTEE_IS_USER; ident.ptstrName = user; @@ -311,9 +305,9 @@ protection |= convert_prot(acc, prot_scope_group); } } -if (dll_worldid) { +if (acr_everyone_sid) { ident.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP; -ident.ptstrName = dll_worldid; +ident.ptstrName = acr_everyone_sid; if (GetEffectiveRightsFromAclW(dacl, ident, acc) == ERROR_SUCCESS) { protection |= convert_prot(acc, prot_scope_world); } Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=769851r1=769850r2=769851view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Wed Apr 29 17:50:57 2009 @@ -43,7 +43,8 @@ extern int ACR_InitClazzCache(JNIEnv *); extern int ACR_DestroyClazzCache(JNIEnv *); -PSID dll_worldid = NULL; +PSID acr_everyone_sid = NULL; +PSID acr_adminsgr_sid = NULL; typedef struct acr_thread_local_t { JNIEnv *env; @@ -83,9 +84,13 @@ * or FreeLibrary. */ case DLL_PROCESS_DETACH: -if (dll_worldid) { -FreeSid(dll_worldid); -dll_worldid = NULL; +if (acr_everyone_sid) { +LocalFree(acr_everyone_sid); +acr_everyone_sid = NULL; +} +if (acr_adminsgr_sid) { +LocalFree(acr_adminsgr_sid); +acr_adminsgr_sid = NULL; } if (dll_tls_index != TLS_OUT_OF_INDEXES) { tlsd = (acr_thread_local_t *)TlsGetValue(dll_tls_index); Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=769851r1=769850r2=769851view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Wed Apr 29 17:50:57 2009 @@ -43,6 +43,32 @@ ia[7] = 32760; (*_E)-SetIntArrayRegion(_E, p, 0, 8, ia[0]); + +if (!acr_everyone_sid) { +/* Create a well known SID for Everyone group. */ +DWORD ss = SECURITY_MAX_SID_SIZE; +PSID sid = LocalAlloc(LMEM_FIXED, ss); +if (sid) { +if (!CreateWellKnownSid(WinWorldSid, +NULL, sid, ss)) +LocalFree(sid); +else +acr_everyone_sid = sid; +} +} +if (!acr_adminsgr_sid) { +/* Create a well known SID for BUILTIN\Administrators group. */ +DWORD ss = SECURITY_MAX_SID_SIZE; +PSID sid = LocalAlloc(LMEM_FIXED, ss); +if (sid) { +if (!CreateWellKnownSid(WinBuiltinAdministratorsSid, +NULL, sid, ss)) +LocalFree(sid); +else +acr_adminsgr_sid = sid; +} +} + } ACR_JNI_EXPORT_DECLARE(jboolean, Platform, supported)(ACR_JNISTDARGS)
svn commit: r769853 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
Author: mturk Date: Wed Apr 29 17:53:06 2009 New Revision: 769853 URL: http://svn.apache.org/viewvc?rev=769853view=rev Log: This should probably go to acr_arch.h Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=769853r1=769852r2=769853view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Wed Apr 29 17:53:06 2009 @@ -21,6 +21,8 @@ #include acr_platform.h static const char unknown[] = unknown; +extern PSID acr_everyone_sid; +extern PSID acr_adminsgr_sid; ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS, jintArray p)
svn commit: r769867 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/util/MathUtils.java site/xdoc/changes.xml test/org/apache/commons/math/util/MathUtilsTest.java
Author: luc Date: Wed Apr 29 18:33:59 2009 New Revision: 769867 URL: http://svn.apache.org/viewvc?rev=769867view=rev Log: Added an utility equality method between double numbers using tolerance in ulps (Units in Last Position) JIRA: MATH-264 Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java commons/proper/math/trunk/src/site/xdoc/changes.xml commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java?rev=769867r1=769866r2=769867view=diff == --- commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/util/MathUtils.java Wed Apr 29 18:33:59 2009 @@ -59,6 +59,9 @@ /** 2 pi;. */ private static final double TWO_PI = 2 * Math.PI; +private static final int NAN_GAP = 4 * 1024 * 1024; +private static final long SGN_MASK = 0x8000L; + /** * Private Constructor */ @@ -407,6 +410,39 @@ } /** + * Returns true iff both arguments are equal or within the range of allowed + * error (inclusive). + * Adapted from a + * href=http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm; + * Bruce Dawson/a + * + * @param x first value + * @param y second value + * @param maxUlps {...@code (maxUlps - 1)} is the number of floating point + * values between {...@code x} and {...@code y}. + * @return {...@code true} if there are less than {...@code maxUlps} floating + * point values between {...@code x} and {...@code y} + */ +public static boolean equals(double x, double y, int maxUlps) { +// Check that maxUlps is non-negative and small enough so that the +// default NAN won't compare as equal to anything. +assert maxUlps 0 maxUlps NAN_GAP; + +long xInt = Double.doubleToLongBits(x); +long yInt = Double.doubleToLongBits(y); + +// Make lexicographically ordered as a two's-complement integer. +if (xInt 0) { +xInt = SGN_MASK - xInt; +} +if (yInt 0) { +yInt = SGN_MASK - yInt; +} + +return Math.abs(xInt - yInt) = maxUlps; +} + +/** * Returns true iff both arguments are null or have same dimensions * and all their elements are {...@link #equals(double,double) equals} * Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=769867r1=769866r2=769867view=diff == --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Wed Apr 29 18:33:59 2009 @@ -39,6 +39,10 @@ /properties body release version=2.0 date=TBD description=TBD + action dev=luc type=fix issue=MATH-264 due-to=Gilles Sadowski +Added an utility equality method between double numbers using tolerance +in ulps (Units in Last Position) + /action action dev=luc type=add Added support for any type of field in linear algebra (FielxMatrix, FieldVector, FieldLUDecomposition) Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java?rev=769867r1=769866r2=769867view=diff == --- commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java (original) +++ commons/proper/math/trunk/src/test/org/apache/commons/math/util/MathUtilsTest.java Wed Apr 29 18:33:59 2009 @@ -353,6 +353,31 @@ assertFalse(MathUtils.equals(153., 153.0625, .0624)); assertFalse(MathUtils.equals(152.9374, 153., .0625)); } + +public void testEqualsWithAllowedUlps() { +assertTrue(MathUtils.equals(153, 153, 1)); + +assertTrue(MathUtils.equals(153, 153.03, 1)); +assertFalse(MathUtils.equals(153, 153.06, 1)); +assertTrue(MathUtils.equals(153, 152.97, 1)); +assertFalse(MathUtils.equals(153, 152.94, 1)); + +assertTrue(MathUtils.equals(-128, -127.99, 1)); +assertFalse(MathUtils.equals(-128, -127.97, 1)); +assertTrue(MathUtils.equals(-128, -128.03, 1)); +assertFalse(MathUtils.equals(-128, -128.06, 1)); + +
svn commit: r769871 - in /commons/proper/math/trunk/src/java/org/apache/commons/math/linear: RealVector.java RealVectorImpl.java
Author: luc Date: Wed Apr 29 18:49:30 2009 New Revision: 769871 URL: http://svn.apache.org/viewvc?rev=769871view=rev Log: typo in HTML 4 entity Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorImpl.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java?rev=769871r1=769870r2=769871view=diff == --- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVector.java Wed Apr 29 18:49:30 2009 @@ -542,8 +542,8 @@ double getL1Norm(); /** - * Returns the Lsubinfty;/sub norm of the vector. - * pThe Lsubinfty;/sub norm is the max of the absolute + * Returns the Lsubinfin;/sub norm of the vector. + * pThe Lsubinfin;/sub norm is the max of the absolute * values of elements./p * @return norm * @see #getNorm() @@ -615,7 +615,7 @@ /** * Distance between two vectors. * pThis method computes the distance consistent with - * Lsubinfty;/sub norm, i.e. the max of the absolute values of + * Lsubinfin;/sub norm, i.e. the max of the absolute values of * elements differences./p * @param v vector to which distance is requested * @return distance between two vectors. @@ -630,7 +630,7 @@ /** * Distance between two vectors. * pThis method computes the distance consistent with - * Lsubinfty;/sub norm, i.e. the max of the absolute values of + * Lsubinfin;/sub norm, i.e. the max of the absolute values of * elements differences./p * @param v vector to which distance is requested * @return distance between two vectors. Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorImpl.java?rev=769871r1=769870r2=769871view=diff == --- commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorImpl.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/linear/RealVectorImpl.java Wed Apr 29 18:49:30 2009 @@ -1050,7 +1050,7 @@ /** * Distance between two vectors. * pThis method computes the distance consistent with - * Lsubinfty;/sub norm, i.e. the max of the absolute values of + * Lsubinfin;/sub norm, i.e. the max of the absolute values of * elements differences./p * @param v vector to which distance is requested * @return distance between two vectors.
svn commit: r769880 - in /commons/proper/math/trunk/src: java/org/apache/commons/math/geometry/Vector3D.java site/xdoc/changes.xml test/org/apache/commons/math/geometry/Vector3DTest.java
Author: luc Date: Wed Apr 29 19:10:01 2009 New Revision: 769880 URL: http://svn.apache.org/viewvc?rev=769880view=rev Log: added getNorm1, getNormInf, distance1 and distanceInf to the Vector3D class Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java commons/proper/math/trunk/src/site/xdoc/changes.xml commons/proper/math/trunk/src/test/org/apache/commons/math/geometry/Vector3DTest.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java?rev=769880r1=769879r2=769880view=diff == --- commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/geometry/Vector3D.java Wed Apr 29 19:10:01 2009 @@ -196,7 +196,14 @@ return z; } - /** Get the norm for the vector. + /** Get the Lsub1/sub norm for the vector. + * @return Lsub1/sub norm for the vector + */ + public double getNorm1() { +return Math.abs(x) + Math.abs(y) + Math.abs(z); + } + + /** Get the Lsub2/sub norm for the vector. * @return euclidian norm for the vector */ public double getNorm() { @@ -210,6 +217,13 @@ return x * x + y * y + z * z; } + /** Get the Lsubinfin;/sub norm for the vector. + * @return Lsubinfin;/sub norm for the vector + */ + public double getNormInf() { +return Math.max(Math.max(Math.abs(x), Math.abs(y)), Math.abs(z)); + } + /** Get the azimuth of the vector. * @return azimuth (alpha;) of the vector, between -pi; and +pi; * @see #Vector3D(double, double) @@ -309,7 +323,7 @@ /** Compute the angular separation between two vectors. * pThis method computes the angular separation between two * vectors using the dot product for well separated vectors and the - * cross product for almost aligned vectors. This allow to have a + * cross product for almost aligned vectors. This allows to have a * good accuracy in all cases, even for vectors very close to each * other./p * @param v1 first vector @@ -454,13 +468,28 @@ v1.x * v2.y - v1.y * v2.x); } - /** Compute the distance between two vectors. + /** Compute the distance between two vectors according to the Lsub1/sub norm. + * pCalling this method is equivalent to calling: + * codev1.subtract(v2).getNorm1()/code except that no intermediate + * vector is built/p + * @param v1 first vector + * @param v2 second vector + * @return the distance between v1 and v2 according to the Lsub1/sub norm + */ + public static double distance1(Vector3D v1, Vector3D v2) { +final double dx = Math.abs(v2.x - v1.x); +final double dy = Math.abs(v2.y - v1.y); +final double dz = Math.abs(v2.z - v1.z); +return dx + dy + dz; + } + + /** Compute the distance between two vectors according to the Lsub2/sub norm. * pCalling this method is equivalent to calling: * codev1.subtract(v2).getNorm()/code except that no intermediate * vector is built/p * @param v1 first vector * @param v2 second vector - * @return the distance between v1 and v2 + * @return the distance between v1 and v2 according to the Lsub2/sub norm */ public static double distance(Vector3D v1, Vector3D v2) { final double dx = v2.x - v1.x; @@ -469,6 +498,21 @@ return Math.sqrt(dx * dx + dy * dy + dz * dz); } + /** Compute the distance between two vectors according to the Lsubinfin;/sub norm. + * pCalling this method is equivalent to calling: + * codev1.subtract(v2).getNormInf()/code except that no intermediate + * vector is built/p + * @param v1 first vector + * @param v2 second vector + * @return the distance between v1 and v2 according to the Lsubinfin;/sub norm + */ + public static double distanceInf(Vector3D v1, Vector3D v2) { +final double dx = Math.abs(v2.x - v1.x); +final double dy = Math.abs(v2.y - v1.y); +final double dz = Math.abs(v2.z - v1.z); +return Math.max(Math.max(dx, dy), dz); + } + /** Compute the square of the distance between two vectors. * pCalling this method is equivalent to calling: * codev1.subtract(v2).getNormSq()/code except that no intermediate Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=769880r1=769879r2=769880view=diff == --- commons/proper/math/trunk/src/site/xdoc/changes.xml (original) +++ commons/proper/math/trunk/src/site/xdoc/changes.xml Wed Apr 29 19:10:01 2009 @@ -41,7 +41,10 @@ release version=2.0 date=TBD description=TBD action dev=luc type=fix issue=MATH-264 due-to=Gilles Sadowski Added an utility
svn commit: r770071 - /commons/proper/commons-build/trunk/downloads/downloads.xml
Author: dfabulich Date: Thu Apr 30 05:22:55 2009 New Revision: 770071 URL: http://svn.apache.org/viewvc?rev=770071view=rev Log: releasing dbutils 1.2 Modified: commons/proper/commons-build/trunk/downloads/downloads.xml Modified: commons/proper/commons-build/trunk/downloads/downloads.xml URL: http://svn.apache.org/viewvc/commons/proper/commons-build/trunk/downloads/downloads.xml?rev=770071r1=770070r2=770071view=diff == --- commons/proper/commons-build/trunk/downloads/downloads.xml (original) +++ commons/proper/commons-build/trunk/downloads/downloads.xml Thu Apr 30 05:22:55 2009 @@ -172,12 +172,12 @@ project id=dbutils name=DbUtils href=http://commons.apache.org/dbutils/; downloads keys=commons/KEYS primary=http://www.apache.org/dist/; mirrored=true archive=http://archive.apache.org/dist/commons/dbutils/; group label=Binary -download name=1.1.tar.gz href=commons/dbutils/binaries/commons-dbutils-1.1.tar.gz/ -download name=1.1.zip href=commons/dbutils/binaries/commons-dbutils-1.1.zip/ +download name=1.2.tar.gz href=commons/dbutils/binaries/commons-dbutils-1.2-bin.tar.gz/ +download name=1.2.zip href=commons/dbutils/binaries/commons-dbutils-1.2-bin.zip/ /group group label=Source -download name=1.1.tar.gz href=commons/dbutils/source/commons-dbutils-1.1-src.tar.gz/ -download name=1.1.zip href=commons/dbutils/source/commons-dbutils-1.1-src.zip/ +download name=1.2.tar.gz href=commons/dbutils/source/commons-dbutils-1.2-src.tar.gz/ +download name=1.2.zip href=commons/dbutils/source/commons-dbutils-1.2-src.zip/ /group download name=browse download area href=commons/dbutils/ directory=true/ /downloads