[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdelibs/kio
From:       Till Adam <adam () kde ! org>
Date:       2006-01-16 19:12:11
Message-ID: 1137438731.259952.2614.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 498977 by tilladam:

Don't re-calculate the maximum possible mask based on named groups and
users when there is already a specific one set. Add test case for adding 
a mask to an ACL which previously didn't have one. Thanks for the nice
test case, Tim.

BUG: 119366


 M  +14 -5     kio/kacl.cpp  
 M  +14 -0     tests/kacltest.cpp  
 M  +1 -0      tests/kacltest.h  


--- branches/KDE/3.5/kdelibs/kio/kio/kacl.cpp #498976:498977
@@ -289,7 +289,12 @@
 #ifdef USE_POSIX_ACL
 bool KACL::KACLPrivate::setMaskPermissions( unsigned short v )
 {
-    permissionsToEntry( entryForTag( m_acl, ACL_MASK ), v );
+    acl_entry_t entry = entryForTag( m_acl, ACL_MASK );
+    if ( entry == 0 ) {
+        acl_create_entry( &m_acl, &entry );
+        acl_set_tag_type( entry, ACL_MASK );
+    }
+    permissionsToEntry( entry, v );
     return true;
 }
 #endif
@@ -372,8 +377,10 @@
     if ( allIsWell && createdNewEntry ) {
         // 23.1.1 of 1003.1e states that as soon as there is a named user or
         // named group entry, there needs to be a mask entry as well, so add
-        // one.
-        setMaskPermissions( acl_calc_mask( &newACL ) );
+        // one, if the user hasn't explicitely set one.
+        if ( entryForTag( newACL, ACL_MASK ) == 0 ) {
+            acl_calc_mask( &newACL );
+        }
     }
 
     if ( !allIsWell || acl_valid( newACL ) != 0 ) {
@@ -469,8 +476,10 @@
     if ( allIsWell && atLeastOneUserOrGroup ) {
         // 23.1.1 of 1003.1e states that as soon as there is a named user or
         // named group entry, there needs to be a mask entry as well, so add
-        // one.
-        setMaskPermissions( acl_calc_mask( &newACL ) );
+        // one, if the user hasn't explicitely set one.
+        if ( entryForTag( newACL, ACL_MASK ) == 0 ) {
+            acl_calc_mask( &newACL );
+        }
     }
     if ( allIsWell && ( acl_valid( newACL ) == 0 ) ) {
         acl_free( m_acl );
--- branches/KDE/3.5/kdelibs/kio/tests/kacltest.cpp #498976:498977
@@ -126,6 +126,8 @@
   testSettingBasic();
   testSettingExtended();
   testSettingErrorHandling();
+
+  testNewMask();
 }
 
 void KACLTest::cleanup()
@@ -293,3 +295,15 @@
   v = foo.setNamedUserPermissions( "jongel", 7 ); // non-existing user
   check( "Non-existing user: ", v, false );
 }
+
+void KACLTest::testNewMask()
+{
+  KACL CharlesII( "user::rw-\ngroup::rw-\nother::rw\n" );
+  bool dummy = false;
+  CharlesII.maskPermissions( dummy );
+  check( "mask exists: ", dummy, false );
+
+  CharlesII.setMaskPermissions( 6 );
+  check( "new mask set: ", QString::number( CharlesII.maskPermissions( dummy ) ), "6" );
+  check( "mask exists now: ", dummy, true );
+}
--- branches/KDE/3.5/kdelibs/kio/tests/kacltest.h #498976:498977
@@ -44,6 +44,7 @@
     void testSettingBasic();
     void testSettingExtended();
     void testSettingErrorHandling();
+    void testNewMask();
 
 private:
     KACL m_acl;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic