There is no client side logic stopping an empty profile name from being
set, so it's possible for someone to try and set empty system profile
names during registration. The automatic profile name as determined by
rhn_register might also fail and give an empty profile name (as can
happen with KVM guests).

Add some server-side logic to set a reasonable default profile name
("unknown") if one is not provided, rather than causing an ISE due to a
schema constraint.

Patch attached.

-James
From a6dc848d048a1a706635c09ca5e9cf34222172c9 Mon Sep 17 00:00:00 2001
From: James Bowes <[email protected]>
Date: Fri, 3 Jul 2009 12:18:24 -0400
Subject: [PATCH] Set a default system profile name if one isn't given

There is no client side logic stopping an empty profile name from being
set, so it's possible for someone to try and set empty system profile
names during registration. The automatic profile name as determined by
rhn_register might also fail and give an empty profile name (as can
happen with KVM guests).

Add some server-side logic to set a reasonable default profile name
("unknown") if one is not provided, rather than causing an ISE due to a
schema constraint.
---
 backend/server/handlers/xmlrpc/registration.py |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/backend/server/handlers/xmlrpc/registration.py 
b/backend/server/handlers/xmlrpc/registration.py
index 3172143..6001fe6 100644
--- a/backend/server/handlers/xmlrpc/registration.py
+++ b/backend/server/handlers/xmlrpc/registration.py
@@ -303,9 +303,12 @@ class Registration(rhnHandler):
             for hw in data['hardware_profile']:
                 newserv.add_hardware(hw)
         # fill in the other details from the data dictionary
-        if profile_name is not None and not \
-           rhnFlags.test("re_registration_token"):
-            newserv.server["name"] = profile_name[:128]
+        if not rhnFlags.test("re_registration_token"):
+            if profile_name not in [None, ""]:
+                newserv.server["name"] = profile_name[:128]
+            else:
+                # some clients can send up an empty profile name.
+                newserv.server["name"] = "unknown"
         if data.has_key("os"):
             newserv.server["os"] = data["os"][:64]
         if data.has_key("description"):
-- 
1.6.2.5

Attachment: pgpwPy3PSVUjZ.pgp
Description: PGP signature

_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to