2009-05-13 07:21:30 -05:00
|
|
|
# Authors:
|
|
|
|
# Rob Crittenden <rcritten@redhat.com>
|
|
|
|
# Pavel Zuna <pzuna@redhat.com>
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Red Hat
|
|
|
|
# see file 'COPYING' for use and warranty information
|
|
|
|
#
|
2010-12-09 06:59:11 -06:00
|
|
|
# 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.
|
2009-05-13 07:21:30 -05:00
|
|
|
#
|
|
|
|
# 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
|
2010-12-09 06:59:11 -06:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-05-13 07:21:30 -05:00
|
|
|
"""
|
2010-08-24 22:40:32 -05:00
|
|
|
Manage the IPA configuration
|
2010-06-02 13:08:50 -05:00
|
|
|
|
2011-03-04 10:08:54 -06:00
|
|
|
Manage the default values that IPA uses and some of its tuning parameters.
|
2010-06-02 13:08:50 -05:00
|
|
|
|
2010-08-24 22:40:32 -05:00
|
|
|
To show the current configuration:
|
2010-06-02 13:08:50 -05:00
|
|
|
ipa config-show
|
|
|
|
|
2010-08-24 22:40:32 -05:00
|
|
|
To modify the configuration:
|
2010-06-02 13:08:50 -05:00
|
|
|
ipa config-mod --maxusername=99
|
|
|
|
|
|
|
|
The available options are:
|
|
|
|
|
|
|
|
User management options:
|
|
|
|
|
2011-03-04 10:08:54 -06:00
|
|
|
--maxusername=INT Max. username length when creating/modifying a user
|
2010-06-02 13:08:50 -05:00
|
|
|
--homedirectory=STR Default location of home directories (default /home)
|
|
|
|
--defaultshell=STR Default shell for new users (default /bin/sh)
|
2010-12-03 02:39:29 -06:00
|
|
|
--defaultgroup=STR Default group for new users (default ipausers). The
|
2011-03-04 10:08:54 -06:00
|
|
|
group must exist, or adding new users will fail.
|
|
|
|
--emaildomain=STR Default e-mail domain for new users
|
2010-06-02 13:08:50 -05:00
|
|
|
|
|
|
|
Search tuning options. These impact how much data is searched through and
|
|
|
|
how many records may be returned on a given search.
|
|
|
|
|
2011-02-07 10:42:17 -06:00
|
|
|
--searchtimelimit=INT Max. amount of time (sec.) for a search (> 0, or -1 for
|
2010-06-02 13:08:50 -05:00
|
|
|
unlimited)
|
|
|
|
--searchrecordslimit=INT Max. number of records to search (-1 is unlimited)
|
|
|
|
|
|
|
|
Server Configuration.
|
|
|
|
|
|
|
|
--enable-migration=BOOL Enable migration mode
|
2010-12-01 16:48:41 -06:00
|
|
|
--pwdexpnotify=INT Password Expiration Notification (days)
|
2010-06-02 13:08:50 -05:00
|
|
|
|
2010-12-01 16:48:41 -06:00
|
|
|
The password notification value is stored here so it will be replicated.
|
|
|
|
It is not currently used to notify users in advance of an expiring
|
|
|
|
password.
|
|
|
|
|
2011-03-04 10:08:54 -06:00
|
|
|
Some attributes are read-only, provided only for information purposes. These
|
2010-12-01 16:48:41 -06:00
|
|
|
include:
|
|
|
|
|
|
|
|
Certificate Subject base: the configured certificate subject base,
|
|
|
|
e.g. O=EXAMPLE.COM. This is configurable only at install time.
|
2011-03-04 10:08:54 -06:00
|
|
|
Password plug-in features: currently defines additional hashes that the
|
2010-12-01 16:48:41 -06:00
|
|
|
password will generate (there may be other conditions).
|
2009-05-13 07:21:30 -05:00
|
|
|
"""
|
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
from ipalib import api
|
2010-12-06 14:09:03 -06:00
|
|
|
from ipalib import Bool, Int, Str, IA5Str
|
2009-08-27 08:49:58 -05:00
|
|
|
from ipalib.plugins.baseldap import *
|
2010-02-19 10:08:16 -06:00
|
|
|
from ipalib import _
|
2011-01-13 12:08:52 -06:00
|
|
|
from ipalib.errors import ValidationError
|
2009-05-13 07:21:30 -05:00
|
|
|
|
|
|
|
|
2011-01-13 12:08:52 -06:00
|
|
|
def validate_searchtimelimit(ugettext, limit):
|
|
|
|
if limit == 0:
|
|
|
|
raise ValidationError(name='ipasearchtimelimit', error=_('searchtimelimit must be -1 or > 1.'))
|
|
|
|
return None
|
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
class config(LDAPObject):
|
2009-05-13 07:21:30 -05:00
|
|
|
"""
|
2009-08-27 08:49:58 -05:00
|
|
|
IPA configuration object
|
2009-05-13 07:21:30 -05:00
|
|
|
"""
|
2009-08-27 08:49:58 -05:00
|
|
|
object_name = 'configuration options'
|
|
|
|
default_attributes = [
|
|
|
|
'ipamaxusernamelength', 'ipahomesrootdir', 'ipadefaultloginshell',
|
2010-12-05 02:26:52 -06:00
|
|
|
'ipadefaultprimarygroup', 'ipadefaultemaildomain', 'ipasearchtimelimit',
|
2009-08-27 08:49:58 -05:00
|
|
|
'ipasearchrecordslimit', 'ipausersearchfields', 'ipagroupsearchfields',
|
2010-01-20 10:26:20 -06:00
|
|
|
'ipamigrationenabled', 'ipacertificatesubjectbase',
|
2009-08-27 08:49:58 -05:00
|
|
|
]
|
|
|
|
|
2010-09-24 19:48:23 -05:00
|
|
|
label = _('Configuration')
|
2011-06-23 19:48:50 -05:00
|
|
|
label_singular = _('configuration')
|
2010-09-24 19:48:23 -05:00
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
takes_params = (
|
2009-05-13 07:21:30 -05:00
|
|
|
Int('ipamaxusernamelength?',
|
|
|
|
cli_name='maxusername',
|
2011-03-04 10:08:54 -06:00
|
|
|
label=_('Max. username length'),
|
2009-05-13 07:21:30 -05:00
|
|
|
minvalue=1,
|
|
|
|
),
|
2010-12-06 14:09:03 -06:00
|
|
|
IA5Str('ipahomesrootdir?',
|
2009-05-13 07:21:30 -05:00
|
|
|
cli_name='homedirectory',
|
2010-02-19 10:08:16 -06:00
|
|
|
label=_('Home directory base'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Default location of home directories.'),
|
2009-05-13 07:21:30 -05:00
|
|
|
),
|
|
|
|
Str('ipadefaultloginshell?',
|
|
|
|
cli_name='defaultshell',
|
2010-02-19 10:08:16 -06:00
|
|
|
label=_('Default shell'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Default shell for new users.'),
|
2009-05-13 07:21:30 -05:00
|
|
|
),
|
|
|
|
Str('ipadefaultprimarygroup?',
|
|
|
|
cli_name='defaultgroup',
|
2010-02-19 10:08:16 -06:00
|
|
|
label=_('Default users group'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Default group for new users.'),
|
2009-05-13 07:21:30 -05:00
|
|
|
),
|
|
|
|
Str('ipadefaultemaildomain?',
|
|
|
|
cli_name='emaildomain',
|
2011-03-04 10:08:54 -06:00
|
|
|
label=_('Default e-mail domain for new users'),
|
|
|
|
doc=_('Default e-mail domain new users.'),
|
2009-05-13 07:21:30 -05:00
|
|
|
),
|
2011-01-13 12:08:52 -06:00
|
|
|
Int('ipasearchtimelimit?', validate_searchtimelimit,
|
2009-05-13 07:21:30 -05:00
|
|
|
cli_name='searchtimelimit',
|
2010-02-19 10:08:16 -06:00
|
|
|
label=_('Search time limit'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Max. amount of time (sec.) for a search (> 0, or -1 for unlimited).'),
|
2009-05-13 07:21:30 -05:00
|
|
|
minvalue=-1,
|
|
|
|
),
|
|
|
|
Int('ipasearchrecordslimit?',
|
|
|
|
cli_name='searchrecordslimit',
|
2010-02-19 10:08:16 -06:00
|
|
|
label=_('Search size limit'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Max. number of records to search (-1 is unlimited).'),
|
2009-05-13 07:21:30 -05:00
|
|
|
minvalue=-1,
|
|
|
|
),
|
2010-12-06 14:09:03 -06:00
|
|
|
IA5Str('ipausersearchfields?',
|
2009-05-13 07:21:30 -05:00
|
|
|
cli_name='usersearch',
|
2010-02-19 10:08:16 -06:00
|
|
|
label=_('User search fields'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('A comma-separated list of fields to search when searching for users.'),
|
2009-05-13 07:21:30 -05:00
|
|
|
),
|
2010-12-06 14:09:03 -06:00
|
|
|
IA5Str('ipagroupsearchfields?',
|
2009-05-13 07:21:30 -05:00
|
|
|
cli_name='groupsearch',
|
2010-01-20 10:26:20 -06:00
|
|
|
label='Group search fields',
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('A comma-separated list of fields to search when searching for groups.'),
|
2009-05-13 07:21:30 -05:00
|
|
|
),
|
2009-11-30 05:10:06 -06:00
|
|
|
Bool('ipamigrationenabled?',
|
|
|
|
cli_name='enable_migration',
|
2011-06-30 12:45:35 -05:00
|
|
|
label=_('Enable migration mode'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Enable migration mode.'),
|
2009-11-30 05:10:06 -06:00
|
|
|
),
|
2010-01-20 10:26:20 -06:00
|
|
|
Str('ipacertificatesubjectbase?',
|
|
|
|
cli_name='subject',
|
2010-02-19 10:08:16 -06:00
|
|
|
label=_('Certificate Subject base'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Base for certificate subjects (OU=Test,O=Example).'),
|
2010-12-01 16:48:41 -06:00
|
|
|
flags=['no_update'],
|
|
|
|
),
|
|
|
|
List('ipagroupobjectclasses?',
|
|
|
|
cli_name='groupobjectclasses',
|
|
|
|
label=_('Default group objectclasses'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Default group objectclassses (comma-separated list).'),
|
2010-12-01 16:48:41 -06:00
|
|
|
),
|
|
|
|
List('ipauserobjectclasses?',
|
|
|
|
cli_name='userobjectclasses',
|
|
|
|
label=_('Default user objectclasses'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Default user objectclassses (comma-separated list).'),
|
2010-12-01 16:48:41 -06:00
|
|
|
),
|
|
|
|
Int('ipapwdexpadvnotify?',
|
|
|
|
cli_name='pwdexpnotify',
|
|
|
|
label=_('Password Expiration Notification'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Number of days\'s notice of impending password expiration.'),
|
2010-12-01 16:48:41 -06:00
|
|
|
minvalue=0,
|
|
|
|
),
|
|
|
|
Str('ipaconfigstring?',
|
|
|
|
cli_name='ipaconfigstring',
|
|
|
|
label=_('Password plugin features'),
|
2011-03-04 10:08:54 -06:00
|
|
|
doc=_('Extra hashes to generate in password plug-in.'),
|
2010-12-01 16:48:41 -06:00
|
|
|
flags=['no_update'],
|
2010-01-20 10:26:20 -06:00
|
|
|
),
|
2009-05-13 07:21:30 -05:00
|
|
|
)
|
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
def get_dn(self, *keys, **kwargs):
|
|
|
|
return 'cn=ipaconfig,cn=etc'
|
2009-05-13 07:21:30 -05:00
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
api.register(config)
|
2009-05-13 07:21:30 -05:00
|
|
|
|
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
class config_mod(LDAPUpdate):
|
|
|
|
"""
|
|
|
|
Modify configuration options.
|
|
|
|
"""
|
2009-11-30 05:10:06 -06:00
|
|
|
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
|
|
|
|
if 'ipamigrationenabled' in entry_attrs:
|
|
|
|
if entry_attrs['ipamigrationenabled']:
|
|
|
|
entry_attrs['ipamigrationenabled'] = 'TRUE'
|
|
|
|
else:
|
|
|
|
entry_attrs['ipamigrationenabled'] = 'FALSE'
|
2010-12-06 10:08:10 -06:00
|
|
|
if 'ipadefaultprimarygroup' in entry_attrs:
|
|
|
|
group=entry_attrs['ipadefaultprimarygroup']
|
|
|
|
try:
|
|
|
|
api.Command['group_show'](group)
|
|
|
|
except errors.NotFound:
|
|
|
|
raise errors.NotFound(message=unicode("The group doesn't exist"))
|
2011-01-25 14:25:52 -06:00
|
|
|
kw = {}
|
|
|
|
if 'ipausersearchfields' in entry_attrs:
|
|
|
|
kw['ipausersearchfields'] = 'ipauserobjectclasses'
|
|
|
|
if 'ipagroupsearchfields' in entry_attrs:
|
|
|
|
kw['ipagroupsearchfields'] = 'ipagroupobjectclasses'
|
|
|
|
if kw:
|
|
|
|
config = ldap.get_ipa_config(kw.values())
|
|
|
|
for (k, v) in kw.iteritems():
|
|
|
|
allowed_attrs = ldap.get_allowed_attributes(config[1][v])
|
|
|
|
fields = entry_attrs[k].split(',')
|
|
|
|
for a in fields:
|
|
|
|
a = a.strip()
|
|
|
|
if a not in allowed_attrs:
|
|
|
|
raise errors.ValidationError(
|
|
|
|
name=k, error='attribute "%s" not allowed' % a
|
|
|
|
)
|
2009-11-30 05:10:06 -06:00
|
|
|
return dn
|
2009-05-13 07:21:30 -05:00
|
|
|
|
2009-07-02 02:50:48 -05:00
|
|
|
api.register(config_mod)
|
2009-05-13 07:21:30 -05:00
|
|
|
|
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
class config_show(LDAPRetrieve):
|
2009-05-13 07:21:30 -05:00
|
|
|
"""
|
2010-08-24 22:40:32 -05:00
|
|
|
Show the current configuration.
|
2009-05-13 07:21:30 -05:00
|
|
|
"""
|
|
|
|
|
2009-08-27 08:49:58 -05:00
|
|
|
api.register(config_show)
|