harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548180 - in /harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix: helpers.c helpers.h
Date Mon, 18 Jun 2007 03:04:28 GMT
Author: tonywu
Date: Sun Jun 17 20:04:27 2007
New Revision: 548180

URL: http://svn.apache.org/viewvc?view=rev&rev=548180
Log:
add missing method hasPrivilegeInOtherGroups

Modified:
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.h

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c?view=diff&rev=548180&r1=548179&r2=548180
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.c
Sun Jun 17 20:04:27 2007
@@ -837,3 +837,29 @@
   result = hasPrivilegeInOtherGroups(env, &buffer, S_IXGRP);
   return -1 == result ? (buffer.st_mode & S_IXOTH) != 0 : result;
 }
+
+I_32 
+hasPrivilegeInOtherGroups(JNIEnv * env, struct stat * buffer, mode_t attr) 
+{
+      // if the user belongs other groups
+      gid_t *group;
+      long ngroups_max;
+      int result;
+      
+      PORT_ACCESS_FROM_ENV (env);
+      ngroups_max = sysconf(_SC_NGROUPS_MAX) + 1;
+      group = (gid_t *) hymem_allocate_memory(ngroups_max * sizeof(gid_t));
+      result = getgroups(ngroups_max, group);
+      
+      if(-1 != result) {
+            int i = 0;
+            for (i = 0; i < result; i++) {
+                if (buffer->st_gid == group[i]) {
+                  hymem_free_memory(group);
+                  return (buffer->st_mode & attr) != 0;
+                }
+           } 
+      }
+      hymem_free_memory(group);
+      return result;    	
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.h?view=diff&rev=548180&r1=548179&r2=548180
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.h
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/luni/unix/helpers.h
Sun Jun 17 20:04:27 2007
@@ -63,5 +63,6 @@
 I_32 getPlatformGetInterfaceAddresses(JNIEnv * env, jstring ifname, jint index, interfaceAddressArray_struct*
interfaceAddressArray);
 I_32 getPlatformIsExecutable (JNIEnv * env, char *path);
 I_32 setPlatformExecutable (JNIEnv * env, char *path, jboolean executable, jboolean ownerOnly);
+I_32 hasPrivilegeInOtherGroups(JNIEnv * env, struct stat * buffer, mode_t attr);
 #endif /* helpers_h */
 



Mime
View raw message