Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 4089 invoked from network); 2 May 2009 10:43:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 May 2009 10:43:31 -0000 Received: (qmail 97295 invoked by uid 500); 2 May 2009 10:43:30 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 97167 invoked by uid 500); 2 May 2009 10:43:30 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 97157 invoked by uid 99); 2 May 2009 10:43:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 May 2009 10:43:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 May 2009 10:43:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 391702388A23; Sat, 2 May 2009 10:43:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r770923 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/User.java main/native/os/win32/user.c test/org/apache/commons/runtime/TestFile.java Date: Sat, 02 May 2009 10:43:07 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090502104307.391702388A23@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Sat May 2 10:43:06 2009 New Revision: 770923 URL: http://svn.apache.org/viewvc?rev=770923&view=rev Log: Return uid if euid returns null Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/User.java commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestFile.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=770923&r1=770922&r2=770923&view=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 Sat May 2 10:43:06 2009 @@ -108,7 +108,7 @@ { User u = get2(); if (u == null) - throw new NoSuchObjectException("Effective user not found."); + u = get(); return u; } 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=770923&r1=770922&r2=770923&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Sat May 2 10:43:06 2009 @@ -145,6 +145,24 @@ return sidtype; } +SID_NAME_USE ACR_GetAccountSidType(PSID psid) +{ + WCHAR domname[MAX_PATH]; + WCHAR accname[MAX_PATH]; + DWORD domlen = MAX_PATH; + DWORD acclen = MAX_PATH; + SID_NAME_USE sidtype; + + if (!LookupAccountSidW(NULL, psid, + accname, &acclen, + domname, &domlen, + &sidtype)) { + + sidtype = -1; + } + return sidtype; +} + LPVOID ACR_GetTokenInformation(JNIEnv *_E, HANDLE h, TOKEN_INFORMATION_CLASS ic) { @@ -155,8 +173,11 @@ GetTokenInformation(h, ic, NULL, sz, &sz); if ((rc = GetLastError()) != ERROR_INSUFFICIENT_BUFFER) { if(_E) { - ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, - ACR_FROM_OS_ERROR(rc)); + if (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc))) + ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); + else if (rc != NERR_UserNotFound && rc != NERR_GroupNotFound) + ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, + ACR_FROM_OS_ERROR(rc)); } return NULL; } @@ -165,11 +186,8 @@ } if (!GetTokenInformation(h, ic, rv, sz, &sz)) { if(_E) { - 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()); + ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, + ACR_GET_OS_ERROR()); } free(rv); rv = NULL; @@ -441,7 +459,9 @@ } usr = ACR_GetTokenInformation(_E, token, TokenOwner); if (usr) { - uid = ACR_UserObjectCreateFromId(_E, usr->Owner); + SID_NAME_USE sidtype = ACR_GetAccountSidType(usr->Owner); + if (sidtype == SidTypeUser) + uid = ACR_UserObjectCreateFromId(_E, usr->Owner); free(usr); } 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=770923&r1=770922&r2=770923&view=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 Sat May 2 10:43:06 2009 @@ -71,7 +71,7 @@ FileType t = f.getFileType(); assertEquals("Type", FileType.BLK, t); } - +/* public void testMakeSymlink() throws Exception { @@ -86,27 +86,31 @@ // fail("Unsupported Operating system"); } } - +*/ public void testReadSymlink() throws Exception { try { - File target = new File("foo"); - File symlnk = target.createSymbolicLink("bar"); - FileType t = symlnk.getFileType(); + File target = new File("\\\\.\\pipe\\browser"); + System.out.println("Target " + target.getPath()); + File symlnk = new File("bar"); + File.createSymbolicLink(target.getPath(), "bar"); +// FileType t = symlnk.getFileType(); + System.out.println("Link " + symlnk.getTargetFile()); +/* assertEquals("Name", "bar", symlnk.getPath()); assertEquals("Type", FileType.LNK, t); - File second = new File("foo"); + File second = new File("\\\\.\\pipe\\bar"); File link2 = second.createSymbolicLink("bar"); assertEquals("Name", "bar", link2.getPath()); - - symlnk.delete(); +*/ + // symlnk.delete(); } catch (UnsupportedOperationException u) { // fail("Unsupported Operating system"); } } - +/* public void testReadSymlinkExists() throws Exception { @@ -166,7 +170,7 @@ // fail("Unsupported Operating system"); } } - +*/ public void testProtection() throws Exception {