[Spacewalk-devel] [PATCH] Pam setting on the user page not saving

2011-10-12 Thread Johannes Renner
Hello,

I just fixed a bug in Spacewalk about the pam setting on the user page not 
saving,
it can be reproduced like this:

1. Configure pam on the server (e.g. echo "pam_auth_service = rhn-satellite" >> 
/etc/rhn/rhn.conf)
2. Restart the tomcat
3. Log into spacewalk as an org_admin
4. In the page header click on  to edit the user's settings
5. Check on/off the "use pam" checkbox
6. Click on update

Result: The pam setting is not saved and the checkbox on the resulting page is
therefore shown in the same state as before.

(Note that it works to set the pam option for a user via "Users" -> )

Apply my attached patch for a fix, i.e. save the pam option using either
AdminUserEditAction.java or SelfUserEditAction.java.

Thanks,
Johannes

P.S.: I can also create a bugzilla entry if necessary, just tell me.

-- 
SUSE LINUX Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer, HRB 16746 (AG Nürnberg)
>From 4abfbdcaea3ea3ddc5d9bb6aa1d478f2975d5723 Mon Sep 17 00:00:00 2001
From: Johannes Renner 
Date: Wed, 12 Oct 2011 13:23:01 +0200
Subject: [PATCH] Fixed pam setting on user page not saving

---
 .../frontend/action/user/AdminUserEditAction.java  |   24 +--
 .../rhn/frontend/action/user/SelfEditAction.java   |3 ++
 .../frontend/action/user/UserEditActionHelper.java |   24 
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java b/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java
index e34b726..fdcd29d 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/user/AdminUserEditAction.java
@@ -14,8 +14,6 @@
  */
 package com.redhat.rhn.frontend.action.user;
 
-import com.redhat.rhn.common.conf.Config;
-import com.redhat.rhn.common.conf.ConfigDefaults;
 import com.redhat.rhn.common.security.PermissionException;
 import com.redhat.rhn.domain.org.Org;
 import com.redhat.rhn.domain.role.Role;
@@ -85,26 +83,8 @@ public class AdminUserEditAction extends UserEditActionHelper {
 return returnFailure(mapping, request, errors, targetUser.getId());
 }
 
-/*
- * Update PAM Authentication attribute
- * If we're a satellite that is configured to use pam and the loggedIn user is an
- * org_admin (and therefore the checkbox was displayed), we need to inspect the
- * "usepam" field on the form and set the targetUser's pam auth attribute
- * accordingly. (we don't want to set this field if it wasn't displayed or if the
- * user doesn't have access to set this attribute)
- */
-String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE);
-if (pamAuthService != null &&
-pamAuthService.trim().length() > 0 &&
-loggedInUser.hasRole(RoleFactory.ORG_ADMIN)) {
-if (form.get("usepam") != null &&
-((Boolean) form.get("usepam")).booleanValue()) {
-targetUser.setUsePamAuthentication(true);
-}
-else {
-targetUser.setUsePamAuthentication(false);
-}
-}
+// Update PAM Authentication attribute
+updatePamAttribute(loggedInUser, targetUser, form);
 
 //Create the user info updated success message
 createSuccessMessage(request, "message.userInfoUpdated", null);
diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java b/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java
index d7f8dcc..cf3201b 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/user/SelfEditAction.java
@@ -48,6 +48,9 @@ public class SelfEditAction extends UserEditActionHelper {
 
 //If there are no errors, store the user and return the success mapping
 if (errors.isEmpty()) {
+// Update the PAM Authentication attribute
+updatePamAttribute(user, user, form);
+
 UserManager.storeUser(user);
 
 ActionMessages msgs = new ActionMessages();
diff --git a/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java b/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java
index c61fbc6..a9c1625 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/user/UserEditActionHelper.java
@@ -14,6 +14,9 @@
  */
 package com.redhat.rhn.frontend.action.user;
 
+import com.redhat.rhn.common.conf.Config;
+import com.redhat.rhn.common.conf.ConfigDefaults;
+import com.redhat.rhn.domain.role.RoleFactory;
 import com.redhat.rhn.domain.user.User;
 import com.redhat.rhn.frontend.struts.RhnAction;
 import com.redhat.rhn.frontend.struts.RhnValida

[Spacewalk-devel] [PATCH] Set breed in cobbler correctly

2011-10-12 Thread Uwe Gansert
Hi,

I noticed that the breed in cobbler is not set correctly when you edit/create 
a distro with the webfrontend.
I did a patch to fix that and attached it.


-- 
ciao, Uwe Gansert

SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
Home: http://www.suse.de/~ug - Blog: http://suse.gansert.net
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartInstallType.java b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartInstallType.java
index bdc0c35..56063e7 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartInstallType.java
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartInstallType.java
@@ -32,6 +32,7 @@ public class KickstartInstallType extends BaseDomainHelper {
 public static final String FEDORA = "fedora";
 public static final String GENERIC = "generic";
 public static final String SUSE = "suse";
+public static final String REDHAT = "redhat";
 
 private Long id;
 private String label;
@@ -166,4 +167,20 @@ public class KickstartInstallType extends BaseDomainHelper {
 return new HashCodeBuilder().append(getLabel()).toHashCode();
 }
 
+/**
+ * get the string cobbler understands as breed
+ * @return cobbler breed compatible string
+ */
+public String getCobblerBreed() {
+	String breed = REDHAT;
+	
+	if(getLabel().equals("generic_rpm")) {
+		breed = GENERIC;
+	} else if(getLabel().equals(SUSE)) {
+		breed = SUSE;
+	}
+
+	return breed;
+}
+
 }
diff --git a/java/code/src/com/redhat/rhn/manager/kickstart/cobbler/CobblerDistroCommand.java b/java/code/src/com/redhat/rhn/manager/kickstart/cobbler/CobblerDistroCommand.java
index 77ffa19..f495f2d 100644
--- a/java/code/src/com/redhat/rhn/manager/kickstart/cobbler/CobblerDistroCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/kickstart/cobbler/CobblerDistroCommand.java
@@ -84,12 +84,14 @@ public class CobblerDistroCommand extends CobblerCommand {
 if (xen == null) {
 xen = Distro.create(con, tree.getCobblerXenDistroName(),
 tree.getKernelXenPath(), tree.getInitrdXenPath(), ksmeta);
+xen.setBreed(tree.getInstallType().getCobblerBreed());
 xen.save();
 tree.setCobblerXenId(xen.getId());
 }
 else {
 xen.setKernel(tree.getKernelXenPath());
 xen.setInitrd(tree.getInitrdXenPath());
+xen.setBreed(tree.getInstallType().getCobblerBreed());
 xen.setKsMeta(ksmeta);
 xen.save();
 }
@@ -106,6 +108,7 @@ public class CobblerDistroCommand extends CobblerCommand {
 if (nonXen != null) {
 nonXen.setInitrd(tree.getInitrdPath());
 nonXen.setKernel(tree.getKernelPath());
+nonXen.setBreed(tree.getInstallType().getCobblerBreed());
 nonXen.setKsMeta(ksmeta);
 nonXen.save();
 }
___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] [PATCH] Pam setting on the user page not saving

2011-10-12 Thread Tomas Lestach

Hello Johannes,

yes, you're right.

I just have one comment to your patch - I'd move updatePamAttribute() in 
SelfEditAction.java file into the updateDetails method. If you're ok 
with the change, I'd commit it.

Let me know.


Regards,
--
Tomas Lestach
RHN Satellite Engineering, Red Hat


On 10/12/2011 02:28 PM, Johannes Renner wrote:

Hello,

I just fixed a bug in Spacewalk about the pam setting on the user page not 
saving,
it can be reproduced like this:

1. Configure pam on the server (e.g. echo "pam_auth_service = rhn-satellite">>  
/etc/rhn/rhn.conf)
2. Restart the tomcat
3. Log into spacewalk as an org_admin
4. In the page header click on  to edit the user's settings
5. Check on/off the "use pam" checkbox
6. Click on update

Result: The pam setting is not saved and the checkbox on the resulting page is
therefore shown in the same state as before.

(Note that it works to set the pam option for a user via "Users" ->  )

Apply my attached patch for a fix, i.e. save the pam option using either
AdminUserEditAction.java or SelfUserEditAction.java.

Thanks,
Johannes

P.S.: I can also create a bugzilla entry if necessary, just tell me.




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


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


Re: [Spacewalk-devel] [PATCH] Pam setting on the user page not saving

2011-10-12 Thread Johannes Renner
On 10/12/2011 05:00 PM, Tomas Lestach wrote:
> Hello Johannes,
> 
> yes, you're right.
> 
> I just have one comment to your patch - I'd move updatePamAttribute() in 
> SelfEditAction.java file
> into the updateDetails method. If you're ok with the change, I'd commit it.
> Let me know.

Yes, I was just keeping things separated, but it seems as if there would be no
difference in the semantics. And you rather mean the class UserEditActionHelper,
right? You will then also need to add another parameter for the updateDetails()
method (the loggedInUser), but sure, commit it ;-)

Thanks,
Johannes

> Regards,
> -- 
> Tomas Lestach
> RHN Satellite Engineering, Red Hat
> 
> 
> On 10/12/2011 02:28 PM, Johannes Renner wrote:
>> Hello,
>>
>> I just fixed a bug in Spacewalk about the pam setting on the user page not 
>> saving,
>> it can be reproduced like this:
>>
>> 1. Configure pam on the server (e.g. echo "pam_auth_service = 
>> rhn-satellite">>  /etc/rhn/rhn.conf)
>> 2. Restart the tomcat
>> 3. Log into spacewalk as an org_admin
>> 4. In the page header click on  to edit the user's settings
>> 5. Check on/off the "use pam" checkbox
>> 6. Click on update
>>
>> Result: The pam setting is not saved and the checkbox on the resulting page 
>> is
>> therefore shown in the same state as before.
>>
>> (Note that it works to set the pam option for a user via "Users" ->  
>> )
>>
>> Apply my attached patch for a fix, i.e. save the pam option using either
>> AdminUserEditAction.java or SelfUserEditAction.java.
>>
>> Thanks,
>> Johannes
>>
>> P.S.: I can also create a bugzilla entry if necessary, just tell me.
>>
>>
>>
>>
>> ___
>> Spacewalk-devel mailing list
>> Spacewalk-devel@redhat.com
>> https://www.redhat.com/mailman/listinfo/spacewalk-devel
> 
> ___
> Spacewalk-devel mailing list
> Spacewalk-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-devel

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


Re: [Spacewalk-devel] [PATCH] Set breed in cobbler correctly

2011-10-12 Thread Tomas Lestach

Hello Uwe,

thank you for your patch.
I just needed to make minor formatting changes to match our checkstyle 
rules.

Commited as: 43100e9cd4b055b1421c3e9614455586763fab08
http://git.fedorahosted.org/git/?p=spacewalk.git;a=commitdiff;h=43100e9cd4b055b1421c3e9614455586763fab08

Thank you!

Regards,
Tomas
--
Tomas Lestach
RHN Satellite Engineering, Red Hat

On 10/12/2011 03:25 PM, Uwe Gansert wrote:

Hi,

I noticed that the breed in cobbler is not set correctly when you edit/create
a distro with the webfrontend.
I did a patch to fix that and attached it.





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


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