svn commit: r769272 - in /commons/sandbox/runtime/trunk/src: main/native/include/ main/native/include/arch/windows/ main/native/os/win32/ test/org/apache/commons/runtime/
Author: mturk Date: Tue Apr 28 07:46:58 2009 New Revision: 769272 URL: http://svn.apache.org/viewvc?rev=769272view=rev Log: Implement group and user on windows Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h 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 commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestUser.java Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h?rev=769272r1=769271r2=769272view=diff == --- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Tue Apr 28 07:46:58 2009 @@ -360,6 +360,13 @@ (*_E)-DeleteLocalRef(_E, _str);\ } else (void)(0) +#define SET_IFIELD_C(I, O, V) \ +if (_f##I##n.i (V) *(V)) {\ +jstring _str = ACR_NewJavaStringW(_E, (V)); \ +(*_E)-SetObjectField(_E, (O), _f##I##n.i, _str); \ +(*_E)-DeleteLocalRef(_E, _str);\ +} else (void)(0) + #define SET_IFIELD_O(I, O, V) \ if (_f##I##n.i) { \ (*_E)-SetObjectField(_E, (O), _f##I##n.i, (jobject)(V)); \ Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h?rev=769272r1=769271r2=769272view=diff == --- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h Tue Apr 28 07:46:58 2009 @@ -59,6 +59,11 @@ #define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN) \ JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_platform_windows_##CL##_##FN +/** + * Local functions from user.c + */ +PSID ACR_GetSidFromAccountName(LPCWSTR name, PSID_NAME_USE sidtype); +SID_NAME_USE ACR_GetAccountNameFromSid(LPWSTR buf, size_t blen, PSID psid); #ifdef __cplusplus 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=769272r1=769271r2=769272view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c Tue Apr 28 07:46:58 2009 @@ -88,14 +88,83 @@ return NULL; } -ACR_JNI_EXPORT_DECLARE(jobject, Hroup, get0)(ACR_JNISTDARGS, +static int sid_descriptor_handler(ACR_JNISTDARGS, acr_descriptor_cb_type_e t, + acr_descriptor_cb_t *cb) +{ +if (t == ACR_DESC_CLOSE) { +if (cb-dp) { +free(cb-dp); +return ACR_SUCCESS; +} +return ACR_EINCOMPLETE; +} +else { +/* We don't handle anything but close. */ +return ACR_ENOTIMPL; +} +} + +static jobject grp_object_create(JNIEnv *_E, LPCWSTR name) +{ +jobject grp; +jobject gid; +int err; +DWORD rc; +SID_NAME_USE sidtype; +PSID sid; +PLOCALGROUP_INFO_1 pb = NULL; +LPWSTR ssid = NULL; + +sid = ACR_GetSidFromAccountName(name, sidtype); +if (!sid) { +err = ACR_GET_OS_ERROR(); +if (ACR_STATUS_IS_EACCES(err)) +ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); +else if (ACR_TO_OS_ERROR(err) != ERROR_NONE_MAPPED) +ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, err); + +/* TODO: Throw exception */ +return NULL; +} + +gid = ACR_DescriptorCreate(_E, 0, -1, sid, sid_descriptor_handler); +if (!gid) { +free(gid); +return NULL; +} +grp = (*_E)-NewObject(_E, _clazzn.i, J4MID(), gid); +if (!grp) { +ACR_DescriptorCleanup(_E, grp); +return NULL; +} + +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); +NetApiBufferFree(pb); +} +else { +SET_IFIELD_W(, grp, name); +} +if (ConvertSidToStringSidW(sid, ssid)) { + +
svn commit: r769281 - in /commons/sandbox/runtime/trunk/src/main/native: include/arch/darwin/acr_arch_private.h os/unix/file.c os/unix/user.c
Author: mturk Date: Tue Apr 28 08:10:56 2009 New Revision: 769281 URL: http://svn.apache.org/viewvc?rev=769281view=rev Log: Add few settings for Mac Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h?rev=769281r1=769280r2=769281view=diff == --- commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h Tue Apr 28 08:10:56 2009 @@ -24,6 +24,7 @@ #include sys/utsname.h #include mach/machine.h #include mach-o/arch.h +#include sys/stat.h #ifdef __cplusplus extern C { Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c?rev=769281r1=769280r2=769281view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/file.c Tue Apr 28 08:10:56 2009 @@ -25,7 +25,6 @@ * Posix file functions * */ - #if defined(_LARGEFILE64_SOURCE) #define stat(f,b) stat64(f,b) #define lstat(f,b) lstat64(f,b) 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=769281r1=769280r2=769281view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c Tue Apr 28 08:10:56 2009 @@ -123,7 +123,10 @@ SET_IFIELD_S(, usr, pw-pw_name); SET_IFIELD_S(0001, usr, pw-pw_gecos); -/* Comment is unknown */ +#ifdef DARWIN +/* Use user class name for comment */ +SET_IFIELD_N(0002, usr, pw-pw_class); +#endif SET_IFIELD_S(0003, usr, pw-pw_dir); SET_IFIELD_S(0004, usr, pw-pw_shell); sid = ACR_Ltoa((acr_long_t)pw-pw_uid);
svn commit: r769291 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Author: bodewig Date: Tue Apr 28 08:31:15 2009 New Revision: 769291 URL: http://svn.apache.org/viewvc?rev=769291view=rev Log: Only use the zip-extra-field if configured to do so and the entry didn't set the EFS flag - COMPRESS-70 Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=769291r1=769290r2=769291view=diff == --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java Tue Apr 28 08:31:15 2009 @@ -54,7 +54,7 @@ /** * Whether to look for and use Unicode extra fields. */ -private final boolean useUnicodeExtraFields; // TODO not yet used +private final boolean useUnicodeExtraFields; private final InputStream in; @@ -178,8 +178,9 @@ readFully(extraData); current.setExtra(extraData); -ZipUtil.setNameAndCommentFromExtraFields(current, fileName, null); - +if (!hasEFS useUnicodeExtraFields) { +ZipUtil.setNameAndCommentFromExtraFields(current, fileName, null); +} return current; }
svn commit: r769360 - /commons/proper/math/trunk/pom.xml
Author: luc Date: Tue Apr 28 12:20:11 2009 New Revision: 769360 URL: http://svn.apache.org/viewvc?rev=769360view=rev Log: typo Modified: commons/proper/math/trunk/pom.xml Modified: commons/proper/math/trunk/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/pom.xml?rev=769360r1=769359r2=769360view=diff == --- commons/proper/math/trunk/pom.xml (original) +++ commons/proper/math/trunk/pom.xml Tue Apr 28 12:20:11 2009 @@ -149,7 +149,7 @@ /contributor contributor nameBenjamin McCann/name - urlhttp://www.benmccann.com;/url + urlhttp://www.benmccann.com/url /contributor contributor nameFredrik Norin/name
svn commit: r769367 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/ main/java/org/apache/commons/runtime/util/ main/native/ main/native/include/ main/native/os/unix/ mai
Author: mturk Date: Tue Apr 28 12:29:15 2009 New Revision: 769367 URL: http://svn.apache.org/viewvc?rev=769367view=rev Log: Add Syslog implementations Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java - copied, changed from r769281, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java commons/sandbox/runtime/trunk/src/main/native/os/unix/syslog.c (with props) commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestSyslog.java (with props) Removed: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h commons/sandbox/runtime/trunk/src/main/native/os/win32/syslog.c commons/sandbox/runtime/trunk/src/main/native/shared/string.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java Copied: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java (from r769281, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java) URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.javap1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.javar1=769281r2=769367rev=769367view=diff == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SyslogLevel.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/SyslogLevel.java Tue Apr 28 12:29:15 2009 @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.apache.commons.runtime; +package org.apache.commons.runtime.util; /** * System log levels. 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=769367r1=769366r2=769367view=diff == --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Tue Apr 28 12:29:15 2009 @@ -82,6 +82,7 @@ $(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) \ $(SRCDIR)/os/linux/platform.$(OBJ) \ @@ -92,6 +93,7 @@ $(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) \ $(SRCDIR)/os/solaris/platform.$(OBJ) \ @@ -102,6 +104,7 @@ $(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) \ $(SRCDIR)/os/darwin/platform.$(OBJ) \ @@ -110,6 +113,7 @@ HPUX_OBJS= \ $(SRCDIR)/os/unix/file.$(OBJ) \ $(SRCDIR)/os/unix/main.$(OBJ) \ + $(SRCDIR)/os/unix/syslog.$(OBJ) \ $(SRCDIR)/os/unix/uuid.$(OBJ) \ $(SRCDIR)/os/unix/uutils.$(OBJ) \ $(SRCDIR)/os/hpux/platform.$(OBJ) \ Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h?rev=769367r1=769366r2=769367view=diff == --- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Tue Apr 28 12:29:15 2009 @@ -101,6 +101,11 @@ wchar_t *_w##V = ACR_GetJavaStringW(_E, (V)); \ if (!_w##V) goto _cw##V; +#define WITH_ZWSTR(V) \ +if (_E) { \ +wchar_t *_w##V = ACR_GetJavaStringW(_E, (V)); \ +if (!_w##V (V)) goto _cw##V; + #define END_WITH_WSTR(V)\ _cw##V :\ if (_w##V) free (_w##V);\ @@ -111,6 +116,11 @@ char *_c##V = ACR_GetJavaStringA(_E, (V)); \ if (!_c##V) goto _ca##V; +#define WITH_ZCSTR(V) \ +if (_E) { \ +char *_c##V =
svn commit: r769369 - /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Syslog.java
Author: mturk Date: Tue Apr 28 12:29:46 2009 New Revision: 769369 URL: http://svn.apache.org/viewvc?rev=769369view=rev Log: Add Syslog implementations Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Syslog.java (with props) Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Syslog.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Syslog.java?rev=769369view=auto == --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Syslog.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Syslog.java Tue Apr 28 12:29:46 2009 @@ -0,0 +1,102 @@ +/* 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.util; + +import java.io.Closeable; +import java.io.IOException; + +/** + * Native OS System Log support. + * + * @since Runtime 1.0 + */ +public class Syslog implements Closeable +{ +private static native void init0(); +private static native void init1(String domain); +private static native void close0() +throws IOException, InstantiationException; +private static native void log0(int level, String msg); + +private static boolean isOn = false; +private boolean isOwner = false; + +public Syslog() +{ +if (!isOn) { +isOn= true; +isOwner = true; +init0(); +} +} + +public Syslog(String domain) +{ +if (!isOn) { +isOn= true; +isOwner = true; +init1(domain); +} +} + +/** + * Free the allocated resource by the Operating system. + * + * @see java.io.Closeable#close() + * @throws IOException if an I/O error occurs. + * @throws InstantiationException if native class loader was not initialized. + */ +public final void close() +throws IOException +{ +try { +if (isOwner) { +isOn = false; +close0(); +} +} catch (InstantiationException ex) { +// Class is alreay uninitialized. +// TODO: We could rethrow IOException here. +} +} + +/** + * Object finalize callback. + * Called by the garbage collector on an object when garbage + * collection determines that there are no more references to the object. + */ +@Override +protected final void finalize() +throws Throwable +{ +close(); +} + +/** + * Write the {...@code msg} to the system message logger. + * + * @param level Log level priority. + * @param msg The message to log. + */ +public static void log(SyslogLevel level, String msg) +{ +if (isOn) { +log0(level.valueOf(), msg); +} +} + +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/Syslog.java -- svn:eol-style = native
svn commit: r769380 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
Author: mturk Date: Tue Apr 28 12:55:05 2009 New Revision: 769380 URL: http://svn.apache.org/viewvc?rev=769380view=rev Log: Use the WSTR size Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c 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=769380r1=769379r2=769380view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Tue Apr 28 12:55:05 2009 @@ -274,7 +274,7 @@ if (!RegCreateKeyA(HKEY_LOCAL_MACHINE, event_key, key)) { RegSetValueExW(key, LEventMessageFile, 0, REG_SZ, (LPBYTE)dll_file_name[0], - lstrlenW(dll_file_name) + 1); + (lstrlenW(dll_file_name) + 1) * sizeof(wchar_t)); ts = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
svn commit: r769381 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
Author: mturk Date: Tue Apr 28 12:57:18 2009 New Revision: 769381 URL: http://svn.apache.org/viewvc?rev=769381view=rev Log: Use the EXPAND_SZ for EventMessageFile Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c 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=769381r1=769380r2=769381view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Tue Apr 28 12:57:18 2009 @@ -272,7 +272,7 @@ SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\); lstrcatA(event_key, domain); if (!RegCreateKeyA(HKEY_LOCAL_MACHINE, event_key, key)) { -RegSetValueExW(key, LEventMessageFile, 0, REG_SZ, +RegSetValueExW(key, LEventMessageFile, 0, REG_EXPAND_SZ, (LPBYTE)dll_file_name[0], (lstrlenW(dll_file_name) + 1) * sizeof(wchar_t)); ts = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
svn commit: r769446 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_users.h os/unix/group.c os/unix/user.c os/win32/group.c os/win32/user.c
Author: mturk Date: Tue Apr 28 16:14:20 2009 New Revision: 769446 URL: http://svn.apache.org/viewvc?rev=769446view=rev Log: Make group and user function public Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_users.h (with props) Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c commons/sandbox/runtime/trunk/src/main/native/os/unix/user.c commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_users.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_users.h?rev=769446view=auto == --- commons/sandbox/runtime/trunk/src/main/native/include/acr_users.h (added) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_users.h Tue Apr 28 16:14:20 2009 @@ -0,0 +1,68 @@ +/* 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. + */ + +#ifndef _ACR_USERS_H +#define _ACR_USERS_H + +#include acr.h + +#ifdef __cplusplus +extern C { +#endif + +/** + * @file acr_users.h + * @brief + * + * ACR User and Group class functions + * + */ + +/** + * Create new Group object array. + * @param env JNI environment to use. + * @param size Group object array size. + */ +ACR_DECLARE(jobjectArray) ACR_NewGroupArray(JNIEnv *_E, jsize len); + +/** + * Create new Group object. + * @param env JNI environment to use. + * @param name Group name which object to create. + */ +ACR_DECLARE(jobject) ACR_GroupObjectCreate(JNIEnv *_E, + const acr_pchar_t *name); + +/** + * Create new User object array. + * @param env JNI environment to use. + * @param size User object array size. + */ +ACR_DECLARE(jobjectArray) ACR_NewUserArray(JNIEnv *_E, jsize len); + +/** + * Create new User object. + * @param env JNI environment to use. + * @param name User name which object to create. + */ +ACR_DECLARE(jobject) ACR_UserObjectCreate(JNIEnv *_E, + const acr_pchar_t *name); + +#ifdef __cplusplus +} +#endif + +#endif /* _ACR_POINTER_H */ Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_users.h -- svn:eol-style = native 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=769446r1=769445r2=769446view=diff == --- commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c Tue Apr 28 16:14:20 2009 @@ -22,6 +22,7 @@ #include acr_memory.h #include acr_string.h #include acr_descriptor.h +#include acr_users.h #include pwd.h #include grp.h @@ -91,11 +92,26 @@ return NULL; } -static jobject grp_object_create(JNIEnv *_E, struct group *gr) +ACR_DECLARE(jobject) ACR_GroupObjectCreate(JNIEnv *_E, const char *name) { jobject gid; jobject grp; char *sid; +int rc; +struct group grb; +struct group *gr; +char buffer[4096]; + +rc = getgrnam_r(name, grb, buffer, sizeof(buffer), gr); +if (rc) { +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, +ACR_FROM_OS_ERROR(rc)); +} +if (!gr) +return NULL; gid = ACR_DescriptorCreate(_E, 0, gr-gr_gid, NULL, NULL); if (!gid) { @@ -125,23 +141,8 @@ UNREFERENCED_O; WITH_CSTR(name) { -int rc; -struct group grb; -struct group *pp; -char buffer[4096]; - -rc = getgrnam_r(J2S(name), grb, buffer, sizeof(buffer), pp); -if (rc) { -if (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc))) -ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); -else -ACR_ThrowException(_E,
svn commit: r769484 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/ main/native/ main/native/include/ main/native/os/linux/ main/native/os/unix/ main/native/shared/ test
Author: mturk Date: Tue Apr 28 18:06:25 2009 New Revision: 769484 URL: http://svn.apache.org/viewvc?rev=769484view=rev Log: Add group enum Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c (with props) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java commons/sandbox/runtime/trunk/src/main/native/Makefile.in commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h commons/sandbox/runtime/trunk/src/main/native/os/unix/group.c commons/sandbox/runtime/trunk/src/main/native/shared/string.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestGroup.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=769484r1=769483r2=769484view=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 Tue Apr 28 18:06:25 2009 @@ -38,8 +38,14 @@ Id = id; } -private static native Group get0(String name); +private static native Group get0(String name) +throws IOException, SecurityException; private static native boolean equals0(Descriptor a, Descriptor b); +private static native Group[] enum0() +throws IOException, SecurityException, UnsupportedOperationException; +private static native Group[] enum1() +throws IOException, SecurityException, UnsupportedOperationException; + /** * Create the {...@code Group object from the {...@code name}. @@ -59,6 +65,18 @@ return g; } +public static Group[] getLocalGroups() +throws IOException, SecurityException, UnsupportedOperationException +{ +return enum0(); +} + +public static Group[] getGlobalGroups() +throws IOException, SecurityException, UnsupportedOperationException +{ +return enum1(); +} + /** * String that specifies the name of the group 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=769484r1=769483r2=769484view=diff == --- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Tue Apr 28 18:06:25 2009 @@ -86,6 +86,7 @@ $(SRCDIR)/os/unix/uuid.$(OBJ) \ $(SRCDIR)/os/unix/uutils.$(OBJ) \ $(SRCDIR)/os/linux/platform.$(OBJ) \ + $(SRCDIR)/os/linux/pgroup.$(OBJ) \ $(SRCDIR)/os/linux/os.$(OBJ) SOLARIS_OBJS= \ Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h?rev=769484r1=769483r2=769484view=diff == --- commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h Tue Apr 28 18:06:25 2009 @@ -129,6 +129,29 @@ ACR_DECLARE(int) ACR_StrMatchW(const wchar_t *str, const wchar_t *exp, size_t *match, int icase); +/** + * Apache's replacement for the strdup() function that throws + * the java.lang.OutOfMemoryError in case of failure. + * @param env Current JNI environment. + * @param file Source file where the function was called + * @param line Source file line where the function was called + * @param str String to duplicate. + * @return Pointer to duplicated string. + */ +ACR_DECLARE(char *) ACR_StrdupA(JNIEnv *env, const char *file, int line, + const char *s); + +/** + * Apache's replacement for the wcsdup() function that throws + * the java.lang.OutOfMemoryError in case of failure. + * @param env Current JNI environment. + * @param file Source file where the function was called + * @param line Source file line where the function was called + * @param str String to duplicate. + * @return Pointer to duplicated string. + */ +ACR_DECLARE(wchar_t *) ACR_StrdupW(JNIEnv *env, const char *file, int line, + const wchar_t *s); #ifdef __cplusplus } Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c?rev=769484view=auto == --- commons/sandbox/runtime/trunk/src/main/native/os/linux/pgroup.c (added) +++