|
|
ac7d03 |
From 5012843d350b7a39b78e4eb7cab6cff98cae59d5 Mon Sep 17 00:00:00 2001
|
|
|
ac7d03 |
From: Martin Babinsky <mbabinsk@redhat.com>
|
|
|
ac7d03 |
Date: Fri, 12 May 2017 17:25:30 +0200
|
|
|
ac7d03 |
Subject: [PATCH] Add `pkinit-status` command
|
|
|
ac7d03 |
|
|
|
ac7d03 |
This command is a more streamlined reporting tool for PKINIT feature
|
|
|
ac7d03 |
status in the FreeIPA topology. It prints out whether PKINIT is enabled
|
|
|
ac7d03 |
or disabled on individual masters in a topology. If a`--server` is
|
|
|
ac7d03 |
specified, it reports status for an individual server. If `--status` is
|
|
|
ac7d03 |
specified, it searches for all servers that have PKINIT enabled or
|
|
|
ac7d03 |
disabled.
|
|
|
ac7d03 |
|
|
|
ac7d03 |
https://pagure.io/freeipa/issue/6937
|
|
|
ac7d03 |
|
|
|
ac7d03 |
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
|
|
|
ac7d03 |
Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
|
|
|
ac7d03 |
---
|
|
|
ac7d03 |
API.txt | 15 ++++++
|
|
|
ac7d03 |
VERSION.m4 | 4 +-
|
|
|
ac7d03 |
ipaserver/plugins/pkinit.py | 109 +++++++++++++++++++++++++++++++++++++++++++-
|
|
|
ac7d03 |
3 files changed, 125 insertions(+), 3 deletions(-)
|
|
|
ac7d03 |
|
|
|
ac7d03 |
diff --git a/API.txt b/API.txt
|
|
|
ac7d03 |
index 4e6754afe2deab5c963577f1e1363f1123a31a86..6511ad8d1cb4dc9079628fc058312f31aaec624d 100644
|
|
|
ac7d03 |
--- a/API.txt
|
|
|
ac7d03 |
+++ b/API.txt
|
|
|
ac7d03 |
@@ -3736,6 +3736,20 @@ command: ping/1
|
|
|
ac7d03 |
args: 0,1,1
|
|
|
ac7d03 |
option: Str('version?')
|
|
|
ac7d03 |
output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
|
|
ac7d03 |
+command: pkinit_status/1
|
|
|
ac7d03 |
+args: 1,7,4
|
|
|
ac7d03 |
+arg: Str('criteria?')
|
|
|
ac7d03 |
+option: Flag('all', autofill=True, cli_name='all', default=False)
|
|
|
ac7d03 |
+option: Flag('raw', autofill=True, cli_name='raw', default=False)
|
|
|
ac7d03 |
+option: Str('server_server?', autofill=False, cli_name='server')
|
|
|
ac7d03 |
+option: Int('sizelimit?', autofill=False)
|
|
|
ac7d03 |
+option: StrEnum('status?', autofill=False, cli_name='status', values=[u'enabled', u'disabled'])
|
|
|
ac7d03 |
+option: Int('timelimit?', autofill=False)
|
|
|
ac7d03 |
+option: Str('version?')
|
|
|
ac7d03 |
+output: Output('count', type=[<type 'int'>])
|
|
|
ac7d03 |
+output: ListOfEntries('result')
|
|
|
ac7d03 |
+output: Output('summary', type=[<type 'unicode'>, <type 'NoneType'>])
|
|
|
ac7d03 |
+output: Output('truncated', type=[<type 'bool'>])
|
|
|
ac7d03 |
command: plugins/1
|
|
|
ac7d03 |
args: 0,3,3
|
|
|
ac7d03 |
option: Flag('all', autofill=True, cli_name='all', default=True)
|
|
|
ac7d03 |
@@ -6798,6 +6812,7 @@ default: permission_remove_member/1
|
|
|
ac7d03 |
default: permission_show/1
|
|
|
ac7d03 |
default: ping/1
|
|
|
ac7d03 |
default: pkinit/1
|
|
|
ac7d03 |
+default: pkinit_status/1
|
|
|
ac7d03 |
default: plugins/1
|
|
|
ac7d03 |
default: privilege/1
|
|
|
ac7d03 |
default: privilege_add/1
|
|
|
ac7d03 |
diff --git a/VERSION.m4 b/VERSION.m4
|
|
|
ac7d03 |
index e10ee3cad6f5a6e023ea3cb9ec20591b7caae0bd..8aa3ef03f352cd176579c5d5848ed9550f22105d 100644
|
|
|
ac7d03 |
--- a/VERSION.m4
|
|
|
ac7d03 |
+++ b/VERSION.m4
|
|
|
ac7d03 |
@@ -73,8 +73,8 @@ define(IPA_DATA_VERSION, 20100614120000)
|
|
|
ac7d03 |
# #
|
|
|
ac7d03 |
########################################################
|
|
|
ac7d03 |
define(IPA_API_VERSION_MAJOR, 2)
|
|
|
ac7d03 |
-define(IPA_API_VERSION_MINOR, 226)
|
|
|
ac7d03 |
-# Last change: Remove the pkinit-anonymous command
|
|
|
ac7d03 |
+define(IPA_API_VERSION_MINOR, 227)
|
|
|
ac7d03 |
+# Last change: Add `pkinit-status` command
|
|
|
ac7d03 |
|
|
|
ac7d03 |
|
|
|
ac7d03 |
########################################################
|
|
|
ac7d03 |
diff --git a/ipaserver/plugins/pkinit.py b/ipaserver/plugins/pkinit.py
|
|
|
ac7d03 |
index e49b31091d676865fa7f023be8edc3cdef9d6d2c..970f955c54bc489765d2565255e8805138a35307 100644
|
|
|
ac7d03 |
--- a/ipaserver/plugins/pkinit.py
|
|
|
ac7d03 |
+++ b/ipaserver/plugins/pkinit.py
|
|
|
ac7d03 |
@@ -3,11 +3,33 @@
|
|
|
ac7d03 |
#
|
|
|
ac7d03 |
|
|
|
ac7d03 |
from ipalib import Object
|
|
|
ac7d03 |
-from ipalib import _
|
|
|
ac7d03 |
+from ipalib import _, ngettext
|
|
|
ac7d03 |
+from ipalib.crud import Search
|
|
|
ac7d03 |
+from ipalib.parameters import Int, Str, StrEnum
|
|
|
ac7d03 |
from ipalib.plugable import Registry
|
|
|
ac7d03 |
|
|
|
ac7d03 |
register = Registry()
|
|
|
ac7d03 |
|
|
|
ac7d03 |
+__doc__ = _("""
|
|
|
ac7d03 |
+Kerberos PKINIT feature status reporting tools.
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+Report IPA masters on which Kerberos PKINIT is enabled or disabled
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+EXAMPLES:
|
|
|
ac7d03 |
+ List PKINIT status on all masters:
|
|
|
ac7d03 |
+ ipa pkinit-status
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ Check PKINIT status on `ipa.example.com`:
|
|
|
ac7d03 |
+ ipa pkinit-status --server ipa.example.com
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ List all IPA masters with disabled PKINIT:
|
|
|
ac7d03 |
+ ipa pkinit-status --status='disabled'
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+For more info about PKINIT support see:
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+https://www.freeipa.org/page/V4/Kerberos_PKINIT
|
|
|
ac7d03 |
+""")
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
|
|
|
ac7d03 |
@register()
|
|
|
ac7d03 |
class pkinit(Object):
|
|
|
ac7d03 |
@@ -17,3 +39,88 @@ class pkinit(Object):
|
|
|
ac7d03 |
object_name = _('pkinit')
|
|
|
ac7d03 |
|
|
|
ac7d03 |
label = _('PKINIT')
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ takes_params = (
|
|
|
ac7d03 |
+ Str(
|
|
|
ac7d03 |
+ 'server_server?',
|
|
|
ac7d03 |
+ cli_name='server',
|
|
|
ac7d03 |
+ label=_('Server name'),
|
|
|
ac7d03 |
+ doc=_('IPA server hostname'),
|
|
|
ac7d03 |
+ ),
|
|
|
ac7d03 |
+ StrEnum(
|
|
|
ac7d03 |
+ 'status?',
|
|
|
ac7d03 |
+ cli_name='status',
|
|
|
ac7d03 |
+ label=_('PKINIT status'),
|
|
|
ac7d03 |
+ doc=_('Whether PKINIT is enabled or disabled'),
|
|
|
ac7d03 |
+ values=(u'enabled', u'disabled'),
|
|
|
ac7d03 |
+ flags={'virtual_attribute', 'no_create', 'no_update'}
|
|
|
ac7d03 |
+ )
|
|
|
ac7d03 |
+ )
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+@register()
|
|
|
ac7d03 |
+class pkinit_status(Search):
|
|
|
ac7d03 |
+ __doc__ = _('Report PKINIT status on the IPA masters')
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ msg_summary = ngettext('%(count)s server matched',
|
|
|
ac7d03 |
+ '%(count)s servers matched', 0)
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ takes_options = Search.takes_options + (
|
|
|
ac7d03 |
+ Int(
|
|
|
ac7d03 |
+ 'timelimit?',
|
|
|
ac7d03 |
+ label=_('Time Limit'),
|
|
|
ac7d03 |
+ doc=_('Time limit of search in seconds (0 is unlimited)'),
|
|
|
ac7d03 |
+ flags=['no_display'],
|
|
|
ac7d03 |
+ minvalue=0,
|
|
|
ac7d03 |
+ autofill=False,
|
|
|
ac7d03 |
+ ),
|
|
|
ac7d03 |
+ Int(
|
|
|
ac7d03 |
+ 'sizelimit?',
|
|
|
ac7d03 |
+ label=_('Size Limit'),
|
|
|
ac7d03 |
+ doc=_('Maximum number of entries returned (0 is unlimited)'),
|
|
|
ac7d03 |
+ flags=['no_display'],
|
|
|
ac7d03 |
+ minvalue=0,
|
|
|
ac7d03 |
+ autofill=False,
|
|
|
ac7d03 |
+ ),
|
|
|
ac7d03 |
+ )
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ def get_pkinit_status(self, server, status):
|
|
|
ac7d03 |
+ backend = self.api.Backend.serverroles
|
|
|
ac7d03 |
+ ipa_master_config = backend.config_retrieve("IPA master")
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ if server is not None:
|
|
|
ac7d03 |
+ servers = [server]
|
|
|
ac7d03 |
+ else:
|
|
|
ac7d03 |
+ servers = ipa_master_config['ipa_master_server']
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ pkinit_servers = ipa_master_config['pkinit_server_server']
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ for s in servers:
|
|
|
ac7d03 |
+ pkinit_status = {
|
|
|
ac7d03 |
+ u'server_server': s,
|
|
|
ac7d03 |
+ u'status': (
|
|
|
ac7d03 |
+ u'enabled' if s in pkinit_servers else u'disabled'
|
|
|
ac7d03 |
+ )
|
|
|
ac7d03 |
+ }
|
|
|
ac7d03 |
+ if status is not None and pkinit_status[u'status'] != status:
|
|
|
ac7d03 |
+ continue
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ yield pkinit_status
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ def execute(self, *keys, **options):
|
|
|
ac7d03 |
+ if keys:
|
|
|
ac7d03 |
+ return dict(
|
|
|
ac7d03 |
+ result=[],
|
|
|
ac7d03 |
+ count=0,
|
|
|
ac7d03 |
+ truncated=False
|
|
|
ac7d03 |
+ )
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ server = options.get('server_server', None)
|
|
|
ac7d03 |
+ status = options.get('status', None)
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ if server is not None:
|
|
|
ac7d03 |
+ self.api.Object.server_role.ensure_master_exists(server)
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ result = sorted(self.get_pkinit_status(server, status))
|
|
|
ac7d03 |
+
|
|
|
ac7d03 |
+ return dict(result=result, count=len(result), truncated=False)
|
|
|
ac7d03 |
--
|
|
|
ac7d03 |
2.9.4
|
|
|
ac7d03 |
|