For anyone not on the commit list, if you notice some chatty logging when visiting the package details page it's because I'm trying to capture what's going on on the rare occasion the ACL bug on this page manifests itself. I'll remove the log messages as soon as I get some more information. Sorry for the log spam in the meantime.

-------- Original Message --------
Subject: java/code
Date: Tue, 12 May 2009 19:18:50 +0000 (UTC)
From: Jason Dobies <j...@fedoraproject.org>
Reply-To: Mailing list for spacewalk commits. <spacewalk-comm...@lists.fedorahosted.org>
To: spacewalk-comm...@lists.fedorahosted.org


java/code/src/com/redhat/rhn/common/security/acl/PackageAclHandler.java | 40 ++++++++-- java/code/src/com/redhat/rhn/domain/common/ArchType.java | 11 ++
 2 files changed, 44 insertions(+), 7 deletions(-)

New commits:
commit 3363f86e4acadcbbaedadc4e5f8076fb29aa27de
Author: Jason Dobies <jason.dob...@redhat.com>
Date:   Tue May 12 15:15:37 2009 -0400

495506 - Added temporary verbose logging in case of failed ACL checks for package details page to debug this issue in the next QA build; will remove afterwards.

diff --git a/java/code/src/com/redhat/rhn/common/security/acl/PackageAclHandler.java b/java/code/src/com/redhat/rhn/common/security/acl/PackageAclHandler.java
index 10af8ba..f8d3a81 100644
--- a/java/code/src/com/redhat/rhn/common/security/acl/PackageAclHandler.java +++ b/java/code/src/com/redhat/rhn/common/security/acl/PackageAclHandler.java
@@ -26,14 +26,17 @@ import com.redhat.rhn.manager.rhnpackage.PackageManager;

 import java.util.List;
 import java.util.Map;
-
-
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;

 /**
  * ActivationKeyAclHandler
  * @version $Rev$
  */
 public class PackageAclHandler extends BaseHandler implements AclHandler {
+
+    private final Log log = LogFactory.getLog(this.getClass());
+
     /**
      * Returns true if the Token whose id matches the given tid,
      * has the requested entitlement given by entitlement label in param 0
@@ -66,26 +69,49 @@ public class PackageAclHandler extends BaseHandler implements AclHandler {
      */
     public boolean aclPackageTypeCapable(Object ctx, String[] params) {

+ /* 495506 - Increased the logging since I can't reliably reproduce the issue. + I'll make this quiet again when we figure out why this incorrectly returns
+           false on the Satellite 5.3 builds.
+           jdobies, May 12, 2009
+         */
+
+        if (params.length == 0) {
+ log.warn("Incorrect number of parameters specified to ACL check");
+            return false;
+        }
+
+        String cap = params[0];
         Map map = (Map) ctx;

         User user = (User) map.get("user");
         Long pid = getAsLong(map.get("pid"));
         Package pack = PackageManager.lookupByIdAndUser(pid, user);

- if (user == null || pid == null || params.length == 0 || pack == null) {
+        if (user == null || pid == null || pack == null) {
+ log.warn("Check for capability [" + cap + "] is false. Package: " + pack);
             return false;
         }
-
-        String cap = params[0];
+
         ArchType type = pack.getPackageArch().getArchType();
-
Map<ArchType, List<String>> capMap = PackageFactory.getPackageCapabilityMap();

         if (capMap.get(type) == null) {
+ log.warn("Check for capability [" + cap + "] on type [" + type +
+                     "] is false. Type not found in map. Map contents:");
+            for (ArchType typeKey : capMap.keySet()) {
+                log.warn("Type key: " + typeKey);
+            }
             return false;
         }

-        return capMap.get(type).contains(cap);
+        boolean capFound = capMap.get(type).contains(cap);
+
+        if (!capFound) {
+ log.warn("Check for capability [" + cap + "] on type [" + type +
+                     "] is false. Capability not found in map.");
+        }
+
+        return capFound;
     }

 }
diff --git a/java/code/src/com/redhat/rhn/domain/common/ArchType.java b/java/code/src/com/redhat/rhn/domain/common/ArchType.java
index c59aaf5..1f10a05 100644
--- a/java/code/src/com/redhat/rhn/domain/common/ArchType.java
+++ b/java/code/src/com/redhat/rhn/domain/common/ArchType.java
@@ -14,6 +14,7 @@
  */
 package com.redhat.rhn.domain.common;

+import org.apache.commons.lang.builder.ToStringBuilder;
 import com.redhat.rhn.domain.BaseDomainHelper;

 /**
@@ -90,4 +91,14 @@ public class ArchType extends BaseDomainHelper {
     public int hashCode() {
         return id != null ? id.hashCode() : 0;
     }
+
+    /** {...@inheritdoc} */
+    public String toString() {
+        ToStringBuilder builder = new ToStringBuilder(this);
+
+        builder.append("id", id);
+        builder.append("label", label);
+
+        return builder.toString();
+    }
 }


_______________________________________________
spacewalk-commits mailing list
spacewalk-comm...@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/spacewalk-commits

--
Jason Dobies
RHN Satellite / Spacewalk
RHCE# 805008743336126
Freenode: jdob @ #spacewalk #spacewalk-devel

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to