2013-04-11 09:59:41 -05:00
|
|
|
# Authors:
|
|
|
|
# Tomas Babej <tbabej@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2013 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-05-23 11:35:57 -05:00
|
|
|
import logging
|
|
|
|
|
2016-03-03 08:12:19 -06:00
|
|
|
from ipalib import Registry, errors
|
2015-03-18 09:46:00 -05:00
|
|
|
from ipalib import Updater
|
2013-04-11 09:59:41 -05:00
|
|
|
from ipapython.dn import DN
|
|
|
|
|
2017-05-23 11:35:57 -05:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2016-03-03 08:12:19 -06:00
|
|
|
register = Registry()
|
2013-04-11 09:59:41 -05:00
|
|
|
|
2016-03-03 08:12:19 -06:00
|
|
|
|
|
|
|
@register()
|
2015-03-18 09:46:00 -05:00
|
|
|
class update_pacs(Updater):
|
2013-04-11 09:59:41 -05:00
|
|
|
"""
|
|
|
|
Includes default nfs:None only if no nfs: PAC present in ipakrbauthzdata.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def execute(self, **options):
|
2015-03-18 09:46:00 -05:00
|
|
|
ldap = self.api.Backend.ldap2
|
2013-04-11 09:59:41 -05:00
|
|
|
|
|
|
|
try:
|
2015-03-19 09:32:21 -05:00
|
|
|
dn = DN('cn=ipaConfig', 'cn=etc', self.api.env.basedn)
|
2013-04-11 09:59:41 -05:00
|
|
|
entry = ldap.get_entry(dn, ['ipakrbauthzdata'])
|
|
|
|
pacs = entry.get('ipakrbauthzdata', [])
|
|
|
|
except errors.NotFound:
|
2017-05-23 11:35:57 -05:00
|
|
|
logger.warning('Error retrieving: %s', str(dn))
|
2015-03-17 11:56:34 -05:00
|
|
|
return False, []
|
2013-04-11 09:59:41 -05:00
|
|
|
|
|
|
|
nfs_pac_set = any(pac.startswith('nfs:') for pac in pacs)
|
|
|
|
|
|
|
|
if not nfs_pac_set:
|
2017-05-23 11:35:57 -05:00
|
|
|
logger.debug('Adding nfs:NONE to default PAC types')
|
2013-04-11 09:59:41 -05:00
|
|
|
|
|
|
|
updated_pacs = pacs + [u'nfs:NONE']
|
|
|
|
entry['ipakrbauthzdata'] = updated_pacs
|
|
|
|
ldap.update_entry(entry)
|
|
|
|
else:
|
2017-05-23 11:35:57 -05:00
|
|
|
logger.debug('PAC for nfs is already set, not adding nfs:NONE.')
|
2013-04-11 09:59:41 -05:00
|
|
|
|
2015-03-17 11:56:34 -05:00
|
|
|
return False, []
|