pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0038-certprofile-import-do-not-require-profileId-in-profi.patch

590d18
From ae5939600d367172a1e830c87254d2fc1bb56fe8 Mon Sep 17 00:00:00 2001
590d18
From: Christian Heimes <cheimes@redhat.com>
590d18
Date: Thu, 23 Jul 2015 17:48:56 +0200
590d18
Subject: [PATCH] certprofile-import: do not require profileId in profile data
590d18
590d18
certprofile-import no longer requires profileId in profile data. Instead
590d18
the profile ID from the command line is taken and added to the profile
590d18
data internally.
590d18
590d18
If profileId is set in the profile, then it still has to match the CLI
590d18
option.
590d18
590d18
https://fedorahosted.org/freeipa/ticket/5090
590d18
590d18
Reviewed-By: Martin Basti <mbasti@redhat.com>
590d18
---
590d18
 ipalib/plugins/certprofile.py | 8 +++++---
590d18
 1 file changed, 5 insertions(+), 3 deletions(-)
590d18
590d18
diff --git a/ipalib/plugins/certprofile.py b/ipalib/plugins/certprofile.py
590d18
index 5550ed942521dbab2e783fba1570520268f9b378..b0b76ca8e78f2482b5c08dad21d9161fd4c2c2d0 100644
590d18
--- a/ipalib/plugins/certprofile.py
590d18
+++ b/ipalib/plugins/certprofile.py
590d18
@@ -11,6 +11,7 @@ from ipalib.plugins.virtual import VirtualCommand
590d18
 from ipalib.plugins.baseldap import (
590d18
     LDAPObject, LDAPSearch, LDAPCreate,
590d18
     LDAPDelete, LDAPUpdate, LDAPRetrieve)
590d18
+from ipalib.request import context
590d18
 from ipalib import ngettext
590d18
 from ipalib.text import _
590d18
 from ipapython.version import API_VERSION
590d18
@@ -230,11 +231,12 @@ class certprofile_import(LDAPCreate):
590d18
 
590d18
     def pre_callback(self, ldap, dn, entry, entry_attrs, *keys, **options):
590d18
         ca_enabled_check()
590d18
+        context.profile = options['file']
590d18
 
590d18
         match = self.PROFILE_ID_PATTERN.search(options['file'])
590d18
         if match is None:
590d18
-            raise errors.ValidationError(name='file',
590d18
-                error=_("Profile ID is not present in profile data"))
590d18
+            # no profileId found, use CLI value as profileId.
590d18
+            context.profile = u'profileId=%s\n%s' % (keys[0], context.profile)
590d18
         elif keys[0] != match.group(1):
590d18
             raise errors.ValidationError(name='file',
590d18
                 error=_("Profile ID '%(cli_value)s' does not match profile data '%(file_value)s'")
590d18
@@ -250,7 +252,7 @@ class certprofile_import(LDAPCreate):
590d18
         """
590d18
         try:
590d18
             with self.api.Backend.ra_certprofile as profile_api:
590d18
-                profile_api.create_profile(options['file'])
590d18
+                profile_api.create_profile(context.profile)
590d18
                 profile_api.enable_profile(keys[0])
590d18
         except:
590d18
             # something went wrong ; delete entry
590d18
-- 
590d18
2.4.3
590d18