commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r770950 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/Group.java native/include/arch/windows/acr_arch_private.h native/os/win32/group.c native/os/win32/user.c
Date Sat, 02 May 2009 13:11:00 GMT
Author: mturk
Date: Sat May  2 13:10:59 2009
New Revision: 770950

URL: http://svn.apache.org/viewvc?rev=770950&view=rev
Log:
Fix local and global group namings

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Group.java
    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

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=770950&r1=770949&r2=770950&view=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 Sat
May  2 13:10:59 2009
@@ -107,7 +107,7 @@
     public static Group getEffective()
         throws IOException, SecurityException, NoSuchObjectException
     {
-        Group g = get1();
+        Group g = get2();
         if (g == null)
             throw new NoSuchObjectException("Effective group not found.");
         return g;

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=770950&r1=770949&r2=770950&view=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
Sat May  2 13:10:59 2009
@@ -64,6 +64,7 @@
  */
 PSID         ACR_GetSidFromAccountName(LPCWSTR name, PSID_NAME_USE sidtype);
 SID_NAME_USE ACR_GetAccountNameFromSid(LPWSTR buf, size_t blen, PSID psid);
+SID_NAME_USE ACR_GetAccountSidType(PSID psid);
 LPVOID       ACR_GetTokenInformation(JNIEnv *_E, HANDLE h, TOKEN_INFORMATION_CLASS ic);
 
 /**

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=770950&r1=770949&r2=770950&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c Sat May  2 13:10:59 2009
@@ -139,7 +139,9 @@
     }
     (*_E)->DeleteLocalRef(_E, gid);
 
-    rc =  NetGroupGetInfo(NULL, name, 1, (LPBYTE *)&pb);
+    rc = NetLocalGroupGetInfo(NULL, name, 1, (LPBYTE *)&pb);
+    if (rc == NERR_GroupNotFound)
+        rc = NetGroupGetInfo(NULL, name, 1, (LPBYTE *)&pb);
     if (rc == ERROR_SUCCESS) {
         SET_IFIELD_W(0000, grp, pb->lgrpi1_name);
         SET_IFIELD_C(0001, grp, pb->lgrpi1_comment);
@@ -194,13 +196,18 @@
         ACR_DescriptorCleanup(_E, grp);
         return NULL;
     }
-
-    rc =  NetGroupGetInfo(NULL, name, 1, (LPBYTE *)&pb);
+    rc = NetLocalGroupGetInfo(NULL, name, 1, (LPBYTE *)&pb);
+    if (rc == NERR_GroupNotFound || rc == ERROR_NO_SUCH_ALIAS)
+        rc = NetGroupGetInfo(NULL, name, 1, (LPBYTE *)&pb);
     if (rc == ERROR_SUCCESS) {
         SET_IFIELD_W(0000, grp, pb->lgrpi1_name);
         SET_IFIELD_C(0001, grp, pb->lgrpi1_comment);
         NetApiBufferFree(pb);
     }
+    else if ((rc == NERR_GroupNotFound  || rc == ERROR_NO_SUCH_ALIAS) &&
+             sidtype == SidTypeGroup) {
+        SET_IFIELD_W(0000, grp, name);
+    }
     else {
         ACR_DescriptorCleanup(_E, gid);
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO,
@@ -208,7 +215,6 @@
         return NULL;
     }
     if (ConvertSidToStringSidW(sid, &ssid)) {
-
         SET_IFIELD_W(0002, grp, ssid);
         LocalFree(ssid);
     }
@@ -275,7 +281,9 @@
     jobject gid = NULL;
     DWORD   i, rc  = ERROR_SUCCESS;
     HANDLE  token;
+    SID_NAME_USE  sidtype;
     PTOKEN_GROUPS grp = NULL;
+    PTOKEN_OWNER  own = NULL;
 
     UNREFERENCED_O;
     if (!OpenThreadToken(GetCurrentThread(),
@@ -299,20 +307,28 @@
             return NULL;
         }
     }
-    grp = ACR_GetTokenInformation(_E, token, TokenGroups);
-    if (!grp) {
-        goto cleanup;
+    own = ACR_GetTokenInformation(_E, token, TokenOwner);
+    if (own) {
+        sidtype = ACR_GetAccountSidType(own->Owner);
+        if (sidtype == SidTypeGroup || sidtype == SidTypeWellKnownGroup)
+            gid = ACR_GroupObjectCreateFromId(_E, own->Owner);
+        free(own);
     }
-    for (i = 0; i < grp->GroupCount; i++) {
-        if (grp->Groups[i].Attributes & SE_GROUP_OWNER) {
-            gid = ACR_GroupObjectCreateFromId(_E, grp->Groups[i].Sid);
-            if (!gid) {
-                goto cleanup;
+    if (!gid) {
+        grp = ACR_GetTokenInformation(_E, token, TokenGroups);
+        if (!grp) {
+            goto cleanup;
+        }
+        for (i = 0; i < grp->GroupCount; i++) {
+            if (grp->Groups[i].Attributes & SE_GROUP_OWNER) {
+                gid = ACR_GroupObjectCreateFromId(_E, grp->Groups[i].Sid);
+                if (!gid) {
+                    goto cleanup;
+                }
+                break;
             }
-            break;
         }
     }
-
 cleanup:
     if (grp)
         free(grp);

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=770950&r1=770949&r2=770950&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 13:10:59 2009
@@ -460,6 +460,7 @@
     usr = ACR_GetTokenInformation(_E, token, TokenOwner);
     if (usr) {
         SID_NAME_USE sidtype = ACR_GetAccountSidType(usr->Owner);
+        fprintf(stderr, "NUGI is %d\n", sidtype);
         if (sidtype == SidTypeUser)
             uid = ACR_UserObjectCreateFromId(_E, usr->Owner);
         free(usr);



Mime
View raw message