id
int64 0
458k
| file_name
stringlengths 4
119
| file_path
stringlengths 14
227
| content
stringlengths 24
9.96M
| size
int64 24
9.96M
| language
stringclasses 1
value | extension
stringclasses 14
values | total_lines
int64 1
219k
| avg_line_length
float64 2.52
4.63M
| max_line_length
int64 5
9.91M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 7
101
| repo_stars
int64 100
139k
| repo_forks
int64 0
26.4k
| repo_open_issues
int64 0
2.27k
| repo_license
stringclasses 12
values | repo_extraction_date
stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
17,000
|
user.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/user.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Users
Manage user entries. All users are POSIX users.
IPA supports a wide range of username formats, but you need to be aware of any
restrictions that may apply to your particular environment. For example,
usernames that start with a digit or usernames that exceed a certain length
may cause problems for some UNIX systems.
Use 'ipa config-mod' to change the username format allowed by IPA tools.
Disabling a user account prevents that user from obtaining new Kerberos
credentials. It does not invalidate any credentials that have already
been issued.
Password management is not a part of this module. For more information
about this topic please see: ipa help passwd
Account lockout on password failure happens per IPA master. The user-status
command can be used to identify which master the user is locked out on.
It is on that master the administrator must unlock the user.
EXAMPLES:
Add a new user:
ipa user-add --first=Tim --last=User --password tuser1
Find all users whose entries include the string "Tim":
ipa user-find Tim
Find all users with "Tim" as the first name:
ipa user-find --first=Tim
Disable a user account:
ipa user-disable tuser1
Enable a user account:
ipa user-enable tuser1
Delete a user:
ipa user-del tuser1
""")
register = Registry()
@register()
class user(Object):
takes_params = (
parameters.Str(
'uid',
primary_key=True,
label=_(u'User login'),
),
parameters.Str(
'givenname',
label=_(u'First name'),
),
parameters.Str(
'sn',
label=_(u'Last name'),
),
parameters.Str(
'cn',
label=_(u'Full name'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
),
parameters.Str(
'homedirectory',
required=False,
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Str(
'loginshell',
required=False,
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
label=_(u'Kerberos principal'),
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
),
parameters.Str(
'randompassword',
required=False,
label=_(u'Random password'),
),
parameters.Int(
'uidnumber',
required=False,
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
label=_(u'SSH public key'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Flag(
'has_password',
label=_(u'Password'),
),
parameters.Str(
'memberof_group',
required=False,
label=_(u'Member of groups'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberofindirect_group',
required=False,
label=_(u'Indirect Member of group'),
),
parameters.Str(
'memberofindirect_netgroup',
required=False,
label=_(u'Indirect Member of netgroup'),
),
parameters.Str(
'memberofindirect_role',
required=False,
label=_(u'Indirect Member of role'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
parameters.Flag(
'has_keytab',
label=_(u'Kerberos keys available'),
),
)
@register()
class user_add(Method):
__doc__ = _("Add a new user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'givenname',
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
autofill=True,
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
autofill=True,
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'principal'),
autofill=True,
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
autofill=True,
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Kerberos principal'),
default_from=DefaultFrom(lambda uid: '%s@%s' % (uid.lower(), api.env.realm), 'principal'),
autofill=True,
no_convert=True,
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
default=False,
autofill=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'noprivate',
doc=_(u"Don't create user private group"),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_del(Method):
__doc__ = _("Delete a user.")
takes_args = (
parameters.Str(
'uid',
multivalue=True,
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class user_disable(Method):
__doc__ = _("Disable a user account.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_enable(Method):
__doc__ = _("Enable a user account.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_find(Method):
__doc__ = _("Search for users.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
parameters.Str(
'givenname',
required=False,
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
required=False,
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'principal'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Kerberos principal'),
default_from=DefaultFrom(lambda uid: '%s@%s' % (uid.lower(), api.env.realm), 'principal'),
no_convert=True,
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'whoami',
label=_(u'Self'),
doc=_(u'Display user record for current Kerberos principal'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("login")'),
default=False,
autofill=True,
),
parameters.Str(
'in_group',
required=False,
multivalue=True,
cli_name='in_groups',
label=_(u'group'),
doc=_(u'Search for users with these member of groups.'),
),
parameters.Str(
'not_in_group',
required=False,
multivalue=True,
cli_name='not_in_groups',
label=_(u'group'),
doc=_(u'Search for users without these member of groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for users with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for users without these member of netgroups.'),
),
parameters.Str(
'in_role',
required=False,
multivalue=True,
cli_name='in_roles',
label=_(u'role'),
doc=_(u'Search for users with these member of roles.'),
),
parameters.Str(
'not_in_role',
required=False,
multivalue=True,
cli_name='not_in_roles',
label=_(u'role'),
doc=_(u'Search for users without these member of roles.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for users with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for users without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for users with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for users without these member of sudo rules.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class user_mod(Method):
__doc__ = _("Modify a user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'givenname',
required=False,
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
required=False,
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'principal'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
default=False,
autofill=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the user object'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_show(Method):
__doc__ = _("Display information about a user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_status(Method):
__doc__ = _("""
Lockout status of a user account
An account may become locked if the password is entered incorrectly too
many times within a specific time period as controlled by password
policy. A locked account is a temporary condition and may be unlocked by
an administrator.
This connects to each IPA master and displays the lockout status on
each one.
To determine whether an account is locked on a given server you need
to compare the number of failed logins and the time of the last failure.
For an account to be locked it must exceed the maxfail failures within
the failinterval duration as specified in the password policy associated
with the user.
The failed login counter is modified only when a user attempts a log in
so it is possible that an account may appear locked but the last failed
login attempt is older than the lockouttime of the password policy. This
means that the user may attempt a login again.
""")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class user_unlock(Method):
__doc__ = _("""
Unlock a user account
An account may become locked if the password is entered incorrectly too
many times within a specific time period as controlled by password
policy. A locked account is a temporary condition and may be unlocked by
an administrator.
""")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 46,927
|
Python
|
.py
| 1,572
| 18.956743
| 162
| 0.496866
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,001
|
config.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/config.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Server configuration
Manage the default values that IPA uses and some of its tuning parameters.
NOTES:
The password notification value (--pwdexpnotify) is stored here so it will
be replicated. It is not currently used to notify users in advance of an
expiring password.
Some attributes are read-only, provided only for information purposes. These
include:
Certificate Subject base: the configured certificate subject base,
e.g. O=EXAMPLE.COM. This is configurable only at install time.
Password plug-in features: currently defines additional hashes that the
password will generate (there may be other conditions).
When setting the order list for mapping SELinux users you may need to
quote the value so it isn't interpreted by the shell.
EXAMPLES:
Show basic server configuration:
ipa config-show
Show all configuration options:
ipa config-show --all
Change maximum username length to 99 characters:
ipa config-mod --maxusername=99
Increase default time and size limits for maximum IPA server search:
ipa config-mod --searchtimelimit=10 --searchrecordslimit=2000
Set default user e-mail domain:
ipa config-mod --emaildomain=example.com
Enable migration mode to make "ipa migrate-ds" command operational:
ipa config-mod --enable-migration=TRUE
Define SELinux user map order:
ipa config-mod --ipaselinuxusermaporder='guest_u:s0$xguest_u:s0$user_u:s0-s0:c0.c1023$staff_u:s0-s0:c0.c1023$unconfined_u:s0-s0:c0.c1023'
""")
register = Registry()
@register()
class config(Object):
takes_params = (
parameters.Int(
'ipamaxusernamelength',
label=_(u'Maximum username length'),
),
parameters.Str(
'ipahomesrootdir',
label=_(u'Home directory base'),
doc=_(u'Default location of home directories'),
),
parameters.Str(
'ipadefaultloginshell',
label=_(u'Default shell'),
doc=_(u'Default shell for new users'),
),
parameters.Str(
'ipadefaultprimarygroup',
label=_(u'Default users group'),
doc=_(u'Default group for new users'),
),
parameters.Str(
'ipadefaultemaildomain',
required=False,
label=_(u'Default e-mail domain'),
),
parameters.Int(
'ipasearchtimelimit',
label=_(u'Search time limit'),
doc=_(u'Maximum amount of time (seconds) for a search (> 0, or -1 for unlimited)'),
),
parameters.Int(
'ipasearchrecordslimit',
label=_(u'Search size limit'),
doc=_(u'Maximum number of records to search (-1 is unlimited)'),
),
parameters.Str(
'ipausersearchfields',
label=_(u'User search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for users'),
),
parameters.Str(
'ipagroupsearchfields',
label=_(u'Group search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for groups'),
),
parameters.Bool(
'ipamigrationenabled',
label=_(u'Enable migration mode'),
),
parameters.DNParam(
'ipacertificatesubjectbase',
label=_(u'Certificate Subject base'),
doc=_(u'Base for certificate subjects (OU=Test,O=Example)'),
),
parameters.Str(
'ipagroupobjectclasses',
multivalue=True,
label=_(u'Default group objectclasses'),
doc=_(u'Default group objectclasses (comma-separated list)'),
),
parameters.Str(
'ipauserobjectclasses',
multivalue=True,
label=_(u'Default user objectclasses'),
doc=_(u'Default user objectclasses (comma-separated list)'),
),
parameters.Int(
'ipapwdexpadvnotify',
label=_(u'Password Expiration Notification (days)'),
doc=_(u"Number of days's notice of impending password expiration"),
),
parameters.Str(
'ipaconfigstring',
required=False,
multivalue=True,
label=_(u'Password plugin features'),
doc=_(u'Extra hashes to generate in password plug-in'),
),
parameters.Str(
'ipaselinuxusermaporder',
label=_(u'SELinux user map order'),
doc=_(u'Order in increasing priority of SELinux users, delimited by $'),
),
parameters.Str(
'ipaselinuxusermapdefault',
required=False,
label=_(u'Default SELinux user'),
doc=_(u'Default SELinux user when no match is found in SELinux map rule'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
label=_(u'Default PAC types'),
doc=_(u'Default types of PAC supported for services'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
label=_(u'Default user authentication types'),
doc=_(u'Default types of supported user authentication'),
),
)
@register()
class config_mod(Method):
__doc__ = _("Modify configuration options.")
takes_options = (
parameters.Int(
'ipamaxusernamelength',
required=False,
cli_name='maxusername',
label=_(u'Maximum username length'),
),
parameters.Str(
'ipahomesrootdir',
required=False,
cli_name='homedirectory',
label=_(u'Home directory base'),
doc=_(u'Default location of home directories'),
),
parameters.Str(
'ipadefaultloginshell',
required=False,
cli_name='defaultshell',
label=_(u'Default shell'),
doc=_(u'Default shell for new users'),
),
parameters.Str(
'ipadefaultprimarygroup',
required=False,
cli_name='defaultgroup',
label=_(u'Default users group'),
doc=_(u'Default group for new users'),
),
parameters.Str(
'ipadefaultemaildomain',
required=False,
cli_name='emaildomain',
label=_(u'Default e-mail domain'),
),
parameters.Int(
'ipasearchtimelimit',
required=False,
cli_name='searchtimelimit',
label=_(u'Search time limit'),
doc=_(u'Maximum amount of time (seconds) for a search (> 0, or -1 for unlimited)'),
),
parameters.Int(
'ipasearchrecordslimit',
required=False,
cli_name='searchrecordslimit',
label=_(u'Search size limit'),
doc=_(u'Maximum number of records to search (-1 is unlimited)'),
),
parameters.Str(
'ipausersearchfields',
required=False,
cli_name='usersearch',
label=_(u'User search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for users'),
),
parameters.Str(
'ipagroupsearchfields',
required=False,
cli_name='groupsearch',
label=_(u'Group search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for groups'),
),
parameters.Bool(
'ipamigrationenabled',
required=False,
cli_name='enable_migration',
label=_(u'Enable migration mode'),
),
parameters.Str(
'ipagroupobjectclasses',
required=False,
multivalue=True,
cli_name='groupobjectclasses',
label=_(u'Default group objectclasses'),
doc=_(u'Default group objectclasses (comma-separated list)'),
),
parameters.Str(
'ipauserobjectclasses',
required=False,
multivalue=True,
cli_name='userobjectclasses',
label=_(u'Default user objectclasses'),
doc=_(u'Default user objectclasses (comma-separated list)'),
),
parameters.Int(
'ipapwdexpadvnotify',
required=False,
cli_name='pwdexpnotify',
label=_(u'Password Expiration Notification (days)'),
doc=_(u"Number of days's notice of impending password expiration"),
),
parameters.Str(
'ipaconfigstring',
required=False,
multivalue=True,
cli_metavar="['AllowNThash', 'KDC:Disable Last Success', 'KDC:Disable Lockout']",
label=_(u'Password plugin features'),
doc=_(u'Extra hashes to generate in password plug-in'),
),
parameters.Str(
'ipaselinuxusermaporder',
required=False,
label=_(u'SELinux user map order'),
doc=_(u'Order in increasing priority of SELinux users, delimited by $'),
),
parameters.Str(
'ipaselinuxusermapdefault',
required=False,
label=_(u'Default SELinux user'),
doc=_(u'Default SELinux user when no match is found in SELinux map rule'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'nfs:NONE']",
label=_(u'Default PAC types'),
doc=_(u'Default types of PAC supported for services'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'Default user authentication types'),
doc=_(u'Default types of supported user authentication'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class config_show(Method):
__doc__ = _("Show the current configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 13,684
|
Python
|
.py
| 381
| 25.732283
| 162
| 0.572537
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,002
|
otptoken.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/otptoken.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
OTP Tokens
Manage OTP tokens.
IPA supports the use of OTP tokens for multi-factor authentication. This
code enables the management of OTP tokens.
EXAMPLES:
Add a new token:
ipa otptoken-add --type=totp --owner=jdoe --desc="My soft token"
Examine the token:
ipa otptoken-show a93db710-a31a-4639-8647-f15b2c70b78a
Change the vendor:
ipa otptoken-mod a93db710-a31a-4639-8647-f15b2c70b78a --vendor="Red Hat"
Delete a token:
ipa otptoken-del a93db710-a31a-4639-8647-f15b2c70b78a
""")
register = Registry()
@register()
class otptoken(Object):
takes_params = (
parameters.Str(
'ipatokenuniqueid',
primary_key=True,
label=_(u'Unique ID'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of the token'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Str(
'managedby_user',
required=False,
label=_(u'Manager'),
doc=_(u'Assigned manager of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Bytes(
'ipatokenotpkey',
required=False,
label=_(u'Key'),
doc=_(u'Token secret (Base32; default: random)'),
),
parameters.Str(
'ipatokenotpalgorithm',
required=False,
label=_(u'Algorithm'),
doc=_(u'Token hash algorithm'),
),
parameters.Int(
'ipatokenotpdigits',
required=False,
label=_(u'Digits'),
doc=_(u'Number of digits each token code will have'),
),
parameters.Int(
'ipatokentotpclockoffset',
required=False,
label=_(u'Clock offset'),
doc=_(u'TOTP token / IPA server time difference'),
),
parameters.Int(
'ipatokentotptimestep',
required=False,
label=_(u'Clock interval'),
doc=_(u'Length of TOTP token code validity'),
),
parameters.Int(
'ipatokenhotpcounter',
required=False,
label=_(u'Counter'),
doc=_(u'Initial counter for the HOTP token'),
),
)
@register()
class otptoken_add(Method):
__doc__ = _("Add a new OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
required=False,
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Str(
'type',
required=False,
cli_metavar="['totp', 'hotp', 'TOTP', 'HOTP']",
label=_(u'Type'),
doc=_(u'Type of the token'),
default=u'totp',
autofill=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
cli_name='owner',
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
cli_name='disabled',
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
cli_name='not_before',
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
cli_name='not_after',
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
cli_name='vendor',
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
cli_name='model',
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
cli_name='serial',
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Bytes(
'ipatokenotpkey',
required=False,
cli_name='key',
label=_(u'Key'),
doc=_(u'Token secret (Base32; default: random)'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: os.urandom(KEY_LENGTH)
autofill=True,
),
parameters.Str(
'ipatokenotpalgorithm',
required=False,
cli_name='algo',
cli_metavar="['sha1', 'sha256', 'sha384', 'sha512']",
label=_(u'Algorithm'),
doc=_(u'Token hash algorithm'),
default=u'sha1',
autofill=True,
),
parameters.Int(
'ipatokenotpdigits',
required=False,
cli_name='digits',
cli_metavar="['6', '8']",
label=_(u'Digits'),
doc=_(u'Number of digits each token code will have'),
default=6,
autofill=True,
),
parameters.Int(
'ipatokentotpclockoffset',
required=False,
cli_name='offset',
label=_(u'Clock offset'),
doc=_(u'TOTP token / IPA server time difference'),
default=0,
autofill=True,
),
parameters.Int(
'ipatokentotptimestep',
required=False,
cli_name='interval',
label=_(u'Clock interval'),
doc=_(u'Length of TOTP token code validity'),
default=30,
autofill=True,
),
parameters.Int(
'ipatokenhotpcounter',
required=False,
cli_name='counter',
label=_(u'Counter'),
doc=_(u'Initial counter for the HOTP token'),
default=0,
autofill=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'qrcode',
required=False,
label=_(u'(deprecated)'),
exclude=('cli', 'webui'),
default=False,
autofill=True,
),
parameters.Flag(
'no_qrcode',
label=_(u'Do not display QR code'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class otptoken_add_managedby(Method):
__doc__ = _("Add users that can manage this token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class otptoken_del(Method):
__doc__ = _("Delete an OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
multivalue=True,
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class otptoken_find(Method):
__doc__ = _("Search for OTP token.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'ipatokenuniqueid',
required=False,
cli_name='id',
label=_(u'Unique ID'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['totp', 'hotp', 'TOTP', 'HOTP']",
label=_(u'Type'),
doc=_(u'Type of the token'),
default=u'totp',
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
cli_name='owner',
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
cli_name='disabled',
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
cli_name='not_before',
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
cli_name='not_after',
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
cli_name='vendor',
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
cli_name='model',
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
cli_name='serial',
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Str(
'ipatokenotpalgorithm',
required=False,
cli_name='algo',
cli_metavar="['sha1', 'sha256', 'sha384', 'sha512']",
label=_(u'Algorithm'),
doc=_(u'Token hash algorithm'),
default=u'sha1',
),
parameters.Int(
'ipatokenotpdigits',
required=False,
cli_name='digits',
cli_metavar="['6', '8']",
label=_(u'Digits'),
doc=_(u'Number of digits each token code will have'),
default=6,
),
parameters.Int(
'ipatokentotpclockoffset',
required=False,
cli_name='offset',
label=_(u'Clock offset'),
doc=_(u'TOTP token / IPA server time difference'),
default=0,
),
parameters.Int(
'ipatokentotptimestep',
required=False,
cli_name='interval',
label=_(u'Clock interval'),
doc=_(u'Length of TOTP token code validity'),
default=30,
),
parameters.Int(
'ipatokenhotpcounter',
required=False,
cli_name='counter',
label=_(u'Counter'),
doc=_(u'Initial counter for the HOTP token'),
default=0,
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("id")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class otptoken_mod(Method):
__doc__ = _("Modify a OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
cli_name='owner',
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
cli_name='disabled',
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
cli_name='not_before',
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
cli_name='not_after',
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
cli_name='vendor',
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
cli_name='model',
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
cli_name='serial',
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the OTP token object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class otptoken_remove_managedby(Method):
__doc__ = _("Remove hosts that can manage this host.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class otptoken_show(Method):
__doc__ = _("Display information about an OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 25,980
|
Python
|
.py
| 858
| 19.434732
| 162
| 0.495795
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,003
|
automember.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/automember.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Auto Membership Rule.
Bring clarity to the membership of hosts and users by configuring inclusive
or exclusive regex patterns, you can automatically assign a new entries into
a group or hostgroup based upon attribute information.
A rule is directly associated with a group by name, so you cannot create
a rule without an accompanying group or hostgroup.
A condition is a regular expression used by 389-ds to match a new incoming
entry with an automember rule. If it matches an inclusive rule then the
entry is added to the appropriate group or hostgroup.
A default group or hostgroup could be specified for entries that do not
match any rule. In case of user entries this group will be a fallback group
because all users are by default members of group specified in IPA config.
The automember-rebuild command can be used to retroactively run automember rules
against existing entries, thus rebuilding their membership.
EXAMPLES:
Add the initial group or hostgroup:
ipa hostgroup-add --desc="Web Servers" webservers
ipa group-add --desc="Developers" devel
Add the initial rule:
ipa automember-add --type=hostgroup webservers
ipa automember-add --type=group devel
Add a condition to the rule:
ipa automember-add-condition --key=fqdn --type=hostgroup --inclusive-regex=^web[1-9]+\.example\.com webservers
ipa automember-add-condition --key=manager --type=group --inclusive-regex=^uid=mscott devel
Add an exclusive condition to the rule to prevent auto assignment:
ipa automember-add-condition --key=fqdn --type=hostgroup --exclusive-regex=^web5\.example\.com webservers
Add a host:
ipa host-add web1.example.com
Add a user:
ipa user-add --first=Tim --last=User --password tuser1 --manager=mscott
Verify automembership:
ipa hostgroup-show webservers
Host-group: webservers
Description: Web Servers
Member hosts: web1.example.com
ipa group-show devel
Group name: devel
Description: Developers
GID: 1004200000
Member users: tuser
Remove a condition from the rule:
ipa automember-remove-condition --key=fqdn --type=hostgroup --inclusive-regex=^web[1-9]+\.example\.com webservers
Modify the automember rule:
ipa automember-mod
Set the default (fallback) target group:
ipa automember-default-group-set --default-group=webservers --type=hostgroup
ipa automember-default-group-set --default-group=ipausers --type=group
Remove the default (fallback) target group:
ipa automember-default-group-remove --type=hostgroup
ipa automember-default-group-remove --type=group
Show the default (fallback) target group:
ipa automember-default-group-show --type=hostgroup
ipa automember-default-group-show --type=group
Find all of the automember rules:
ipa automember-find
Display a automember rule:
ipa automember-show --type=hostgroup webservers
ipa automember-show --type=group devel
Delete an automember rule:
ipa automember-del --type=hostgroup webservers
ipa automember-del --type=group devel
Rebuild membership for all users:
ipa automember-rebuild --type=group
Rebuild membership for all hosts:
ipa automember-rebuild --type=hostgroup
Rebuild membership for specified users:
ipa automember-rebuild --users=tuser1 --users=tuser2
Rebuild membership for specified hosts:
ipa automember-rebuild --hosts=web1.example.com --hosts=web2.example.com
""")
register = Registry()
@register()
class automember(Object):
takes_params = (
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberdefaultgroup',
required=False,
label=_(u'Default (fallback) Group'),
doc=_(u'Default group for entries to land'),
),
)
@register()
class automember_add(Method):
__doc__ = _("Add an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_add_condition(Method):
__doc__ = _("Add conditions to an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberinclusiveregex',
required=False,
multivalue=True,
cli_name='inclusive_regex',
label=_(u'Inclusive Regex'),
alwaysask=True,
),
parameters.Str(
'automemberexclusiveregex',
required=False,
multivalue=True,
cli_name='exclusive_regex',
label=_(u'Exclusive Regex'),
alwaysask=True,
),
parameters.Str(
'key',
label=_(u'Attribute Key'),
doc=_(u'Attribute to filter via regex. For example fqdn for a host, or manager for a user'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
output.Output(
'failed',
dict,
doc=_(u'Conditions that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of conditions added'),
),
)
@register()
class automember_default_group_remove(Method):
__doc__ = _("Remove default (fallback) group for all unmatched entries.")
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_default_group_set(Method):
__doc__ = _("Set default (fallback) group for all unmatched entries.")
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberdefaultgroup',
cli_name='default_group',
label=_(u'Default (fallback) Group'),
doc=_(u'Default (fallback) group for entries to land'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_default_group_show(Method):
__doc__ = _("Display information about the default (fallback) automember groups.")
takes_options = (
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_del(Method):
__doc__ = _("Delete an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class automember_find(Method):
__doc__ = _("Search for automember rules.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class automember_mod(Method):
__doc__ = _("Modify an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_rebuild(Command):
__doc__ = _("Rebuild auto membership.")
takes_options = (
parameters.Str(
'type',
required=False,
cli_metavar="['group', 'hostgroup']",
label=_(u'Rebuild membership for all members of a grouping'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Str(
'users',
required=False,
multivalue=True,
label=_(u'Users'),
doc=_(u'Rebuild membership for specified users'),
),
parameters.Str(
'hosts',
required=False,
multivalue=True,
label=_(u'Hosts'),
doc=_(u'Rebuild membership for specified hosts'),
),
parameters.Flag(
'no_wait',
required=False,
label=_(u'No wait'),
doc=_(u"Don't wait for rebuilding membership"),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_remove_condition(Method):
__doc__ = _("Remove conditions from an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberinclusiveregex',
required=False,
multivalue=True,
cli_name='inclusive_regex',
label=_(u'Inclusive Regex'),
alwaysask=True,
),
parameters.Str(
'automemberexclusiveregex',
required=False,
multivalue=True,
cli_name='exclusive_regex',
label=_(u'Exclusive Regex'),
alwaysask=True,
),
parameters.Str(
'key',
label=_(u'Attribute Key'),
doc=_(u'Attribute to filter via regex. For example fqdn for a host, or manager for a user'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
output.Output(
'failed',
dict,
doc=_(u'Conditions that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of conditions removed'),
),
)
@register()
class automember_show(Method):
__doc__ = _("Display information about an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 24,427
|
Python
|
.py
| 761
| 22.332457
| 162
| 0.544703
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,004
|
passwd.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/passwd.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Set a user's password
If someone other than a user changes that user's password (e.g., Helpdesk
resets it) then the password will need to be changed the first time it
is used. This is so the end-user is the only one who knows the password.
The IPA password policy controls how often a password may be changed,
what strength requirements exist, and the length of the password history.
EXAMPLES:
To reset your own password:
ipa passwd
To change another user's password:
ipa passwd tuser1
""")
register = Registry()
@register()
class passwd(Command):
__doc__ = _("Set a user's password.")
takes_args = (
parameters.Str(
'principal',
cli_name='user',
label=_(u'User name'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: util.get_current_principal()
autofill=True,
no_convert=True,
),
parameters.Password(
'password',
label=_(u'New Password'),
confirm=True,
),
parameters.Password(
'current_password',
label=_(u'Current Password'),
default_from=DefaultFrom(lambda principal: None, 'principal'),
# FIXME:
# lambda principal: get_current_password(principal)
autofill=True,
),
)
takes_options = (
parameters.Password(
'otp',
required=False,
label=_(u'OTP'),
doc=_(u'One Time Password'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 2,431
|
Python
|
.py
| 80
| 22.975
| 81
| 0.605646
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,005
|
krbtpolicy.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/krbtpolicy.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Kerberos ticket policy
There is a single Kerberos ticket policy. This policy defines the
maximum ticket lifetime and the maximum renewal age, the period during
which the ticket is renewable.
You can also create a per-user ticket policy by specifying the user login.
For changes to the global policy to take effect, restarting the KDC service
is required, which can be achieved using:
service krb5kdc restart
Changes to per-user policies take effect immediately for newly requested
tickets (e.g. when the user next runs kinit).
EXAMPLES:
Display the current Kerberos ticket policy:
ipa krbtpolicy-show
Reset the policy to the default:
ipa krbtpolicy-reset
Modify the policy to 8 hours max life, 1-day max renewal:
ipa krbtpolicy-mod --maxlife=28800 --maxrenew=86400
Display effective Kerberos ticket policy for user 'admin':
ipa krbtpolicy-show admin
Reset per-user policy for user 'admin':
ipa krbtpolicy-reset admin
Modify per-user policy for user 'admin':
ipa krbtpolicy-mod admin --maxlife=3600
""")
register = Registry()
@register()
class krbtpolicy(Object):
takes_params = (
parameters.Str(
'uid',
required=False,
primary_key=True,
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
parameters.Int(
'krbmaxticketlife',
required=False,
label=_(u'Max life'),
doc=_(u'Maximum ticket life (seconds)'),
),
parameters.Int(
'krbmaxrenewableage',
required=False,
label=_(u'Max renew'),
doc=_(u'Maximum renewable age (seconds)'),
),
)
@register()
class krbtpolicy_mod(Method):
__doc__ = _("Modify Kerberos ticket policy.")
takes_args = (
parameters.Str(
'uid',
required=False,
cli_name='user',
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
)
takes_options = (
parameters.Int(
'krbmaxticketlife',
required=False,
cli_name='maxlife',
label=_(u'Max life'),
doc=_(u'Maximum ticket life (seconds)'),
),
parameters.Int(
'krbmaxrenewableage',
required=False,
cli_name='maxrenew',
label=_(u'Max renew'),
doc=_(u'Maximum renewable age (seconds)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class krbtpolicy_reset(Method):
__doc__ = _("Reset Kerberos ticket policy to the default values.")
takes_args = (
parameters.Str(
'uid',
required=False,
cli_name='user',
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class krbtpolicy_show(Method):
__doc__ = _("Display the current Kerberos ticket policy.")
takes_args = (
parameters.Str(
'uid',
required=False,
cli_name='user',
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 7,559
|
Python
|
.py
| 238
| 22.684874
| 162
| 0.56232
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,006
|
hbacsvc.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/hbacsvc.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
HBAC Services
The PAM services that HBAC can control access to. The name used here
must match the service name that PAM is evaluating.
EXAMPLES:
Add a new HBAC service:
ipa hbacsvc-add tftp
Modify an existing HBAC service:
ipa hbacsvc-mod --desc="TFTP service" tftp
Search for HBAC services. This example will return two results, the FTP
service and the newly-added tftp service:
ipa hbacsvc-find ftp
Delete an HBAC service:
ipa hbacsvc-del tftp
""")
register = Registry()
@register()
class hbacsvc(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Service name'),
doc=_(u'HBAC service'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Str(
'memberof_hbacsvcgroup',
required=False,
label=_(u'Member of HBAC service groups'),
),
)
@register()
class hbacsvc_add(Method):
__doc__ = _("Add a new HBAC service.")
takes_args = (
parameters.Str(
'cn',
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvc_del(Method):
__doc__ = _("Delete an existing HBAC service.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hbacsvc_find(Method):
__doc__ = _("Search for HBAC services.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("service")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hbacsvc_mod(Method):
__doc__ = _("Modify an HBAC service.")
takes_args = (
parameters.Str(
'cn',
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvc_show(Method):
__doc__ = _("Display information about an HBAC service.")
takes_args = (
parameters.Str(
'cn',
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 11,491
|
Python
|
.py
| 385
| 19.857143
| 162
| 0.516339
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,007
|
radiusproxy.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/radiusproxy.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
RADIUS Proxy Servers
Manage RADIUS Proxy Servers.
IPA supports the use of an external RADIUS proxy server for krb5 OTP
authentications. This permits a great deal of flexibility when
integrating with third-party authentication services.
EXAMPLES:
Add a new server:
ipa radiusproxy-add MyRADIUS --server=radius.example.com:1812
Find all servers whose entries include the string "example.com":
ipa radiusproxy-find example.com
Examine the configuration:
ipa radiusproxy-show MyRADIUS
Change the secret:
ipa radiusproxy-mod MyRADIUS --secret
Delete a configuration:
ipa radiusproxy-del MyRADIUS
""")
register = Registry()
@register()
class radiusproxy(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'RADIUS proxy server name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
multivalue=True,
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
)
@register()
class radiusproxy_add(Method):
__doc__ = _("Add a new RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
multivalue=True,
cli_name='server',
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
cli_name='secret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
exclude=('cli', 'webui'),
confirm=True,
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
cli_name='timeout',
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
cli_name='retries',
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
cli_name='userattr',
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class radiusproxy_del(Method):
__doc__ = _("Delete a RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class radiusproxy_find(Method):
__doc__ = _("Search for RADIUS proxy servers.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
required=False,
multivalue=True,
cli_name='server',
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
required=False,
cli_name='secret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
exclude=('cli', 'webui'),
confirm=True,
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
cli_name='timeout',
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
cli_name='retries',
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
cli_name='userattr',
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class radiusproxy_mod(Method):
__doc__ = _("Modify a RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
required=False,
multivalue=True,
cli_name='server',
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
required=False,
cli_name='secret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
exclude=('cli', 'webui'),
confirm=True,
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
cli_name='timeout',
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
cli_name='retries',
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
cli_name='userattr',
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the RADIUS proxy server object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class radiusproxy_show(Method):
__doc__ = _("Display information about a RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 15,257
|
Python
|
.py
| 491
| 20.757637
| 162
| 0.522801
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,008
|
permission.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/permission.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Permissions
A permission enables fine-grained delegation of rights. A permission is
a human-readable wrapper around a 389-ds Access Control Rule,
or instruction (ACI).
A permission grants the right to perform a specific task such as adding a
user, modifying a group, etc.
A permission may not contain other permissions.
* A permission grants access to read, write, add, delete, read, search,
or compare.
* A privilege combines similar permissions (for example all the permissions
needed to add a user).
* A role grants a set of privileges to users, groups, hosts or hostgroups.
A permission is made up of a number of different parts:
1. The name of the permission.
2. The target of the permission.
3. The rights granted by the permission.
Rights define what operations are allowed, and may be one or more
of the following:
1. write - write one or more attributes
2. read - read one or more attributes
3. search - search on one or more attributes
4. compare - compare one or more attributes
5. add - add a new entry to the tree
6. delete - delete an existing entry
7. all - all permissions are granted
Note the distinction between attributes and entries. The permissions are
independent, so being able to add a user does not mean that the user will
be editable.
There are a number of allowed targets:
1. subtree: a DN; the permission applies to the subtree under this DN
2. target filter: an LDAP filter
3. target: DN with possible wildcards, specifies entries permission applies to
Additionally, there are the following convenience options.
Setting one of these options will set the corresponding attribute(s).
1. type: a type of object (user, group, etc); sets subtree and target filter.
2. memberof: apply to members of a group; sets target filter
3. targetgroup: grant access to modify a specific group (such as granting
the rights to manage group membership); sets target.
Managed permissions
Permissions that come with IPA by default can be so-called "managed"
permissions. These have a default set of attributes they apply to,
but the administrator can add/remove individual attributes to/from the set.
Deleting or renaming a managed permission, as well as changing its target,
is not allowed.
EXAMPLES:
Add a permission that grants the creation of users:
ipa permission-add --type=user --permissions=add "Add Users"
Add a permission that grants the ability to manage group membership:
ipa permission-add --attrs=member --permissions=write --type=group "Manage Group Members"
""")
register = Registry()
@register()
class permission(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Permission name'),
),
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermincludedattr',
required=False,
multivalue=True,
label=_(u'Included attributes'),
doc=_(u'User-specified attributes to which the permission applies'),
),
parameters.Str(
'ipapermexcludedattr',
required=False,
multivalue=True,
label=_(u'Excluded attributes'),
doc=_(u'User-specified attributes to which the permission explicitly does not apply'),
),
parameters.Str(
'ipapermdefaultattr',
required=False,
multivalue=True,
label=_(u'Default attributes'),
doc=_(u'Attributes to which the permission applies by default'),
),
parameters.Str(
'ipapermbindruletype',
label=_(u'Bind rule type'),
),
parameters.Str(
'ipapermlocation',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
),
parameters.Str(
'member_privilege',
required=False,
label=_(u'Granted to Privilege'),
),
parameters.Str(
'memberindirect_role',
required=False,
label=_(u'Indirect Member of roles'),
),
)
@register()
class permission_add(Method):
__doc__ = _("Add a new permission.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
cli_name='right',
cli_metavar="['read', 'search', 'compare', 'write', 'add', 'delete', 'all']",
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
alwaysask=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermbindruletype',
cli_name='bindtype',
cli_metavar="['permission', 'all', 'anonymous']",
label=_(u'Bind rule type'),
default=u'permission',
autofill=True,
),
parameters.Str(
'ipapermlocation',
required=False,
cli_name='subtree',
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
alwaysask=True,
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
cli_name='filter',
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
cli_name='rawfilter',
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
cli_name='target',
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
alwaysask=True,
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
alwaysask=True,
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
alwaysask=True,
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
exclude=('cli', 'webui'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
exclude=('cli', 'webui'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class permission_add_member(Method):
__doc__ = _("Add members to a permission.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'privilege',
required=False,
multivalue=True,
cli_name='privileges',
label=_(u'member privilege'),
doc=_(u'privileges to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class permission_add_noaci(Method):
__doc__ = _("Add a system permission without an ACI (internal command)")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Str(
'ipapermissiontype',
multivalue=True,
label=_(u'Permission flags'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class permission_del(Method):
__doc__ = _("Delete a permission.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force delete of SYSTEM permissions'),
exclude=('cli', 'webui'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class permission_find(Method):
__doc__ = _("Search for permissions.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Permission name'),
),
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
cli_name='right',
cli_metavar="['read', 'search', 'compare', 'write', 'add', 'delete', 'all']",
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermincludedattr',
required=False,
multivalue=True,
cli_name='includedattrs',
label=_(u'Included attributes'),
doc=_(u'User-specified attributes to which the permission applies'),
),
parameters.Str(
'ipapermexcludedattr',
required=False,
multivalue=True,
cli_name='excludedattrs',
label=_(u'Excluded attributes'),
doc=_(u'User-specified attributes to which the permission explicitly does not apply'),
),
parameters.Str(
'ipapermdefaultattr',
required=False,
multivalue=True,
cli_name='defaultattrs',
label=_(u'Default attributes'),
doc=_(u'Attributes to which the permission applies by default'),
),
parameters.Str(
'ipapermbindruletype',
required=False,
cli_name='bindtype',
cli_metavar="['permission', 'all', 'anonymous']",
label=_(u'Bind rule type'),
default=u'permission',
),
parameters.Str(
'ipapermlocation',
required=False,
cli_name='subtree',
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
cli_name='filter',
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
cli_name='rawfilter',
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
cli_name='target',
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
exclude=('cli', 'webui'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
exclude=('cli', 'webui'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class permission_mod(Method):
__doc__ = _("Modify a permission.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
cli_name='right',
cli_metavar="['read', 'search', 'compare', 'write', 'add', 'delete', 'all']",
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermincludedattr',
required=False,
multivalue=True,
cli_name='includedattrs',
label=_(u'Included attributes'),
doc=_(u'User-specified attributes to which the permission applies'),
),
parameters.Str(
'ipapermexcludedattr',
required=False,
multivalue=True,
cli_name='excludedattrs',
label=_(u'Excluded attributes'),
doc=_(u'User-specified attributes to which the permission explicitly does not apply'),
),
parameters.Str(
'ipapermbindruletype',
required=False,
cli_name='bindtype',
cli_metavar="['permission', 'all', 'anonymous']",
label=_(u'Bind rule type'),
default=u'permission',
),
parameters.Str(
'ipapermlocation',
required=False,
cli_name='subtree',
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
cli_name='filter',
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
cli_name='rawfilter',
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
cli_name='target',
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
exclude=('cli', 'webui'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
exclude=('cli', 'webui'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the permission object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class permission_remove_member(Method):
__doc__ = _("Remove members from a permission.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'privilege',
required=False,
multivalue=True,
cli_name='privileges',
label=_(u'member privilege'),
doc=_(u'privileges to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class permission_show(Method):
__doc__ = _("Display information about a permission.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 31,931
|
Python
|
.py
| 996
| 21.569277
| 162
| 0.527715
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,009
|
ping.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/ping.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Ping the remote IPA server to ensure it is running.
The ping command sends an echo request to an IPA server. The server
returns its version information. This is used by an IPA client
to confirm that the server is available and accepting requests.
The server from xmlrpc_uri in /etc/ipa/default.conf is contacted first.
If it does not respond then the client will contact any servers defined
by ldap SRV records in DNS.
EXAMPLES:
Ping an IPA server:
ipa ping
------------------------------------------
IPA server version 2.1.9. API version 2.20
------------------------------------------
Ping an IPA server verbosely:
ipa -v ping
ipa: INFO: trying https://ipa.example.com/ipa/xml
ipa: INFO: Forwarding 'ping' to server 'https://ipa.example.com/ipa/xml'
-----------------------------------------------------
IPA server version 2.1.9. API version 2.20
-----------------------------------------------------
""")
register = Registry()
@register()
class ping(Command):
__doc__ = _("Ping a remote server.")
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
)
| 1,675
|
Python
|
.py
| 49
| 30.714286
| 75
| 0.637322
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,010
|
host.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/host.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Hosts/Machines
A host represents a machine. It can be used in a number of contexts:
- service entries are associated with a host
- a host stores the host/ service principal
- a host can be used in Host-based Access Control (HBAC) rules
- every enrolled client generates a host entry
ENROLLMENT:
There are three enrollment scenarios when enrolling a new client:
1. You are enrolling as a full administrator. The host entry may exist
or not. A full administrator is a member of the hostadmin role
or the admins group.
2. You are enrolling as a limited administrator. The host must already
exist. A limited administrator is a member a role with the
Host Enrollment privilege.
3. The host has been created with a one-time password.
RE-ENROLLMENT:
Host that has been enrolled at some point, and lost its configuration (e.g. VM
destroyed) can be re-enrolled.
For more information, consult the manual pages for ipa-client-install.
A host can optionally store information such as where it is located,
the OS that it runs, etc.
EXAMPLES:
Add a new host:
ipa host-add --location="3rd floor lab" --locality=Dallas test.example.com
Delete a host:
ipa host-del test.example.com
Add a new host with a one-time password:
ipa host-add --os='Fedora 12' --password=Secret123 test.example.com
Add a new host with a random one-time password:
ipa host-add --os='Fedora 12' --random test.example.com
Modify information about a host:
ipa host-mod --os='Fedora 12' test.example.com
Remove SSH public keys of a host and update DNS to reflect this change:
ipa host-mod --sshpubkey= --updatedns test.example.com
Disable the host Kerberos key, SSL certificate and all of its services:
ipa host-disable test.example.com
Add a host that can manage this host's keytab and certificate:
ipa host-add-managedby --hosts=test2 test
Allow user to create a keytab:
ipa host-allow-create-keytab test2 --users=tuser1
""")
register = Registry()
@register()
class host(Object):
takes_params = (
parameters.Str(
'fqdn',
primary_key=True,
label=_(u'Host name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random password to be used in bulk enrollment'),
),
parameters.Str(
'randompassword',
required=False,
label=_(u'Random password'),
),
parameters.Bytes(
'usercertificate',
required=False,
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'krbprincipalname',
required=False,
label=_(u'Principal name'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
label=_(u'SSH public key'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Flag(
'has_password',
label=_(u'Password'),
),
parameters.Str(
'memberof_hostgroup',
required=False,
label=_(u'Member of host-groups'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberofindirect_netgroup',
required=False,
label=_(u'Indirect Member of netgroup'),
),
parameters.Str(
'memberofindirect_hostgroup',
required=False,
label=_(u'Indirect Member of host-group'),
),
parameters.Str(
'memberofindirect_role',
required=False,
label=_(u'Indirect Member of role'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
parameters.Flag(
'has_keytab',
label=_(u'Keytab'),
),
parameters.Str(
'managedby_host',
label=_(u'Managed by'),
),
parameters.Str(
'managing_host',
label=_(u'Managing'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_user',
label=_(u'Users allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_group',
label=_(u'Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_host',
label=_(u'Hosts allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_hostgroup',
label=_(u'Host Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_user',
label=_(u'Users allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_group',
label=_(u'Groups allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_host',
label=_(u'Hosts allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_hostgroup',
label=_(u'Host Groups allowed to create keytab'),
),
)
@register()
class host_add(Method):
__doc__ = _("Add a new host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
cli_name='locality',
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
cli_name='location',
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
cli_name='password',
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random password to be used in bulk enrollment'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
no_convert=True,
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
exclude=('cli', 'webui'),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force host name even if not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'no_reverse',
doc=_(u'skip reverse DNS detection'),
default=False,
autofill=True,
),
parameters.Str(
'ip_address',
required=False,
label=_(u'IP Address'),
doc=_(u'Add the host to DNS with this IP address'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_add_managedby(Method):
__doc__ = _("Add hosts that can manage this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class host_allow_create_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to create a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class host_allow_retrieve_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to retrieve a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class host_del(Method):
__doc__ = _("Delete a host.")
takes_args = (
parameters.Str(
'fqdn',
multivalue=True,
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Flag(
'updatedns',
required=False,
doc=_(u'Remove entries from DNS'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class host_disable(Method):
__doc__ = _("Disable the Kerberos key, SSL certificate and all services of a host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_disallow_create_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to create a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class host_disallow_retrieve_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to retrieve a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class host_find(Method):
__doc__ = _("Search for hosts.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'fqdn',
required=False,
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
cli_name='locality',
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
cli_name='location',
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
cli_name='password',
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Bytes(
'usercertificate',
required=False,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
no_convert=True,
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("hostname")'),
default=False,
autofill=True,
),
parameters.Str(
'in_hostgroup',
required=False,
multivalue=True,
cli_name='in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for hosts with these member of host groups.'),
),
parameters.Str(
'not_in_hostgroup',
required=False,
multivalue=True,
cli_name='not_in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for hosts without these member of host groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for hosts with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for hosts without these member of netgroups.'),
),
parameters.Str(
'in_role',
required=False,
multivalue=True,
cli_name='in_roles',
label=_(u'role'),
doc=_(u'Search for hosts with these member of roles.'),
),
parameters.Str(
'not_in_role',
required=False,
multivalue=True,
cli_name='not_in_roles',
label=_(u'role'),
doc=_(u'Search for hosts without these member of roles.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for hosts with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for hosts without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for hosts with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for hosts without these member of sudo rules.'),
),
parameters.Str(
'enroll_by_user',
required=False,
multivalue=True,
cli_name='enroll_by_users',
label=_(u'user'),
doc=_(u'Search for hosts with these enrolled by users.'),
),
parameters.Str(
'not_enroll_by_user',
required=False,
multivalue=True,
cli_name='not_enroll_by_users',
label=_(u'user'),
doc=_(u'Search for hosts without these enrolled by users.'),
),
parameters.Str(
'man_by_host',
required=False,
multivalue=True,
cli_name='man_by_hosts',
label=_(u'host'),
doc=_(u'Search for hosts with these managed by hosts.'),
),
parameters.Str(
'not_man_by_host',
required=False,
multivalue=True,
cli_name='not_man_by_hosts',
label=_(u'host'),
doc=_(u'Search for hosts without these managed by hosts.'),
),
parameters.Str(
'man_host',
required=False,
multivalue=True,
cli_name='man_hosts',
label=_(u'host'),
doc=_(u'Search for hosts with these managing hosts.'),
),
parameters.Str(
'not_man_host',
required=False,
multivalue=True,
cli_name='not_man_hosts',
label=_(u'host'),
doc=_(u'Search for hosts without these managing hosts.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class host_mod(Method):
__doc__ = _("Modify information about a host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
cli_name='locality',
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
cli_name='location',
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
cli_name='password',
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random password to be used in bulk enrollment'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
no_convert=True,
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
exclude=('cli', 'webui'),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principalname',
label=_(u'Principal name'),
doc=_(u'Kerberos principal name for this host'),
),
parameters.Flag(
'updatedns',
required=False,
doc=_(u'Update DNS entries'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_remove_managedby(Method):
__doc__ = _("Remove hosts that can manage this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class host_show(Method):
__doc__ = _("Display information about a host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'out',
required=False,
doc=_(u'file to store certificate in'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 45,438
|
Python
|
.py
| 1,495
| 19.562542
| 162
| 0.500592
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,011
|
netgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/netgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Netgroups
A netgroup is a group used for permission checking. It can contain both
user and host values.
EXAMPLES:
Add a new netgroup:
ipa netgroup-add --desc="NFS admins" admins
Add members to the netgroup:
ipa netgroup-add-member --users=tuser1 --users=tuser2 admins
Remove a member from the netgroup:
ipa netgroup-remove-member --users=tuser2 admins
Display information about a netgroup:
ipa netgroup-show admins
Delete a netgroup:
ipa netgroup-del admins
""")
register = Registry()
@register()
class netgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Netgroup name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
label=_(u'NIS domain name'),
),
parameters.Str(
'ipauniqueid',
required=False,
label=_(u'IPA unique ID'),
doc=_(u'IPA unique ID'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
),
parameters.Str(
'member_netgroup',
required=False,
label=_(u'Member netgroups'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberindirect_netgroup',
required=False,
label=_(u'Indirect Member netgroups'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Member User'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'Member Group'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Member Host'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Member Hostgroup'),
),
)
@register()
class netgroup_add(Method):
__doc__ = _("Add a new netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
cli_name='nisdomain',
label=_(u'NIS domain name'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class netgroup_add_member(Method):
__doc__ = _("Add members to a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
parameters.Str(
'netgroup',
required=False,
multivalue=True,
cli_name='netgroups',
label=_(u'member netgroup'),
doc=_(u'netgroups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class netgroup_del(Method):
__doc__ = _("Delete a netgroup.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class netgroup_find(Method):
__doc__ = _("Search for a netgroup.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
cli_name='nisdomain',
label=_(u'NIS domain name'),
),
parameters.Str(
'ipauniqueid',
required=False,
cli_name='uuid',
label=_(u'IPA unique ID'),
doc=_(u'IPA unique ID'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'private',
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'managed',
doc=_(u'search for managed groups'),
default=False,
default_from=DefaultFrom(lambda private: private),
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
parameters.Str(
'netgroup',
required=False,
multivalue=True,
cli_name='netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups with these member netgroups.'),
),
parameters.Str(
'no_netgroup',
required=False,
multivalue=True,
cli_name='no_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups without these member netgroups.'),
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'user'),
doc=_(u'Search for netgroups with these member users.'),
),
parameters.Str(
'no_user',
required=False,
multivalue=True,
cli_name='no_users',
label=_(u'user'),
doc=_(u'Search for netgroups without these member users.'),
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'group'),
doc=_(u'Search for netgroups with these member groups.'),
),
parameters.Str(
'no_group',
required=False,
multivalue=True,
cli_name='no_groups',
label=_(u'group'),
doc=_(u'Search for netgroups without these member groups.'),
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'host'),
doc=_(u'Search for netgroups with these member hosts.'),
),
parameters.Str(
'no_host',
required=False,
multivalue=True,
cli_name='no_hosts',
label=_(u'host'),
doc=_(u'Search for netgroups without these member hosts.'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'host group'),
doc=_(u'Search for netgroups with these member host groups.'),
),
parameters.Str(
'no_hostgroup',
required=False,
multivalue=True,
cli_name='no_hostgroups',
label=_(u'host group'),
doc=_(u'Search for netgroups without these member host groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups without these member of netgroups.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class netgroup_mod(Method):
__doc__ = _("Modify a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
cli_name='nisdomain',
label=_(u'NIS domain name'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class netgroup_remove_member(Method):
__doc__ = _("Remove members from a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
parameters.Str(
'netgroup',
required=False,
multivalue=True,
cli_name='netgroups',
label=_(u'member netgroup'),
doc=_(u'netgroups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class netgroup_show(Method):
__doc__ = _("Display information about a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 24,339
|
Python
|
.py
| 830
| 18.513253
| 162
| 0.490458
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,012
|
pkinit.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/pkinit.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Kerberos pkinit options
Enable or disable anonymous pkinit using the principal
WELLKNOWN/ANONYMOUS@REALM. The server must have been installed with
pkinit support.
EXAMPLES:
Enable anonymous pkinit:
ipa pkinit-anonymous enable
Disable anonymous pkinit:
ipa pkinit-anonymous disable
For more information on anonymous pkinit see:
http://k5wiki.kerberos.org/wiki/Projects/Anonymous_pkinit
""")
register = Registry()
@register()
class pkinit(Object):
takes_params = (
)
@register()
class pkinit_anonymous(Command):
__doc__ = _("Enable or Disable Anonymous PKINIT.")
takes_args = (
parameters.Str(
'action',
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
| 1,198
|
Python
|
.py
| 47
| 21.978723
| 67
| 0.729515
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,013
|
trust.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/trust.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Cross-realm trusts
Manage trust relationship between IPA and Active Directory domains.
In order to allow users from a remote domain to access resources in IPA
domain, trust relationship needs to be established. Currently IPA supports
only trusts between IPA and Active Directory domains under control of Windows
Server 2008 or later, with functional level 2008 or later.
Please note that DNS on both IPA and Active Directory domain sides should be
configured properly to discover each other. Trust relationship relies on
ability to discover special resources in the other domain via DNS records.
Examples:
1. Establish cross-realm trust with Active Directory using AD administrator
credentials:
ipa trust-add --type=ad <ad.domain> --admin <AD domain administrator> --password
2. List all existing trust relationships:
ipa trust-find
3. Show details of the specific trust relationship:
ipa trust-show <ad.domain>
4. Delete existing trust relationship:
ipa trust-del <ad.domain>
Once trust relationship is established, remote users will need to be mapped
to local POSIX groups in order to actually use IPA resources. The mapping should
be done via use of external membership of non-POSIX group and then this group
should be included into one of local POSIX groups.
Example:
1. Create group for the trusted domain admins' mapping and their local POSIX group:
ipa group-add --desc='<ad.domain> admins external map' ad_admins_external --external
ipa group-add --desc='<ad.domain> admins' ad_admins
2. Add security identifier of Domain Admins of the <ad.domain> to the ad_admins_external
group:
ipa group-add-member ad_admins_external --external 'AD\Domain Admins'
3. Allow members of ad_admins_external group to be associated with ad_admins POSIX group:
ipa group-add-member ad_admins --groups ad_admins_external
4. List members of external members of ad_admins_external group to see their SIDs:
ipa group-show ad_admins_external
GLOBAL TRUST CONFIGURATION
When IPA AD trust subpackage is installed and ipa-adtrust-install is run,
a local domain configuration (SID, GUID, NetBIOS name) is generated. These
identifiers are then used when communicating with a trusted domain of the
particular type.
1. Show global trust configuration for Active Directory type of trusts:
ipa trustconfig-show --type ad
2. Modify global configuration for all trusts of Active Directory type and set
a different fallback primary group (fallback primary group GID is used as
a primary user GID if user authenticating to IPA domain does not have any other
primary GID already set):
ipa trustconfig-mod --type ad --fallback-primary-group "alternative AD group"
3. Change primary fallback group back to default hidden group (any group with
posixGroup object class is allowed):
ipa trustconfig-mod --type ad --fallback-primary-group "Default SMB Group"
""")
register = Registry()
@register()
class trust(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Realm name'),
),
parameters.Str(
'ipantflatname',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipantsidblacklistincoming',
required=False,
multivalue=True,
label=_(u'SID blacklist incoming'),
),
parameters.Str(
'ipantsidblacklistoutgoing',
required=False,
multivalue=True,
label=_(u'SID blacklist outgoing'),
),
)
@register()
class trustconfig(Object):
takes_params = (
parameters.Str(
'cn',
label=_(u'Domain'),
),
parameters.Str(
'ipantsecurityidentifier',
label=_(u'Security Identifier'),
),
parameters.Str(
'ipantflatname',
label=_(u'NetBIOS name'),
),
parameters.Str(
'ipantdomainguid',
label=_(u'Domain GUID'),
),
parameters.Str(
'ipantfallbackprimarygroup',
label=_(u'Fallback primary group'),
),
)
@register()
class trustdomain(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Domain name'),
),
parameters.Str(
'ipantflatname',
required=False,
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
),
)
@register()
class adtrust_is_enabled(Command):
__doc__ = _("Determine whether ipa-adtrust-install has been run on this system")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class compat_is_enabled(Command):
__doc__ = _("Determine whether Schema Compatibility plugin is configured to serve trusted domain users and groups")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class sidgen_was_run(Command):
__doc__ = _("Determine whether ipa-adtrust-install has been run with sidgen task")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class trust_add(Method):
__doc__ = _("""
Add new trust to use.
This command establishes trust relationship to another domain
which becomes 'trusted'. As result, users of the trusted domain
may access resources of this domain.
Only trusts to Active Directory domains are supported right now.
The command can be safely run multiple times against the same domain,
this will cause change to trust relationship credentials on both
sides.
""")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Str(
'realm_admin',
required=False,
cli_name='admin',
label=_(u'Active Directory domain administrator'),
),
parameters.Password(
'realm_passwd',
required=False,
cli_name='password',
label=_(u"Active Directory domain administrator's password"),
),
parameters.Str(
'realm_server',
required=False,
cli_name='server',
label=_(u'Domain controller for the Active Directory domain (optional)'),
),
parameters.Password(
'trust_secret',
required=False,
label=_(u'Shared secret for the trust'),
),
parameters.Int(
'base_id',
required=False,
label=_(u'First Posix ID of the range reserved for the trusted domain'),
),
parameters.Int(
'range_size',
required=False,
label=_(u'Size of the ID range reserved for the trusted domain'),
),
parameters.Str(
'range_type',
required=False,
cli_metavar="['ipa-ad-trust-posix', 'ipa-ad-trust']",
label=_(u'Range type'),
doc=_(u'Type of trusted domain ID range, one of ipa-ad-trust-posix, ipa-ad-trust'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trust_del(Method):
__doc__ = _("Delete a trust.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class trust_fetch_domains(Method):
__doc__ = _("Refresh list of the domains associated with the trust")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class trust_find(Method):
__doc__ = _("Search for trusts.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='realm',
label=_(u'Realm name'),
),
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipantsidblacklistincoming',
required=False,
multivalue=True,
cli_name='sid_blacklist_incoming',
label=_(u'SID blacklist incoming'),
),
parameters.Str(
'ipantsidblacklistoutgoing',
required=False,
multivalue=True,
cli_name='sid_blacklist_outgoing',
label=_(u'SID blacklist outgoing'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("realm")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class trust_mod(Method):
__doc__ = _("""
Modify a trust (for future use).
Currently only the default option to modify the LDAP attributes is
available. More specific options will be added in coming releases.
""")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Str(
'ipantsidblacklistincoming',
required=False,
multivalue=True,
cli_name='sid_blacklist_incoming',
label=_(u'SID blacklist incoming'),
),
parameters.Str(
'ipantsidblacklistoutgoing',
required=False,
multivalue=True,
cli_name='sid_blacklist_outgoing',
label=_(u'SID blacklist outgoing'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trust_resolve(Command):
__doc__ = _("Resolve security identifiers of users and groups in trusted domains")
NO_CLI = True
takes_options = (
parameters.Str(
'sids',
multivalue=True,
label=_(u'Security Identifiers (SIDs)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.ListOfEntries(
'result',
),
)
@register()
class trust_show(Method):
__doc__ = _("Display information about a trust.")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustconfig_mod(Method):
__doc__ = _("Modify global trust configuration.")
takes_options = (
parameters.Str(
'ipantfallbackprimarygroup',
required=False,
cli_name='fallback_primary_group',
label=_(u'Fallback primary group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustconfig_show(Method):
__doc__ = _("Show global trust configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_add(Method):
__doc__ = _("Allow access from the trusted domain")
NO_CLI = True
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_del(Method):
__doc__ = _("Remove information about the domain associated with the trust.")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
multivalue=True,
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class trustdomain_disable(Method):
__doc__ = _("Disable use of IPA resources by the domain of the trust")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_enable(Method):
__doc__ = _("Allow use of IPA resources by the domain of the trust")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_find(Method):
__doc__ = _("Search domains of the trust")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='domain',
label=_(u'Domain name'),
),
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("domain")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class trustdomain_mod(Method):
__doc__ = _("Modify trustdomain of the trust")
NO_CLI = True
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 35,406
|
Python
|
.py
| 1,144
| 21.068182
| 162
| 0.532879
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,014
|
hbactest.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/hbactest.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Simulate use of Host-based access controls
HBAC rules control who can access what services on what hosts.
You can use HBAC to control which users or groups can access a service,
or group of services, on a target host.
Since applying HBAC rules implies use of a production environment,
this plugin aims to provide simulation of HBAC rules evaluation without
having access to the production environment.
Test user coming to a service on a named host against
existing enabled rules.
ipa hbactest --user= --host= --service=
[--rules=rules-list] [--nodetail] [--enabled] [--disabled]
[--sizelimit= ]
--user, --host, and --service are mandatory, others are optional.
If --rules is specified simulate enabling of the specified rules and test
the login of the user using only these rules.
If --enabled is specified, all enabled HBAC rules will be added to simulation
If --disabled is specified, all disabled HBAC rules will be added to simulation
If --nodetail is specified, do not return information about rules matched/not matched.
If both --rules and --enabled are specified, apply simulation to --rules _and_
all IPA enabled rules.
If no --rules specified, simulation is run against all IPA enabled rules.
By default there is a IPA-wide limit to number of entries fetched, you can change it
with --sizelimit option.
EXAMPLES:
1. Use all enabled HBAC rules in IPA database to simulate:
$ ipa hbactest --user=a1a --host=bar --service=sshd
--------------------
Access granted: True
--------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
Matched rules: allow_all
2. Disable detailed summary of how rules were applied:
$ ipa hbactest --user=a1a --host=bar --service=sshd --nodetail
--------------------
Access granted: True
--------------------
3. Test explicitly specified HBAC rules:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--rules=myrule --rules=my-second-rule
---------------------
Access granted: False
---------------------
Not matched rules: my-second-rule
Not matched rules: myrule
4. Use all enabled HBAC rules in IPA database + explicitly specified rules:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--rules=myrule --rules=my-second-rule --enabled
--------------------
Access granted: True
--------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
Matched rules: allow_all
5. Test all disabled HBAC rules in IPA database:
$ ipa hbactest --user=a1a --host=bar --service=sshd --disabled
---------------------
Access granted: False
---------------------
Not matched rules: new-rule
6. Test all disabled HBAC rules in IPA database + explicitly specified rules:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--rules=myrule --rules=my-second-rule --disabled
---------------------
Access granted: False
---------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
7. Test all (enabled and disabled) HBAC rules in IPA database:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--enabled --disabled
--------------------
Access granted: True
--------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
Not matched rules: new-rule
Matched rules: allow_all
HBACTEST AND TRUSTED DOMAINS
When an external trusted domain is configured in IPA, HBAC rules are also applied
on users accessing IPA resources from the trusted domain. Trusted domain users and
groups (and their SIDs) can be then assigned to external groups which can be
members of POSIX groups in IPA which can be used in HBAC rules and thus allowing
access to resources protected by the HBAC system.
hbactest plugin is capable of testing access for both local IPA users and users
from the trusted domains, either by a fully qualified user name or by user SID.
Such user names need to have a trusted domain specified as a short name
(DOMAIN\Administrator) or with a user principal name (UPN), Administrator@ad.test.
Please note that hbactest executed with a trusted domain user as --user parameter
can be only run by members of "trust admins" group.
EXAMPLES:
1. Test if a user from a trusted domain specified by its shortname matches any
rule:
$ ipa hbactest --user 'DOMAIN\Administrator' --host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Matched rules: can_login
2. Test if a user from a trusted domain specified by its domain name matches
any rule:
$ ipa hbactest --user 'Administrator@domain.com' --host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Matched rules: can_login
3. Test if a user from a trusted domain specified by its SID matches any rule:
$ ipa hbactest --user S-1-5-21-3035198329-144811719-1378114514-500 \
--host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Matched rules: can_login
4. Test if other user from a trusted domain specified by its SID matches any rule:
$ ipa hbactest --user S-1-5-21-3035198329-144811719-1378114514-1203 \
--host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Not matched rules: can_login
5. Test if other user from a trusted domain specified by its shortname matches
any rule:
$ ipa hbactest --user 'DOMAIN\Otheruser' --host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Not matched rules: can_login
""")
register = Registry()
@register()
class hbactest(Command):
__doc__ = _("Simulate use of Host-based access controls")
takes_options = (
parameters.Str(
'user',
label=_(u'User name'),
),
parameters.Str(
'sourcehost',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'targethost',
cli_name='host',
label=_(u'Target host'),
),
parameters.Str(
'service',
label=_(u'Service'),
),
parameters.Str(
'rules',
required=False,
multivalue=True,
label=_(u'Rules to test. If not specified, --enabled is assumed'),
),
parameters.Flag(
'nodetail',
required=False,
label=_(u'Hide details which rules are matched, not matched, or invalid'),
default=False,
autofill=True,
),
parameters.Flag(
'enabled',
required=False,
label=_(u'Include all enabled IPA rules into test [default]'),
default=False,
autofill=True,
),
parameters.Flag(
'disabled',
required=False,
label=_(u'Include all disabled IPA rules into test'),
default=False,
autofill=True,
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of rules to process when no --rules is specified'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'warning',
(list, tuple, type(None)),
doc=_(u'Warning'),
),
output.Output(
'matched',
(list, tuple, type(None)),
doc=_(u'Matched rules'),
),
output.Output(
'notmatched',
(list, tuple, type(None)),
doc=_(u'Not matched rules'),
),
output.Output(
'error',
(list, tuple, type(None)),
doc=_(u'Non-existent or invalid rules'),
),
output.Output(
'value',
bool,
doc=_(u'Result of simulation'),
),
)
| 9,123
|
Python
|
.py
| 241
| 30.751037
| 87
| 0.611947
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,015
|
internal.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/internal.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Plugins not accessible directly through the CLI, commands used internally
""")
register = Registry()
@register()
class i18n_messages(Command):
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'texts',
dict,
doc=_(u'Dict of I18N messages'),
),
)
@register()
class json_metadata(Command):
__doc__ = _("Export plugin meta-data for the webUI.")
NO_CLI = True
takes_args = (
parameters.Str(
'objname',
required=False,
doc=_(u'Name of object to export'),
),
parameters.Str(
'methodname',
required=False,
doc=_(u'Name of method to export'),
),
)
takes_options = (
parameters.Str(
'object',
required=False,
doc=_(u'Name of object to export'),
),
parameters.Str(
'method',
required=False,
doc=_(u'Name of method to export'),
),
parameters.Str(
'command',
required=False,
doc=_(u'Name of command to export'),
),
)
has_output = (
output.Output(
'objects',
dict,
doc=_(u'Dict of JSON encoded IPA Objects'),
),
output.Output(
'methods',
dict,
doc=_(u'Dict of JSON encoded IPA Methods'),
),
output.Output(
'commands',
dict,
doc=_(u'Dict of JSON encoded IPA Commands'),
),
)
| 2,019
|
Python
|
.py
| 80
| 17.5375
| 73
| 0.548521
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,016
|
batch.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/batch.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Plugin to make multiple ipa calls via one remote procedure call
To run this code in the lite-server
curl -H "Content-Type:application/json" -H "Accept:application/json" -H "Accept-Language:en" --negotiate -u : --cacert /etc/ipa/ca.crt -d @batch_request.json -X POST http://localhost:8888/ipa/json
where the contents of the file batch_request.json follow the below example
{"method":"batch","params":[[
{"method":"group_find","params":[[],{}]},
{"method":"user_find","params":[[],{"whoami":"true","all":"true"}]},
{"method":"user_show","params":[["admin"],{"all":true}]}
],{}],"id":1}
The format of the response is nested the same way. At the top you will see
"error": null,
"id": 1,
"result": {
"count": 3,
"results": [
And then a nested response for each IPA command method sent in the request
""")
register = Registry()
@register()
class batch(Command):
NO_CLI = True
takes_args = (
parameters.Any(
'methods',
required=False,
multivalue=True,
doc=_(u'Nested Methods to execute'),
),
)
takes_options = (
)
has_output = (
output.Output(
'count',
int,
),
output.Output(
'results',
(list, tuple),
),
)
| 1,806
|
Python
|
.py
| 56
| 26.732143
| 240
| 0.613256
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,017
|
__init__.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/__init__.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
from ..compat import CompatCommand, CompatMethod, CompatObject
Object = CompatObject
class Command(CompatCommand):
api_version = u'2.114'
class Method(Command, CompatMethod):
pass
| 265
|
Python
|
.py
| 9
| 26.888889
| 66
| 0.792
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,018
|
hbacsvcgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/hbacsvcgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
HBAC Service Groups
HBAC service groups can contain any number of individual services,
or "members". Every group must have a description.
EXAMPLES:
Add a new HBAC service group:
ipa hbacsvcgroup-add --desc="login services" login
Add members to an HBAC service group:
ipa hbacsvcgroup-add-member --hbacsvcs=sshd --hbacsvcs=login login
Display information about a named group:
ipa hbacsvcgroup-show login
Delete an HBAC service group:
ipa hbacsvcgroup-del login
""")
register = Registry()
@register()
class hbacsvcgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Service group name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Str(
'member_hbacsvc',
required=False,
label=_(u'Member HBAC service'),
),
)
@register()
class hbacsvcgroup_add(Method):
__doc__ = _("Add a new HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvcgroup_add_member(Method):
__doc__ = _("Add members to an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacsvcgroup_del(Method):
__doc__ = _("Delete an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hbacsvcgroup_find(Method):
__doc__ = _("Search for an HBAC service group.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hbacsvcgroup_mod(Method):
__doc__ = _("Modify an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvcgroup_remove_member(Method):
__doc__ = _("Remove members from an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacsvcgroup_show(Method):
__doc__ = _("Display information about an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 14,599
|
Python
|
.py
| 494
| 19.447368
| 162
| 0.511549
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,019
|
realmdomains.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/realmdomains.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Realm domains
Manage the list of domains associated with IPA realm.
EXAMPLES:
Display the current list of realm domains:
ipa realmdomains-show
Replace the list of realm domains:
ipa realmdomains-mod --domain=example.com
ipa realmdomains-mod --domain={example1.com,example2.com,example3.com}
Add a domain to the list of realm domains:
ipa realmdomains-mod --add-domain=newdomain.com
Delete a domain from the list of realm domains:
ipa realmdomains-mod --del-domain=olddomain.com
""")
register = Registry()
@register()
class realmdomains(Object):
takes_params = (
parameters.Str(
'associateddomain',
multivalue=True,
label=_(u'Domain'),
),
parameters.Str(
'add_domain',
required=False,
label=_(u'Add domain'),
),
parameters.Str(
'del_domain',
required=False,
label=_(u'Delete domain'),
),
)
@register()
class realmdomains_mod(Method):
__doc__ = _("Modify realm domains.")
takes_options = (
parameters.Str(
'associateddomain',
required=False,
multivalue=True,
cli_name='domain',
label=_(u'Domain'),
no_convert=True,
),
parameters.Str(
'add_domain',
required=False,
label=_(u'Add domain'),
no_convert=True,
),
parameters.Str(
'del_domain',
required=False,
label=_(u'Delete domain'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'Force adding domain even if not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class realmdomains_show(Method):
__doc__ = _("Display the list of realm domains.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 5,425
|
Python
|
.py
| 176
| 21.517045
| 162
| 0.551052
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,020
|
hbacrule.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/hbacrule.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Host-based access control
Control who can access what services on what hosts. You
can use HBAC to control which users or groups can
access a service, or group of services, on a target host.
You can also specify a category of users and target hosts.
This is currently limited to "all", but might be expanded in the
future.
Target hosts in HBAC rules must be hosts managed by IPA.
The available services and groups of services are controlled by the
hbacsvc and hbacsvcgroup plug-ins respectively.
EXAMPLES:
Create a rule, "test1", that grants all users access to the host "server" from
anywhere:
ipa hbacrule-add --usercat=all test1
ipa hbacrule-add-host --hosts=server.example.com test1
Display the properties of a named HBAC rule:
ipa hbacrule-show test1
Create a rule for a specific service. This lets the user john access
the sshd service on any machine from any machine:
ipa hbacrule-add --hostcat=all john_sshd
ipa hbacrule-add-user --users=john john_sshd
ipa hbacrule-add-service --hbacsvcs=sshd john_sshd
Create a rule for a new service group. This lets the user john access
the FTP service on any machine from any machine:
ipa hbacsvcgroup-add ftpers
ipa hbacsvc-add sftp
ipa hbacsvcgroup-add-member --hbacsvcs=ftp --hbacsvcs=sftp ftpers
ipa hbacrule-add --hostcat=all john_ftp
ipa hbacrule-add-user --users=john john_ftp
ipa hbacrule-add-service --hbacsvcgroups=ftpers john_ftp
Disable a named HBAC rule:
ipa hbacrule-disable test1
Remove a named HBAC rule:
ipa hbacrule-del allow_server
""")
register = Registry()
@register()
class hbacrule(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Rule name'),
),
parameters.Str(
'accessruletype',
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
),
parameters.Str(
'servicecategory',
required=False,
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Users'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'User Groups'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Hosts'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Host Groups'),
),
parameters.Str(
'sourcehost_host',
required=False,
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
),
parameters.Str(
'memberservice_hbacsvc',
required=False,
label=_(u'Services'),
),
parameters.Str(
'memberservice_hbacsvcgroup',
required=False,
label=_(u'Service Groups'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
),
)
@register()
class hbacrule_add(Method):
__doc__ = _("Create a new HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'accessruletype',
cli_name='type',
cli_metavar="['allow', 'deny']",
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
default=u'allow',
autofill=True,
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_host',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_add_host(Method):
__doc__ = _("Add target hosts and hostgroups to an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_add_service(Method):
__doc__ = _("Add services to an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to add'),
alwaysask=True,
),
parameters.Str(
'hbacsvcgroup',
required=False,
multivalue=True,
cli_name='hbacsvcgroups',
label=_(u'member HBAC service group'),
doc=_(u'HBAC service groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_add_sourcehost(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_add_user(Method):
__doc__ = _("Add users and groups to an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_del(Method):
__doc__ = _("Delete an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hbacrule_disable(Method):
__doc__ = _("Disable an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_enable(Method):
__doc__ = _("Enable an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_find(Method):
__doc__ = _("Search for HBAC rules.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Rule name'),
),
parameters.Str(
'accessruletype',
required=False,
cli_name='type',
cli_metavar="['allow', 'deny']",
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
default=u'allow',
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_host',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hbacrule_mod(Method):
__doc__ = _("Modify an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'accessruletype',
required=False,
cli_name='type',
cli_metavar="['allow', 'deny']",
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
default=u'allow',
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_host',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_remove_host(Method):
__doc__ = _("Remove target hosts and hostgroups from an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_remove_service(Method):
__doc__ = _("Remove service and service groups from an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to remove'),
alwaysask=True,
),
parameters.Str(
'hbacsvcgroup',
required=False,
multivalue=True,
cli_name='hbacsvcgroups',
label=_(u'member HBAC service group'),
doc=_(u'HBAC service groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_remove_sourcehost(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_remove_user(Method):
__doc__ = _("Remove users and groups from an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_show(Method):
__doc__ = _("Display the properties of an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 35,745
|
Python
|
.py
| 1,242
| 18.284219
| 162
| 0.490941
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,021
|
sudocmdgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/sudocmdgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Groups of Sudo Commands
Manage groups of Sudo Commands.
EXAMPLES:
Add a new Sudo Command Group:
ipa sudocmdgroup-add --desc='administrators commands' admincmds
Remove a Sudo Command Group:
ipa sudocmdgroup-del admincmds
Manage Sudo Command Group membership, commands:
ipa sudocmdgroup-add-member --sudocmds=/usr/bin/less --sudocmds=/usr/bin/vim admincmds
Manage Sudo Command Group membership, commands:
ipa group-remove-member --sudocmds=/usr/bin/less admincmds
Show a Sudo Command Group:
ipa group-show localadmins
""")
register = Registry()
@register()
class sudocmdgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Sudo Command Group'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Str(
'membercmd_sudocmd',
required=False,
label=_(u'Commands'),
),
parameters.Str(
'membercmd_sudocmdgroup',
required=False,
label=_(u'Sudo Command Groups'),
),
parameters.Str(
'member_sudocmd',
required=False,
label=_(u'Member Sudo commands'),
),
)
@register()
class sudocmdgroup_add(Method):
__doc__ = _("Create new Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmdgroup_add_member(Method):
__doc__ = _("Add members to Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudocmdgroup_del(Method):
__doc__ = _("Delete Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class sudocmdgroup_find(Method):
__doc__ = _("Search for Sudo Command Groups.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("sudocmdgroup-name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class sudocmdgroup_mod(Method):
__doc__ = _("Modify Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmdgroup_remove_member(Method):
__doc__ = _("Remove members from Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudocmdgroup_show(Method):
__doc__ = _("Display Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 14,955
|
Python
|
.py
| 505
| 19.491089
| 162
| 0.513285
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,022
|
join.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/join.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Joining an IPA domain
""")
register = Registry()
@register()
class join(Command):
__doc__ = _("Join an IPA domain")
takes_args = (
parameters.Str(
'cn',
cli_name='hostname',
doc=_(u'The hostname to register as'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: unicode(installutils.get_fqdn())
autofill=True,
),
)
takes_options = (
parameters.Str(
'realm',
doc=_(u'The IPA realm'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: get_realm()
autofill=True,
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
doc=_(u'Hardware platform of the host (e.g. Lenovo T61)'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
doc=_(u'Operating System and version of the host (e.g. Fedora 9)'),
),
)
has_output = (
)
| 1,537
|
Python
|
.py
| 56
| 20.089286
| 79
| 0.576375
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,023
|
privilege.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/privilege.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Privileges
A privilege combines permissions into a logical task. A permission provides
the rights to do a single task. There are some IPA operations that require
multiple permissions to succeed. A privilege is where permissions are
combined in order to perform a specific task.
For example, adding a user requires the following permissions:
* Creating a new user entry
* Resetting a user password
* Adding the new user to the default IPA users group
Combining these three low-level tasks into a higher level task in the
form of a privilege named "Add User" makes it easier to manage Roles.
A privilege may not contain other privileges.
See role and permission for additional information.
""")
register = Registry()
@register()
class privilege(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Privilege name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Str(
'memberof_permission',
required=False,
label=_(u'Permissions'),
),
parameters.Str(
'member_role',
required=False,
label=_(u'Granting privilege to roles'),
),
)
@register()
class privilege_add(Method):
__doc__ = _("Add a new privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class privilege_add_member(Method):
__doc__ = _("Add members to a privilege.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'role',
required=False,
multivalue=True,
cli_name='roles',
label=_(u'member role'),
doc=_(u'roles to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class privilege_add_permission(Method):
__doc__ = _("Add permissions to a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'permission',
required=False,
multivalue=True,
cli_name='permissions',
label=_(u'permission'),
doc=_(u'permissions'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of permissions added'),
),
)
@register()
class privilege_del(Method):
__doc__ = _("Delete a privilege.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class privilege_find(Method):
__doc__ = _("Search for privileges.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Privilege name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class privilege_mod(Method):
__doc__ = _("Modify a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the privilege object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class privilege_remove_member(Method):
__doc__ = _("Remove members from a privilege")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'role',
required=False,
multivalue=True,
cli_name='roles',
label=_(u'member role'),
doc=_(u'roles to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class privilege_remove_permission(Method):
__doc__ = _("Remove permissions from a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'permission',
required=False,
multivalue=True,
cli_name='permissions',
label=_(u'permission'),
doc=_(u'permissions'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of permissions removed'),
),
)
@register()
class privilege_show(Method):
__doc__ = _("Display information about a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 17,885
|
Python
|
.py
| 615
| 18.956098
| 162
| 0.505891
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,024
|
service.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/service.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Services
A IPA service represents a service that runs on a host. The IPA service
record can store a Kerberos principal, an SSL certificate, or both.
An IPA service can be managed directly from a machine, provided that
machine has been given the correct permission. This is true even for
machines other than the one the service is associated with. For example,
requesting an SSL certificate using the host service principal credentials
of the host. To manage a service using host credentials you need to
kinit as the host:
# kinit -kt /etc/krb5.keytab host/ipa.example.com@EXAMPLE.COM
Adding an IPA service allows the associated service to request an SSL
certificate or keytab, but this is performed as a separate step; they
are not produced as a result of adding the service.
Only the public aspect of a certificate is stored in a service record;
the private key is not stored.
EXAMPLES:
Add a new IPA service:
ipa service-add HTTP/web.example.com
Allow a host to manage an IPA service certificate:
ipa service-add-host --hosts=web.example.com HTTP/web.example.com
ipa role-add-member --hosts=web.example.com certadmin
Override a default list of supported PAC types for the service:
ipa service-mod HTTP/web.example.com --pac-type=MS-PAC
A typical use case where overriding the PAC type is needed is NFS.
Currently the related code in the Linux kernel can only handle Kerberos
tickets up to a maximal size. Since the PAC data can become quite large it
is recommended to set --pac-type=NONE for NFS services.
Delete an IPA service:
ipa service-del HTTP/web.example.com
Find all IPA services associated with a host:
ipa service-find web.example.com
Find all HTTP services:
ipa service-find HTTP
Disable the service Kerberos key and SSL certificate:
ipa service-disable HTTP/web.example.com
Request a certificate for an IPA service:
ipa cert-request --principal=HTTP/web.example.com example.csr
Allow user to create a keytab:
ipa service-allow-create-keytab HTTP/web.example.com --users=tuser1
Generate and retrieve a keytab for an IPA service:
ipa-getkeytab -s ipa.example.com -p HTTP/web.example.com -k /etc/httpd/httpd.keytab
""")
register = Registry()
@register()
class service(Object):
takes_params = (
parameters.Str(
'krbprincipalname',
primary_key=True,
label=_(u'Principal'),
doc=_(u'Service principal'),
),
parameters.Bytes(
'usercertificate',
required=False,
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Flag(
'has_keytab',
label=_(u'Keytab'),
),
parameters.Str(
'managedby_host',
label=_(u'Managed by'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_user',
label=_(u'Users allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_group',
label=_(u'Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_host',
label=_(u'Hosts allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_hostgroup',
label=_(u'Host Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_user',
label=_(u'Users allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_group',
label=_(u'Groups allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_host',
label=_(u'Hosts allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_hostgroup',
label=_(u'Host Groups allowed to create keytab'),
),
)
@register()
class service_add(Method):
__doc__ = _("Add a new IPA new service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Bytes(
'usercertificate',
required=False,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'NONE']",
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force principal name even if not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_add_host(Method):
__doc__ = _("Add hosts that can manage this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class service_allow_create_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to create a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class service_allow_retrieve_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to retrieve a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class service_del(Method):
__doc__ = _("Delete an IPA service.")
takes_args = (
parameters.Str(
'krbprincipalname',
multivalue=True,
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class service_disable(Method):
__doc__ = _("Disable the Kerberos key and SSL certificate of a service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_disallow_create_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to create a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class service_disallow_retrieve_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to retrieve a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class service_find(Method):
__doc__ = _("Search for IPA services.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'NONE']",
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("principal")'),
default=False,
autofill=True,
),
parameters.Str(
'man_by_host',
required=False,
multivalue=True,
cli_name='man_by_hosts',
label=_(u'host'),
doc=_(u'Search for services with these managed by hosts.'),
),
parameters.Str(
'not_man_by_host',
required=False,
multivalue=True,
cli_name='not_man_by_hosts',
label=_(u'host'),
doc=_(u'Search for services without these managed by hosts.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class service_mod(Method):
__doc__ = _("Modify an existing IPA service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Bytes(
'usercertificate',
required=False,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'NONE']",
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_remove_host(Method):
__doc__ = _("Remove hosts that can manage this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class service_show(Method):
__doc__ = _("Display information about an IPA service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'out',
required=False,
doc=_(u'file to store certificate in'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 32,359
|
Python
|
.py
| 1,040
| 20.691346
| 167
| 0.520266
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,025
|
otptoken_yubikey.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/otptoken_yubikey.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
YubiKey Tokens
Manage YubiKey tokens.
This code is an extension to the otptoken plugin and provides support for
reading/writing YubiKey tokens directly.
EXAMPLES:
Add a new token:
ipa otptoken-add-yubikey --owner=jdoe --desc="My YubiKey"
""")
register = Registry()
| 690
|
Python
|
.py
| 24
| 27.041667
| 73
| 0.797565
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,026
|
selinuxusermap.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/selinuxusermap.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
SELinux User Mapping
Map IPA users to SELinux users by host.
Hosts, hostgroups, users and groups can be either defined within
the rule or it may point to an existing HBAC rule. When using
--hbacrule option to selinuxusermap-find an exact match is made on the
HBAC rule name, so only one or zero entries will be returned.
EXAMPLES:
Create a rule, "test1", that sets all users to xguest_u:s0 on the host "server":
ipa selinuxusermap-add --usercat=all --selinuxuser=xguest_u:s0 test1
ipa selinuxusermap-add-host --hosts=server.example.com test1
Create a rule, "test2", that sets all users to guest_u:s0 and uses an existing HBAC rule for users and hosts:
ipa selinuxusermap-add --usercat=all --hbacrule=webserver --selinuxuser=guest_u:s0 test2
Display the properties of a rule:
ipa selinuxusermap-show test2
Create a rule for a specific user. This sets the SELinux context for
user john to unconfined_u:s0-s0:c0.c1023 on any machine:
ipa selinuxusermap-add --hostcat=all --selinuxuser=unconfined_u:s0-s0:c0.c1023 john_unconfined
ipa selinuxusermap-add-user --users=john john_unconfined
Disable a rule:
ipa selinuxusermap-disable test1
Enable a rule:
ipa selinuxusermap-enable test1
Find a rule referencing a specific HBAC rule:
ipa selinuxusermap-find --hbacrule=allow_some
Remove a rule:
ipa selinuxusermap-del john_unconfined
SEEALSO:
The list controlling the order in which the SELinux user map is applied
and the default SELinux user are available in the config-show command.
""")
register = Registry()
@register()
class selinuxusermap(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Rule name'),
),
parameters.Str(
'ipaselinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Users'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'User Groups'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Hosts'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Host Groups'),
),
)
@register()
class selinuxusermap_add(Method):
__doc__ = _("Create a new SELinux User Map.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'ipaselinuxuser',
cli_name='selinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
cli_name='hbacrule',
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_add_host(Method):
__doc__ = _("Add target hosts and hostgroups to an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class selinuxusermap_add_user(Method):
__doc__ = _("Add users and groups to an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class selinuxusermap_del(Method):
__doc__ = _("Delete a SELinux User Map.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class selinuxusermap_disable(Method):
__doc__ = _("Disable an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_enable(Method):
__doc__ = _("Enable an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_find(Method):
__doc__ = _("Search for SELinux User Maps.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Rule name'),
),
parameters.Str(
'ipaselinuxuser',
required=False,
cli_name='selinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
cli_name='hbacrule',
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class selinuxusermap_mod(Method):
__doc__ = _("Modify a SELinux User Map.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'ipaselinuxuser',
required=False,
cli_name='selinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
cli_name='hbacrule',
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_remove_host(Method):
__doc__ = _("Remove target hosts and hostgroups from an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class selinuxusermap_remove_user(Method):
__doc__ = _("Remove users and groups from an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class selinuxusermap_show(Method):
__doc__ = _("Display the properties of a SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 25,184
|
Python
|
.py
| 852
| 19.279343
| 162
| 0.505128
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,027
|
otpconfig.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/otpconfig.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
OTP configuration
Manage the default values that IPA uses for OTP tokens.
EXAMPLES:
Show basic OTP configuration:
ipa otpconfig-show
Show all OTP configuration options:
ipa otpconfig-show --all
Change maximum TOTP authentication window to 10 minutes:
ipa otpconfig-mod --totp-auth-window=600
Change maximum TOTP synchronization window to 12 hours:
ipa otpconfig-mod --totp-sync-window=43200
Change maximum HOTP authentication window to 5:
ipa hotpconfig-mod --hotp-auth-window=5
Change maximum HOTP synchronization window to 50:
ipa hotpconfig-mod --hotp-sync-window=50
""")
register = Registry()
@register()
class otpconfig(Object):
takes_params = (
parameters.Int(
'ipatokentotpauthwindow',
label=_(u'TOTP authentication Window'),
doc=_(u'TOTP authentication time variance (seconds)'),
),
parameters.Int(
'ipatokentotpsyncwindow',
label=_(u'TOTP Synchronization Window'),
doc=_(u'TOTP synchronization time variance (seconds)'),
),
parameters.Int(
'ipatokenhotpauthwindow',
label=_(u'HOTP Authentication Window'),
doc=_(u'HOTP authentication skip-ahead'),
),
parameters.Int(
'ipatokenhotpsyncwindow',
label=_(u'HOTP Synchronization Window'),
doc=_(u'HOTP synchronization skip-ahead'),
),
)
@register()
class otpconfig_mod(Method):
__doc__ = _("Modify OTP configuration options.")
takes_options = (
parameters.Int(
'ipatokentotpauthwindow',
required=False,
cli_name='totp_auth_window',
label=_(u'TOTP authentication Window'),
doc=_(u'TOTP authentication time variance (seconds)'),
),
parameters.Int(
'ipatokentotpsyncwindow',
required=False,
cli_name='totp_sync_window',
label=_(u'TOTP Synchronization Window'),
doc=_(u'TOTP synchronization time variance (seconds)'),
),
parameters.Int(
'ipatokenhotpauthwindow',
required=False,
cli_name='hotp_auth_window',
label=_(u'HOTP Authentication Window'),
doc=_(u'HOTP authentication skip-ahead'),
),
parameters.Int(
'ipatokenhotpsyncwindow',
required=False,
cli_name='hotp_sync_window',
label=_(u'HOTP Synchronization Window'),
doc=_(u'HOTP synchronization skip-ahead'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class otpconfig_show(Method):
__doc__ = _("Show the current OTP configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 6,184
|
Python
|
.py
| 185
| 24.140541
| 162
| 0.576614
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,028
|
cert.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/cert.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
IPA certificate operations
Implements a set of commands for managing server SSL certificates.
Certificate requests exist in the form of a Certificate Signing Request (CSR)
in PEM format.
The dogtag CA uses just the CN value of the CSR and forces the rest of the
subject to values configured in the server.
A certificate is stored with a service principal and a service principal
needs a host.
In order to request a certificate:
* The host must exist
* The service must exist (or you use the --add option to automatically add it)
SEARCHING:
Certificates may be searched on by certificate subject, serial number,
revocation reason, validity dates and the issued date.
When searching on dates the _from date does a >= search and the _to date
does a <= search. When combined these are done as an AND.
Dates are treated as GMT to match the dates in the certificates.
The date format is YYYY-mm-dd.
EXAMPLES:
Request a new certificate and add the principal:
ipa cert-request --add --principal=HTTP/lion.example.com example.csr
Retrieve an existing certificate:
ipa cert-show 1032
Revoke a certificate (see RFC 5280 for reason details):
ipa cert-revoke --revocation-reason=6 1032
Remove a certificate from revocation hold status:
ipa cert-remove-hold 1032
Check the status of a signing request:
ipa cert-status 10
Search for certificates by hostname:
ipa cert-find --subject=ipaserver.example.com
Search for revoked certificates by reason:
ipa cert-find --revocation-reason=5
Search for certificates based on issuance date
ipa cert-find --issuedon-from=2013-02-01 --issuedon-to=2013-02-07
IPA currently immediately issues (or declines) all certificate requests so
the status of a request is not normally useful. This is for future use
or the case where a CA does not immediately issue a certificate.
The following revocation reasons are supported:
* 0 - unspecified
* 1 - keyCompromise
* 2 - cACompromise
* 3 - affiliationChanged
* 4 - superseded
* 5 - cessationOfOperation
* 6 - certificateHold
* 8 - removeFromCRL
* 9 - privilegeWithdrawn
* 10 - aACompromise
Note that reason code 7 is not used. See RFC 5280 for more details:
http://www.ietf.org/rfc/rfc5280.txt
""")
register = Registry()
@register()
class ca_is_enabled(Command):
__doc__ = _("Checks if any of the servers has the CA service enabled.")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class cert_find(Command):
__doc__ = _("Search for existing certificates.")
takes_options = (
parameters.Str(
'subject',
required=False,
label=_(u'Match cn attribute in subject'),
),
parameters.Int(
'revocation_reason',
required=False,
label=_(u'Reason'),
doc=_(u'Reason for revoking the certificate (0-10)'),
),
parameters.Int(
'min_serial_number',
required=False,
doc=_(u'minimum serial number'),
),
parameters.Int(
'max_serial_number',
required=False,
doc=_(u'maximum serial number'),
),
parameters.Flag(
'exactly',
required=False,
doc=_(u'match the common name exactly'),
default=False,
autofill=True,
),
parameters.Str(
'validnotafter_from',
required=False,
doc=_(u'Valid not after from this date (YYYY-mm-dd)'),
),
parameters.Str(
'validnotafter_to',
required=False,
doc=_(u'Valid not after to this date (YYYY-mm-dd)'),
),
parameters.Str(
'validnotbefore_from',
required=False,
doc=_(u'Valid not before from this date (YYYY-mm-dd)'),
),
parameters.Str(
'validnotbefore_to',
required=False,
doc=_(u'Valid not before to this date (YYYY-mm-dd)'),
),
parameters.Str(
'issuedon_from',
required=False,
doc=_(u'Issued on from this date (YYYY-mm-dd)'),
),
parameters.Str(
'issuedon_to',
required=False,
doc=_(u'Issued on to this date (YYYY-mm-dd)'),
),
parameters.Str(
'revokedon_from',
required=False,
doc=_(u'Revoked on from this date (YYYY-mm-dd)'),
),
parameters.Str(
'revokedon_to',
required=False,
doc=_(u'Revoked on to this date (YYYY-mm-dd)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of certs returned'),
default=100,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class cert_remove_hold(Command):
__doc__ = _("Take a revoked certificate off hold.")
takes_args = (
parameters.Str(
'serial_number',
label=_(u'Serial number'),
doc=_(u'Serial number in decimal or if prefixed with 0x in hexadecimal'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class cert_request(Command):
__doc__ = _("Submit a certificate signing request.")
takes_args = (
parameters.Str(
'csr',
cli_name='csr_file',
label=_(u'CSR'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'principal',
label=_(u'Principal'),
doc=_(u'Service principal for this certificate (e.g. HTTP/test.example.com)'),
),
parameters.Str(
'request_type',
default=u'pkcs10',
autofill=True,
),
parameters.Flag(
'add',
doc=_(u"automatically add the principal if it doesn't exist"),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'result',
dict,
doc=_(u'Dictionary mapping variable name to value'),
),
)
@register()
class cert_revoke(Command):
__doc__ = _("Revoke a certificate.")
takes_args = (
parameters.Str(
'serial_number',
label=_(u'Serial number'),
doc=_(u'Serial number in decimal or if prefixed with 0x in hexadecimal'),
no_convert=True,
),
)
takes_options = (
parameters.Int(
'revocation_reason',
label=_(u'Reason'),
doc=_(u'Reason for revoking the certificate (0-10)'),
default=0,
autofill=True,
),
)
has_output = (
output.Output(
'result',
),
)
@register()
class cert_show(Command):
__doc__ = _("Retrieve an existing certificate.")
takes_args = (
parameters.Str(
'serial_number',
label=_(u'Serial number'),
doc=_(u'Serial number in decimal or if prefixed with 0x in hexadecimal'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'out',
required=False,
label=_(u'Output filename'),
doc=_(u'File to store the certificate in.'),
exclude=('webui',),
),
)
has_output = (
output.Output(
'result',
),
)
@register()
class cert_status(Command):
__doc__ = _("Check the status of a certificate signing request.")
takes_args = (
parameters.Str(
'request_id',
label=_(u'Request id'),
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
| 9,773
|
Python
|
.py
| 324
| 21.87963
| 97
| 0.572523
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,029
|
hostgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/hostgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Groups of hosts.
Manage groups of hosts. This is useful for applying access control to a
number of hosts by using Host-based Access Control.
EXAMPLES:
Add a new host group:
ipa hostgroup-add --desc="Baltimore hosts" baltimore
Add another new host group:
ipa hostgroup-add --desc="Maryland hosts" maryland
Add members to the hostgroup (using Bash brace expansion):
ipa hostgroup-add-member --hosts={box1,box2,box3} baltimore
Add a hostgroup as a member of another hostgroup:
ipa hostgroup-add-member --hostgroups=baltimore maryland
Remove a host from the hostgroup:
ipa hostgroup-remove-member --hosts=box2 baltimore
Display a host group:
ipa hostgroup-show baltimore
Delete a hostgroup:
ipa hostgroup-del baltimore
""")
register = Registry()
@register()
class hostgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Str(
'member_host',
required=False,
label=_(u'Member hosts'),
),
parameters.Str(
'member_hostgroup',
required=False,
label=_(u'Member host-groups'),
),
parameters.Str(
'memberof_hostgroup',
required=False,
label=_(u'Member of host-groups'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberindirect_host',
required=False,
label=_(u'Indirect Member hosts'),
),
parameters.Str(
'memberindirect_hostgroup',
required=False,
label=_(u'Indirect Member host-groups'),
),
parameters.Str(
'memberofindirect_hostgroup',
required=False,
label=_(u'Indirect Member of host-group'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
)
@register()
class hostgroup_add(Method):
__doc__ = _("Add a new hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hostgroup_add_member(Method):
__doc__ = _("Add members to a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hostgroup_del(Method):
__doc__ = _("Delete a hostgroup.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hostgroup_find(Method):
__doc__ = _("Search for hostgroups.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("hostgroup-name")'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'host'),
doc=_(u'Search for host groups with these member hosts.'),
),
parameters.Str(
'no_host',
required=False,
multivalue=True,
cli_name='no_hosts',
label=_(u'host'),
doc=_(u'Search for host groups without these member hosts.'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups with these member host groups.'),
),
parameters.Str(
'no_hostgroup',
required=False,
multivalue=True,
cli_name='no_hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups without these member host groups.'),
),
parameters.Str(
'in_hostgroup',
required=False,
multivalue=True,
cli_name='in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups with these member of host groups.'),
),
parameters.Str(
'not_in_hostgroup',
required=False,
multivalue=True,
cli_name='not_in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups without these member of host groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for host groups with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for host groups without these member of netgroups.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for host groups with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for host groups without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for host groups with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for host groups without these member of sudo rules.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hostgroup_mod(Method):
__doc__ = _("Modify a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hostgroup_remove_member(Method):
__doc__ = _("Remove members from a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hostgroup_show(Method):
__doc__ = _("Display information about a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 20,339
|
Python
|
.py
| 672
| 19.764881
| 162
| 0.508202
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,030
|
aci.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/aci.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Directory Server Access Control Instructions (ACIs)
ACIs are used to allow or deny access to information. This module is
currently designed to allow, not deny, access.
The aci commands are designed to grant permissions that allow updating
existing entries or adding or deleting new ones. The goal of the ACIs
that ship with IPA is to provide a set of low-level permissions that
grant access to special groups called taskgroups. These low-level
permissions can be combined into roles that grant broader access. These
roles are another type of group, roles.
For example, if you have taskgroups that allow adding and modifying users you
could create a role, useradmin. You would assign users to the useradmin
role to allow them to do the operations defined by the taskgroups.
You can create ACIs that delegate permission so users in group A can write
attributes on group B.
The type option is a map that applies to all entries in the users, groups or
host location. It is primarily designed to be used when granting add
permissions (to write new entries).
An ACI consists of three parts:
1. target
2. permissions
3. bind rules
The target is a set of rules that define which LDAP objects are being
targeted. This can include a list of attributes, an area of that LDAP
tree or an LDAP filter.
The targets include:
- attrs: list of attributes affected
- type: an object type (user, group, host, service, etc)
- memberof: members of a group
- targetgroup: grant access to modify a specific group. This is primarily
designed to enable users to add or remove members of a specific group.
- filter: A legal LDAP filter used to narrow the scope of the target.
- subtree: Used to apply a rule across an entire set of objects. For example,
to allow adding users you need to grant "add" permission to the subtree
ldap://uid=*,cn=users,cn=accounts,dc=example,dc=com. The subtree option
is a fail-safe for objects that may not be covered by the type option.
The permissions define what the ACI is allowed to do, and are one or
more of:
1. write - write one or more attributes
2. read - read one or more attributes
3. add - add a new entry to the tree
4. delete - delete an existing entry
5. all - all permissions are granted
Note the distinction between attributes and entries. The permissions are
independent, so being able to add a user does not mean that the user will
be editable.
The bind rule defines who this ACI grants permissions to. The LDAP server
allows this to be any valid LDAP entry but we encourage the use of
taskgroups so that the rights can be easily shared through roles.
For a more thorough description of access controls see
http://www.redhat.com/docs/manuals/dir-server/ag/8.0/Managing_Access_Control.html
EXAMPLES:
NOTE: ACIs are now added via the permission plugin. These examples are to
demonstrate how the various options work but this is done via the permission
command-line now (see last example).
Add an ACI so that the group "secretaries" can update the address on any user:
ipa group-add --desc="Office secretaries" secretaries
ipa aci-add --attrs=streetAddress --memberof=ipausers --group=secretaries --permissions=write --prefix=none "Secretaries write addresses"
Show the new ACI:
ipa aci-show --prefix=none "Secretaries write addresses"
Add an ACI that allows members of the "addusers" permission to add new users:
ipa aci-add --type=user --permission=addusers --permissions=add --prefix=none "Add new users"
Add an ACI that allows members of the editors manage members of the admins group:
ipa aci-add --permissions=write --attrs=member --targetgroup=admins --group=editors --prefix=none "Editors manage admins"
Add an ACI that allows members of the admins group to manage the street and zip code of those in the editors group:
ipa aci-add --permissions=write --memberof=editors --group=admins --attrs=street --attrs=postalcode --prefix=none "admins edit the address of editors"
Add an ACI that allows the admins group manage the street and zipcode of those who work for the boss:
ipa aci-add --permissions=write --group=admins --attrs=street --attrs=postalcode --filter="(manager=uid=boss,cn=users,cn=accounts,dc=example,dc=com)" --prefix=none "Edit the address of those who work for the boss"
Add an entirely new kind of record to IPA that isn't covered by any of the --type options, creating a permission:
ipa permission-add --permissions=add --subtree="cn=*,cn=orange,cn=accounts,dc=example,dc=com" --desc="Add Orange Entries" add_orange
The show command shows the raw 389-ds ACI.
IMPORTANT: When modifying the target attributes of an existing ACI you
must include all existing attributes as well. When doing an aci-mod the
targetattr REPLACES the current attributes, it does not add to them.
""")
register = Registry()
@register()
class aci(Object):
takes_params = (
parameters.Str(
'aciname',
primary_key=True,
label=_(u'ACI name'),
),
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
),
)
@register()
class aci_add(Method):
__doc__ = _("Create new ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
autofill=True,
),
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Flag(
'test',
required=False,
doc=_(u"Test the ACI syntax but don't write anything"),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_del(Method):
__doc__ = _("Delete ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_find(Method):
__doc__ = _("""
Search for ACIs.
Returns a list of ACIs
EXAMPLES:
To find all ACIs that apply directly to members of the group ipausers:
ipa aci-find --memberof=ipausers
To find all ACIs that grant add access:
ipa aci-find --permissions=add
Note that the find command only looks for the given text in the set of
ACIs, it does not evaluate the ACIs to see if something would apply.
For example, searching on memberof=ipausers will find all ACIs that
have ipausers as a memberof. There may be other ACIs that apply to
members of that group indirectly.
""")
NO_CLI = True
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'aciname',
required=False,
cli_name='name',
label=_(u'ACI name'),
),
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Bool(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
),
parameters.Str(
'aciprefix',
required=False,
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class aci_mod(Method):
__doc__ = _("Modify ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
autofill=True,
),
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_rename(Method):
__doc__ = _("Rename an ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
autofill=True,
),
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Str(
'newname',
doc=_(u'New ACI name'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_show(Method):
__doc__ = _("Display a single ACI given an ACI name.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.DNParam(
'location',
required=False,
label=_(u'Location of the ACI'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 25,449
|
Python
|
.py
| 752
| 24.06117
| 216
| 0.549499
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,031
|
pwpolicy.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/pwpolicy.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Password policy
A password policy sets limitations on IPA passwords, including maximum
lifetime, minimum lifetime, the number of passwords to save in
history, the number of character classes required (for stronger passwords)
and the minimum password length.
By default there is a single, global policy for all users. You can also
create a password policy to apply to a group. Each user is only subject
to one password policy, either the group policy or the global policy. A
group policy stands alone; it is not a super-set of the global policy plus
custom settings.
Each group password policy requires a unique priority setting. If a user
is in multiple groups that have password policies, this priority determines
which password policy is applied. A lower value indicates a higher priority
policy.
Group password policies are automatically removed when the groups they
are associated with are removed.
EXAMPLES:
Modify the global policy:
ipa pwpolicy-mod --minlength=10
Add a new group password policy:
ipa pwpolicy-add --maxlife=90 --minlife=1 --history=10 --minclasses=3 --minlength=8 --priority=10 localadmins
Display the global password policy:
ipa pwpolicy-show
Display a group password policy:
ipa pwpolicy-show localadmins
Display the policy that would be applied to a given user:
ipa pwpolicy-show --user=tuser1
Modify a group password policy:
ipa pwpolicy-mod --minclasses=2 localadmins
""")
register = Registry()
@register()
class cosentry(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
),
parameters.DNParam(
'krbpwdpolicyreference',
),
parameters.Int(
'cospriority',
),
)
@register()
class pwpolicy(Object):
takes_params = (
parameters.Str(
'cn',
required=False,
primary_key=True,
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
parameters.Int(
'krbmaxpwdlife',
required=False,
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
)
@register()
class cosentry_add(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
),
)
takes_options = (
parameters.DNParam(
'krbpwdpolicyreference',
),
parameters.Int(
'cospriority',
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class cosentry_del(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
multivalue=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class cosentry_find(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
),
parameters.DNParam(
'krbpwdpolicyreference',
required=False,
),
parameters.Int(
'cospriority',
required=False,
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("cn")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class cosentry_mod(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
),
)
takes_options = (
parameters.DNParam(
'krbpwdpolicyreference',
required=False,
),
parameters.Int(
'cospriority',
required=False,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class cosentry_show(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class pwpolicy_add(Method):
__doc__ = _("Add a new group password policy.")
takes_args = (
parameters.Str(
'cn',
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Int(
'krbmaxpwdlife',
required=False,
cli_name='maxlife',
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
cli_name='minlife',
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
cli_name='history',
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
cli_name='minclasses',
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
cli_name='minlength',
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
cli_name='priority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
cli_name='maxfail',
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
cli_name='failinterval',
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
cli_name='lockouttime',
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class pwpolicy_del(Method):
__doc__ = _("Delete a group password policy.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class pwpolicy_find(Method):
__doc__ = _("Search for group password policies.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
parameters.Int(
'krbmaxpwdlife',
required=False,
cli_name='maxlife',
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
cli_name='minlife',
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
cli_name='history',
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
cli_name='minclasses',
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
cli_name='minlength',
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
required=False,
cli_name='priority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
cli_name='maxfail',
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
cli_name='failinterval',
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
cli_name='lockouttime',
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("group")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class pwpolicy_mod(Method):
__doc__ = _("Modify a group password policy.")
takes_args = (
parameters.Str(
'cn',
required=False,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Int(
'krbmaxpwdlife',
required=False,
cli_name='maxlife',
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
cli_name='minlife',
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
cli_name='history',
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
cli_name='minclasses',
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
cli_name='minlength',
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
required=False,
cli_name='priority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
cli_name='maxfail',
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
cli_name='failinterval',
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
cli_name='lockouttime',
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class pwpolicy_show(Method):
__doc__ = _("Display information about password policy.")
takes_args = (
parameters.Str(
'cn',
required=False,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
label=_(u'User'),
doc=_(u'Display effective policy for a specific user'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 27,438
|
Python
|
.py
| 887
| 20.62345
| 162
| 0.523075
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,032
|
misc.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/misc.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Misc plug-ins
""")
register = Registry()
@register()
class env(Command):
__doc__ = _("Show environment variables.")
takes_args = (
parameters.Str(
'variables',
required=False,
multivalue=True,
),
)
takes_options = (
parameters.Flag(
'server',
required=False,
doc=_(u'Forward to server instead of running locally'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=True,
autofill=True,
),
)
has_output = (
output.Output(
'result',
dict,
doc=_(u'Dictionary mapping variable name to value'),
),
output.Output(
'total',
int,
doc=_(u'Total number of variables env (>= count)'),
),
output.Output(
'count',
int,
doc=_(u'Number of variables returned (<= total)'),
),
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
)
@register()
class plugins(Command):
__doc__ = _("Show all loaded plugins.")
takes_options = (
parameters.Flag(
'server',
required=False,
doc=_(u'Forward to server instead of running locally'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=True,
autofill=True,
),
)
has_output = (
output.Output(
'result',
dict,
doc=_(u'Dictionary mapping plugin names to bases'),
),
output.Output(
'count',
int,
doc=_(u'Number of plugins loaded'),
),
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
)
| 2,753
|
Python
|
.py
| 102
| 18.313725
| 97
| 0.534091
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,033
|
sudocmd.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/sudocmd.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Sudo Commands
Commands used as building blocks for sudo
EXAMPLES:
Create a new command
ipa sudocmd-add --desc='For reading log files' /usr/bin/less
Remove a command
ipa sudocmd-del /usr/bin/less
""")
register = Registry()
@register()
class sudocmd(Object):
takes_params = (
parameters.Str(
'sudocmd',
primary_key=True,
label=_(u'Sudo Command'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Str(
'memberof_sudocmdgroup',
required=False,
label=_(u'Sudo Command Groups'),
),
)
@register()
class sudocmd_add(Method):
__doc__ = _("Create new Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmd_del(Method):
__doc__ = _("Delete Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
multivalue=True,
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class sudocmd_find(Method):
__doc__ = _("Search for Sudo Commands.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'sudocmd',
required=False,
cli_name='command',
label=_(u'Sudo Command'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("command")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class sudocmd_mod(Method):
__doc__ = _("Modify Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmd_show(Method):
__doc__ = _("Display Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 10,873
|
Python
|
.py
| 368
| 19.529891
| 162
| 0.512358
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,034
|
idrange.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/idrange.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
ID ranges
Manage ID ranges used to map Posix IDs to SIDs and back.
There are two type of ID ranges which are both handled by this utility:
- the ID ranges of the local domain
- the ID ranges of trusted remote domains
Both types have the following attributes in common:
- base-id: the first ID of the Posix ID range
- range-size: the size of the range
With those two attributes a range object can reserve the Posix IDs starting
with base-id up to but not including base-id+range-size exclusively.
Additionally an ID range of the local domain may set
- rid-base: the first RID(*) of the corresponding RID range
- secondary-rid-base: first RID of the secondary RID range
and an ID range of a trusted domain must set
- rid-base: the first RID of the corresponding RID range
- sid: domain SID of the trusted domain
EXAMPLE: Add a new ID range for a trusted domain
Since there might be more than one trusted domain the domain SID must be given
while creating the ID range.
ipa idrange-add --base-id=1200000 --range-size=200000 --rid-base=0 \
--dom-sid=S-1-5-21-123-456-789 trusted_dom_range
This ID range is then used by the IPA server and the SSSD IPA provider to
assign Posix UIDs to users from the trusted domain.
If e.g. a range for a trusted domain is configured with the following values:
base-id = 1200000
range-size = 200000
rid-base = 0
the RIDs 0 to 199999 are mapped to the Posix ID from 1200000 to 13999999. So
RID 1000 <-> Posix ID 1201000
EXAMPLE: Add a new ID range for the local domain
To create an ID range for the local domain it is not necessary to specify a
domain SID. But since it is possible that a user and a group can have the same
value as Posix ID a second RID interval is needed to handle conflicts.
ipa idrange-add --base-id=1200000 --range-size=200000 --rid-base=1000 \
--secondary-rid-base=1000000 local_range
The data from the ID ranges of the local domain are used by the IPA server
internally to assign SIDs to IPA users and groups. The SID will then be stored
in the user or group objects.
If e.g. the ID range for the local domain is configured with the values from
the example above then a new user with the UID 1200007 will get the RID 1007.
If this RID is already used by a group the RID will be 1000007. This can only
happen if a user or a group object was created with a fixed ID because the
automatic assignment will not assign the same ID twice. Since there are only
users and groups sharing the same ID namespace it is sufficient to have only
one fallback range to handle conflicts.
To find the Posix ID for a given RID from the local domain it has to be
checked first if the RID falls in the primary or secondary RID range and
the rid-base or the secondary-rid-base has to be subtracted, respectively,
and the base-id has to be added to get the Posix ID.
Typically the creation of ID ranges happens behind the scenes and this CLI
must not be used at all. The ID range for the local domain will be created
during installation or upgrade from an older version. The ID range for a
trusted domain will be created together with the trust by 'ipa trust-add ...'.
USE CASES:
Add an ID range from a transitively trusted domain
If the trusted domain (A) trusts another domain (B) as well and this trust
is transitive 'ipa trust-add domain-A' will only create a range for
domain A. The ID range for domain B must be added manually.
Add an additional ID range for the local domain
If the ID range of the local domain is exhausted, i.e. no new IDs can be
assigned to Posix users or groups by the DNA plugin, a new range has to be
created to allow new users and groups to be added. (Currently there is no
connection between this range CLI and the DNA plugin, but a future version
might be able to modify the configuration of the DNS plugin as well)
In general it is not necessary to modify or delete ID ranges. If there is no
other way to achieve a certain configuration than to modify or delete an ID
range it should be done with great care. Because UIDs are stored in the file
system and are used for access control it might be possible that users are
allowed to access files of other users if an ID range got deleted and reused
for a different domain.
(*) The RID is typically the last integer of a user or group SID which follows
the domain SID. E.g. if the domain SID is S-1-5-21-123-456-789 and a user from
this domain has the SID S-1-5-21-123-456-789-1010 then 1010 is the RID of the
user. RIDs are unique in a domain, 32bit values and are used for users and
groups.
WARNING:
DNA plugin in 389-ds will allocate IDs based on the ranges configured for the
local domain. Currently the DNA plugin *cannot* be reconfigured itself based
on the local ranges set via this family of commands.
Manual configuration change has to be done in the DNA plugin configuration for
the new local range. Specifically, The dnaNextRange attribute of 'cn=Posix
IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' has to be
modified to match the new range.
""")
register = Registry()
@register()
class idrange(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Range name'),
),
parameters.Int(
'ipabaseid',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
label=_(u'Domain SID of the trusted domain'),
),
parameters.Str(
'ipanttrusteddomainname',
required=False,
label=_(u'Name of the trusted domain'),
),
parameters.Str(
'iparangetype',
required=False,
label=_(u'Range type'),
doc=_(u'ID range type, one of ipa-ad-trust-posix, ipa-ad-trust, ipa-local'),
),
)
@register()
class idrange_add(Method):
__doc__ = _("""
Add new ID range.
To add a new ID range you always have to specify
--base-id
--range-size
Additionally
--rid-base
--secondary-rid-base
may be given for a new ID range for the local domain while
--rid-base
--dom-sid
must be given to add a new range for a trusted AD domain.
WARNING:
DNA plugin in 389-ds will allocate IDs based on the ranges configured for the
local domain. Currently the DNA plugin *cannot* be reconfigured itself based
on the local ranges set via this family of commands.
Manual configuration change has to be done in the DNA plugin configuration for
the new local range. Specifically, The dnaNextRange attribute of 'cn=Posix
IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' has to be
modified to match the new range.
""")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Int(
'ipabaseid',
cli_name='base_id',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
cli_name='range_size',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
cli_name='rid_base',
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
cli_name='secondary_rid_base',
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='dom_sid',
label=_(u'Domain SID of the trusted domain'),
),
parameters.Str(
'ipanttrusteddomainname',
required=False,
cli_name='dom_name',
label=_(u'Name of the trusted domain'),
),
parameters.Str(
'iparangetype',
required=False,
cli_name='type',
cli_metavar="['ipa-ad-trust-posix', 'ipa-ad-trust', 'ipa-local']",
label=_(u'Range type'),
doc=_(u'ID range type, one of ipa-ad-trust-posix, ipa-ad-trust, ipa-local'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idrange_del(Method):
__doc__ = _("Delete an ID range.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idrange_find(Method):
__doc__ = _("Search for ranges.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Range name'),
),
parameters.Int(
'ipabaseid',
required=False,
cli_name='base_id',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
required=False,
cli_name='range_size',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
cli_name='rid_base',
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
cli_name='secondary_rid_base',
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='dom_sid',
label=_(u'Domain SID of the trusted domain'),
),
parameters.Str(
'iparangetype',
required=False,
cli_name='type',
cli_metavar="['ipa-ad-trust-posix', 'ipa-ad-trust', 'ipa-local']",
label=_(u'Range type'),
doc=_(u'ID range type, one of ipa-ad-trust-posix, ipa-ad-trust, ipa-local'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idrange_mod(Method):
__doc__ = _("Modify ID range.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Int(
'ipabaseid',
required=False,
cli_name='base_id',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
required=False,
cli_name='range_size',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
cli_name='rid_base',
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
cli_name='secondary_rid_base',
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipanttrusteddomainname',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idrange_show(Method):
__doc__ = _("Display information about a range.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 19,509
|
Python
|
.py
| 554
| 26.126354
| 162
| 0.58632
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,035
|
idviews.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/idviews.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
ID Views
Manage ID Views
IPA allows to override certain properties of users and groups per each host.
This functionality is primarily used to allow migration from older systems or
other Identity Management solutions.
""")
register = Registry()
@register()
class idoverridegroup(Object):
takes_params = (
parameters.Str(
'ipaanchoruuid',
primary_key=True,
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Group name'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
)
@register()
class idoverrideuser(Object):
takes_params = (
parameters.Str(
'ipaanchoruuid',
primary_key=True,
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
label=_(u'User login'),
),
parameters.Int(
'uidnumber',
required=False,
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
label=_(u'SSH public key'),
),
)
@register()
class idview(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'ID View Name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
)
@register()
class idoverridegroup_add(Method):
__doc__ = _("Add a new Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverridegroup_del(Method):
__doc__ = _("Delete an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
multivalue=True,
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idoverridegroup_find(Method):
__doc__ = _("Search for an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'ipaanchoruuid',
required=False,
cli_name='anchor',
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("anchor")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idoverridegroup_mod(Method):
__doc__ = _("Modify an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the Group ID override object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverridegroup_show(Method):
__doc__ = _("Display information about an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverrideuser_add(Method):
__doc__ = _("Add a new User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
no_convert=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverrideuser_del(Method):
__doc__ = _("Delete an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
multivalue=True,
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idoverrideuser_find(Method):
__doc__ = _("Search for an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'ipaanchoruuid',
required=False,
cli_name='anchor',
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
no_convert=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("anchor")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idoverrideuser_mod(Method):
__doc__ = _("Modify an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
no_convert=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the User ID override object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverrideuser_show(Method):
__doc__ = _("Display information about an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_add(Method):
__doc__ = _("Add a new ID View.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_apply(Method):
__doc__ = _("Applies ID View to specified hosts or current members of specified hostgroups. If any other ID View is applied to the host, it is overriden.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'hosts'),
doc=_(u'Hosts to apply the ID View to'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'hostgroups'),
doc=_(u'Hostgroups to whose hosts apply the ID View to. Please note that view is not applied automatically to any hosts added to the hostgroup after running the idview-apply command.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'succeeded',
dict,
doc=_(u'Hosts that this ID View was applied to.'),
),
output.Output(
'failed',
dict,
doc=_(u'Hosts or hostgroups that this ID View could not be applied to.'),
),
output.Output(
'completed',
int,
doc=_(u'Number of hosts the ID View was applied to:'),
),
)
@register()
class idview_del(Method):
__doc__ = _("Delete an ID View.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idview_find(Method):
__doc__ = _("Search for an ID View.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'ID View Name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idview_mod(Method):
__doc__ = _("Modify an ID View.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the ID View object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_show(Method):
__doc__ = _("Display information about an ID View.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'show_hosts',
required=False,
doc=_(u'Enumerate all the hosts the view applies to.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_unapply(Method):
__doc__ = _("Clears ID View from specified hosts or current members of specified hostgroups.")
takes_options = (
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'hosts'),
doc=_(u'Hosts to clear (any) ID View from.'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'hostgroups'),
doc=_(u'Hostgroups whose hosts should have ID Views cleared. Note that view is not cleared automatically from any host added to the hostgroup after running idview-unapply command.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'succeeded',
dict,
doc=_(u'Hosts that ID View was cleared from.'),
),
output.Output(
'failed',
dict,
doc=_(u'Hosts or hostgroups that ID View could not be cleared from.'),
),
output.Output(
'completed',
int,
doc=_(u'Number of hosts that had a ID View was unset:'),
),
)
| 39,044
|
Python
|
.py
| 1,349
| 18.383247
| 197
| 0.488693
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,036
|
session.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/session.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Session Support for IPA
John Dennis <jdennis@redhat.com>
Goals
=====
Provide per-user session data caching which persists between
requests. Desired features are:
* Integrates cleanly with minimum impact on existing infrastructure.
* Provides maximum security balanced against real-world performance
demands.
* Sessions must be able to be revoked (flushed).
* Should be flexible and easy to use for developers.
* Should leverage existing technology and code to the maximum extent
possible to avoid re-invention, excessive implementation time and to
benefit from robustness in field proven components commonly shared
in the open source community.
* Must support multiple independent processes which share session
data.
* System must function correctly if session data is available or not.
* Must be high performance.
* Should not be tied to specific web servers or browsers. Should
integrate with our chosen WSGI model.
Issues
======
Cookies
-------
Most session implementations are based on the use of cookies. Cookies
have some inherent problems.
* User has the option to disable cookies.
* User stored cookie data is not secure. Can be mitigated by setting
flags indicating the cookie is only to be used with SSL secured HTTP
connections to specific web resources and setting the cookie to
expire at session termination. Most modern browsers enforce these.
Where to store session data?
----------------------------
Session data may be stored on either on the client or on the
server. Storing session data on the client addresses the problem of
session data availability when requests are serviced by independent web
servers because the session data travels with the request. However
there are data size limitations. Storing session data on the client
also exposes sensitive data but this can be mitigated by encrypting
the session data such that only the server can decrypt it.
The more conventional approach is to bind session data to a unique
name, the session ID. The session ID is transmitted to the client and
the session data is paired with the session ID on the server in a
associative data store. The session data is retrieved by the server
using the session ID when the receiving the request. This eliminates
exposing sensitive session data on the client along with limitations
on data size. It however introduces the issue of session data
availability when requests are serviced by more than one server
process.
Multi-process session data availability
---------------------------------------
Apache (and other web servers) fork child processes to handle requests
in parallel. Also web servers may be deployed in a farm where requests
are load balanced in round robin fashion across different nodes. In
both cases session data cannot be stored in the memory of a server
process because it is not available to other processes, either sibling
children of a master server process or server processes on distinct
nodes.
Typically this is addressed by storing session data in a SQL
database. When a request is received by a server process containing a
session ID in it's cookie data the session ID is used to perform a SQL
query and the resulting data is then attached to the request as it
proceeds through the request processing pipeline. This of course
introduces coherency issues.
For IPA the introduction of a SQL database dependency is undesired and
should be avoided.
Session data may also be shared by independent processes by storing
the session data in files.
An alternative solution which has gained considerable popularity
recently is the use of a fast memory based caching server. Data is
stored in a single process memory and may be queried and set via a
light weight protocol using standard socket mechanisms, memcached is
one example. A typical use is to optimize SQL queries by storing a SQL
result in shared memory cache avoiding the more expensive SQL
operation. But the memory cache has distinct advantages in non-SQL
situations as well.
Possible implementations for use by IPA
=======================================
Apache Sessions
---------------
Apache has 2.3 has implemented session support via these modules:
mod_session
Overarching session support based on cookies.
See: http://httpd.apache.org/docs/2.3/mod/mod_session.html
mod_session_cookie
Stores session data in the client.
See: http://httpd.apache.org/docs/2.3/mod/mod_session_cookie.html
mod_session_crypto
Encrypts session data for security. Encryption key is shared
configuration parameter visible to all Apache processes and is
stored in a configuration file.
See: http://httpd.apache.org/docs/2.3/mod/mod_session_crypto.html
mod_session_dbd
Stores session data in a SQL database permitting multiple
processes to access and share the same session data.
See: http://httpd.apache.org/docs/2.3/mod/mod_session_dbd.html
Issues with Apache sessions
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Although Apache has implemented generic session support and Apache is
our web server of preference it nonetheless introduces issues for IPA.
* Session support is only available in httpd >= 2.3 which at the
time of this writing is currently only available as a Beta release
from upstream. We currently only ship httpd 2.2, the same is true
for other distributions.
* We could package and ship the sessions modules as a temporary
package in httpd 2.2 environments. But this has the following
consequences:
- The code has to be backported. the module API has changed
slightly between httpd 2.2 and 2.3. The backporting is not
terribly difficult and a proof of concept has been
implemented.
- We would then be on the hook to package and maintain a special
case Apache package. This is maintenance burden as well as a
distribution packaging burden. Both of which would be best
avoided if possible.
* The design of the Apache session modules is such that they can
only be manipulated by other Apache modules. The ability of
consumers of the session data to control the session data is
simplistic, constrained and static during the period the request
is processed. Request handlers which are not native Apache modules
(e.g. IPA via WSGI) can only examine the session data
via request headers and reset it in response headers.
* Shared session data is available exclusively via SQL.
However using the 2.3 Apache session modules would give us robust
session support implemented in C based on standardized Apache
interfaces which are widely used.
Python Web Frameworks
---------------------
Virtually every Python web framework supports cookie based sessions,
e.g. Django, Twisted, Zope, Turbogears etc. Early on in IPA we decided
to avoid the use of these frameworks. Trying to pull in just one part
of these frameworks just to get session support would be problematic
because the code does not function outside it's framework.
IPA implemented sessions
------------------------
Originally it was believed the path of least effort was to utilize
existing session support, most likely what would be provided by
Apache. However there are enough basic modular components available in
native Python and other standard packages it should be possible to
provide session support meeting the aforementioned goals with a modest
implementation effort. Because we're leveraging existing components
the implementation difficulties are subsumed by other components which
have already been field proven and have community support. This is a
smart strategy.
Proposed Solution
=================
Our interface to the web server is via WSGI which invokes a callback
per request passing us an environmental context for the request. For
this discussion we'll name the WSGI callback "application()", a
conventional name in WSGI parlance.
Shared session data will be handled by memcached. We will create one
instance of memcached on each server node dedicated to IPA
exclusively. Communication with memcached will be via a UNIX socket
located in the file system under /var/run/ipa_memcached. It will be
protected by file permissions and optionally SELinux policy.
In application() we examine the request cookies and if there is an IPA
session cookie with a session ID we retrieve the session data from our
memcached instance.
The session data will be a Python dict. IPA components will read or
write their session information by using a pre-agreed upon name
(e.g. key) in the dict. This is a very flexible system and consistent
with how we pass data in most parts of IPA.
If the session data is not available an empty session data dict will
be created.
How does this session data travel with the request in the IPA
pipeline? In IPA we use the HTTP request/response to implement RPC. In
application() we convert the request into a procedure call passing it
arguments derived from the HTTP request. The passed parameters are
specific to the RPC method being invoked. The context the RPC call is
executing in is not passed as an RPC parameter.
How would the contextual information such as session data be bound to
the request and hence the RPC call?
In IPA when a RPC invocation is being prepared from a request we
recognize this will only ever be processed serially by one Python
thread. A thread local dict called "context" is allocated for each
thread. The context dict is cleared in between requests (e.g. RPC method
invocations). The per-thread context dict is populated during the
lifetime of the request and is used as a global data structure unique to
the request that various IPA component can read from and write to with
the assurance the data is unique to the current request and/or method
call.
The session data dict will be written into the context dict under the
session key before the RPC method begins execution. Thus session data
can be read and written by any IPA component by accessing
``context.session``.
When the RPC method finishes execution the session data bound to the
request/method is retrieved from the context and written back to the
memcached instance. The session ID is set in the response sent back to
the client in the ``Set-Cookie`` header along with the flags
controlling it's usage.
Issues and details
------------------
IPA code cannot depend on session data being present, however it
should always update session data with the hope it will be available
in the future. Session data may not be available because:
* This is the first request from the user and no session data has
been created yet.
* The user may have cookies disabled.
* The session data may have been flushed. memcached operates with
a fixed memory allocation and will flush entries on a LRU basis,
like with any cache there is no guarantee of persistence.
Also we may have have deliberately expired or deleted session
data, see below.
Cookie manipulation is done via the standard Python Cookie module.
Session cookies will be set to only persist as long as the browser has
the session open. They will be tagged so the browser only returns
the session ID on SSL secured HTTP requests. They will not be visible
to Javascript in the browser.
Session ID's will be created by using 48 bits of random data and
converted to 12 hexadecimal digits. Newly generated session ID's will
be checked for prior existence to handle the unlikely case the random
number repeats.
memcached will have significantly higher performance than a SQL or file
based storage solution. Communication is effectively though a pipe
(UNIX socket) using a very simple protocol and the data is held
entirely in process memory. memcached also scales easily, it is easy
to add more memcached processes and distribute the load across them.
At this point in time we don't anticipate the need for this.
A very nice feature of the Python memcached module is that when a data
item is written to the cache it is done with standard Python pickling
(pickling is a standard Python mechanism to marshal and unmarshal
Python objects). We adopt the convention the object written to cache
will be a dict to meet our internal data handling conventions. The
pickling code will recursively handle nested objects in the dict. Thus
we gain a lot of flexibility using standard Python data structures to
store and retrieve our session data without having to author and debug
code to marshal and unmarshal the data if some other storage mechanism
had been used. This is a significant implementation win. Of course
some common sense limitations need to observed when deciding on what
is written to the session cache keeping in mind the data is shared
between processes and it should not be excessively large (a
configurable option)
We can set an expiration on memcached entries. We may elect to do that
to force session data to be refreshed periodically. For example we may
wish the client to present fresh credentials on a periodic basis even
if the cached credentials are otherwise within their validity period.
We can explicitly delete session data if for some reason we believe it
is stale, invalid or compromised.
memcached also gives us certain facilities to prevent race conditions
between different processes utilizing the cache. For example you can
check of the entry has been modified since you last read it or use CAS
(Check And Set) semantics. What has to be protected in terms of cache
coherency will likely have to be determined as the session support is
utilized and different data items are added to the cache. This is very
much data and context specific. Fortunately memcached operations are
atomic.
Controlling the memcached process
---------------------------------
We need a mechanism to start the memcached process and secure it so
that only IPA components can access it.
Although memcached ships with both an initscript and systemd unit
files those are for generic instances. We want a memcached instance
dedicated exclusively to IPA usage. To accomplish this we would install
a systemd unit file or an SysV initscript to control the IPA specific
memcached service. ipactl would be extended to know about this
additional service. systemd's cgroup facility would give us additional
mechanisms to integrate the IPA memcached service within a larger IPA
process group.
Protecting the memcached data would be done via file permissions (and
optionally SELinux policy) on the UNIX domain socket. Although recent
implementations of memcached support authentication via SASL this
introduces a performance and complexity burden not warranted when
cached is dedicated to our exclusive use and access controlled by OS
mechanisms.
Conventionally daemons are protected by assigning a system uid and/or
gid to the daemon. A daemon launched by root will drop it's privileges
by assuming the effective uid:gid assigned to it. File system access
is controlled by the OS via the effective identity and SELinux policy
can be crafted based on the identity. Thus the memcached UNIX socket
would be protected by having it owned by a specific system user and/or
membership in a restricted system group (discounting for the moment
SELinux).
Unfortunately we currently do not have an IPA system uid whose
identity our processes operate under nor do we have an IPA system
group. IPA does manage a collection of related processes (daemons) and
historically each has been assigned their own uid. When these
unrelated processes communicate they mutually authenticate via other
mechanisms. We do not have much of a history of using shared file
system objects across identities. When file objects are created they
are typically assigned the identity of daemon needing to access the
object and are not accessed by other daemons, or they carry root
identity.
When our WSGI application runs in Apache it is run as a WSGI
daemon. This means when Apache starts up it forks off WSGI processes
for us and we are independent of other Apache processes. When WSGI is
run in this mode there is the ability to set the uid:gid of the WSGI
process hosting us, however we currently do not take advantage of this
option. WSGI can be run in other modes as well, only in daemon mode
can the uid:gid be independently set from the rest of Apache. All
processes started by Apache can be set to a common uid:gid specified
in the global Apache configuration, by default it's
apache:apache. Thus when our IPA code executes it is running as
apache:apache.
To protect our memcached UNIX socket we can do one of two things:
1. Assign it's uid:gid as apache:apache. This would limit access to
our cache only to processes running under httpd. It's somewhat
restricted but far from ideal. Any code running in the web server
could potentially access our cache. It's difficult to control what the
web server runs and admins may not understand the consequences of
configuring httpd to serve other things besides IPA.
2. Create an IPA specific uid:gid, for example ipa:ipa. We then configure
our WSGI application to run as the ipa:ipa user and group. We also
configure our memcached instance to run as the ipa:ipa user and
group. In this configuration we are now fully protected, only our WSGI
code can read & write to our memcached UNIX socket.
However there may be unforeseen issues by converting our code to run as
something other than apache:apache. This would require some
investigation and testing.
IPA is dependent on other system daemons, specifically Directory
Server (ds) and Certificate Server (cs). Currently we configure ds to
run under the dirsrv:dirsrv user and group, an identity of our
creation. We allow cs to default to it's pkiuser:pkiuser user and
group. Should these other cooperating daemons also run under the
common ipa:ipa user and group identities? At first blush there would
seem to be an advantage to coalescing all process identities under a
common IPA user and group identity. However these other processes do
not depend on user and group permissions when working with external
agents, processes, etc. Rather they are designed to be stand-alone
network services which authenticate their clients via other
mechanisms. They do depend on user and group permission to manage
their own file system objects. If somehow the ipa user and/or group
were compromised or malicious code somehow executed under the ipa
identity there would be an advantage in having the cooperating
processes cordoned off under their own identities providing one extra
layer of protection. (Note, these cooperating daemons may not even be
co-located on the same node in which case the issue is moot)
The UNIX socket behavior (ldapi) with Directory Server is as follows:
* The socket ownership is: root:root
* The socket permissions are: 0666
* When connecting via ldapi you must authenticate as you would
normally with a TCP socket, except ...
* If autobind is enabled and the uid:gid is available via
SO_PEERCRED and the uid:gid can be found in the set of users known
to the Directory Server then that connection will be bound as that
user.
* Otherwise an anonymous bind will occur.
memcached UNIX socket behavior is as follows:
* memcached can be invoked with a user argument, no group may be
specified. The effective uid is the uid of the user argument and
the effective gid is the primary group of the user, let's call
this euid:egid
* The socket ownership is: euid:egid
* The socket permissions are 0700 by default, but this can be
modified by the -a mask command line arg which sets the umask
(defaults to 0700).
Overview of authentication in IPA
=================================
This describes how we currently authenticate and how we plan to
improve authentication performance. First some definitions.
There are 4 major players:
1. client
2. mod_auth_kerb (in Apache process)
3. wsgi handler (in IPA wsgi python process)
4. ds (directory server)
There are several resources:
1. /ipa/ui (unprotected, web UI static resources)
2. /ipa/xml (protected, xmlrpc RPC used by command line clients)
3. /ipa/json (protected, json RPC used by javascript in web UI)
4. ds (protected, wsgi acts as proxy, our LDAP server)
Current Model
-------------
This describes how things work in our current system for the web UI.
1. Client requests /ipa/ui, this is unprotected, is static and
contains no sensitive information. Apache replies with html and
javascript. The javascript requests /ipa/json.
2. Client sends post to /ipa/json.
3. mod_auth_kerb is configured to protect /ipa/json, replies 401
authenticate negotiate.
4. Client resends with credentials
5. mod_auth_kerb validates credentials
a. if invalid replies 403 access denied (stops here)
b. if valid creates temporary ccache, adds KRB5CCNAME to request
headers
6. Request passed to wsgi handler
a. validates request, KRB5CCNAME must be present, referrer, etc.
b. ccache saved and used to bind to ds
c. routes to specified RPC handler.
7. wsgi handler replies to client
Proposed new session based optimization
---------------------------------------
The round trip negotiate and credential validation in steps 3,4,5 is
expensive. This can be avoided if we can cache the client
credentials. With client sessions we can store the client credentials
in the session bound to the client.
A few notes about the session implementation.
* based on session cookies, cookies must be enabled
* session cookie is secure, only passed on secure connections, only
passed to our URL resource, never visible to client javascript
etc.
* session cookie has a session id which is used by wsgi handler to
retrieve client session data from shared multi-process cache.
Changes to Apache's resource protection
---------------------------------------
* /ipa/json is no longer protected by mod_auth_kerb. This is
necessary to avoid the negotiate expense in steps 3,4,5
above. Instead the /ipa/json resource will be protected in our wsgi
handler via the session cookie.
* A new protected URI is introduced, /ipa/login. This resource
does no serve any data, it is used exclusively for authentication.
The new sequence is:
1. Client requests /ipa/ui, this is unprotected. Apache replies with
html and javascript. The javascript requests /ipa/json.
2. Client sends post to /ipa/json, which is unprotected.
3. wsgi handler obtains session data from session cookie.
a. if ccache is present in session data and is valid
- request is further validated
- ccache is established for bind to ds
- request is routed to RPC handler
- wsgi handler eventually replies to client
b. if ccache is not present or not valid processing continues ...
4. wsgi handler replies with 401 Unauthorized
5. client sends request to /ipa/login to obtain session credentials
6. mod_auth_kerb replies 401 negotiate on /ipa/login
7. client sends credentials to /ipa/login
8. mod_auth_kerb validates credentials
a. if valid
- mod_auth_kerb permits access to /ipa/login. wsgi handler is
invoked and does the following:
* establishes session for client
* retrieves the ccache from KRB5CCNAME and stores it
a. if invalid
- mod_auth_kerb sends 403 access denied (processing stops)
9. client now posts the same data again to /ipa/json including
session cookie. Processing repeats starting at step 2 and since
the session data now contains a valid ccache step 3a executes, a
successful reply is sent to client.
Command line client using xmlrpc
--------------------------------
The above describes the web UI utilizing the json RPC mechanism. The
IPA command line tools utilize a xmlrpc RPC mechanism on the same
HTTP server. Access to the xmlrpc is via the /ipa/xml URI. The json
and xmlrpc API's are the same, they differ only on how their procedure
calls are marshalled and unmarshalled.
Under the new scheme /ipa/xml will continue to be Kerberos protected
at all times. Apache's mod_auth_kerb will continue to require the
client provides valid Kerberos credentials.
When the WSGI handler routes to /ipa/xml the Kerberos credentials will
be extracted from the KRB5CCNAME environment variable as provided by
mod_auth_kerb. Everything else remains the same.
""")
register = Registry()
@register()
class session_logout(Command):
__doc__ = _("RPC command used to log the current user out of their session.")
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
| 25,143
|
Python
|
.py
| 467
| 51.233405
| 81
| 0.789044
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,037
|
group.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/group.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Groups of users
Manage groups of users. By default, new groups are POSIX groups. You
can add the --nonposix option to the group-add command to mark a new group
as non-POSIX. You can use the --posix argument with the group-mod command
to convert a non-POSIX group into a POSIX group. POSIX groups cannot be
converted to non-POSIX groups.
Every group must have a description.
POSIX groups must have a Group ID (GID) number. Changing a GID is
supported but can have an impact on your file permissions. It is not necessary
to supply a GID when creating a group. IPA will generate one automatically
if it is not provided.
EXAMPLES:
Add a new group:
ipa group-add --desc='local administrators' localadmins
Add a new non-POSIX group:
ipa group-add --nonposix --desc='remote administrators' remoteadmins
Convert a non-POSIX group to posix:
ipa group-mod --posix remoteadmins
Add a new POSIX group with a specific Group ID number:
ipa group-add --gid=500 --desc='unix admins' unixadmins
Add a new POSIX group and let IPA assign a Group ID number:
ipa group-add --desc='printer admins' printeradmins
Remove a group:
ipa group-del unixadmins
To add the "remoteadmins" group to the "localadmins" group:
ipa group-add-member --groups=remoteadmins localadmins
Add multiple users to the "localadmins" group:
ipa group-add-member --users=test1 --users=test2 localadmins
Remove a user from the "localadmins" group:
ipa group-remove-member --users=test2 localadmins
Display information about a named group.
ipa group-show localadmins
External group membership is designed to allow users from trusted domains
to be mapped to local POSIX groups in order to actually use IPA resources.
External members should be added to groups that specifically created as
external and non-POSIX. Such group later should be included into one of POSIX
groups.
An external group member is currently a Security Identifier (SID) as defined by
the trusted domain. When adding external group members, it is possible to
specify them in either SID, or DOM\name, or name@domain format. IPA will attempt
to resolve passed name to SID with the use of Global Catalog of the trusted domain.
Example:
1. Create group for the trusted domain admins' mapping and their local POSIX group:
ipa group-add --desc='<ad.domain> admins external map' ad_admins_external --external
ipa group-add --desc='<ad.domain> admins' ad_admins
2. Add security identifier of Domain Admins of the <ad.domain> to the ad_admins_external
group:
ipa group-add-member ad_admins_external --external 'AD\Domain Admins'
3. Allow members of ad_admins_external group to be associated with ad_admins POSIX group:
ipa group-add-member ad_admins --groups ad_admins_external
4. List members of external members of ad_admins_external group to see their SIDs:
ipa group-show ad_admins_external
""")
register = Registry()
@register()
class group(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Group name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Str(
'member_user',
required=False,
label=_(u'Member users'),
),
parameters.Str(
'member_group',
required=False,
label=_(u'Member groups'),
),
parameters.Str(
'memberof_group',
required=False,
label=_(u'Member of groups'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberindirect_user',
required=False,
label=_(u'Indirect Member users'),
),
parameters.Str(
'memberindirect_group',
required=False,
label=_(u'Indirect Member groups'),
),
parameters.Str(
'memberofindirect_group',
required=False,
label=_(u'Indirect Member of group'),
),
parameters.Str(
'memberofindirect_netgroup',
required=False,
label=_(u'Indirect Member of netgroup'),
),
parameters.Str(
'memberofindirect_role',
required=False,
label=_(u'Indirect Member of role'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
)
@register()
class group_add(Method):
__doc__ = _("Create a new group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'nonposix',
doc=_(u'Create as a non-POSIX group'),
default=False,
autofill=True,
),
parameters.Flag(
'external',
doc=_(u'Allow adding external non-IPA members from trusted domains'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class group_add_member(Method):
__doc__ = _("Add members to a group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'ipaexternalmember',
required=False,
multivalue=True,
cli_name='external',
label=_(u'External member'),
doc=_(u'Members of a trusted domain in DOM\\name or name@domain form'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class group_del(Method):
__doc__ = _("Delete group.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class group_detach(Method):
__doc__ = _("Detach a managed group from a user.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class group_find(Method):
__doc__ = _("Search for groups.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'private',
doc=_(u'search for private groups'),
default=False,
autofill=True,
),
parameters.Flag(
'posix',
doc=_(u'search for POSIX groups'),
default=False,
autofill=True,
),
parameters.Flag(
'external',
doc=_(u'search for groups with support of external non-IPA members from trusted domains'),
default=False,
autofill=True,
),
parameters.Flag(
'nonposix',
doc=_(u'search for non-POSIX groups'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("group-name")'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'user'),
doc=_(u'Search for groups with these member users.'),
),
parameters.Str(
'no_user',
required=False,
multivalue=True,
cli_name='no_users',
label=_(u'user'),
doc=_(u'Search for groups without these member users.'),
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'group'),
doc=_(u'Search for groups with these member groups.'),
),
parameters.Str(
'no_group',
required=False,
multivalue=True,
cli_name='no_groups',
label=_(u'group'),
doc=_(u'Search for groups without these member groups.'),
),
parameters.Str(
'in_group',
required=False,
multivalue=True,
cli_name='in_groups',
label=_(u'group'),
doc=_(u'Search for groups with these member of groups.'),
),
parameters.Str(
'not_in_group',
required=False,
multivalue=True,
cli_name='not_in_groups',
label=_(u'group'),
doc=_(u'Search for groups without these member of groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for groups with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for groups without these member of netgroups.'),
),
parameters.Str(
'in_role',
required=False,
multivalue=True,
cli_name='in_roles',
label=_(u'role'),
doc=_(u'Search for groups with these member of roles.'),
),
parameters.Str(
'not_in_role',
required=False,
multivalue=True,
cli_name='not_in_roles',
label=_(u'role'),
doc=_(u'Search for groups without these member of roles.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for groups with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for groups without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for groups with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for groups without these member of sudo rules.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class group_mod(Method):
__doc__ = _("Modify a group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'posix',
doc=_(u'change to a POSIX group'),
default=False,
autofill=True,
),
parameters.Flag(
'external',
doc=_(u'change to support external non-IPA members from trusted domains'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the group object'),
no_convert=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class group_remove_member(Method):
__doc__ = _("Remove members from a group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'ipaexternalmember',
required=False,
multivalue=True,
cli_name='external',
label=_(u'External member'),
doc=_(u'Members of a trusted domain in DOM\\name or name@domain form'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class group_show(Method):
__doc__ = _("Display information about a named group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 26,481
|
Python
|
.py
| 856
| 20.634346
| 162
| 0.521686
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,038
|
dns.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_114/dns.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Domain Name System (DNS)
Manage DNS zone and resource records.
SUPPORTED ZONE TYPES
* Master zone (dnszone-*), contains authoritative data.
* Forward zone (dnsforwardzone-*), forwards queries to configured forwarders
(a set of DNS servers).
USING STRUCTURED PER-TYPE OPTIONS
There are many structured DNS RR types where DNS data stored in LDAP server
is not just a scalar value, for example an IP address or a domain name, but
a data structure which may be often complex. A good example is a LOC record
[RFC1876] which consists of many mandatory and optional parts (degrees,
minutes, seconds of latitude and longitude, altitude or precision).
It may be difficult to manipulate such DNS records without making a mistake
and entering an invalid value. DNS module provides an abstraction over these
raw records and allows to manipulate each RR type with specific options. For
each supported RR type, DNS module provides a standard option to manipulate
a raw records with format --<rrtype>-rec, e.g. --mx-rec, and special options
for every part of the RR structure with format --<rrtype>-<partname>, e.g.
--mx-preference and --mx-exchanger.
When adding a record, either RR specific options or standard option for a raw
value can be used, they just should not be combined in one add operation. When
modifying an existing entry, new RR specific options can be used to change
one part of a DNS record, where the standard option for raw value is used
to specify the modified value. The following example demonstrates
a modification of MX record preference from 0 to 1 in a record without
modifying the exchanger:
ipa dnsrecord-mod --mx-rec="0 mx.example.com." --mx-preference=1
EXAMPLES:
Add new zone:
ipa dnszone-add example.com --admin-email=admin@example.com
Add system permission that can be used for per-zone privilege delegation:
ipa dnszone-add-permission example.com
Modify the zone to allow dynamic updates for hosts own records in realm EXAMPLE.COM:
ipa dnszone-mod example.com --dynamic-update=TRUE
This is the equivalent of:
ipa dnszone-mod example.com --dynamic-update=TRUE \
--update-policy="grant EXAMPLE.COM krb5-self * A; grant EXAMPLE.COM krb5-self * AAAA; grant EXAMPLE.COM krb5-self * SSHFP;"
Modify the zone to allow zone transfers for local network only:
ipa dnszone-mod example.com --allow-transfer=192.0.2.0/24
Add new reverse zone specified by network IP address:
ipa dnszone-add --name-from-ip=192.0.2.0/24
Add second nameserver for example.com:
ipa dnsrecord-add example.com @ --ns-rec=nameserver2.example.com
Add a mail server for example.com:
ipa dnsrecord-add example.com @ --mx-rec="10 mail1"
Add another record using MX record specific options:
ipa dnsrecord-add example.com @ --mx-preference=20 --mx-exchanger=mail2
Add another record using interactive mode (started when dnsrecord-add, dnsrecord-mod,
or dnsrecord-del are executed with no options):
ipa dnsrecord-add example.com @
Please choose a type of DNS resource record to be added
The most common types for this type of zone are: NS, MX, LOC
DNS resource record type: MX
MX Preference: 30
MX Exchanger: mail3
Record name: example.com
MX record: 10 mail1, 20 mail2, 30 mail3
NS record: nameserver.example.com., nameserver2.example.com.
Delete previously added nameserver from example.com:
ipa dnsrecord-del example.com @ --ns-rec=nameserver2.example.com.
Add LOC record for example.com:
ipa dnsrecord-add example.com @ --loc-rec="49 11 42.4 N 16 36 29.6 E 227.64m"
Add new A record for www.example.com. Create a reverse record in appropriate
reverse zone as well. In this case a PTR record "2" pointing to www.example.com
will be created in zone 2.0.192.in-addr.arpa.
ipa dnsrecord-add example.com www --a-rec=192.0.2.2 --a-create-reverse
Add new PTR record for www.example.com
ipa dnsrecord-add 2.0.192.in-addr.arpa. 2 --ptr-rec=www.example.com.
Add new SRV records for LDAP servers. Three quarters of the requests
should go to fast.example.com, one quarter to slow.example.com. If neither
is available, switch to backup.example.com.
ipa dnsrecord-add example.com _ldap._tcp --srv-rec="0 3 389 fast.example.com"
ipa dnsrecord-add example.com _ldap._tcp --srv-rec="0 1 389 slow.example.com"
ipa dnsrecord-add example.com _ldap._tcp --srv-rec="1 1 389 backup.example.com"
The interactive mode can be used for easy modification:
ipa dnsrecord-mod example.com _ldap._tcp
No option to modify specific record provided.
Current DNS record contents:
SRV record: 0 3 389 fast.example.com, 0 1 389 slow.example.com, 1 1 389 backup.example.com
Modify SRV record '0 3 389 fast.example.com'? Yes/No (default No):
Modify SRV record '0 1 389 slow.example.com'? Yes/No (default No): y
SRV Priority [0]: (keep the default value)
SRV Weight [1]: 2 (modified value)
SRV Port [389]: (keep the default value)
SRV Target [slow.example.com]: (keep the default value)
1 SRV record skipped. Only one value per DNS record type can be modified at one time.
Record name: _ldap._tcp
SRV record: 0 3 389 fast.example.com, 1 1 389 backup.example.com, 0 2 389 slow.example.com
After this modification, three fifths of the requests should go to
fast.example.com and two fifths to slow.example.com.
An example of the interactive mode for dnsrecord-del command:
ipa dnsrecord-del example.com www
No option to delete specific record provided.
Delete all? Yes/No (default No): (do not delete all records)
Current DNS record contents:
A record: 192.0.2.2, 192.0.2.3
Delete A record '192.0.2.2'? Yes/No (default No):
Delete A record '192.0.2.3'? Yes/No (default No): y
Record name: www
A record: 192.0.2.2 (A record 192.0.2.3 has been deleted)
Show zone example.com:
ipa dnszone-show example.com
Find zone with "example" in its domain name:
ipa dnszone-find example
Find records for resources with "www" in their name in zone example.com:
ipa dnsrecord-find example.com www
Find A records with value 192.0.2.2 in zone example.com
ipa dnsrecord-find example.com --a-rec=192.0.2.2
Show records for resource www in zone example.com
ipa dnsrecord-show example.com www
Delegate zone sub.example to another nameserver:
ipa dnsrecord-add example.com ns.sub --a-rec=203.0.113.1
ipa dnsrecord-add example.com sub --ns-rec=ns.sub.example.com.
Delete zone example.com with all resource records:
ipa dnszone-del example.com
If a global forwarder is configured, all queries for which this server is not
authoritative (e.g. sub.example.com) will be routed to the global forwarder.
Global forwarding configuration can be overridden per-zone.
Semantics of forwarding in IPA matches BIND semantics and depends on the type
of zone:
* Master zone: local BIND replies authoritatively to queries for data in
the given zone (including authoritative NXDOMAIN answers) and forwarding
affects only queries for names below zone cuts (NS records) of locally
served zones.
* Forward zone: forward zone contains no authoritative data. BIND forwards
queries, which cannot be answered from its local cache, to configured
forwarders.
Semantics of the --forward-policy option:
* none - disable forwarding for the given zone.
* first - forward all queries to configured forwarders. If they fail,
do resolution using DNS root servers.
* only - forward all queries to configured forwarders and if they fail,
return failure.
Disable global forwarding for given sub-tree:
ipa dnszone-mod example.com --forward-policy=none
This configuration forwards all queries for names outside the example.com
sub-tree to global forwarders. Normal recursive resolution process is used
for names inside the example.com sub-tree (i.e. NS records are followed etc.).
Forward all requests for the zone external.example.com to another forwarder
using a "first" policy (it will send the queries to the selected forwarder
and if not answered it will use global root servers):
ipa dnsforwardzone-add external.example.com --forward-policy=first \
--forwarder=203.0.113.1
Change forward-policy for external.example.com:
ipa dnsforwardzone-mod external.example.com --forward-policy=only
Show forward zone external.example.com:
ipa dnsforwardzone-show external.example.com
List all forward zones:
ipa dnsforwardzone-find
Delete forward zone external.example.com:
ipa dnsforwardzone-del external.example.com
Resolve a host name to see if it exists (will add default IPA domain
if one is not included):
ipa dns-resolve www.example.com
ipa dns-resolve www
GLOBAL DNS CONFIGURATION
DNS configuration passed to command line install script is stored in a local
configuration file on each IPA server where DNS service is configured. These
local settings can be overridden with a common configuration stored in LDAP
server:
Show global DNS configuration:
ipa dnsconfig-show
Modify global DNS configuration and set a list of global forwarders:
ipa dnsconfig-mod --forwarder=203.0.113.113
""")
register = Registry()
@register()
class dnsconfig(Object):
takes_params = (
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
label=_(u'Global forwarders'),
doc=_(u'Global forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
label=_(u'Forward policy'),
doc=_(u'Global forwarding policy. Set to "none" to disable any configured global forwarders.'),
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records'),
),
parameters.Int(
'idnszonerefresh',
required=False,
label=_(u'Zone refresh interval'),
),
)
@register()
class dnsforwardzone(Object):
takes_params = (
parameters.DNSNameParam(
'idnsname',
primary_key=True,
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
)
@register()
class dnsrecord(Object):
takes_params = (
parameters.DNSNameParam(
'idnsname',
primary_key=True,
label=_(u'Record name'),
),
parameters.Int(
'dnsttl',
required=False,
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
),
parameters.Any(
'dnsrecords',
required=False,
label=_(u'Records'),
),
parameters.Str(
'dnstype',
required=False,
label=_(u'Record type'),
),
parameters.Str(
'dnsdata',
required=False,
label=_(u'Record data'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'a_part_ip_address',
required=False,
label=_(u'A IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'a_extra_create_reverse',
required=False,
label=_(u'A Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'aaaa_part_ip_address',
required=False,
label=_(u'AAAA IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'aaaa_extra_create_reverse',
required=False,
label=_(u'AAAA Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'a6_part_data',
required=False,
label=_(u'A6 Record data'),
doc=_(u'Record data'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Int(
'afsdb_part_subtype',
required=False,
label=_(u'AFSDB Subtype'),
doc=_(u'Subtype'),
),
parameters.DNSNameParam(
'afsdb_part_hostname',
required=False,
label=_(u'AFSDB Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
label=_(u'APL record'),
doc=_(u'Raw APL records'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Int(
'cert_part_type',
required=False,
label=_(u'CERT Certificate Type'),
doc=_(u'Certificate Type'),
),
parameters.Int(
'cert_part_key_tag',
required=False,
label=_(u'CERT Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'cert_part_algorithm',
required=False,
label=_(u'CERT Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Str(
'cert_part_certificate_or_crl',
required=False,
label=_(u'CERT Certificate/CRL'),
doc=_(u'Certificate/CRL'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.DNSNameParam(
'cname_part_hostname',
required=False,
label=_(u'CNAME Hostname'),
doc=_(u'A hostname which this alias hostname points to'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Int(
'dlv_part_key_tag',
required=False,
label=_(u'DLV Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'dlv_part_algorithm',
required=False,
label=_(u'DLV Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'dlv_part_digest_type',
required=False,
label=_(u'DLV Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'dlv_part_digest',
required=False,
label=_(u'DLV Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.DNSNameParam(
'dname_part_target',
required=False,
label=_(u'DNAME Target'),
doc=_(u'Target'),
),
parameters.Str(
'dnskeyrecord',
required=False,
multivalue=True,
label=_(u'DNSKEY record'),
doc=_(u'Raw DNSKEY records'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Int(
'ds_part_key_tag',
required=False,
label=_(u'DS Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'ds_part_algorithm',
required=False,
label=_(u'DS Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'ds_part_digest_type',
required=False,
label=_(u'DS Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'ds_part_digest',
required=False,
label=_(u'DS Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Int(
'kx_part_preference',
required=False,
label=_(u'KX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'kx_part_exchanger',
required=False,
label=_(u'KX Exchanger'),
doc=_(u'A host willing to act as a key exchanger'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Int(
'loc_part_lat_deg',
required=False,
label=_(u'LOC Degrees Latitude'),
doc=_(u'Degrees Latitude'),
),
parameters.Int(
'loc_part_lat_min',
required=False,
label=_(u'LOC Minutes Latitude'),
doc=_(u'Minutes Latitude'),
),
parameters.Decimal(
'loc_part_lat_sec',
required=False,
label=_(u'LOC Seconds Latitude'),
doc=_(u'Seconds Latitude'),
),
parameters.Str(
'loc_part_lat_dir',
required=False,
label=_(u'LOC Direction Latitude'),
doc=_(u'Direction Latitude'),
),
parameters.Int(
'loc_part_lon_deg',
required=False,
label=_(u'LOC Degrees Longitude'),
doc=_(u'Degrees Longitude'),
),
parameters.Int(
'loc_part_lon_min',
required=False,
label=_(u'LOC Minutes Longitude'),
doc=_(u'Minutes Longitude'),
),
parameters.Decimal(
'loc_part_lon_sec',
required=False,
label=_(u'LOC Seconds Longitude'),
doc=_(u'Seconds Longitude'),
),
parameters.Str(
'loc_part_lon_dir',
required=False,
label=_(u'LOC Direction Longitude'),
doc=_(u'Direction Longitude'),
),
parameters.Decimal(
'loc_part_altitude',
required=False,
label=_(u'LOC Altitude'),
doc=_(u'Altitude'),
),
parameters.Decimal(
'loc_part_size',
required=False,
label=_(u'LOC Size'),
doc=_(u'Size'),
),
parameters.Decimal(
'loc_part_h_precision',
required=False,
label=_(u'LOC Horizontal Precision'),
doc=_(u'Horizontal Precision'),
),
parameters.Decimal(
'loc_part_v_precision',
required=False,
label=_(u'LOC Vertical Precision'),
doc=_(u'Vertical Precision'),
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Int(
'mx_part_preference',
required=False,
label=_(u'MX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'mx_part_exchanger',
required=False,
label=_(u'MX Exchanger'),
doc=_(u'A host willing to act as a mail exchanger'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Int(
'naptr_part_order',
required=False,
label=_(u'NAPTR Order'),
doc=_(u'Order'),
),
parameters.Int(
'naptr_part_preference',
required=False,
label=_(u'NAPTR Preference'),
doc=_(u'Preference'),
),
parameters.Str(
'naptr_part_flags',
required=False,
label=_(u'NAPTR Flags'),
doc=_(u'Flags'),
),
parameters.Str(
'naptr_part_service',
required=False,
label=_(u'NAPTR Service'),
doc=_(u'Service'),
),
parameters.Str(
'naptr_part_regexp',
required=False,
label=_(u'NAPTR Regular Expression'),
doc=_(u'Regular Expression'),
),
parameters.Str(
'naptr_part_replacement',
required=False,
label=_(u'NAPTR Replacement'),
doc=_(u'Replacement'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.DNSNameParam(
'ns_part_hostname',
required=False,
label=_(u'NS Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
),
parameters.Str(
'nsec3record',
required=False,
multivalue=True,
label=_(u'NSEC3 record'),
doc=_(u'Raw NSEC3 records'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.DNSNameParam(
'ptr_part_hostname',
required=False,
label=_(u'PTR Hostname'),
doc=_(u'The hostname this reverse record points to'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
label=_(u'RP record'),
doc=_(u'Raw RP records'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Int(
'srv_part_priority',
required=False,
label=_(u'SRV Priority'),
doc=_(u'Priority'),
),
parameters.Int(
'srv_part_weight',
required=False,
label=_(u'SRV Weight'),
doc=_(u'Weight'),
),
parameters.Int(
'srv_part_port',
required=False,
label=_(u'SRV Port'),
doc=_(u'Port'),
),
parameters.DNSNameParam(
'srv_part_target',
required=False,
label=_(u'SRV Target'),
doc=_(u"The domain name of the target host or '.' if the service is decidedly not available at this domain"),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Int(
'sshfp_part_algorithm',
required=False,
label=_(u'SSHFP Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'sshfp_part_fp_type',
required=False,
label=_(u'SSHFP Fingerprint Type'),
doc=_(u'Fingerprint Type'),
),
parameters.Str(
'sshfp_part_fingerprint',
required=False,
label=_(u'SSHFP Fingerprint'),
doc=_(u'Fingerprint'),
),
parameters.Str(
'tarecord',
required=False,
multivalue=True,
label=_(u'TA record'),
doc=_(u'Raw TA records'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Int(
'tlsa_part_cert_usage',
required=False,
label=_(u'TLSA Certificate Usage'),
doc=_(u'Certificate Usage'),
),
parameters.Int(
'tlsa_part_selector',
required=False,
label=_(u'TLSA Selector'),
doc=_(u'Selector'),
),
parameters.Int(
'tlsa_part_matching_type',
required=False,
label=_(u'TLSA Matching Type'),
doc=_(u'Matching Type'),
),
parameters.Str(
'tlsa_part_cert_association_data',
required=False,
label=_(u'TLSA Certificate Association Data'),
doc=_(u'Certificate Association Data'),
),
parameters.Str(
'tkeyrecord',
required=False,
multivalue=True,
label=_(u'TKEY record'),
doc=_(u'Raw TKEY records'),
),
parameters.Str(
'tsigrecord',
required=False,
multivalue=True,
label=_(u'TSIG record'),
doc=_(u'Raw TSIG records'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Str(
'txt_part_data',
required=False,
label=_(u'TXT Text Data'),
doc=_(u'Text Data'),
),
)
@register()
class dnszone(Object):
takes_params = (
parameters.DNSNameParam(
'idnsname',
primary_key=True,
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
label=_(u'Administrator e-mail address'),
),
parameters.Int(
'idnssoaserial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
),
parameters.Int(
'idnssoarefresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
),
parameters.Int(
'idnssoaretry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
),
parameters.Int(
'idnssoaexpire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
),
parameters.Int(
'idnssoaminimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
),
parameters.Int(
'dnsttl',
required=False,
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
),
parameters.Str(
'idnsupdatepolicy',
required=False,
label=_(u'BIND update policy'),
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
),
parameters.Str(
'idnsallowquery',
required=False,
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
),
parameters.Str(
'idnsallowtransfer',
required=False,
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
),
parameters.Str(
'nsec3paramrecord',
required=False,
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
)
@register()
class dns_is_enabled(Command):
__doc__ = _("Checks if any of the servers has the DNS service enabled.")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dns_resolve(Command):
__doc__ = _("Resolve a host name in DNS.")
takes_args = (
parameters.Str(
'hostname',
label=_(u'Hostname'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsconfig_mod(Method):
__doc__ = _("Modify global DNS configuration.")
takes_options = (
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Global forwarders'),
doc=_(u'Global forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Global forwarding policy. Set to "none" to disable any configured global forwarders.'),
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records'),
),
parameters.Int(
'idnszonerefresh',
required=False,
deprecated=True,
cli_name='zone_refresh',
label=_(u'Zone refresh interval'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsconfig_show(Method):
__doc__ = _("Show the current global DNS configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_add(Method):
__doc__ = _("Create new DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_add_permission(Method):
__doc__ = _("Add a permission for per-forward zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnsforwardzone_del(Method):
__doc__ = _("Delete DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
multivalue=True,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnsforwardzone_disable(Method):
__doc__ = _("Disable DNS Forward Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_enable(Method):
__doc__ = _("Enable DNS Forward Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_find(Method):
__doc__ = _("Search for DNS forward zones.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.DNSNameParam(
'idnsname',
required=False,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
cli_name='zone_active',
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class dnsforwardzone_mod(Method):
__doc__ = _("Modify DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_remove_permission(Method):
__doc__ = _("Remove a permission for per-forward zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnsforwardzone_show(Method):
__doc__ = _("Display information about a DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsrecord_add(Method):
__doc__ = _("Add new DNS resource record.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
option_group=u'A Record',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'a_part_ip_address',
required=False,
cli_name='a_ip_address',
option_group=u'A Record',
label=_(u'A IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'a_extra_create_reverse',
required=False,
cli_name='a_create_reverse',
option_group=u'A Record',
label=_(u'A Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
default=False,
autofill=True,
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
option_group=u'AAAA Record',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'aaaa_part_ip_address',
required=False,
cli_name='aaaa_ip_address',
option_group=u'AAAA Record',
label=_(u'AAAA IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'aaaa_extra_create_reverse',
required=False,
cli_name='aaaa_create_reverse',
option_group=u'AAAA Record',
label=_(u'AAAA Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
default=False,
autofill=True,
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
option_group=u'A6 Record',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'a6_part_data',
required=False,
cli_name='a6_data',
option_group=u'A6 Record',
label=_(u'A6 Record data'),
doc=_(u'Record data'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
option_group=u'AFSDB Record',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Int(
'afsdb_part_subtype',
required=False,
cli_name='afsdb_subtype',
option_group=u'AFSDB Record',
label=_(u'AFSDB Subtype'),
doc=_(u'Subtype'),
),
parameters.DNSNameParam(
'afsdb_part_hostname',
required=False,
cli_name='afsdb_hostname',
option_group=u'AFSDB Record',
label=_(u'AFSDB Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
option_group=u'APL Record',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
option_group=u'CERT Record',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Int(
'cert_part_type',
required=False,
cli_name='cert_type',
option_group=u'CERT Record',
label=_(u'CERT Certificate Type'),
doc=_(u'Certificate Type'),
),
parameters.Int(
'cert_part_key_tag',
required=False,
cli_name='cert_key_tag',
option_group=u'CERT Record',
label=_(u'CERT Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'cert_part_algorithm',
required=False,
cli_name='cert_algorithm',
option_group=u'CERT Record',
label=_(u'CERT Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Str(
'cert_part_certificate_or_crl',
required=False,
cli_name='cert_certificate_or_crl',
option_group=u'CERT Record',
label=_(u'CERT Certificate/CRL'),
doc=_(u'Certificate/CRL'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
option_group=u'CNAME Record',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.DNSNameParam(
'cname_part_hostname',
required=False,
cli_name='cname_hostname',
option_group=u'CNAME Record',
label=_(u'CNAME Hostname'),
doc=_(u'A hostname which this alias hostname points to'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
option_group=u'DHCID Record',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
option_group=u'DLV Record',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Int(
'dlv_part_key_tag',
required=False,
cli_name='dlv_key_tag',
option_group=u'DLV Record',
label=_(u'DLV Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'dlv_part_algorithm',
required=False,
cli_name='dlv_algorithm',
option_group=u'DLV Record',
label=_(u'DLV Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'dlv_part_digest_type',
required=False,
cli_name='dlv_digest_type',
option_group=u'DLV Record',
label=_(u'DLV Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'dlv_part_digest',
required=False,
cli_name='dlv_digest',
option_group=u'DLV Record',
label=_(u'DLV Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
option_group=u'DNAME Record',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.DNSNameParam(
'dname_part_target',
required=False,
cli_name='dname_target',
option_group=u'DNAME Record',
label=_(u'DNAME Target'),
doc=_(u'Target'),
),
parameters.Str(
'dnskeyrecord',
required=False,
multivalue=True,
cli_name='dnskey_rec',
option_group=u'DNSKEY Record',
label=_(u'DNSKEY record'),
doc=_(u'Raw DNSKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
option_group=u'DS Record',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Int(
'ds_part_key_tag',
required=False,
cli_name='ds_key_tag',
option_group=u'DS Record',
label=_(u'DS Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'ds_part_algorithm',
required=False,
cli_name='ds_algorithm',
option_group=u'DS Record',
label=_(u'DS Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'ds_part_digest_type',
required=False,
cli_name='ds_digest_type',
option_group=u'DS Record',
label=_(u'DS Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'ds_part_digest',
required=False,
cli_name='ds_digest',
option_group=u'DS Record',
label=_(u'DS Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
option_group=u'HIP Record',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
option_group=u'IPSECKEY Record',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
option_group=u'KEY Record',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
option_group=u'KX Record',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Int(
'kx_part_preference',
required=False,
cli_name='kx_preference',
option_group=u'KX Record',
label=_(u'KX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'kx_part_exchanger',
required=False,
cli_name='kx_exchanger',
option_group=u'KX Record',
label=_(u'KX Exchanger'),
doc=_(u'A host willing to act as a key exchanger'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
option_group=u'LOC Record',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Int(
'loc_part_lat_deg',
required=False,
cli_name='loc_lat_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Latitude'),
doc=_(u'Degrees Latitude'),
),
parameters.Int(
'loc_part_lat_min',
required=False,
cli_name='loc_lat_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Latitude'),
doc=_(u'Minutes Latitude'),
),
parameters.Decimal(
'loc_part_lat_sec',
required=False,
cli_name='loc_lat_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Latitude'),
doc=_(u'Seconds Latitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lat_dir',
required=False,
cli_name='loc_lat_dir',
option_group=u'LOC Record',
cli_metavar="['N', 'S']",
label=_(u'LOC Direction Latitude'),
doc=_(u'Direction Latitude'),
),
parameters.Int(
'loc_part_lon_deg',
required=False,
cli_name='loc_lon_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Longitude'),
doc=_(u'Degrees Longitude'),
),
parameters.Int(
'loc_part_lon_min',
required=False,
cli_name='loc_lon_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Longitude'),
doc=_(u'Minutes Longitude'),
),
parameters.Decimal(
'loc_part_lon_sec',
required=False,
cli_name='loc_lon_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Longitude'),
doc=_(u'Seconds Longitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lon_dir',
required=False,
cli_name='loc_lon_dir',
option_group=u'LOC Record',
cli_metavar="['E', 'W']",
label=_(u'LOC Direction Longitude'),
doc=_(u'Direction Longitude'),
),
parameters.Decimal(
'loc_part_altitude',
required=False,
cli_name='loc_altitude',
option_group=u'LOC Record',
label=_(u'LOC Altitude'),
doc=_(u'Altitude'),
no_convert=True,
),
parameters.Decimal(
'loc_part_size',
required=False,
cli_name='loc_size',
option_group=u'LOC Record',
label=_(u'LOC Size'),
doc=_(u'Size'),
no_convert=True,
),
parameters.Decimal(
'loc_part_h_precision',
required=False,
cli_name='loc_h_precision',
option_group=u'LOC Record',
label=_(u'LOC Horizontal Precision'),
doc=_(u'Horizontal Precision'),
no_convert=True,
),
parameters.Decimal(
'loc_part_v_precision',
required=False,
cli_name='loc_v_precision',
option_group=u'LOC Record',
label=_(u'LOC Vertical Precision'),
doc=_(u'Vertical Precision'),
no_convert=True,
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
option_group=u'MX Record',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Int(
'mx_part_preference',
required=False,
cli_name='mx_preference',
option_group=u'MX Record',
label=_(u'MX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'mx_part_exchanger',
required=False,
cli_name='mx_exchanger',
option_group=u'MX Record',
label=_(u'MX Exchanger'),
doc=_(u'A host willing to act as a mail exchanger'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
option_group=u'NAPTR Record',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Int(
'naptr_part_order',
required=False,
cli_name='naptr_order',
option_group=u'NAPTR Record',
label=_(u'NAPTR Order'),
doc=_(u'Order'),
),
parameters.Int(
'naptr_part_preference',
required=False,
cli_name='naptr_preference',
option_group=u'NAPTR Record',
label=_(u'NAPTR Preference'),
doc=_(u'Preference'),
),
parameters.Str(
'naptr_part_flags',
required=False,
cli_name='naptr_flags',
option_group=u'NAPTR Record',
label=_(u'NAPTR Flags'),
doc=_(u'Flags'),
no_convert=True,
),
parameters.Str(
'naptr_part_service',
required=False,
cli_name='naptr_service',
option_group=u'NAPTR Record',
label=_(u'NAPTR Service'),
doc=_(u'Service'),
),
parameters.Str(
'naptr_part_regexp',
required=False,
cli_name='naptr_regexp',
option_group=u'NAPTR Record',
label=_(u'NAPTR Regular Expression'),
doc=_(u'Regular Expression'),
),
parameters.Str(
'naptr_part_replacement',
required=False,
cli_name='naptr_replacement',
option_group=u'NAPTR Record',
label=_(u'NAPTR Replacement'),
doc=_(u'Replacement'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
option_group=u'NS Record',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.DNSNameParam(
'ns_part_hostname',
required=False,
cli_name='ns_hostname',
option_group=u'NS Record',
label=_(u'NS Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
option_group=u'NSEC Record',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'nsec3record',
required=False,
multivalue=True,
cli_name='nsec3_rec',
option_group=u'NSEC3 Record',
label=_(u'NSEC3 record'),
doc=_(u'Raw NSEC3 records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
option_group=u'PTR Record',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.DNSNameParam(
'ptr_part_hostname',
required=False,
cli_name='ptr_hostname',
option_group=u'PTR Record',
label=_(u'PTR Hostname'),
doc=_(u'The hostname this reverse record points to'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
option_group=u'RRSIG Record',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
option_group=u'RP Record',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
option_group=u'SIG Record',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
option_group=u'SPF Record',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
option_group=u'SRV Record',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Int(
'srv_part_priority',
required=False,
cli_name='srv_priority',
option_group=u'SRV Record',
label=_(u'SRV Priority'),
doc=_(u'Priority'),
),
parameters.Int(
'srv_part_weight',
required=False,
cli_name='srv_weight',
option_group=u'SRV Record',
label=_(u'SRV Weight'),
doc=_(u'Weight'),
),
parameters.Int(
'srv_part_port',
required=False,
cli_name='srv_port',
option_group=u'SRV Record',
label=_(u'SRV Port'),
doc=_(u'Port'),
),
parameters.DNSNameParam(
'srv_part_target',
required=False,
cli_name='srv_target',
option_group=u'SRV Record',
label=_(u'SRV Target'),
doc=_(u"The domain name of the target host or '.' if the service is decidedly not available at this domain"),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
option_group=u'SSHFP Record',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Int(
'sshfp_part_algorithm',
required=False,
cli_name='sshfp_algorithm',
option_group=u'SSHFP Record',
label=_(u'SSHFP Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'sshfp_part_fp_type',
required=False,
cli_name='sshfp_fp_type',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint Type'),
doc=_(u'Fingerprint Type'),
),
parameters.Str(
'sshfp_part_fingerprint',
required=False,
cli_name='sshfp_fingerprint',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint'),
doc=_(u'Fingerprint'),
),
parameters.Str(
'tarecord',
required=False,
multivalue=True,
cli_name='ta_rec',
option_group=u'TA Record',
label=_(u'TA record'),
doc=_(u'Raw TA records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
option_group=u'TLSA Record',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Int(
'tlsa_part_cert_usage',
required=False,
cli_name='tlsa_cert_usage',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Usage'),
doc=_(u'Certificate Usage'),
),
parameters.Int(
'tlsa_part_selector',
required=False,
cli_name='tlsa_selector',
option_group=u'TLSA Record',
label=_(u'TLSA Selector'),
doc=_(u'Selector'),
),
parameters.Int(
'tlsa_part_matching_type',
required=False,
cli_name='tlsa_matching_type',
option_group=u'TLSA Record',
label=_(u'TLSA Matching Type'),
doc=_(u'Matching Type'),
),
parameters.Str(
'tlsa_part_cert_association_data',
required=False,
cli_name='tlsa_cert_association_data',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Association Data'),
doc=_(u'Certificate Association Data'),
),
parameters.Str(
'tkeyrecord',
required=False,
multivalue=True,
cli_name='tkey_rec',
option_group=u'TKEY Record',
label=_(u'TKEY record'),
doc=_(u'Raw TKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tsigrecord',
required=False,
multivalue=True,
cli_name='tsig_rec',
option_group=u'TSIG Record',
label=_(u'TSIG record'),
doc=_(u'Raw TSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
option_group=u'TXT Record',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Str(
'txt_part_data',
required=False,
cli_name='txt_data',
option_group=u'TXT Record',
label=_(u'TXT Text Data'),
doc=_(u'Text Data'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force NS record creation even if its hostname is not in DNS'),
exclude=('cli', 'webui'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsrecord_del(Method):
__doc__ = _("Delete DNS resource record.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.Str(
'dnskeyrecord',
required=False,
multivalue=True,
cli_name='dnskey_rec',
label=_(u'DNSKEY record'),
doc=_(u'Raw DNSKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'nsec3record',
required=False,
multivalue=True,
cli_name='nsec3_rec',
label=_(u'NSEC3 record'),
doc=_(u'Raw NSEC3 records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Str(
'tarecord',
required=False,
multivalue=True,
cli_name='ta_rec',
label=_(u'TA record'),
doc=_(u'Raw TA records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Str(
'tkeyrecord',
required=False,
multivalue=True,
cli_name='tkey_rec',
label=_(u'TKEY record'),
doc=_(u'Raw TKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tsigrecord',
required=False,
multivalue=True,
cli_name='tsig_rec',
label=_(u'TSIG record'),
doc=_(u'Raw TSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Flag(
'del_all',
label=_(u'Delete all associated records'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnsrecord_delentry(Method):
__doc__ = _("Delete DNS record entry.")
NO_CLI = True
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
multivalue=True,
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnsrecord_find(Method):
__doc__ = _("Search for DNS resources.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.DNSNameParam(
'idnsname',
required=False,
cli_name='name',
label=_(u'Record name'),
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.Str(
'dnskeyrecord',
required=False,
multivalue=True,
cli_name='dnskey_rec',
label=_(u'DNSKEY record'),
doc=_(u'Raw DNSKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'nsec3record',
required=False,
multivalue=True,
cli_name='nsec3_rec',
label=_(u'NSEC3 record'),
doc=_(u'Raw NSEC3 records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Str(
'tarecord',
required=False,
multivalue=True,
cli_name='ta_rec',
label=_(u'TA record'),
doc=_(u'Raw TA records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Str(
'tkeyrecord',
required=False,
multivalue=True,
cli_name='tkey_rec',
label=_(u'TKEY record'),
doc=_(u'Raw TKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tsigrecord',
required=False,
multivalue=True,
cli_name='tsig_rec',
label=_(u'TSIG record'),
doc=_(u'Raw TSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class dnsrecord_mod(Method):
__doc__ = _("Modify a DNS resource record.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
option_group=u'A Record',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'a_part_ip_address',
required=False,
cli_name='a_ip_address',
option_group=u'A Record',
label=_(u'A IP Address'),
doc=_(u'IP Address'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
option_group=u'AAAA Record',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'aaaa_part_ip_address',
required=False,
cli_name='aaaa_ip_address',
option_group=u'AAAA Record',
label=_(u'AAAA IP Address'),
doc=_(u'IP Address'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
option_group=u'A6 Record',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'a6_part_data',
required=False,
cli_name='a6_data',
option_group=u'A6 Record',
label=_(u'A6 Record data'),
doc=_(u'Record data'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
option_group=u'AFSDB Record',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Int(
'afsdb_part_subtype',
required=False,
cli_name='afsdb_subtype',
option_group=u'AFSDB Record',
label=_(u'AFSDB Subtype'),
doc=_(u'Subtype'),
),
parameters.DNSNameParam(
'afsdb_part_hostname',
required=False,
cli_name='afsdb_hostname',
option_group=u'AFSDB Record',
label=_(u'AFSDB Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
option_group=u'APL Record',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
option_group=u'CERT Record',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Int(
'cert_part_type',
required=False,
cli_name='cert_type',
option_group=u'CERT Record',
label=_(u'CERT Certificate Type'),
doc=_(u'Certificate Type'),
),
parameters.Int(
'cert_part_key_tag',
required=False,
cli_name='cert_key_tag',
option_group=u'CERT Record',
label=_(u'CERT Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'cert_part_algorithm',
required=False,
cli_name='cert_algorithm',
option_group=u'CERT Record',
label=_(u'CERT Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Str(
'cert_part_certificate_or_crl',
required=False,
cli_name='cert_certificate_or_crl',
option_group=u'CERT Record',
label=_(u'CERT Certificate/CRL'),
doc=_(u'Certificate/CRL'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
option_group=u'CNAME Record',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.DNSNameParam(
'cname_part_hostname',
required=False,
cli_name='cname_hostname',
option_group=u'CNAME Record',
label=_(u'CNAME Hostname'),
doc=_(u'A hostname which this alias hostname points to'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
option_group=u'DHCID Record',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
option_group=u'DLV Record',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Int(
'dlv_part_key_tag',
required=False,
cli_name='dlv_key_tag',
option_group=u'DLV Record',
label=_(u'DLV Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'dlv_part_algorithm',
required=False,
cli_name='dlv_algorithm',
option_group=u'DLV Record',
label=_(u'DLV Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'dlv_part_digest_type',
required=False,
cli_name='dlv_digest_type',
option_group=u'DLV Record',
label=_(u'DLV Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'dlv_part_digest',
required=False,
cli_name='dlv_digest',
option_group=u'DLV Record',
label=_(u'DLV Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
option_group=u'DNAME Record',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.DNSNameParam(
'dname_part_target',
required=False,
cli_name='dname_target',
option_group=u'DNAME Record',
label=_(u'DNAME Target'),
doc=_(u'Target'),
),
parameters.Str(
'dnskeyrecord',
required=False,
multivalue=True,
cli_name='dnskey_rec',
option_group=u'DNSKEY Record',
label=_(u'DNSKEY record'),
doc=_(u'Raw DNSKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
option_group=u'DS Record',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Int(
'ds_part_key_tag',
required=False,
cli_name='ds_key_tag',
option_group=u'DS Record',
label=_(u'DS Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'ds_part_algorithm',
required=False,
cli_name='ds_algorithm',
option_group=u'DS Record',
label=_(u'DS Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'ds_part_digest_type',
required=False,
cli_name='ds_digest_type',
option_group=u'DS Record',
label=_(u'DS Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'ds_part_digest',
required=False,
cli_name='ds_digest',
option_group=u'DS Record',
label=_(u'DS Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
option_group=u'HIP Record',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
option_group=u'IPSECKEY Record',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
option_group=u'KEY Record',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
option_group=u'KX Record',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Int(
'kx_part_preference',
required=False,
cli_name='kx_preference',
option_group=u'KX Record',
label=_(u'KX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'kx_part_exchanger',
required=False,
cli_name='kx_exchanger',
option_group=u'KX Record',
label=_(u'KX Exchanger'),
doc=_(u'A host willing to act as a key exchanger'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
option_group=u'LOC Record',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Int(
'loc_part_lat_deg',
required=False,
cli_name='loc_lat_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Latitude'),
doc=_(u'Degrees Latitude'),
),
parameters.Int(
'loc_part_lat_min',
required=False,
cli_name='loc_lat_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Latitude'),
doc=_(u'Minutes Latitude'),
),
parameters.Decimal(
'loc_part_lat_sec',
required=False,
cli_name='loc_lat_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Latitude'),
doc=_(u'Seconds Latitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lat_dir',
required=False,
cli_name='loc_lat_dir',
option_group=u'LOC Record',
cli_metavar="['N', 'S']",
label=_(u'LOC Direction Latitude'),
doc=_(u'Direction Latitude'),
),
parameters.Int(
'loc_part_lon_deg',
required=False,
cli_name='loc_lon_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Longitude'),
doc=_(u'Degrees Longitude'),
),
parameters.Int(
'loc_part_lon_min',
required=False,
cli_name='loc_lon_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Longitude'),
doc=_(u'Minutes Longitude'),
),
parameters.Decimal(
'loc_part_lon_sec',
required=False,
cli_name='loc_lon_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Longitude'),
doc=_(u'Seconds Longitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lon_dir',
required=False,
cli_name='loc_lon_dir',
option_group=u'LOC Record',
cli_metavar="['E', 'W']",
label=_(u'LOC Direction Longitude'),
doc=_(u'Direction Longitude'),
),
parameters.Decimal(
'loc_part_altitude',
required=False,
cli_name='loc_altitude',
option_group=u'LOC Record',
label=_(u'LOC Altitude'),
doc=_(u'Altitude'),
no_convert=True,
),
parameters.Decimal(
'loc_part_size',
required=False,
cli_name='loc_size',
option_group=u'LOC Record',
label=_(u'LOC Size'),
doc=_(u'Size'),
no_convert=True,
),
parameters.Decimal(
'loc_part_h_precision',
required=False,
cli_name='loc_h_precision',
option_group=u'LOC Record',
label=_(u'LOC Horizontal Precision'),
doc=_(u'Horizontal Precision'),
no_convert=True,
),
parameters.Decimal(
'loc_part_v_precision',
required=False,
cli_name='loc_v_precision',
option_group=u'LOC Record',
label=_(u'LOC Vertical Precision'),
doc=_(u'Vertical Precision'),
no_convert=True,
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
option_group=u'MX Record',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Int(
'mx_part_preference',
required=False,
cli_name='mx_preference',
option_group=u'MX Record',
label=_(u'MX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'mx_part_exchanger',
required=False,
cli_name='mx_exchanger',
option_group=u'MX Record',
label=_(u'MX Exchanger'),
doc=_(u'A host willing to act as a mail exchanger'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
option_group=u'NAPTR Record',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Int(
'naptr_part_order',
required=False,
cli_name='naptr_order',
option_group=u'NAPTR Record',
label=_(u'NAPTR Order'),
doc=_(u'Order'),
),
parameters.Int(
'naptr_part_preference',
required=False,
cli_name='naptr_preference',
option_group=u'NAPTR Record',
label=_(u'NAPTR Preference'),
doc=_(u'Preference'),
),
parameters.Str(
'naptr_part_flags',
required=False,
cli_name='naptr_flags',
option_group=u'NAPTR Record',
label=_(u'NAPTR Flags'),
doc=_(u'Flags'),
no_convert=True,
),
parameters.Str(
'naptr_part_service',
required=False,
cli_name='naptr_service',
option_group=u'NAPTR Record',
label=_(u'NAPTR Service'),
doc=_(u'Service'),
),
parameters.Str(
'naptr_part_regexp',
required=False,
cli_name='naptr_regexp',
option_group=u'NAPTR Record',
label=_(u'NAPTR Regular Expression'),
doc=_(u'Regular Expression'),
),
parameters.Str(
'naptr_part_replacement',
required=False,
cli_name='naptr_replacement',
option_group=u'NAPTR Record',
label=_(u'NAPTR Replacement'),
doc=_(u'Replacement'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
option_group=u'NS Record',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.DNSNameParam(
'ns_part_hostname',
required=False,
cli_name='ns_hostname',
option_group=u'NS Record',
label=_(u'NS Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
option_group=u'NSEC Record',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'nsec3record',
required=False,
multivalue=True,
cli_name='nsec3_rec',
option_group=u'NSEC3 Record',
label=_(u'NSEC3 record'),
doc=_(u'Raw NSEC3 records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
option_group=u'PTR Record',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.DNSNameParam(
'ptr_part_hostname',
required=False,
cli_name='ptr_hostname',
option_group=u'PTR Record',
label=_(u'PTR Hostname'),
doc=_(u'The hostname this reverse record points to'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
option_group=u'RRSIG Record',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
option_group=u'RP Record',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
option_group=u'SIG Record',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
option_group=u'SPF Record',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
option_group=u'SRV Record',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Int(
'srv_part_priority',
required=False,
cli_name='srv_priority',
option_group=u'SRV Record',
label=_(u'SRV Priority'),
doc=_(u'Priority'),
),
parameters.Int(
'srv_part_weight',
required=False,
cli_name='srv_weight',
option_group=u'SRV Record',
label=_(u'SRV Weight'),
doc=_(u'Weight'),
),
parameters.Int(
'srv_part_port',
required=False,
cli_name='srv_port',
option_group=u'SRV Record',
label=_(u'SRV Port'),
doc=_(u'Port'),
),
parameters.DNSNameParam(
'srv_part_target',
required=False,
cli_name='srv_target',
option_group=u'SRV Record',
label=_(u'SRV Target'),
doc=_(u"The domain name of the target host or '.' if the service is decidedly not available at this domain"),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
option_group=u'SSHFP Record',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Int(
'sshfp_part_algorithm',
required=False,
cli_name='sshfp_algorithm',
option_group=u'SSHFP Record',
label=_(u'SSHFP Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'sshfp_part_fp_type',
required=False,
cli_name='sshfp_fp_type',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint Type'),
doc=_(u'Fingerprint Type'),
),
parameters.Str(
'sshfp_part_fingerprint',
required=False,
cli_name='sshfp_fingerprint',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint'),
doc=_(u'Fingerprint'),
),
parameters.Str(
'tarecord',
required=False,
multivalue=True,
cli_name='ta_rec',
option_group=u'TA Record',
label=_(u'TA record'),
doc=_(u'Raw TA records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
option_group=u'TLSA Record',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Int(
'tlsa_part_cert_usage',
required=False,
cli_name='tlsa_cert_usage',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Usage'),
doc=_(u'Certificate Usage'),
),
parameters.Int(
'tlsa_part_selector',
required=False,
cli_name='tlsa_selector',
option_group=u'TLSA Record',
label=_(u'TLSA Selector'),
doc=_(u'Selector'),
),
parameters.Int(
'tlsa_part_matching_type',
required=False,
cli_name='tlsa_matching_type',
option_group=u'TLSA Record',
label=_(u'TLSA Matching Type'),
doc=_(u'Matching Type'),
),
parameters.Str(
'tlsa_part_cert_association_data',
required=False,
cli_name='tlsa_cert_association_data',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Association Data'),
doc=_(u'Certificate Association Data'),
),
parameters.Str(
'tkeyrecord',
required=False,
multivalue=True,
cli_name='tkey_rec',
option_group=u'TKEY Record',
label=_(u'TKEY record'),
doc=_(u'Raw TKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'tsigrecord',
required=False,
multivalue=True,
cli_name='tsig_rec',
option_group=u'TSIG Record',
label=_(u'TSIG record'),
doc=_(u'Raw TSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
option_group=u'TXT Record',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Str(
'txt_part_data',
required=False,
cli_name='txt_data',
option_group=u'TXT Record',
label=_(u'TXT Text Data'),
doc=_(u'Text Data'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.DNSNameParam(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the DNS resource record object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsrecord_show(Method):
__doc__ = _("Display DNS resource.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_add(Method):
__doc__ = _("Create new DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
cli_name='name_server',
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
cli_name='admin_email',
label=_(u'Administrator e-mail address'),
default=DNSName(u'hostmaster'),
autofill=True,
no_convert=True,
),
parameters.Int(
'idnssoaserial',
cli_name='serial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# def _create_zone_serial():
# """
# Generate serial number for zones. bind-dyndb-ldap expects unix time in
# to be used for SOA serial.
#
# SOA serial in a date format would also work, but it may be set to far
# future when many DNS updates are done per day (more than 100). Unix
# timestamp is more resilient to this issue.
# """
# return int(time.time())
autofill=True,
),
parameters.Int(
'idnssoarefresh',
cli_name='refresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
default=3600,
autofill=True,
),
parameters.Int(
'idnssoaretry',
cli_name='retry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
default=900,
autofill=True,
),
parameters.Int(
'idnssoaexpire',
cli_name='expire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
default=1209600,
autofill=True,
),
parameters.Int(
'idnssoaminimum',
cli_name='minimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
default=3600,
autofill=True,
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'idnsupdatepolicy',
required=False,
cli_name='update_policy',
label=_(u'BIND update policy'),
default_from=DefaultFrom(lambda idnsname: None, 'idnsname'),
# FIXME:
# lambda idnsname: default_zone_update_policy(idnsname)
autofill=True,
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
cli_name='dynamic_update',
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
default=False,
autofill=True,
),
parameters.Str(
'idnsallowquery',
required=False,
cli_name='allow_query',
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
default=u'any;',
autofill=True,
no_convert=True,
),
parameters.Str(
'idnsallowtransfer',
required=False,
cli_name='allow_transfer',
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
default=u'none;',
autofill=True,
no_convert=True,
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
cli_name='dnssec',
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
default=False,
),
parameters.Str(
'nsec3paramrecord',
required=False,
cli_name='nsec3param_rec',
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'Force DNS zone creation even if nameserver is not resolvable.'),
default=False,
autofill=True,
),
parameters.Str(
'ip_address',
required=False,
exclude=('cli', 'webui'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_add_permission(Method):
__doc__ = _("Add a permission for per-zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnszone_del(Method):
__doc__ = _("Delete DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
multivalue=True,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnszone_disable(Method):
__doc__ = _("Disable DNS Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_enable(Method):
__doc__ = _("Enable DNS Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_find(Method):
__doc__ = _("Search for DNS zones (SOA records).")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.DNSNameParam(
'idnsname',
required=False,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
cli_name='zone_active',
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
cli_name='name_server',
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
required=False,
cli_name='admin_email',
label=_(u'Administrator e-mail address'),
default=DNSName(u'hostmaster'),
no_convert=True,
),
parameters.Int(
'idnssoaserial',
required=False,
cli_name='serial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# def _create_zone_serial():
# """
# Generate serial number for zones. bind-dyndb-ldap expects unix time in
# to be used for SOA serial.
#
# SOA serial in a date format would also work, but it may be set to far
# future when many DNS updates are done per day (more than 100). Unix
# timestamp is more resilient to this issue.
# """
# return int(time.time())
),
parameters.Int(
'idnssoarefresh',
required=False,
cli_name='refresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
default=3600,
),
parameters.Int(
'idnssoaretry',
required=False,
cli_name='retry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
default=900,
),
parameters.Int(
'idnssoaexpire',
required=False,
cli_name='expire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
default=1209600,
),
parameters.Int(
'idnssoaminimum',
required=False,
cli_name='minimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
default=3600,
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'idnsupdatepolicy',
required=False,
cli_name='update_policy',
label=_(u'BIND update policy'),
default_from=DefaultFrom(lambda idnsname: None, 'idnsname'),
# FIXME:
# lambda idnsname: default_zone_update_policy(idnsname)
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
cli_name='dynamic_update',
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
default=False,
),
parameters.Str(
'idnsallowquery',
required=False,
cli_name='allow_query',
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
default=u'any;',
no_convert=True,
),
parameters.Str(
'idnsallowtransfer',
required=False,
cli_name='allow_transfer',
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
default=u'none;',
no_convert=True,
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
cli_name='dnssec',
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
default=False,
),
parameters.Str(
'nsec3paramrecord',
required=False,
cli_name='nsec3param_rec',
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned'),
),
parameters.Flag(
'forward_only',
label=_(u'Forward zones only'),
doc=_(u'Search for forward zones only'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class dnszone_mod(Method):
__doc__ = _("Modify DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
cli_name='name_server',
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
required=False,
cli_name='admin_email',
label=_(u'Administrator e-mail address'),
default=DNSName(u'hostmaster'),
no_convert=True,
),
parameters.Int(
'idnssoaserial',
required=False,
cli_name='serial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# def _create_zone_serial():
# """
# Generate serial number for zones. bind-dyndb-ldap expects unix time in
# to be used for SOA serial.
#
# SOA serial in a date format would also work, but it may be set to far
# future when many DNS updates are done per day (more than 100). Unix
# timestamp is more resilient to this issue.
# """
# return int(time.time())
),
parameters.Int(
'idnssoarefresh',
required=False,
cli_name='refresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
default=3600,
),
parameters.Int(
'idnssoaretry',
required=False,
cli_name='retry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
default=900,
),
parameters.Int(
'idnssoaexpire',
required=False,
cli_name='expire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
default=1209600,
),
parameters.Int(
'idnssoaminimum',
required=False,
cli_name='minimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
default=3600,
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'idnsupdatepolicy',
required=False,
cli_name='update_policy',
label=_(u'BIND update policy'),
default_from=DefaultFrom(lambda idnsname: None, 'idnsname'),
# FIXME:
# lambda idnsname: default_zone_update_policy(idnsname)
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
cli_name='dynamic_update',
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
default=False,
),
parameters.Str(
'idnsallowquery',
required=False,
cli_name='allow_query',
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
default=u'any;',
no_convert=True,
),
parameters.Str(
'idnsallowtransfer',
required=False,
cli_name='allow_transfer',
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
default=u'none;',
no_convert=True,
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
cli_name='dnssec',
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
default=False,
),
parameters.Str(
'nsec3paramrecord',
required=False,
cli_name='nsec3param_rec',
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'Force nameserver change even if nameserver not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_remove_permission(Method):
__doc__ = _("Remove a permission for per-zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnszone_show(Method):
__doc__ = _("Display information about a DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 167,818
|
Python
|
.py
| 5,218
| 20.942698
| 192
| 0.502909
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,039
|
delegation.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/delegation.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Group to Group Delegation
A permission enables fine-grained delegation of permissions. Access Control
Rules, or instructions (ACIs), grant permission to permissions to perform
given tasks such as adding a user, modifying a group, etc.
Group to Group Delegations grants the members of one group to update a set
of attributes of members of another group.
EXAMPLES:
Add a delegation rule to allow managers to edit employee's addresses:
ipa delegation-add --attrs=street --group=managers --membergroup=employees "managers edit employees' street"
When managing the list of attributes you need to include all attributes
in the list, including existing ones. Add postalCode to the list:
ipa delegation-mod --attrs=street --attrs=postalCode --group=managers --membergroup=employees "managers edit employees' street"
Display our updated rule:
ipa delegation-show "managers edit employees' street"
Delete a rule:
ipa delegation-del "managers edit employees' street"
""")
register = Registry()
@register()
class delegation(Object):
takes_params = (
parameters.Str(
'aciname',
primary_key=True,
label=_(u'Delegation name'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the delegation applies'),
),
parameters.Str(
'memberof',
label=_(u'Member user group'),
doc=_(u'User group to apply delegation to'),
),
parameters.Str(
'group',
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
)
@register()
class delegation_add(Method):
__doc__ = _("Add a new delegation.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the delegation applies'),
no_convert=True,
),
parameters.Str(
'memberof',
cli_name='membergroup',
label=_(u'Member user group'),
doc=_(u'User group to apply delegation to'),
),
parameters.Str(
'group',
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class delegation_del(Method):
__doc__ = _("Delete a delegation.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Delegation name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class delegation_find(Method):
__doc__ = _("Search for delegations.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'aciname',
required=False,
cli_name='name',
label=_(u'Delegation name'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the delegation applies'),
no_convert=True,
),
parameters.Str(
'memberof',
required=False,
cli_name='membergroup',
label=_(u'Member user group'),
doc=_(u'User group to apply delegation to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class delegation_mod(Method):
__doc__ = _("Modify a delegation.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the delegation applies'),
no_convert=True,
),
parameters.Str(
'memberof',
required=False,
cli_name='membergroup',
label=_(u'Member user group'),
doc=_(u'User group to apply delegation to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class delegation_show(Method):
__doc__ = _("Display information about a delegation.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 10,698
|
Python
|
.py
| 354
| 20.525424
| 130
| 0.529326
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,040
|
stageuser.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/stageuser.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Stageusers
Manage stage user entries.
Stage user entries are directly under the container: "cn=stage users,
cn=accounts, cn=provisioning, SUFFIX".
User can not authenticate with those entries (even if the entries
contain credentials) and are candidate to become Active entries.
Active user entries are Posix users directly under the container: "cn=accounts, SUFFIX".
User can authenticate with Active entries, at the condition they have
credentials
Delete user entries are Posix users directly under the container: "cn=deleted users,
cn=accounts, cn=provisioning, SUFFIX".
User can not authenticate with those entries (even if the entries contain credentials)
The stage user container contains entries
- created by 'stageuser-add' commands that are Posix users
- created by external provisioning system
A valid stage user entry MUST:
- entry RDN is 'uid'
- ipaUniqueID is 'autogenerate'
IPA supports a wide range of username formats, but you need to be aware of any
restrictions that may apply to your particular environment. For example,
usernames that start with a digit or usernames that exceed a certain length
may cause problems for some UNIX systems.
Use 'ipa config-mod' to change the username format allowed by IPA tools.
EXAMPLES:
Add a new stageuser:
ipa stageuser-add --first=Tim --last=User --password tuser1
Add a stageuser from the Delete container
ipa stageuser-add --first=Tim --last=User --from-delete tuser1
""")
register = Registry()
@register()
class stageuser(Object):
takes_params = (
parameters.Str(
'uid',
primary_key=True,
label=_(u'User login'),
),
parameters.Str(
'givenname',
label=_(u'First name'),
),
parameters.Str(
'sn',
label=_(u'Last name'),
),
parameters.Str(
'cn',
label=_(u'Full name'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
),
parameters.Str(
'homedirectory',
required=False,
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Str(
'loginshell',
required=False,
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
label=_(u'Kerberos principal'),
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
),
parameters.Str(
'randompassword',
required=False,
label=_(u'Random password'),
),
parameters.Int(
'uidnumber',
required=False,
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
label=_(u'SSH public key'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Flag(
'has_password',
label=_(u'Password'),
),
parameters.Str(
'memberof_group',
required=False,
label=_(u'Member of groups'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberofindirect_group',
required=False,
label=_(u'Indirect Member of group'),
),
parameters.Str(
'memberofindirect_netgroup',
required=False,
label=_(u'Indirect Member of netgroup'),
),
parameters.Str(
'memberofindirect_role',
required=False,
label=_(u'Indirect Member of role'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
parameters.Flag(
'has_keytab',
label=_(u'Kerberos keys available'),
),
)
@register()
class stageuser_activate(Method):
__doc__ = _("Activate a stage user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class stageuser_add(Method):
__doc__ = _("Add a new stage user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'givenname',
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
autofill=True,
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
autofill=True,
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'principal'),
autofill=True,
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
autofill=True,
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Kerberos principal'),
default_from=DefaultFrom(lambda uid: '%s@%s' % (uid.lower(), api.env.realm), 'principal'),
autofill=True,
no_convert=True,
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
default=False,
autofill=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Bool(
'from_delete',
required=False,
deprecated=True,
doc=_(u'Create Stage user in from a delete user'),
exclude=('cli', 'webui'),
default=False,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class stageuser_del(Method):
__doc__ = _("Delete a stage user.")
takes_args = (
parameters.Str(
'uid',
multivalue=True,
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class stageuser_find(Method):
__doc__ = _("Search for stage users.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
parameters.Str(
'givenname',
required=False,
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
required=False,
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'principal'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Kerberos principal'),
default_from=DefaultFrom(lambda uid: '%s@%s' % (uid.lower(), api.env.realm), 'principal'),
no_convert=True,
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("login")'),
default=False,
autofill=True,
),
parameters.Str(
'in_group',
required=False,
multivalue=True,
cli_name='in_groups',
label=_(u'group'),
doc=_(u'Search for stage users with these member of groups.'),
),
parameters.Str(
'not_in_group',
required=False,
multivalue=True,
cli_name='not_in_groups',
label=_(u'group'),
doc=_(u'Search for stage users without these member of groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for stage users with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for stage users without these member of netgroups.'),
),
parameters.Str(
'in_role',
required=False,
multivalue=True,
cli_name='in_roles',
label=_(u'role'),
doc=_(u'Search for stage users with these member of roles.'),
),
parameters.Str(
'not_in_role',
required=False,
multivalue=True,
cli_name='not_in_roles',
label=_(u'role'),
doc=_(u'Search for stage users without these member of roles.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for stage users with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for stage users without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for stage users with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for stage users without these member of sudo rules.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class stageuser_mod(Method):
__doc__ = _("Modify a stage user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'givenname',
required=False,
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
required=False,
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'principal'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'principal'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
default=False,
autofill=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the stage user object'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class stageuser_show(Method):
__doc__ = _("Display information about a stage user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 43,617
|
Python
|
.py
| 1,456
| 18.866071
| 162
| 0.49327
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,041
|
role.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/role.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Roles
A role is used for fine-grained delegation. A permission grants the ability
to perform given low-level tasks (add a user, modify a group, etc.). A
privilege combines one or more permissions into a higher-level abstraction
such as useradmin. A useradmin would be able to add, delete and modify users.
Privileges are assigned to Roles.
Users, groups, hosts and hostgroups may be members of a Role.
Roles can not contain other roles.
EXAMPLES:
Add a new role:
ipa role-add --desc="Junior-level admin" junioradmin
Add some privileges to this role:
ipa role-add-privilege --privileges=addusers junioradmin
ipa role-add-privilege --privileges=change_password junioradmin
ipa role-add-privilege --privileges=add_user_to_default_group junioradmin
Add a group of users to this role:
ipa group-add --desc="User admins" useradmins
ipa role-add-member --groups=useradmins junioradmin
Display information about a role:
ipa role-show junioradmin
The result of this is that any users in the group 'junioradmin' can
add users, reset passwords or add a user to the default IPA user group.
""")
register = Registry()
@register()
class role(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Role name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this role-group'),
),
parameters.Str(
'member_user',
required=False,
label=_(u'Member users'),
),
parameters.Str(
'member_group',
required=False,
label=_(u'Member groups'),
),
parameters.Str(
'member_host',
required=False,
label=_(u'Member hosts'),
),
parameters.Str(
'member_hostgroup',
required=False,
label=_(u'Member host-groups'),
),
parameters.Str(
'memberof_privilege',
required=False,
label=_(u'Privileges'),
),
parameters.Str(
'member_service',
required=False,
label=_(u'Member services'),
),
)
@register()
class role_add(Method):
__doc__ = _("Add a new role.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this role-group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class role_add_member(Method):
__doc__ = _("Add members to a role.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
parameters.Str(
'service',
required=False,
multivalue=True,
cli_name='services',
label=_(u'member service'),
doc=_(u'services to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class role_add_privilege(Method):
__doc__ = _("Add privileges to a role.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'privilege',
required=False,
multivalue=True,
cli_name='privileges',
label=_(u'privilege'),
doc=_(u'privileges'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of privileges added'),
),
)
@register()
class role_del(Method):
__doc__ = _("Delete a role.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class role_find(Method):
__doc__ = _("Search for roles.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Role name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this role-group'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class role_mod(Method):
__doc__ = _("Modify a role.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this role-group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the role object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class role_remove_member(Method):
__doc__ = _("Remove members from a role.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
parameters.Str(
'service',
required=False,
multivalue=True,
cli_name='services',
label=_(u'member service'),
doc=_(u'services to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class role_remove_privilege(Method):
__doc__ = _("Remove privileges from a role.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'privilege',
required=False,
multivalue=True,
cli_name='privileges',
label=_(u'privilege'),
doc=_(u'privileges'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of privileges removed'),
),
)
@register()
class role_show(Method):
__doc__ = _("Display information about a role.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Role name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 20,727
|
Python
|
.py
| 714
| 18.731092
| 162
| 0.499674
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,042
|
automount.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/automount.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Automount
Stores automount(8) configuration for autofs(8) in IPA.
The base of an automount configuration is the configuration file auto.master.
This is also the base location in IPA. Multiple auto.master configurations
can be stored in separate locations. A location is implementation-specific
with the default being a location named 'default'. For example, you can have
locations by geographic region, by floor, by type, etc.
Automount has three basic object types: locations, maps and keys.
A location defines a set of maps anchored in auto.master. This allows you
to store multiple automount configurations. A location in itself isn't
very interesting, it is just a point to start a new automount map.
A map is roughly equivalent to a discrete automount file and provides
storage for keys.
A key is a mount point associated with a map.
When a new location is created, two maps are automatically created for
it: auto.master and auto.direct. auto.master is the root map for all
automount maps for the location. auto.direct is the default map for
direct mounts and is mounted on /-.
An automount map may contain a submount key. This key defines a mount
location within the map that references another map. This can be done
either using automountmap-add-indirect --parentmap or manually
with automountkey-add and setting info to "-type=autofs :<mapname>".
EXAMPLES:
Locations:
Create a named location, "Baltimore":
ipa automountlocation-add baltimore
Display the new location:
ipa automountlocation-show baltimore
Find available locations:
ipa automountlocation-find
Remove a named automount location:
ipa automountlocation-del baltimore
Show what the automount maps would look like if they were in the filesystem:
ipa automountlocation-tofiles baltimore
Import an existing configuration into a location:
ipa automountlocation-import baltimore /etc/auto.master
The import will fail if any duplicate entries are found. For
continuous operation where errors are ignored, use the --continue
option.
Maps:
Create a new map, "auto.share":
ipa automountmap-add baltimore auto.share
Display the new map:
ipa automountmap-show baltimore auto.share
Find maps in the location baltimore:
ipa automountmap-find baltimore
Create an indirect map with auto.share as a submount:
ipa automountmap-add-indirect baltimore --parentmap=auto.share --mount=sub auto.man
This is equivalent to:
ipa automountmap-add-indirect baltimore --mount=/man auto.man
ipa automountkey-add baltimore auto.man --key=sub --info="-fstype=autofs ldap:auto.share"
Remove the auto.share map:
ipa automountmap-del baltimore auto.share
Keys:
Create a new key for the auto.share map in location baltimore. This ties
the map we previously created to auto.master:
ipa automountkey-add baltimore auto.master --key=/share --info=auto.share
Create a new key for our auto.share map, an NFS mount for man pages:
ipa automountkey-add baltimore auto.share --key=man --info="-ro,soft,rsize=8192,wsize=8192 ipa.example.com:/shared/man"
Find all keys for the auto.share map:
ipa automountkey-find baltimore auto.share
Find all direct automount keys:
ipa automountkey-find baltimore --key=/-
Remove the man key from the auto.share map:
ipa automountkey-del baltimore auto.share --key=man
""")
register = Registry()
@register()
class automountkey(Object):
takes_params = (
parameters.Str(
'automountkey',
label=_(u'Key'),
doc=_(u'Automount key name.'),
),
parameters.Str(
'automountinformation',
label=_(u'Mount information'),
),
parameters.Str(
'description',
required=False,
primary_key=True,
label=_(u'description'),
exclude=('webui', 'cli'),
),
)
@register()
class automountlocation(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
)
@register()
class automountmap(Object):
takes_params = (
parameters.Str(
'automountmapname',
primary_key=True,
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
)
@register()
class automountkey_add(Method):
__doc__ = _("Create a new automount key.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapautomountmapname',
cli_name='automountmap',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Str(
'automountkey',
cli_name='key',
label=_(u'Key'),
doc=_(u'Automount key name.'),
),
parameters.Str(
'automountinformation',
cli_name='info',
label=_(u'Mount information'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountkey_del(Method):
__doc__ = _("Delete an automount key.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapautomountmapname',
cli_name='automountmap',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'automountkey',
cli_name='key',
label=_(u'Key'),
doc=_(u'Automount key name.'),
),
parameters.Str(
'automountinformation',
required=False,
cli_name='info',
label=_(u'Mount information'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class automountkey_find(Method):
__doc__ = _("Search for an automount key.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapautomountmapname',
cli_name='automountmap',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'automountkey',
required=False,
cli_name='key',
label=_(u'Key'),
doc=_(u'Automount key name.'),
),
parameters.Str(
'automountinformation',
required=False,
cli_name='info',
label=_(u'Mount information'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class automountkey_mod(Method):
__doc__ = _("Modify an automount key.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapautomountmapname',
cli_name='automountmap',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Str(
'automountkey',
cli_name='key',
label=_(u'Key'),
doc=_(u'Automount key name.'),
),
parameters.Str(
'automountinformation',
required=False,
cli_name='info',
label=_(u'Mount information'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'newautomountinformation',
required=False,
cli_name='newinfo',
label=_(u'New mount information'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the automount key object'),
exclude=('webui',),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountkey_show(Method):
__doc__ = _("Display an automount key.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapautomountmapname',
cli_name='automountmap',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'automountkey',
cli_name='key',
label=_(u'Key'),
doc=_(u'Automount key name.'),
),
parameters.Str(
'automountinformation',
required=False,
cli_name='info',
label=_(u'Mount information'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountlocation_add(Method):
__doc__ = _("Create a new automount location.")
takes_args = (
parameters.Str(
'cn',
cli_name='location',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
)
takes_options = (
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountlocation_del(Method):
__doc__ = _("Delete an automount location.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='location',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class automountlocation_find(Method):
__doc__ = _("Search for an automount location.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='location',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("location")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class automountlocation_show(Method):
__doc__ = _("Display an automount location.")
takes_args = (
parameters.Str(
'cn',
cli_name='location',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountlocation_tofiles(Method):
__doc__ = _("Generate automount files for a specific location.")
takes_args = (
parameters.Str(
'cn',
cli_name='location',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class automountmap_add(Method):
__doc__ = _("Create a new automount map.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapname',
cli_name='map',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountmap_add_indirect(Method):
__doc__ = _("Create a new indirect mount point.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapname',
cli_name='map',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'key',
cli_name='mount',
label=_(u'Mount point'),
),
parameters.Str(
'parentmap',
required=False,
label=_(u'Parent map'),
doc=_(u'Name of parent automount map (default: auto.master).'),
default=u'auto.master',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountmap_del(Method):
__doc__ = _("Delete an automount map.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapname',
multivalue=True,
cli_name='map',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class automountmap_find(Method):
__doc__ = _("Search for an automount map.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'automountmapname',
required=False,
cli_name='map',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("map")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class automountmap_mod(Method):
__doc__ = _("Modify an automount map.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapname',
cli_name='map',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automountmap_show(Method):
__doc__ = _("Display an automount map.")
takes_args = (
parameters.Str(
'automountlocationcn',
cli_name='automountlocation',
label=_(u'Location'),
doc=_(u'Automount location name.'),
),
parameters.Str(
'automountmapname',
cli_name='map',
label=_(u'Map'),
doc=_(u'Automount map name.'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 35,304
|
Python
|
.py
| 1,138
| 21.031634
| 162
| 0.528847
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,043
|
selfservice.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/selfservice.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Self-service Permissions
A permission enables fine-grained delegation of permissions. Access Control
Rules, or instructions (ACIs), grant permission to permissions to perform
given tasks such as adding a user, modifying a group, etc.
A Self-service permission defines what an object can change in its own entry.
EXAMPLES:
Add a self-service rule to allow users to manage their address (using Bash
brace expansion):
ipa selfservice-add --permissions=write --attrs={street,postalCode,l,c,st} "Users manage their own address"
When managing the list of attributes you need to include all attributes
in the list, including existing ones.
Add telephoneNumber to the list (using Bash brace expansion):
ipa selfservice-mod --attrs={street,postalCode,l,c,st,telephoneNumber} "Users manage their own address"
Display our updated rule:
ipa selfservice-show "Users manage their own address"
Delete a rule:
ipa selfservice-del "Users manage their own address"
""")
register = Registry()
@register()
class selfservice(Object):
takes_params = (
parameters.Str(
'aciname',
primary_key=True,
label=_(u'Self-service name'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the permission applies.'),
),
)
@register()
class selfservice_add(Method):
__doc__ = _("Add a new self-service permission.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Self-service name'),
),
)
takes_options = (
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the permission applies.'),
no_convert=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selfservice_del(Method):
__doc__ = _("Delete a self-service permission.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Self-service name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selfservice_find(Method):
__doc__ = _("Search for a self-service permission.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'aciname',
required=False,
cli_name='name',
label=_(u'Self-service name'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the permission applies.'),
no_convert=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class selfservice_mod(Method):
__doc__ = _("Modify a self-service permission.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Self-service name'),
),
)
takes_options = (
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant (read, write). Default is write.'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes'),
doc=_(u'Attributes to which the permission applies.'),
no_convert=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selfservice_show(Method):
__doc__ = _("Display information about a self-service permission.")
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'Self-service name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 9,336
|
Python
|
.py
| 308
| 20.931818
| 110
| 0.540453
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,044
|
sudorule.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/sudorule.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Sudo Rules
Sudo (su "do") allows a system administrator to delegate authority to
give certain users (or groups of users) the ability to run some (or all)
commands as root or another user while providing an audit trail of the
commands and their arguments.
IPA provides a means to configure the various aspects of Sudo:
Users: The user(s)/group(s) allowed to invoke Sudo.
Hosts: The host(s)/hostgroup(s) which the user is allowed to to invoke Sudo.
Allow Command: The specific command(s) permitted to be run via Sudo.
Deny Command: The specific command(s) prohibited to be run via Sudo.
RunAsUser: The user(s) or group(s) of users whose rights Sudo will be invoked with.
RunAsGroup: The group(s) whose gid rights Sudo will be invoked with.
Options: The various Sudoers Options that can modify Sudo's behavior.
An order can be added to a sudorule to control the order in which they
are evaluated (if the client supports it). This order is an integer and
must be unique.
IPA provides a designated binddn to use with Sudo located at:
uid=sudo,cn=sysaccounts,cn=etc,dc=example,dc=com
To enable the binddn run the following command to set the password:
LDAPTLS_CACERT=/etc/ipa/ca.crt /usr/bin/ldappasswd -S -W \\
-H ldap://ipa.example.com -ZZ -D "cn=Directory Manager" \\
uid=sudo,cn=sysaccounts,cn=etc,dc=example,dc=com
EXAMPLES:
Create a new rule:
ipa sudorule-add readfiles
Add sudo command object and add it as allowed command in the rule:
ipa sudocmd-add /usr/bin/less
ipa sudorule-add-allow-command readfiles --sudocmds /usr/bin/less
Add a host to the rule:
ipa sudorule-add-host readfiles --hosts server.example.com
Add a user to the rule:
ipa sudorule-add-user readfiles --users jsmith
Add a special Sudo rule for default Sudo server configuration:
ipa sudorule-add defaults
Set a default Sudo option:
ipa sudorule-add-option defaults --sudooption '!authenticate'
""")
register = Registry()
@register()
class sudorule(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Rule name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'cmdcategory',
required=False,
label=_(u'Command category'),
doc=_(u'Command category the rule applies to'),
),
parameters.Str(
'ipasudorunasusercategory',
required=False,
label=_(u'RunAs User category'),
doc=_(u'RunAs User category the rule applies to'),
),
parameters.Str(
'ipasudorunasgroupcategory',
required=False,
label=_(u'RunAs Group category'),
doc=_(u'RunAs Group category the rule applies to'),
),
parameters.Int(
'sudoorder',
required=False,
label=_(u'Sudo order'),
doc=_(u'integer to order the Sudo rules'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Users'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'User Groups'),
),
parameters.Str(
'externaluser',
required=False,
label=_(u'External User'),
doc=_(u'External User the rule applies to (sudorule-find only)'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Hosts'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Host Groups'),
),
parameters.Str(
'hostmask',
multivalue=True,
label=_(u'Host Masks'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
),
parameters.Str(
'memberallowcmd_sudocmd',
required=False,
label=_(u'Sudo Allow Commands'),
),
parameters.Str(
'memberdenycmd_sudocmd',
required=False,
label=_(u'Sudo Deny Commands'),
),
parameters.Str(
'memberallowcmd_sudocmdgroup',
required=False,
label=_(u'Sudo Allow Command Groups'),
),
parameters.Str(
'memberdenycmd_sudocmdgroup',
required=False,
label=_(u'Sudo Deny Command Groups'),
),
parameters.Str(
'ipasudorunas_user',
required=False,
label=_(u'RunAs Users'),
doc=_(u'Run as a user'),
),
parameters.Str(
'ipasudorunas_group',
required=False,
label=_(u'Groups of RunAs Users'),
doc=_(u'Run as any user within a specified group'),
),
parameters.Str(
'ipasudorunasextuser',
required=False,
label=_(u'RunAs External User'),
doc=_(u'External User the commands can run as (sudorule-find only)'),
),
parameters.Str(
'ipasudorunasextusergroup',
required=False,
label=_(u'External Groups of RunAs Users'),
doc=_(u'External Groups of users that the command can run as'),
),
parameters.Str(
'ipasudorunasgroup_group',
required=False,
label=_(u'RunAs Groups'),
doc=_(u'Run with the gid of a specified POSIX group'),
),
parameters.Str(
'ipasudorunasextgroup',
required=False,
label=_(u'RunAs External Group'),
doc=_(u'External Group the commands can run as (sudorule-find only)'),
),
parameters.Str(
'ipasudoopt',
required=False,
label=_(u'Sudo Option'),
),
)
@register()
class sudorule_add(Method):
__doc__ = _("Create new Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'cmdcategory',
required=False,
cli_name='cmdcat',
cli_metavar="['all']",
label=_(u'Command category'),
doc=_(u'Command category the rule applies to'),
),
parameters.Str(
'ipasudorunasusercategory',
required=False,
cli_name='runasusercat',
cli_metavar="['all']",
label=_(u'RunAs User category'),
doc=_(u'RunAs User category the rule applies to'),
),
parameters.Str(
'ipasudorunasgroupcategory',
required=False,
cli_name='runasgroupcat',
cli_metavar="['all']",
label=_(u'RunAs Group category'),
doc=_(u'RunAs Group category the rule applies to'),
),
parameters.Int(
'sudoorder',
required=False,
cli_name='order',
label=_(u'Sudo order'),
doc=_(u'integer to order the Sudo rules'),
default=0,
),
parameters.Str(
'externaluser',
required=False,
label=_(u'External User'),
doc=_(u'External User the rule applies to (sudorule-find only)'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasudorunasextuser',
required=False,
cli_name='runasexternaluser',
label=_(u'RunAs External User'),
doc=_(u'External User the commands can run as (sudorule-find only)'),
),
parameters.Str(
'ipasudorunasextgroup',
required=False,
cli_name='runasexternalgroup',
label=_(u'RunAs External Group'),
doc=_(u'External Group the commands can run as (sudorule-find only)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudorule_add_allow_command(Method):
__doc__ = _("Add commands and sudo command groups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to add'),
alwaysask=True,
),
parameters.Str(
'sudocmdgroup',
required=False,
multivalue=True,
cli_name='sudocmdgroups',
label=_(u'member sudo command group'),
doc=_(u'sudo command groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudorule_add_deny_command(Method):
__doc__ = _("Add commands and sudo command groups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to add'),
alwaysask=True,
),
parameters.Str(
'sudocmdgroup',
required=False,
multivalue=True,
cli_name='sudocmdgroups',
label=_(u'member sudo command group'),
doc=_(u'sudo command groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudorule_add_host(Method):
__doc__ = _("Add hosts and hostgroups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
parameters.Str(
'hostmask',
required=False,
multivalue=True,
label=_(u'host masks of allowed hosts'),
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudorule_add_option(Method):
__doc__ = _("Add an option to the Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'ipasudoopt',
cli_name='sudooption',
label=_(u'Sudo Option'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudorule_add_runasgroup(Method):
__doc__ = _("Add group for Sudo to execute as.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudorule_add_runasuser(Method):
__doc__ = _("Add users and groups for Sudo to execute as.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudorule_add_user(Method):
__doc__ = _("Add users and groups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudorule_del(Method):
__doc__ = _("Delete Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class sudorule_disable(Method):
__doc__ = _("Disable a Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class sudorule_enable(Method):
__doc__ = _("Enable a Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class sudorule_find(Method):
__doc__ = _("Search for Sudo Rule.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='sudorule_name',
label=_(u'Rule name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'cmdcategory',
required=False,
cli_name='cmdcat',
cli_metavar="['all']",
label=_(u'Command category'),
doc=_(u'Command category the rule applies to'),
),
parameters.Str(
'ipasudorunasusercategory',
required=False,
cli_name='runasusercat',
cli_metavar="['all']",
label=_(u'RunAs User category'),
doc=_(u'RunAs User category the rule applies to'),
),
parameters.Str(
'ipasudorunasgroupcategory',
required=False,
cli_name='runasgroupcat',
cli_metavar="['all']",
label=_(u'RunAs Group category'),
doc=_(u'RunAs Group category the rule applies to'),
),
parameters.Int(
'sudoorder',
required=False,
cli_name='order',
label=_(u'Sudo order'),
doc=_(u'integer to order the Sudo rules'),
default=0,
),
parameters.Str(
'externaluser',
required=False,
label=_(u'External User'),
doc=_(u'External User the rule applies to (sudorule-find only)'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasudorunasextuser',
required=False,
cli_name='runasexternaluser',
label=_(u'RunAs External User'),
doc=_(u'External User the commands can run as (sudorule-find only)'),
),
parameters.Str(
'ipasudorunasextgroup',
required=False,
cli_name='runasexternalgroup',
label=_(u'RunAs External Group'),
doc=_(u'External Group the commands can run as (sudorule-find only)'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("sudorule-name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class sudorule_mod(Method):
__doc__ = _("Modify Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'cmdcategory',
required=False,
cli_name='cmdcat',
cli_metavar="['all']",
label=_(u'Command category'),
doc=_(u'Command category the rule applies to'),
),
parameters.Str(
'ipasudorunasusercategory',
required=False,
cli_name='runasusercat',
cli_metavar="['all']",
label=_(u'RunAs User category'),
doc=_(u'RunAs User category the rule applies to'),
),
parameters.Str(
'ipasudorunasgroupcategory',
required=False,
cli_name='runasgroupcat',
cli_metavar="['all']",
label=_(u'RunAs Group category'),
doc=_(u'RunAs Group category the rule applies to'),
),
parameters.Int(
'sudoorder',
required=False,
cli_name='order',
label=_(u'Sudo order'),
doc=_(u'integer to order the Sudo rules'),
default=0,
),
parameters.Str(
'externaluser',
required=False,
label=_(u'External User'),
doc=_(u'External User the rule applies to (sudorule-find only)'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasudorunasextuser',
required=False,
cli_name='runasexternaluser',
label=_(u'RunAs External User'),
doc=_(u'External User the commands can run as (sudorule-find only)'),
),
parameters.Str(
'ipasudorunasextgroup',
required=False,
cli_name='runasexternalgroup',
label=_(u'RunAs External Group'),
doc=_(u'External Group the commands can run as (sudorule-find only)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudorule_remove_allow_command(Method):
__doc__ = _("Remove commands and sudo command groups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to remove'),
alwaysask=True,
),
parameters.Str(
'sudocmdgroup',
required=False,
multivalue=True,
cli_name='sudocmdgroups',
label=_(u'member sudo command group'),
doc=_(u'sudo command groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudorule_remove_deny_command(Method):
__doc__ = _("Remove commands and sudo command groups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to remove'),
alwaysask=True,
),
parameters.Str(
'sudocmdgroup',
required=False,
multivalue=True,
cli_name='sudocmdgroups',
label=_(u'member sudo command group'),
doc=_(u'sudo command groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudorule_remove_host(Method):
__doc__ = _("Remove hosts and hostgroups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
parameters.Str(
'hostmask',
required=False,
multivalue=True,
label=_(u'host masks of allowed hosts'),
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudorule_remove_option(Method):
__doc__ = _("Remove an option from Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'ipasudoopt',
cli_name='sudooption',
label=_(u'Sudo Option'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudorule_remove_runasgroup(Method):
__doc__ = _("Remove group for Sudo to execute as.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudorule_remove_runasuser(Method):
__doc__ = _("Remove users and groups for Sudo to execute as.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudorule_remove_user(Method):
__doc__ = _("Remove users and groups affected by Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudorule_show(Method):
__doc__ = _("Display Sudo Rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudorule_name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 50,260
|
Python
|
.py
| 1,694
| 19.090909
| 162
| 0.49835
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,045
|
migration.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/migration.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Migration to IPA
Migrate users and groups from an LDAP server to IPA.
This performs an LDAP query against the remote server searching for
users and groups in a container. In order to migrate passwords you need
to bind as a user that can read the userPassword attribute on the remote
server. This is generally restricted to high-level admins such as
cn=Directory Manager in 389-ds (this is the default bind user).
The default user container is ou=People.
The default group container is ou=Groups.
Users and groups that already exist on the IPA server are skipped.
Two LDAP schemas define how group members are stored: RFC2307 and
RFC2307bis. RFC2307bis uses member and uniquemember to specify group
members, RFC2307 uses memberUid. The default schema is RFC2307bis.
The schema compat feature allows IPA to reformat data for systems that
do not support RFC2307bis. It is recommended that this feature is disabled
during migration to reduce system overhead. It can be re-enabled after
migration. To migrate with it enabled use the "--with-compat" option.
Migrated users do not have Kerberos credentials, they have only their
LDAP password. To complete the migration process, users need to go
to http://ipa.example.com/ipa/migration and authenticate using their
LDAP password in order to generate their Kerberos credentials.
Migration is disabled by default. Use the command ipa config-mod to
enable it:
ipa config-mod --enable-migration=TRUE
If a base DN is not provided with --basedn then IPA will use either
the value of defaultNamingContext if it is set or the first value
in namingContexts set in the root of the remote LDAP server.
Users are added as members to the default user group. This can be a
time-intensive task so during migration this is done in a batch
mode for every 100 users. As a result there will be a window in which
users will be added to IPA but will not be members of the default
user group.
EXAMPLES:
The simplest migration, accepting all defaults:
ipa migrate-ds ldap://ds.example.com:389
Specify the user and group container. This can be used to migrate user
and group data from an IPA v1 server:
ipa migrate-ds --user-container='cn=users,cn=accounts' \
--group-container='cn=groups,cn=accounts' \
ldap://ds.example.com:389
Since IPA v2 server already contain predefined groups that may collide with
groups in migrated (IPA v1) server (for example admins, ipausers), users
having colliding group as their primary group may happen to belong to
an unknown group on new IPA v2 server.
Use --group-overwrite-gid option to overwrite GID of already existing groups
to prevent this issue:
ipa migrate-ds --group-overwrite-gid \
--user-container='cn=users,cn=accounts' \
--group-container='cn=groups,cn=accounts' \
ldap://ds.example.com:389
Migrated users or groups may have object class and accompanied attributes
unknown to the IPA v2 server. These object classes and attributes may be
left out of the migration process:
ipa migrate-ds --user-container='cn=users,cn=accounts' \
--group-container='cn=groups,cn=accounts' \
--user-ignore-objectclass=radiusprofile \
--user-ignore-attribute=radiusgroupname \
ldap://ds.example.com:389
LOGGING
Migration will log warnings and errors to the Apache error log. This
file should be evaluated post-migration to correct or investigate any
issues that were discovered.
For every 100 users migrated an info-level message will be displayed to
give the current progress and duration to make it possible to track
the progress of migration.
If the log level is debug, either by setting debug = True in
/etc/ipa/default.conf or /etc/ipa/server.conf, then an entry will be printed
for each user added plus a summary when the default user group is
updated.
""")
register = Registry()
@register()
class migrate_ds(Command):
__doc__ = _("Migrate users and groups from DS to IPA.")
takes_args = (
parameters.Str(
'ldapuri',
cli_name='ldap_uri',
label=_(u'LDAP URI'),
doc=_(u'LDAP URI of DS server to migrate from'),
),
parameters.Password(
'bindpw',
cli_name='password',
label=_(u'Password'),
doc=_(u'bind password'),
),
)
takes_options = (
parameters.DNParam(
'binddn',
required=False,
cli_name='bind_dn',
label=_(u'Bind DN'),
default=DN(u'cn=directory manager'),
autofill=True,
),
parameters.DNParam(
'usercontainer',
cli_name='user_container',
label=_(u'User container'),
doc=_(u'DN of container for users in DS relative to base DN'),
default=DN(u'ou=people'),
autofill=True,
),
parameters.DNParam(
'groupcontainer',
cli_name='group_container',
label=_(u'Group container'),
doc=_(u'DN of container for groups in DS relative to base DN'),
default=DN(u'ou=groups'),
autofill=True,
),
parameters.Str(
'userobjectclass',
multivalue=True,
cli_name='user_objectclass',
label=_(u'User object class'),
doc=_(u'Objectclasses used to search for user entries in DS'),
default=(u'person',),
autofill=True,
),
parameters.Str(
'groupobjectclass',
multivalue=True,
cli_name='group_objectclass',
label=_(u'Group object class'),
doc=_(u'Objectclasses used to search for group entries in DS'),
default=(u'groupOfUniqueNames', u'groupOfNames'),
autofill=True,
),
parameters.Str(
'userignoreobjectclass',
required=False,
multivalue=True,
cli_name='user_ignore_objectclass',
label=_(u'Ignore user object class'),
doc=_(u'Objectclasses to be ignored for user entries in DS'),
default=(),
autofill=True,
),
parameters.Str(
'userignoreattribute',
required=False,
multivalue=True,
cli_name='user_ignore_attribute',
label=_(u'Ignore user attribute'),
doc=_(u'Attributes to be ignored for user entries in DS'),
default=(),
autofill=True,
),
parameters.Str(
'groupignoreobjectclass',
required=False,
multivalue=True,
cli_name='group_ignore_objectclass',
label=_(u'Ignore group object class'),
doc=_(u'Objectclasses to be ignored for group entries in DS'),
default=(),
autofill=True,
),
parameters.Str(
'groupignoreattribute',
required=False,
multivalue=True,
cli_name='group_ignore_attribute',
label=_(u'Ignore group attribute'),
doc=_(u'Attributes to be ignored for group entries in DS'),
default=(),
autofill=True,
),
parameters.Flag(
'groupoverwritegid',
cli_name='group_overwrite_gid',
label=_(u'Overwrite GID'),
doc=_(u'When migrating a group already existing in IPA domain overwrite the group GID and report as success'),
default=False,
autofill=True,
),
parameters.Str(
'schema',
required=False,
cli_metavar="['RFC2307bis', 'RFC2307']",
label=_(u'LDAP schema'),
doc=_(u'The schema used on the LDAP server. Supported values are RFC2307 and RFC2307bis. The default is RFC2307bis'),
default=u'RFC2307bis',
autofill=True,
),
parameters.Flag(
'continue',
required=False,
label=_(u'Continue'),
doc=_(u'Continuous operation mode. Errors are reported but the process continues'),
default=False,
autofill=True,
),
parameters.DNParam(
'basedn',
required=False,
cli_name='base_dn',
label=_(u'Base DN'),
doc=_(u'Base DN on remote LDAP server'),
),
parameters.Flag(
'compat',
required=False,
cli_name='with_compat',
label=_(u'Ignore compat plugin'),
doc=_(u'Allows migration despite the usage of compat plugin'),
default=False,
autofill=True,
),
parameters.Str(
'cacertfile',
required=False,
cli_name='ca_cert_file',
label=_(u'CA certificate'),
doc=_(u'Load CA certificate of LDAP server from FILE'),
),
parameters.Bool(
'use_def_group',
required=False,
cli_name='use_default_group',
label=_(u'Add to default group'),
doc=_(u'Add migrated users without a group to a default group (default: true)'),
default=True,
autofill=True,
),
parameters.Str(
'scope',
cli_metavar="['base', 'subtree', 'onelevel']",
label=_(u'Search scope'),
doc=_(u'LDAP search scope for users and groups: base, onelevel, or subtree. Defaults to onelevel'),
default=u'onelevel',
autofill=True,
),
parameters.Str(
'exclude_groups',
required=False,
multivalue=True,
doc=_(u'groups to exclude from migration'),
default=(),
autofill=True,
),
parameters.Str(
'exclude_users',
required=False,
multivalue=True,
doc=_(u'users to exclude from migration'),
default=(),
autofill=True,
),
)
has_output = (
output.Output(
'result',
dict,
doc=_(u'Lists of objects migrated; categorized by type.'),
),
output.Output(
'failed',
dict,
doc=_(u'Lists of objects that could not be migrated; categorized by type.'),
),
output.Output(
'enabled',
bool,
doc=_(u'False if migration mode was disabled.'),
),
output.Output(
'compat',
bool,
doc=_(u'False if migration fails because the compatibility plug-in is enabled.'),
),
)
| 11,089
|
Python
|
.py
| 290
| 29.327586
| 129
| 0.620427
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,046
|
user.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/user.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Users
Manage user entries. All users are POSIX users.
IPA supports a wide range of username formats, but you need to be aware of any
restrictions that may apply to your particular environment. For example,
usernames that start with a digit or usernames that exceed a certain length
may cause problems for some UNIX systems.
Use 'ipa config-mod' to change the username format allowed by IPA tools.
Disabling a user account prevents that user from obtaining new Kerberos
credentials. It does not invalidate any credentials that have already
been issued.
Password management is not a part of this module. For more information
about this topic please see: ipa help passwd
Account lockout on password failure happens per IPA master. The user-status
command can be used to identify which master the user is locked out on.
It is on that master the administrator must unlock the user.
EXAMPLES:
Add a new user:
ipa user-add --first=Tim --last=User --password tuser1
Find all users whose entries include the string "Tim":
ipa user-find Tim
Find all users with "Tim" as the first name:
ipa user-find --first=Tim
Disable a user account:
ipa user-disable tuser1
Enable a user account:
ipa user-enable tuser1
Delete a user:
ipa user-del tuser1
""")
register = Registry()
@register()
class user(Object):
takes_params = (
parameters.Str(
'uid',
primary_key=True,
label=_(u'User login'),
),
parameters.Str(
'givenname',
label=_(u'First name'),
),
parameters.Str(
'sn',
label=_(u'Last name'),
),
parameters.Str(
'cn',
label=_(u'Full name'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
),
parameters.Str(
'homedirectory',
required=False,
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Str(
'loginshell',
required=False,
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
label=_(u'Kerberos principal'),
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
),
parameters.Str(
'randompassword',
required=False,
label=_(u'Random password'),
),
parameters.Int(
'uidnumber',
required=False,
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
label=_(u'SSH public key'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
),
parameters.Bool(
'preserved',
required=False,
label=_(u'Preserved user'),
),
parameters.Flag(
'has_password',
label=_(u'Password'),
),
parameters.Str(
'memberof_group',
required=False,
label=_(u'Member of groups'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberofindirect_group',
required=False,
label=_(u'Indirect Member of group'),
),
parameters.Str(
'memberofindirect_netgroup',
required=False,
label=_(u'Indirect Member of netgroup'),
),
parameters.Str(
'memberofindirect_role',
required=False,
label=_(u'Indirect Member of role'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
parameters.Flag(
'has_keytab',
label=_(u'Kerberos keys available'),
),
)
@register()
class user_add(Method):
__doc__ = _("Add a new user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'givenname',
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
autofill=True,
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
autofill=True,
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
autofill=True,
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
autofill=True,
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Kerberos principal'),
default_from=DefaultFrom(lambda uid: '%s@%s' % (uid.lower(), api.env.realm), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
autofill=True,
no_convert=True,
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
default=False,
autofill=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'noprivate',
doc=_(u"Don't create user private group"),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_add_cert(Method):
__doc__ = _("Add one or more certificates to the user entry")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
alwaysask=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_del(Method):
__doc__ = _("Delete a user.")
takes_args = (
parameters.Str(
'uid',
multivalue=True,
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Bool(
'preserve',
required=False,
exclude=('cli',),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class user_disable(Method):
__doc__ = _("Disable a user account.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_enable(Method):
__doc__ = _("Enable a user account.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_find(Method):
__doc__ = _("Search for users.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
parameters.Str(
'givenname',
required=False,
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
required=False,
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Kerberos principal'),
default_from=DefaultFrom(lambda uid: '%s@%s' % (uid.lower(), api.env.realm), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
exclude=('cli', 'webui'),
),
parameters.Bool(
'preserved',
required=False,
label=_(u'Preserved user'),
default=False,
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'whoami',
label=_(u'Self'),
doc=_(u'Display user record for current Kerberos principal'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("login")'),
default=False,
autofill=True,
),
parameters.Str(
'in_group',
required=False,
multivalue=True,
cli_name='in_groups',
label=_(u'group'),
doc=_(u'Search for users with these member of groups.'),
),
parameters.Str(
'not_in_group',
required=False,
multivalue=True,
cli_name='not_in_groups',
label=_(u'group'),
doc=_(u'Search for users without these member of groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for users with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for users without these member of netgroups.'),
),
parameters.Str(
'in_role',
required=False,
multivalue=True,
cli_name='in_roles',
label=_(u'role'),
doc=_(u'Search for users with these member of roles.'),
),
parameters.Str(
'not_in_role',
required=False,
multivalue=True,
cli_name='not_in_roles',
label=_(u'role'),
doc=_(u'Search for users without these member of roles.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for users with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for users without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for users with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for users without these member of sudo rules.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class user_mod(Method):
__doc__ = _("Modify a user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'givenname',
required=False,
cli_name='first',
label=_(u'First name'),
),
parameters.Str(
'sn',
required=False,
cli_name='last',
label=_(u'Last name'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Full name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'displayname',
required=False,
label=_(u'Display name'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'initials',
required=False,
label=_(u'Initials'),
default_from=DefaultFrom(lambda givenname, sn: '%c%c' % (givenname[0], sn[0]), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
default_from=DefaultFrom(lambda givenname, sn: '%s %s' % (givenname, sn), 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.DateTime(
'krbprincipalexpiration',
required=False,
cli_name='principal_expiration',
label=_(u'Kerberos principal expiration'),
),
parameters.Str(
'mail',
required=False,
multivalue=True,
cli_name='email',
label=_(u'Email address'),
),
parameters.Password(
'userpassword',
required=False,
cli_name='password',
label=_(u'Password'),
doc=_(u'Prompt to set the user password'),
exclude=('webui',),
confirm=True,
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random user password'),
default=False,
autofill=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number (system will assign one if not provided)'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'street',
required=False,
label=_(u'Street address'),
),
parameters.Str(
'l',
required=False,
cli_name='city',
label=_(u'City'),
),
parameters.Str(
'st',
required=False,
cli_name='state',
label=_(u'State/Province'),
),
parameters.Str(
'postalcode',
required=False,
label=_(u'ZIP'),
),
parameters.Str(
'telephonenumber',
required=False,
multivalue=True,
cli_name='phone',
label=_(u'Telephone Number'),
),
parameters.Str(
'mobile',
required=False,
multivalue=True,
label=_(u'Mobile Telephone Number'),
),
parameters.Str(
'pager',
required=False,
multivalue=True,
label=_(u'Pager Number'),
),
parameters.Str(
'facsimiletelephonenumber',
required=False,
multivalue=True,
cli_name='fax',
label=_(u'Fax Number'),
),
parameters.Str(
'ou',
required=False,
cli_name='orgunit',
label=_(u'Org. Unit'),
),
parameters.Str(
'title',
required=False,
label=_(u'Job Title'),
),
parameters.Str(
'manager',
required=False,
label=_(u'Manager'),
),
parameters.Str(
'carlicense',
required=False,
multivalue=True,
label=_(u'Car License'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp']",
label=_(u'User authentication types'),
doc=_(u'Types of supported user authentication'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'User category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipatokenradiusconfiglink',
required=False,
cli_name='radius',
label=_(u'RADIUS proxy configuration'),
),
parameters.Str(
'ipatokenradiususername',
required=False,
cli_name='radius_username',
label=_(u'RADIUS proxy username'),
),
parameters.Str(
'departmentnumber',
required=False,
multivalue=True,
label=_(u'Department Number'),
),
parameters.Str(
'employeenumber',
required=False,
label=_(u'Employee Number'),
),
parameters.Str(
'employeetype',
required=False,
label=_(u'Employee Type'),
),
parameters.Str(
'preferredlanguage',
required=False,
label=_(u'Preferred Language'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Bool(
'nsaccountlock',
required=False,
label=_(u'Account disabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the user object'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_remove_cert(Method):
__doc__ = _("Remove one or more certificates to the user entry")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
alwaysask=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_show(Method):
__doc__ = _("Display information about a user.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'out',
required=False,
doc=_(u'file to store certificate in'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_stage(Method):
__doc__ = _("Move deleted user into staged area")
takes_args = (
parameters.Str(
'uid',
multivalue=True,
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class user_status(Method):
__doc__ = _("""
Lockout status of a user account
An account may become locked if the password is entered incorrectly too
many times within a specific time period as controlled by password
policy. A locked account is a temporary condition and may be unlocked by
an administrator.
This connects to each IPA master and displays the lockout status on
each one.
To determine whether an account is locked on a given server you need
to compare the number of failed logins and the time of the last failure.
For an account to be locked it must exceed the maxfail failures within
the failinterval duration as specified in the password policy associated
with the user.
The failed login counter is modified only when a user attempts a log in
so it is possible that an account may appear locked but the last failed
login attempt is older than the lockouttime of the password policy. This
means that the user may attempt a login again.
""")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class user_undel(Method):
__doc__ = _("Undelete a delete user account.")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class user_unlock(Method):
__doc__ = _("""
Unlock a user account
An account may become locked if the password is entered incorrectly too
many times within a specific time period as controlled by password
policy. A locked account is a temporary condition and may be unlocked by
an administrator.
""")
takes_args = (
parameters.Str(
'uid',
cli_name='login',
label=_(u'User login'),
default_from=DefaultFrom(lambda givenname, sn: givenname[0] + sn, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 55,185
|
Python
|
.py
| 1,806
| 19.705426
| 162
| 0.507446
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,047
|
config.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/config.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Server configuration
Manage the default values that IPA uses and some of its tuning parameters.
NOTES:
The password notification value (--pwdexpnotify) is stored here so it will
be replicated. It is not currently used to notify users in advance of an
expiring password.
Some attributes are read-only, provided only for information purposes. These
include:
Certificate Subject base: the configured certificate subject base,
e.g. O=EXAMPLE.COM. This is configurable only at install time.
Password plug-in features: currently defines additional hashes that the
password will generate (there may be other conditions).
When setting the order list for mapping SELinux users you may need to
quote the value so it isn't interpreted by the shell.
EXAMPLES:
Show basic server configuration:
ipa config-show
Show all configuration options:
ipa config-show --all
Change maximum username length to 99 characters:
ipa config-mod --maxusername=99
Increase default time and size limits for maximum IPA server search:
ipa config-mod --searchtimelimit=10 --searchrecordslimit=2000
Set default user e-mail domain:
ipa config-mod --emaildomain=example.com
Enable migration mode to make "ipa migrate-ds" command operational:
ipa config-mod --enable-migration=TRUE
Define SELinux user map order:
ipa config-mod --ipaselinuxusermaporder='guest_u:s0$xguest_u:s0$user_u:s0-s0:c0.c1023$staff_u:s0-s0:c0.c1023$unconfined_u:s0-s0:c0.c1023'
""")
register = Registry()
@register()
class config(Object):
takes_params = (
parameters.Int(
'ipamaxusernamelength',
label=_(u'Maximum username length'),
),
parameters.Str(
'ipahomesrootdir',
label=_(u'Home directory base'),
doc=_(u'Default location of home directories'),
),
parameters.Str(
'ipadefaultloginshell',
label=_(u'Default shell'),
doc=_(u'Default shell for new users'),
),
parameters.Str(
'ipadefaultprimarygroup',
label=_(u'Default users group'),
doc=_(u'Default group for new users'),
),
parameters.Str(
'ipadefaultemaildomain',
required=False,
label=_(u'Default e-mail domain'),
),
parameters.Int(
'ipasearchtimelimit',
label=_(u'Search time limit'),
doc=_(u'Maximum amount of time (seconds) for a search (-1 or 0 is unlimited)'),
),
parameters.Int(
'ipasearchrecordslimit',
label=_(u'Search size limit'),
doc=_(u'Maximum number of records to search (-1 or 0 is unlimited)'),
),
parameters.Str(
'ipausersearchfields',
label=_(u'User search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for users'),
),
parameters.Str(
'ipagroupsearchfields',
label=_(u'Group search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for groups'),
),
parameters.Bool(
'ipamigrationenabled',
label=_(u'Enable migration mode'),
),
parameters.DNParam(
'ipacertificatesubjectbase',
label=_(u'Certificate Subject base'),
doc=_(u'Base for certificate subjects (OU=Test,O=Example)'),
),
parameters.Str(
'ipagroupobjectclasses',
multivalue=True,
label=_(u'Default group objectclasses'),
doc=_(u'Default group objectclasses (comma-separated list)'),
),
parameters.Str(
'ipauserobjectclasses',
multivalue=True,
label=_(u'Default user objectclasses'),
doc=_(u'Default user objectclasses (comma-separated list)'),
),
parameters.Int(
'ipapwdexpadvnotify',
label=_(u'Password Expiration Notification (days)'),
doc=_(u"Number of days's notice of impending password expiration"),
),
parameters.Str(
'ipaconfigstring',
required=False,
multivalue=True,
label=_(u'Password plugin features'),
doc=_(u'Extra hashes to generate in password plug-in'),
),
parameters.Str(
'ipaselinuxusermaporder',
label=_(u'SELinux user map order'),
doc=_(u'Order in increasing priority of SELinux users, delimited by $'),
),
parameters.Str(
'ipaselinuxusermapdefault',
required=False,
label=_(u'Default SELinux user'),
doc=_(u'Default SELinux user when no match is found in SELinux map rule'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
label=_(u'Default PAC types'),
doc=_(u'Default types of PAC supported for services'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
label=_(u'Default user authentication types'),
doc=_(u'Default types of supported user authentication'),
),
)
@register()
class config_mod(Method):
__doc__ = _("Modify configuration options.")
takes_options = (
parameters.Int(
'ipamaxusernamelength',
required=False,
cli_name='maxusername',
label=_(u'Maximum username length'),
),
parameters.Str(
'ipahomesrootdir',
required=False,
cli_name='homedirectory',
label=_(u'Home directory base'),
doc=_(u'Default location of home directories'),
),
parameters.Str(
'ipadefaultloginshell',
required=False,
cli_name='defaultshell',
label=_(u'Default shell'),
doc=_(u'Default shell for new users'),
),
parameters.Str(
'ipadefaultprimarygroup',
required=False,
cli_name='defaultgroup',
label=_(u'Default users group'),
doc=_(u'Default group for new users'),
),
parameters.Str(
'ipadefaultemaildomain',
required=False,
cli_name='emaildomain',
label=_(u'Default e-mail domain'),
),
parameters.Int(
'ipasearchtimelimit',
required=False,
cli_name='searchtimelimit',
label=_(u'Search time limit'),
doc=_(u'Maximum amount of time (seconds) for a search (-1 or 0 is unlimited)'),
),
parameters.Int(
'ipasearchrecordslimit',
required=False,
cli_name='searchrecordslimit',
label=_(u'Search size limit'),
doc=_(u'Maximum number of records to search (-1 or 0 is unlimited)'),
),
parameters.Str(
'ipausersearchfields',
required=False,
cli_name='usersearch',
label=_(u'User search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for users'),
),
parameters.Str(
'ipagroupsearchfields',
required=False,
cli_name='groupsearch',
label=_(u'Group search fields'),
doc=_(u'A comma-separated list of fields to search in when searching for groups'),
),
parameters.Bool(
'ipamigrationenabled',
required=False,
cli_name='enable_migration',
label=_(u'Enable migration mode'),
),
parameters.Str(
'ipagroupobjectclasses',
required=False,
multivalue=True,
cli_name='groupobjectclasses',
label=_(u'Default group objectclasses'),
doc=_(u'Default group objectclasses (comma-separated list)'),
),
parameters.Str(
'ipauserobjectclasses',
required=False,
multivalue=True,
cli_name='userobjectclasses',
label=_(u'Default user objectclasses'),
doc=_(u'Default user objectclasses (comma-separated list)'),
),
parameters.Int(
'ipapwdexpadvnotify',
required=False,
cli_name='pwdexpnotify',
label=_(u'Password Expiration Notification (days)'),
doc=_(u"Number of days's notice of impending password expiration"),
),
parameters.Str(
'ipaconfigstring',
required=False,
multivalue=True,
cli_metavar="['AllowNThash', 'KDC:Disable Last Success', 'KDC:Disable Lockout']",
label=_(u'Password plugin features'),
doc=_(u'Extra hashes to generate in password plug-in'),
),
parameters.Str(
'ipaselinuxusermaporder',
required=False,
label=_(u'SELinux user map order'),
doc=_(u'Order in increasing priority of SELinux users, delimited by $'),
),
parameters.Str(
'ipaselinuxusermapdefault',
required=False,
label=_(u'Default SELinux user'),
doc=_(u'Default SELinux user when no match is found in SELinux map rule'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'nfs:NONE']",
label=_(u'Default PAC types'),
doc=_(u'Default types of PAC supported for services'),
),
parameters.Str(
'ipauserauthtype',
required=False,
multivalue=True,
cli_name='user_auth_type',
cli_metavar="['password', 'radius', 'otp', 'disabled']",
label=_(u'Default user authentication types'),
doc=_(u'Default types of supported user authentication'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class config_show(Method):
__doc__ = _("Show the current configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 13,698
|
Python
|
.py
| 381
| 25.769029
| 162
| 0.572837
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,048
|
otptoken.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/otptoken.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
OTP Tokens
Manage OTP tokens.
IPA supports the use of OTP tokens for multi-factor authentication. This
code enables the management of OTP tokens.
EXAMPLES:
Add a new token:
ipa otptoken-add --type=totp --owner=jdoe --desc="My soft token"
Examine the token:
ipa otptoken-show a93db710-a31a-4639-8647-f15b2c70b78a
Change the vendor:
ipa otptoken-mod a93db710-a31a-4639-8647-f15b2c70b78a --vendor="Red Hat"
Delete a token:
ipa otptoken-del a93db710-a31a-4639-8647-f15b2c70b78a
""")
register = Registry()
@register()
class otptoken(Object):
takes_params = (
parameters.Str(
'ipatokenuniqueid',
primary_key=True,
label=_(u'Unique ID'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of the token'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Str(
'managedby_user',
required=False,
label=_(u'Manager'),
doc=_(u'Assigned manager of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Bytes(
'ipatokenotpkey',
required=False,
label=_(u'Key'),
doc=_(u'Token secret (Base32; default: random)'),
),
parameters.Str(
'ipatokenotpalgorithm',
required=False,
label=_(u'Algorithm'),
doc=_(u'Token hash algorithm'),
),
parameters.Int(
'ipatokenotpdigits',
required=False,
label=_(u'Digits'),
doc=_(u'Number of digits each token code will have'),
),
parameters.Int(
'ipatokentotpclockoffset',
required=False,
label=_(u'Clock offset'),
doc=_(u'TOTP token / IPA server time difference'),
),
parameters.Int(
'ipatokentotptimestep',
required=False,
label=_(u'Clock interval'),
doc=_(u'Length of TOTP token code validity'),
),
parameters.Int(
'ipatokenhotpcounter',
required=False,
label=_(u'Counter'),
doc=_(u'Initial counter for the HOTP token'),
),
)
@register()
class otptoken_add(Method):
__doc__ = _("Add a new OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
required=False,
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Str(
'type',
required=False,
cli_metavar="['totp', 'hotp', 'TOTP', 'HOTP']",
label=_(u'Type'),
doc=_(u'Type of the token'),
default=u'totp',
autofill=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
cli_name='owner',
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
cli_name='disabled',
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
cli_name='not_before',
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
cli_name='not_after',
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
cli_name='vendor',
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
cli_name='model',
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
cli_name='serial',
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Bytes(
'ipatokenotpkey',
required=False,
cli_name='key',
label=_(u'Key'),
doc=_(u'Token secret (Base32; default: random)'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: os.urandom(KEY_LENGTH)
autofill=True,
),
parameters.Str(
'ipatokenotpalgorithm',
required=False,
cli_name='algo',
cli_metavar="['sha1', 'sha256', 'sha384', 'sha512']",
label=_(u'Algorithm'),
doc=_(u'Token hash algorithm'),
default=u'sha1',
autofill=True,
),
parameters.Int(
'ipatokenotpdigits',
required=False,
cli_name='digits',
cli_metavar="['6', '8']",
label=_(u'Digits'),
doc=_(u'Number of digits each token code will have'),
default=6,
autofill=True,
),
parameters.Int(
'ipatokentotpclockoffset',
required=False,
cli_name='offset',
label=_(u'Clock offset'),
doc=_(u'TOTP token / IPA server time difference'),
default=0,
autofill=True,
),
parameters.Int(
'ipatokentotptimestep',
required=False,
cli_name='interval',
label=_(u'Clock interval'),
doc=_(u'Length of TOTP token code validity'),
default=30,
autofill=True,
),
parameters.Int(
'ipatokenhotpcounter',
required=False,
cli_name='counter',
label=_(u'Counter'),
doc=_(u'Initial counter for the HOTP token'),
default=0,
autofill=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'qrcode',
required=False,
label=_(u'(deprecated)'),
exclude=('cli', 'webui'),
default=False,
autofill=True,
),
parameters.Flag(
'no_qrcode',
label=_(u'Do not display QR code'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class otptoken_add_managedby(Method):
__doc__ = _("Add users that can manage this token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class otptoken_del(Method):
__doc__ = _("Delete an OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
multivalue=True,
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class otptoken_find(Method):
__doc__ = _("Search for OTP token.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'ipatokenuniqueid',
required=False,
cli_name='id',
label=_(u'Unique ID'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['totp', 'hotp', 'TOTP', 'HOTP']",
label=_(u'Type'),
doc=_(u'Type of the token'),
default=u'totp',
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
cli_name='owner',
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
cli_name='disabled',
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
cli_name='not_before',
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
cli_name='not_after',
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
cli_name='vendor',
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
cli_name='model',
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
cli_name='serial',
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Str(
'ipatokenotpalgorithm',
required=False,
cli_name='algo',
cli_metavar="['sha1', 'sha256', 'sha384', 'sha512']",
label=_(u'Algorithm'),
doc=_(u'Token hash algorithm'),
default=u'sha1',
),
parameters.Int(
'ipatokenotpdigits',
required=False,
cli_name='digits',
cli_metavar="['6', '8']",
label=_(u'Digits'),
doc=_(u'Number of digits each token code will have'),
default=6,
),
parameters.Int(
'ipatokentotpclockoffset',
required=False,
cli_name='offset',
label=_(u'Clock offset'),
doc=_(u'TOTP token / IPA server time difference'),
default=0,
),
parameters.Int(
'ipatokentotptimestep',
required=False,
cli_name='interval',
label=_(u'Clock interval'),
doc=_(u'Length of TOTP token code validity'),
default=30,
),
parameters.Int(
'ipatokenhotpcounter',
required=False,
cli_name='counter',
label=_(u'Counter'),
doc=_(u'Initial counter for the HOTP token'),
default=0,
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("id")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class otptoken_mod(Method):
__doc__ = _("Modify a OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Token description (informational only)'),
),
parameters.Str(
'ipatokenowner',
required=False,
cli_name='owner',
label=_(u'Owner'),
doc=_(u'Assigned user of the token (default: self)'),
),
parameters.Bool(
'ipatokendisabled',
required=False,
cli_name='disabled',
label=_(u'Disabled'),
doc=_(u'Mark the token as disabled (default: false)'),
),
parameters.DateTime(
'ipatokennotbefore',
required=False,
cli_name='not_before',
label=_(u'Validity start'),
doc=_(u'First date/time the token can be used'),
),
parameters.DateTime(
'ipatokennotafter',
required=False,
cli_name='not_after',
label=_(u'Validity end'),
doc=_(u'Last date/time the token can be used'),
),
parameters.Str(
'ipatokenvendor',
required=False,
cli_name='vendor',
label=_(u'Vendor'),
doc=_(u'Token vendor name (informational only)'),
),
parameters.Str(
'ipatokenmodel',
required=False,
cli_name='model',
label=_(u'Model'),
doc=_(u'Token model (informational only)'),
),
parameters.Str(
'ipatokenserial',
required=False,
cli_name='serial',
label=_(u'Serial'),
doc=_(u'Token serial (informational only)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the OTP token object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class otptoken_remove_managedby(Method):
__doc__ = _("Remove users that can manage this token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class otptoken_show(Method):
__doc__ = _("Display information about an OTP token.")
takes_args = (
parameters.Str(
'ipatokenuniqueid',
cli_name='id',
label=_(u'Unique ID'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 26,015
|
Python
|
.py
| 858
| 19.475524
| 162
| 0.496099
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,049
|
vault.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/vault.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Vaults
Manage vaults.
Vault is a secure place to store a secret.
Based on the ownership there are three vault categories:
* user/private vault
* service vault
* shared vault
User vaults are vaults owned used by a particular user. Private
vaults are vaults owned the current user. Service vaults are
vaults owned by a service. Shared vaults are owned by the admin
but they can be used by other users or services.
Based on the security mechanism there are three types of
vaults:
* standard vault
* symmetric vault
* asymmetric vault
Standard vault uses a secure mechanism to transport and
store the secret. The secret can only be retrieved by users
that have access to the vault.
Symmetric vault is similar to the standard vault, but it
pre-encrypts the secret using a password before transport.
The secret can only be retrieved using the same password.
Asymmetric vault is similar to the standard vault, but it
pre-encrypts the secret using a public key before transport.
The secret can only be retrieved using the private key.
EXAMPLES:
List vaults:
ipa vault-find
[--user <user>|--service <service>|--shared]
Add a standard vault:
ipa vault-add <name>
[--user <user>|--service <service>|--shared]
--type standard
Add a symmetric vault:
ipa vault-add <name>
[--user <user>|--service <service>|--shared]
--type symmetric --password-file password.txt
Add an asymmetric vault:
ipa vault-add <name>
[--user <user>|--service <service>|--shared]
--type asymmetric --public-key-file public.pem
Show a vault:
ipa vault-show <name>
[--user <user>|--service <service>|--shared]
Modify vault description:
ipa vault-mod <name>
[--user <user>|--service <service>|--shared]
--desc <description>
Modify vault type:
ipa vault-mod <name>
[--user <user>|--service <service>|--shared]
--type <type>
[old password/private key]
[new password/public key]
Modify symmetric vault password:
ipa vault-mod <name>
[--user <user>|--service <service>|--shared]
--change-password
ipa vault-mod <name>
[--user <user>|--service <service>|--shared]
--old-password <old password>
--new-password <new password>
ipa vault-mod <name>
[--user <user>|--service <service>|--shared]
--old-password-file <old password file>
--new-password-file <new password file>
Modify asymmetric vault keys:
ipa vault-mod <name>
[--user <user>|--service <service>|--shared]
--private-key-file <old private key file>
--public-key-file <new public key file>
Delete a vault:
ipa vault-del <name>
[--user <user>|--service <service>|--shared]
Display vault configuration:
ipa vaultconfig-show
Archive data into standard vault:
ipa vault-archive <name>
[--user <user>|--service <service>|--shared]
--in <input file>
Archive data into symmetric vault:
ipa vault-archive <name>
[--user <user>|--service <service>|--shared]
--in <input file>
--password-file password.txt
Archive data into asymmetric vault:
ipa vault-archive <name>
[--user <user>|--service <service>|--shared]
--in <input file>
Retrieve data from standard vault:
ipa vault-retrieve <name>
[--user <user>|--service <service>|--shared]
--out <output file>
Retrieve data from symmetric vault:
ipa vault-retrieve <name>
[--user <user>|--service <service>|--shared]
--out <output file>
--password-file password.txt
Retrieve data from asymmetric vault:
ipa vault-retrieve <name>
[--user <user>|--service <service>|--shared]
--out <output file> --private-key-file private.pem
Add vault owners:
ipa vault-add-owner <name>
[--user <user>|--service <service>|--shared]
[--users <users>] [--groups <groups>] [--services <services>]
Delete vault owners:
ipa vault-remove-owner <name>
[--user <user>|--service <service>|--shared]
[--users <users>] [--groups <groups>] [--services <services>]
Add vault members:
ipa vault-add-member <name>
[--user <user>|--service <service>|--shared]
[--users <users>] [--groups <groups>] [--services <services>]
Delete vault members:
ipa vault-remove-member <name>
[--user <user>|--service <service>|--shared]
[--users <users>] [--groups <groups>] [--services <services>]
""")
register = Registry()
@register()
class vault(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Vault name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Vault description'),
),
parameters.Str(
'ipavaulttype',
required=False,
label=_(u'Type'),
doc=_(u'Vault type'),
),
parameters.Bytes(
'ipavaultsalt',
required=False,
label=_(u'Salt'),
doc=_(u'Vault salt'),
),
parameters.Bytes(
'ipavaultpublickey',
required=False,
label=_(u'Public key'),
doc=_(u'Vault public key'),
),
parameters.Str(
'owner_user',
required=False,
label=_(u'Owner users'),
),
parameters.Str(
'owner_group',
required=False,
label=_(u'Owner groups'),
),
parameters.Str(
'owner_service',
required=False,
label=_(u'Owner services'),
),
parameters.Str(
'owner',
required=False,
label=_(u'Failed owners'),
),
parameters.Str(
'service',
required=False,
label=_(u'Vault service'),
),
parameters.Flag(
'shared',
required=False,
label=_(u'Shared vault'),
),
parameters.Str(
'username',
required=False,
label=_(u'Vault user'),
),
parameters.Str(
'member_user',
required=False,
label=_(u'Member users'),
),
parameters.Str(
'member_group',
required=False,
label=_(u'Member groups'),
),
parameters.Str(
'member_service',
required=False,
label=_(u'Member services'),
),
)
@register()
class vaultconfig(Object):
takes_params = (
parameters.Bytes(
'transport_cert',
label=_(u'Transport Certificate'),
),
)
@register()
class vaultcontainer(Object):
takes_params = (
parameters.Str(
'owner_user',
required=False,
label=_(u'Owner users'),
),
parameters.Str(
'owner_group',
required=False,
label=_(u'Owner groups'),
),
parameters.Str(
'owner_service',
required=False,
label=_(u'Owner services'),
),
parameters.Str(
'owner',
required=False,
label=_(u'Failed owners'),
),
parameters.Str(
'service',
required=False,
label=_(u'Vault service'),
),
parameters.Flag(
'shared',
required=False,
label=_(u'Shared vault'),
),
parameters.Str(
'username',
required=False,
label=_(u'Vault user'),
),
)
@register()
class kra_is_enabled(Command):
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class vault_add_internal(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Vault description'),
),
parameters.Str(
'ipavaulttype',
required=False,
cli_name='type',
cli_metavar="['standard', 'symmetric', 'asymmetric']",
label=_(u'Type'),
doc=_(u'Vault type'),
default=u'symmetric',
autofill=True,
),
parameters.Bytes(
'ipavaultsalt',
required=False,
cli_name='salt',
label=_(u'Salt'),
doc=_(u'Vault salt'),
),
parameters.Bytes(
'ipavaultpublickey',
required=False,
cli_name='public_key',
label=_(u'Public key'),
doc=_(u'Vault public key'),
),
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class vault_add_member(Method):
__doc__ = _("Add members to a vault.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'services',
required=False,
multivalue=True,
label=_(u'member service'),
doc=_(u'services to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class vault_add_owner(Method):
__doc__ = _("Add owners to a vault.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'owner user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'owner group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'services',
required=False,
multivalue=True,
label=_(u'owner service'),
doc=_(u'services to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Owners that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of owners added'),
),
)
@register()
class vault_archive_internal(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Bytes(
'session_key',
doc=_(u'Session key wrapped with transport certificate'),
),
parameters.Bytes(
'vault_data',
doc=_(u'Vault data encrypted with session key'),
),
parameters.Bytes(
'nonce',
doc=_(u'Nonce'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class vault_del(Method):
__doc__ = _("Delete a vault.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class vault_find(Method):
__doc__ = _("Search for vaults.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Vault name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Vault description'),
),
parameters.Str(
'ipavaulttype',
required=False,
cli_name='type',
cli_metavar="['standard', 'symmetric', 'asymmetric']",
label=_(u'Type'),
doc=_(u'Vault type'),
default=u'symmetric',
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'services',
required=False,
doc=_(u'List all service vaults'),
default=False,
autofill=True,
),
parameters.Flag(
'users',
required=False,
doc=_(u'List all user vaults'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class vault_mod_internal(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Vault description'),
),
parameters.Str(
'ipavaulttype',
required=False,
cli_name='type',
cli_metavar="['standard', 'symmetric', 'asymmetric']",
label=_(u'Type'),
doc=_(u'Vault type'),
default=u'symmetric',
),
parameters.Bytes(
'ipavaultsalt',
required=False,
cli_name='salt',
label=_(u'Salt'),
doc=_(u'Vault salt'),
),
parameters.Bytes(
'ipavaultpublickey',
required=False,
cli_name='public_key',
label=_(u'Public key'),
doc=_(u'Vault public key'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class vault_remove_member(Method):
__doc__ = _("Remove members from a vault.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'services',
required=False,
multivalue=True,
label=_(u'member service'),
doc=_(u'services to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class vault_remove_owner(Method):
__doc__ = _("Remove owners from a vault.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'owner user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'owner group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'services',
required=False,
multivalue=True,
label=_(u'owner service'),
doc=_(u'services to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Owners that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of owners removed'),
),
)
@register()
class vault_retrieve_internal(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Bytes(
'session_key',
doc=_(u'Session key wrapped with transport certificate'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class vault_show(Method):
__doc__ = _("Display information about a vault.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Vault name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class vaultconfig_show(Method):
__doc__ = _("Show vault configuration.")
takes_options = (
parameters.Str(
'transport_out',
required=False,
doc=_(u'Output file to store the transport certificate'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class vaultcontainer_add_owner(Method):
__doc__ = _("Add owners to a vault container.")
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'owner user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'owner group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'services',
required=False,
multivalue=True,
label=_(u'owner service'),
doc=_(u'services to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Owners that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of owners added'),
),
)
@register()
class vaultcontainer_del(Method):
__doc__ = _("Delete a vault container.")
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class vaultcontainer_remove_owner(Method):
__doc__ = _("Remove owners from a vault container.")
takes_options = (
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'owner user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'owner group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'services',
required=False,
multivalue=True,
label=_(u'owner service'),
doc=_(u'services to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Owners that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of owners removed'),
),
)
@register()
class vaultcontainer_show(Method):
__doc__ = _("Display information about a vault container.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'service',
required=False,
doc=_(u'Service name of the service vault'),
no_convert=True,
),
parameters.Flag(
'shared',
required=False,
doc=_(u'Shared vault'),
default=False,
autofill=True,
),
parameters.Str(
'username',
required=False,
cli_name='user',
doc=_(u'Username of the user vault'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 45,219
|
Python
|
.py
| 1,588
| 18.131612
| 162
| 0.492225
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,050
|
automember.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/automember.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Auto Membership Rule.
Bring clarity to the membership of hosts and users by configuring inclusive
or exclusive regex patterns, you can automatically assign a new entries into
a group or hostgroup based upon attribute information.
A rule is directly associated with a group by name, so you cannot create
a rule without an accompanying group or hostgroup.
A condition is a regular expression used by 389-ds to match a new incoming
entry with an automember rule. If it matches an inclusive rule then the
entry is added to the appropriate group or hostgroup.
A default group or hostgroup could be specified for entries that do not
match any rule. In case of user entries this group will be a fallback group
because all users are by default members of group specified in IPA config.
The automember-rebuild command can be used to retroactively run automember rules
against existing entries, thus rebuilding their membership.
EXAMPLES:
Add the initial group or hostgroup:
ipa hostgroup-add --desc="Web Servers" webservers
ipa group-add --desc="Developers" devel
Add the initial rule:
ipa automember-add --type=hostgroup webservers
ipa automember-add --type=group devel
Add a condition to the rule:
ipa automember-add-condition --key=fqdn --type=hostgroup --inclusive-regex=^web[1-9]+\.example\.com webservers
ipa automember-add-condition --key=manager --type=group --inclusive-regex=^uid=mscott devel
Add an exclusive condition to the rule to prevent auto assignment:
ipa automember-add-condition --key=fqdn --type=hostgroup --exclusive-regex=^web5\.example\.com webservers
Add a host:
ipa host-add web1.example.com
Add a user:
ipa user-add --first=Tim --last=User --password tuser1 --manager=mscott
Verify automembership:
ipa hostgroup-show webservers
Host-group: webservers
Description: Web Servers
Member hosts: web1.example.com
ipa group-show devel
Group name: devel
Description: Developers
GID: 1004200000
Member users: tuser
Remove a condition from the rule:
ipa automember-remove-condition --key=fqdn --type=hostgroup --inclusive-regex=^web[1-9]+\.example\.com webservers
Modify the automember rule:
ipa automember-mod
Set the default (fallback) target group:
ipa automember-default-group-set --default-group=webservers --type=hostgroup
ipa automember-default-group-set --default-group=ipausers --type=group
Remove the default (fallback) target group:
ipa automember-default-group-remove --type=hostgroup
ipa automember-default-group-remove --type=group
Show the default (fallback) target group:
ipa automember-default-group-show --type=hostgroup
ipa automember-default-group-show --type=group
Find all of the automember rules:
ipa automember-find
Display a automember rule:
ipa automember-show --type=hostgroup webservers
ipa automember-show --type=group devel
Delete an automember rule:
ipa automember-del --type=hostgroup webservers
ipa automember-del --type=group devel
Rebuild membership for all users:
ipa automember-rebuild --type=group
Rebuild membership for all hosts:
ipa automember-rebuild --type=hostgroup
Rebuild membership for specified users:
ipa automember-rebuild --users=tuser1 --users=tuser2
Rebuild membership for specified hosts:
ipa automember-rebuild --hosts=web1.example.com --hosts=web2.example.com
""")
register = Registry()
@register()
class automember(Object):
takes_params = (
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberdefaultgroup',
required=False,
label=_(u'Default (fallback) Group'),
doc=_(u'Default group for entries to land'),
),
)
@register()
class automember_add(Method):
__doc__ = _("Add an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_add_condition(Method):
__doc__ = _("Add conditions to an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberinclusiveregex',
required=False,
multivalue=True,
cli_name='inclusive_regex',
label=_(u'Inclusive Regex'),
alwaysask=True,
),
parameters.Str(
'automemberexclusiveregex',
required=False,
multivalue=True,
cli_name='exclusive_regex',
label=_(u'Exclusive Regex'),
alwaysask=True,
),
parameters.Str(
'key',
label=_(u'Attribute Key'),
doc=_(u'Attribute to filter via regex. For example fqdn for a host, or manager for a user'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
output.Output(
'failed',
dict,
doc=_(u'Conditions that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of conditions added'),
),
)
@register()
class automember_default_group_remove(Method):
__doc__ = _("Remove default (fallback) group for all unmatched entries.")
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_default_group_set(Method):
__doc__ = _("Set default (fallback) group for all unmatched entries.")
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberdefaultgroup',
cli_name='default_group',
label=_(u'Default (fallback) Group'),
doc=_(u'Default (fallback) group for entries to land'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_default_group_show(Method):
__doc__ = _("Display information about the default (fallback) automember groups.")
takes_options = (
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_del(Method):
__doc__ = _("Delete an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class automember_find(Method):
__doc__ = _("Search for automember rules.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class automember_mod(Method):
__doc__ = _("Modify an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_rebuild(Command):
__doc__ = _("Rebuild auto membership.")
takes_options = (
parameters.Str(
'type',
required=False,
cli_metavar="['group', 'hostgroup']",
label=_(u'Rebuild membership for all members of a grouping'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Str(
'users',
required=False,
multivalue=True,
label=_(u'Users'),
doc=_(u'Rebuild membership for specified users'),
),
parameters.Str(
'hosts',
required=False,
multivalue=True,
label=_(u'Hosts'),
doc=_(u'Rebuild membership for specified hosts'),
),
parameters.Flag(
'no_wait',
required=False,
label=_(u'No wait'),
doc=_(u"Don't wait for rebuilding membership"),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class automember_remove_condition(Method):
__doc__ = _("Remove conditions from an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this auto member rule'),
),
parameters.Str(
'automemberinclusiveregex',
required=False,
multivalue=True,
cli_name='inclusive_regex',
label=_(u'Inclusive Regex'),
alwaysask=True,
),
parameters.Str(
'automemberexclusiveregex',
required=False,
multivalue=True,
cli_name='exclusive_regex',
label=_(u'Exclusive Regex'),
alwaysask=True,
),
parameters.Str(
'key',
label=_(u'Attribute Key'),
doc=_(u'Attribute to filter via regex. For example fqdn for a host, or manager for a user'),
),
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
output.Output(
'failed',
dict,
doc=_(u'Conditions that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of conditions removed'),
),
)
@register()
class automember_show(Method):
__doc__ = _("Display information about an automember rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='automember_rule',
label=_(u'Automember Rule'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'type',
cli_metavar="['group', 'hostgroup']",
label=_(u'Grouping Type'),
doc=_(u'Grouping to which the rule applies'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 24,427
|
Python
|
.py
| 761
| 22.332457
| 162
| 0.544703
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,051
|
passwd.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/passwd.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Set a user's password
If someone other than a user changes that user's password (e.g., Helpdesk
resets it) then the password will need to be changed the first time it
is used. This is so the end-user is the only one who knows the password.
The IPA password policy controls how often a password may be changed,
what strength requirements exist, and the length of the password history.
EXAMPLES:
To reset your own password:
ipa passwd
To change another user's password:
ipa passwd tuser1
""")
register = Registry()
@register()
class passwd(Command):
__doc__ = _("Set a user's password.")
takes_args = (
parameters.Str(
'principal',
cli_name='user',
label=_(u'User name'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: util.get_current_principal()
autofill=True,
no_convert=True,
),
parameters.Password(
'password',
label=_(u'New Password'),
confirm=True,
),
parameters.Password(
'current_password',
label=_(u'Current Password'),
default_from=DefaultFrom(lambda principal: None, 'principal'),
# FIXME:
# lambda principal: get_current_password(principal)
autofill=True,
),
)
takes_options = (
parameters.Password(
'otp',
required=False,
label=_(u'OTP'),
doc=_(u'One Time Password'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 2,431
|
Python
|
.py
| 80
| 22.975
| 81
| 0.605646
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,052
|
domainlevel.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/domainlevel.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Raise the IPA Domain Level.
""")
register = Registry()
@register()
class domainlevel_get(Command):
__doc__ = _("Query current Domain Level.")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
int,
doc=_(u'Current domain level:'),
),
)
@register()
class domainlevel_set(Command):
__doc__ = _("Change current Domain Level.")
NO_CLI = True
takes_args = (
parameters.Int(
'ipadomainlevel',
cli_name='level',
label=_(u'Domain Level'),
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
int,
doc=_(u'Current domain level:'),
),
)
| 1,199
|
Python
|
.py
| 51
| 18.019608
| 66
| 0.605286
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,053
|
krbtpolicy.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/krbtpolicy.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Kerberos ticket policy
There is a single Kerberos ticket policy. This policy defines the
maximum ticket lifetime and the maximum renewal age, the period during
which the ticket is renewable.
You can also create a per-user ticket policy by specifying the user login.
For changes to the global policy to take effect, restarting the KDC service
is required, which can be achieved using:
service krb5kdc restart
Changes to per-user policies take effect immediately for newly requested
tickets (e.g. when the user next runs kinit).
EXAMPLES:
Display the current Kerberos ticket policy:
ipa krbtpolicy-show
Reset the policy to the default:
ipa krbtpolicy-reset
Modify the policy to 8 hours max life, 1-day max renewal:
ipa krbtpolicy-mod --maxlife=28800 --maxrenew=86400
Display effective Kerberos ticket policy for user 'admin':
ipa krbtpolicy-show admin
Reset per-user policy for user 'admin':
ipa krbtpolicy-reset admin
Modify per-user policy for user 'admin':
ipa krbtpolicy-mod admin --maxlife=3600
""")
register = Registry()
@register()
class krbtpolicy(Object):
takes_params = (
parameters.Str(
'uid',
required=False,
primary_key=True,
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
parameters.Int(
'krbmaxticketlife',
required=False,
label=_(u'Max life'),
doc=_(u'Maximum ticket life (seconds)'),
),
parameters.Int(
'krbmaxrenewableage',
required=False,
label=_(u'Max renew'),
doc=_(u'Maximum renewable age (seconds)'),
),
)
@register()
class krbtpolicy_mod(Method):
__doc__ = _("Modify Kerberos ticket policy.")
takes_args = (
parameters.Str(
'uid',
required=False,
cli_name='user',
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
)
takes_options = (
parameters.Int(
'krbmaxticketlife',
required=False,
cli_name='maxlife',
label=_(u'Max life'),
doc=_(u'Maximum ticket life (seconds)'),
),
parameters.Int(
'krbmaxrenewableage',
required=False,
cli_name='maxrenew',
label=_(u'Max renew'),
doc=_(u'Maximum renewable age (seconds)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class krbtpolicy_reset(Method):
__doc__ = _("Reset Kerberos ticket policy to the default values.")
takes_args = (
parameters.Str(
'uid',
required=False,
cli_name='user',
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class krbtpolicy_show(Method):
__doc__ = _("Display the current Kerberos ticket policy.")
takes_args = (
parameters.Str(
'uid',
required=False,
cli_name='user',
label=_(u'User name'),
doc=_(u'Manage ticket policy for specific user'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 7,559
|
Python
|
.py
| 238
| 22.684874
| 162
| 0.56232
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,054
|
hbacsvc.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/hbacsvc.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
HBAC Services
The PAM services that HBAC can control access to. The name used here
must match the service name that PAM is evaluating.
EXAMPLES:
Add a new HBAC service:
ipa hbacsvc-add tftp
Modify an existing HBAC service:
ipa hbacsvc-mod --desc="TFTP service" tftp
Search for HBAC services. This example will return two results, the FTP
service and the newly-added tftp service:
ipa hbacsvc-find ftp
Delete an HBAC service:
ipa hbacsvc-del tftp
""")
register = Registry()
@register()
class hbacsvc(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Service name'),
doc=_(u'HBAC service'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Str(
'memberof_hbacsvcgroup',
required=False,
label=_(u'Member of HBAC service groups'),
),
)
@register()
class hbacsvc_add(Method):
__doc__ = _("Add a new HBAC service.")
takes_args = (
parameters.Str(
'cn',
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvc_del(Method):
__doc__ = _("Delete an existing HBAC service.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hbacsvc_find(Method):
__doc__ = _("Search for HBAC services.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("service")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hbacsvc_mod(Method):
__doc__ = _("Modify an HBAC service.")
takes_args = (
parameters.Str(
'cn',
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvc_show(Method):
__doc__ = _("Display information about an HBAC service.")
takes_args = (
parameters.Str(
'cn',
cli_name='service',
label=_(u'Service name'),
doc=_(u'HBAC service'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 11,525
|
Python
|
.py
| 385
| 19.945455
| 162
| 0.516919
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,055
|
radiusproxy.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/radiusproxy.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
RADIUS Proxy Servers
Manage RADIUS Proxy Servers.
IPA supports the use of an external RADIUS proxy server for krb5 OTP
authentications. This permits a great deal of flexibility when
integrating with third-party authentication services.
EXAMPLES:
Add a new server:
ipa radiusproxy-add MyRADIUS --server=radius.example.com:1812
Find all servers whose entries include the string "example.com":
ipa radiusproxy-find example.com
Examine the configuration:
ipa radiusproxy-show MyRADIUS
Change the secret:
ipa radiusproxy-mod MyRADIUS --secret
Delete a configuration:
ipa radiusproxy-del MyRADIUS
""")
register = Registry()
@register()
class radiusproxy(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'RADIUS proxy server name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
multivalue=True,
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
)
@register()
class radiusproxy_add(Method):
__doc__ = _("Add a new RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
multivalue=True,
cli_name='server',
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
cli_name='secret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
exclude=('cli', 'webui'),
confirm=True,
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
cli_name='timeout',
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
cli_name='retries',
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
cli_name='userattr',
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class radiusproxy_del(Method):
__doc__ = _("Delete a RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class radiusproxy_find(Method):
__doc__ = _("Search for RADIUS proxy servers.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
required=False,
multivalue=True,
cli_name='server',
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
required=False,
cli_name='secret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
exclude=('cli', 'webui'),
confirm=True,
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
cli_name='timeout',
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
cli_name='retries',
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
cli_name='userattr',
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class radiusproxy_mod(Method):
__doc__ = _("Modify a RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this RADIUS proxy server'),
),
parameters.Str(
'ipatokenradiusserver',
required=False,
multivalue=True,
cli_name='server',
label=_(u'Server'),
doc=_(u'The hostname or IP (with or without port)'),
),
parameters.Password(
'ipatokenradiussecret',
required=False,
cli_name='secret',
label=_(u'Secret'),
doc=_(u'The secret used to encrypt data'),
exclude=('cli', 'webui'),
confirm=True,
),
parameters.Int(
'ipatokenradiustimeout',
required=False,
cli_name='timeout',
label=_(u'Timeout'),
doc=_(u'The total timeout across all retries (in seconds)'),
),
parameters.Int(
'ipatokenradiusretries',
required=False,
cli_name='retries',
label=_(u'Retries'),
doc=_(u'The number of times to retry authentication'),
),
parameters.Str(
'ipatokenusermapattribute',
required=False,
cli_name='userattr',
label=_(u'User attribute'),
doc=_(u'The username attribute on the user object'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the RADIUS proxy server object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class radiusproxy_show(Method):
__doc__ = _("Display information about a RADIUS proxy server.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'RADIUS proxy server name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 15,291
|
Python
|
.py
| 491
| 20.826884
| 162
| 0.523223
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,056
|
permission.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/permission.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Permissions
A permission enables fine-grained delegation of rights. A permission is
a human-readable wrapper around a 389-ds Access Control Rule,
or instruction (ACI).
A permission grants the right to perform a specific task such as adding a
user, modifying a group, etc.
A permission may not contain other permissions.
* A permission grants access to read, write, add, delete, read, search,
or compare.
* A privilege combines similar permissions (for example all the permissions
needed to add a user).
* A role grants a set of privileges to users, groups, hosts or hostgroups.
A permission is made up of a number of different parts:
1. The name of the permission.
2. The target of the permission.
3. The rights granted by the permission.
Rights define what operations are allowed, and may be one or more
of the following:
1. write - write one or more attributes
2. read - read one or more attributes
3. search - search on one or more attributes
4. compare - compare one or more attributes
5. add - add a new entry to the tree
6. delete - delete an existing entry
7. all - all permissions are granted
Note the distinction between attributes and entries. The permissions are
independent, so being able to add a user does not mean that the user will
be editable.
There are a number of allowed targets:
1. subtree: a DN; the permission applies to the subtree under this DN
2. target filter: an LDAP filter
3. target: DN with possible wildcards, specifies entries permission applies to
Additionally, there are the following convenience options.
Setting one of these options will set the corresponding attribute(s).
1. type: a type of object (user, group, etc); sets subtree and target filter.
2. memberof: apply to members of a group; sets target filter
3. targetgroup: grant access to modify a specific group (such as granting
the rights to manage group membership); sets target.
Managed permissions
Permissions that come with IPA by default can be so-called "managed"
permissions. These have a default set of attributes they apply to,
but the administrator can add/remove individual attributes to/from the set.
Deleting or renaming a managed permission, as well as changing its target,
is not allowed.
EXAMPLES:
Add a permission that grants the creation of users:
ipa permission-add --type=user --permissions=add "Add Users"
Add a permission that grants the ability to manage group membership:
ipa permission-add --attrs=member --permissions=write --type=group "Manage Group Members"
""")
register = Registry()
@register()
class permission(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Permission name'),
),
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermincludedattr',
required=False,
multivalue=True,
label=_(u'Included attributes'),
doc=_(u'User-specified attributes to which the permission applies'),
),
parameters.Str(
'ipapermexcludedattr',
required=False,
multivalue=True,
label=_(u'Excluded attributes'),
doc=_(u'User-specified attributes to which the permission explicitly does not apply'),
),
parameters.Str(
'ipapermdefaultattr',
required=False,
multivalue=True,
label=_(u'Default attributes'),
doc=_(u'Attributes to which the permission applies by default'),
),
parameters.Str(
'ipapermbindruletype',
label=_(u'Bind rule type'),
),
parameters.Str(
'ipapermlocation',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetto',
required=False,
label=_(u'Target DN subtree'),
doc=_(u'Optional DN subtree where an entry can be moved to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetfrom',
required=False,
label=_(u'Origin DN subtree'),
doc=_(u'Optional DN subtree from where an entry can be moved (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
),
parameters.Str(
'member_privilege',
required=False,
label=_(u'Granted to Privilege'),
),
parameters.Str(
'memberindirect_role',
required=False,
label=_(u'Indirect Member of roles'),
),
)
@register()
class permission_add(Method):
__doc__ = _("Add a new permission.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
cli_name='right',
cli_metavar="['read', 'search', 'compare', 'write', 'add', 'delete', 'all']",
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
alwaysask=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermbindruletype',
cli_name='bindtype',
cli_metavar="['permission', 'all', 'anonymous']",
label=_(u'Bind rule type'),
default=u'permission',
autofill=True,
),
parameters.Str(
'ipapermlocation',
required=False,
cli_name='subtree',
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
alwaysask=True,
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
cli_name='filter',
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
cli_name='rawfilter',
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
cli_name='target',
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetto',
required=False,
cli_name='targetto',
label=_(u'Target DN subtree'),
doc=_(u'Optional DN subtree where an entry can be moved to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetfrom',
required=False,
cli_name='targetfrom',
label=_(u'Origin DN subtree'),
doc=_(u'Optional DN subtree from where an entry can be moved (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
alwaysask=True,
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
alwaysask=True,
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
alwaysask=True,
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
exclude=('cli', 'webui'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
exclude=('cli', 'webui'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class permission_add_member(Method):
__doc__ = _("Add members to a permission.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'privilege',
required=False,
multivalue=True,
cli_name='privileges',
label=_(u'member privilege'),
doc=_(u'privileges to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class permission_add_noaci(Method):
__doc__ = _("Add a system permission without an ACI (internal command)")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Str(
'ipapermissiontype',
multivalue=True,
label=_(u'Permission flags'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class permission_del(Method):
__doc__ = _("Delete a permission.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force delete of SYSTEM permissions'),
exclude=('cli', 'webui'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class permission_find(Method):
__doc__ = _("Search for permissions.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Permission name'),
),
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
cli_name='right',
cli_metavar="['read', 'search', 'compare', 'write', 'add', 'delete', 'all']",
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermincludedattr',
required=False,
multivalue=True,
cli_name='includedattrs',
label=_(u'Included attributes'),
doc=_(u'User-specified attributes to which the permission applies'),
),
parameters.Str(
'ipapermexcludedattr',
required=False,
multivalue=True,
cli_name='excludedattrs',
label=_(u'Excluded attributes'),
doc=_(u'User-specified attributes to which the permission explicitly does not apply'),
),
parameters.Str(
'ipapermdefaultattr',
required=False,
multivalue=True,
cli_name='defaultattrs',
label=_(u'Default attributes'),
doc=_(u'Attributes to which the permission applies by default'),
),
parameters.Str(
'ipapermbindruletype',
required=False,
cli_name='bindtype',
cli_metavar="['permission', 'all', 'anonymous']",
label=_(u'Bind rule type'),
default=u'permission',
),
parameters.Str(
'ipapermlocation',
required=False,
cli_name='subtree',
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
cli_name='filter',
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
cli_name='rawfilter',
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
cli_name='target',
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetto',
required=False,
cli_name='targetto',
label=_(u'Target DN subtree'),
doc=_(u'Optional DN subtree where an entry can be moved to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetfrom',
required=False,
cli_name='targetfrom',
label=_(u'Origin DN subtree'),
doc=_(u'Optional DN subtree from where an entry can be moved (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
exclude=('cli', 'webui'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
exclude=('cli', 'webui'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class permission_mod(Method):
__doc__ = _("Modify a permission.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Str(
'ipapermright',
required=False,
multivalue=True,
cli_name='right',
cli_metavar="['read', 'search', 'compare', 'write', 'add', 'delete', 'all']",
label=_(u'Granted rights'),
doc=_(u'Rights to grant (read, search, compare, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Effective attributes'),
doc=_(u'All attributes to which the permission applies'),
),
parameters.Str(
'ipapermincludedattr',
required=False,
multivalue=True,
cli_name='includedattrs',
label=_(u'Included attributes'),
doc=_(u'User-specified attributes to which the permission applies'),
),
parameters.Str(
'ipapermexcludedattr',
required=False,
multivalue=True,
cli_name='excludedattrs',
label=_(u'Excluded attributes'),
doc=_(u'User-specified attributes to which the permission explicitly does not apply'),
),
parameters.Str(
'ipapermbindruletype',
required=False,
cli_name='bindtype',
cli_metavar="['permission', 'all', 'anonymous']",
label=_(u'Bind rule type'),
default=u'permission',
),
parameters.Str(
'ipapermlocation',
required=False,
cli_name='subtree',
label=_(u'Subtree'),
doc=_(u'Subtree to apply permissions to'),
),
parameters.Str(
'extratargetfilter',
required=False,
multivalue=True,
cli_name='filter',
label=_(u'Extra target filter'),
),
parameters.Str(
'ipapermtargetfilter',
required=False,
multivalue=True,
cli_name='rawfilter',
label=_(u'Raw target filter'),
doc=_(u'All target filters, including those implied by type and memberof'),
),
parameters.DNParam(
'ipapermtarget',
required=False,
cli_name='target',
label=_(u'Target DN'),
doc=_(u'Optional DN to apply the permission to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetto',
required=False,
cli_name='targetto',
label=_(u'Target DN subtree'),
doc=_(u'Optional DN subtree where an entry can be moved to (must be in the subtree, but may not yet exist)'),
),
parameters.DNParam(
'ipapermtargetfrom',
required=False,
cli_name='targetfrom',
label=_(u'Origin DN subtree'),
doc=_(u'Optional DN subtree from where an entry can be moved (must be in the subtree, but may not yet exist)'),
),
parameters.Str(
'memberof',
required=False,
multivalue=True,
label=_(u'Member of group'),
doc=_(u'Target members of a group (sets memberOf targetfilter)'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'User group to apply permissions to (sets target)'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'Type of IPA object (sets subtree and objectClass targetfilter)'),
),
parameters.Str(
'filter',
required=False,
multivalue=True,
doc=_(u'Deprecated; use extratargetfilter'),
exclude=('cli', 'webui'),
),
parameters.Str(
'subtree',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermlocation'),
exclude=('cli', 'webui'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
doc=_(u'Deprecated; use ipapermright'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the permission object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class permission_remove_member(Method):
__doc__ = _("Remove members from a permission.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'privilege',
required=False,
multivalue=True,
cli_name='privileges',
label=_(u'member privilege'),
doc=_(u'privileges to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class permission_show(Method):
__doc__ = _("Display information about a permission.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Permission name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 34,289
|
Python
|
.py
| 1,050
| 22.098095
| 162
| 0.530371
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,057
|
ping.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/ping.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Ping the remote IPA server to ensure it is running.
The ping command sends an echo request to an IPA server. The server
returns its version information. This is used by an IPA client
to confirm that the server is available and accepting requests.
The server from xmlrpc_uri in /etc/ipa/default.conf is contacted first.
If it does not respond then the client will contact any servers defined
by ldap SRV records in DNS.
EXAMPLES:
Ping an IPA server:
ipa ping
------------------------------------------
IPA server version 2.1.9. API version 2.20
------------------------------------------
Ping an IPA server verbosely:
ipa -v ping
ipa: INFO: trying https://ipa.example.com/ipa/xml
ipa: INFO: Forwarding 'ping' to server 'https://ipa.example.com/ipa/xml'
-----------------------------------------------------
IPA server version 2.1.9. API version 2.20
-----------------------------------------------------
""")
register = Registry()
@register()
class ping(Command):
__doc__ = _("Ping a remote server.")
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
)
| 1,675
|
Python
|
.py
| 49
| 30.714286
| 75
| 0.637322
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,058
|
host.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/host.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Hosts/Machines
A host represents a machine. It can be used in a number of contexts:
- service entries are associated with a host
- a host stores the host/ service principal
- a host can be used in Host-based Access Control (HBAC) rules
- every enrolled client generates a host entry
ENROLLMENT:
There are three enrollment scenarios when enrolling a new client:
1. You are enrolling as a full administrator. The host entry may exist
or not. A full administrator is a member of the hostadmin role
or the admins group.
2. You are enrolling as a limited administrator. The host must already
exist. A limited administrator is a member a role with the
Host Enrollment privilege.
3. The host has been created with a one-time password.
RE-ENROLLMENT:
Host that has been enrolled at some point, and lost its configuration (e.g. VM
destroyed) can be re-enrolled.
For more information, consult the manual pages for ipa-client-install.
A host can optionally store information such as where it is located,
the OS that it runs, etc.
EXAMPLES:
Add a new host:
ipa host-add --location="3rd floor lab" --locality=Dallas test.example.com
Delete a host:
ipa host-del test.example.com
Add a new host with a one-time password:
ipa host-add --os='Fedora 12' --password=Secret123 test.example.com
Add a new host with a random one-time password:
ipa host-add --os='Fedora 12' --random test.example.com
Modify information about a host:
ipa host-mod --os='Fedora 12' test.example.com
Remove SSH public keys of a host and update DNS to reflect this change:
ipa host-mod --sshpubkey= --updatedns test.example.com
Disable the host Kerberos key, SSL certificate and all of its services:
ipa host-disable test.example.com
Add a host that can manage this host's keytab and certificate:
ipa host-add-managedby --hosts=test2 test
Allow user to create a keytab:
ipa host-allow-create-keytab test2 --users=tuser1
""")
register = Registry()
@register()
class host(Object):
takes_params = (
parameters.Str(
'fqdn',
primary_key=True,
label=_(u'Host name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random password to be used in bulk enrollment'),
),
parameters.Str(
'randompassword',
required=False,
label=_(u'Random password'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'krbprincipalname',
required=False,
label=_(u'Principal name'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
label=_(u'SSH public key'),
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Flag(
'has_password',
label=_(u'Password'),
),
parameters.Str(
'memberof_hostgroup',
required=False,
label=_(u'Member of host-groups'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberofindirect_netgroup',
required=False,
label=_(u'Indirect Member of netgroup'),
),
parameters.Str(
'memberofindirect_hostgroup',
required=False,
label=_(u'Indirect Member of host-group'),
),
parameters.Str(
'memberofindirect_role',
required=False,
label=_(u'Indirect Member of role'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
parameters.Flag(
'has_keytab',
label=_(u'Keytab'),
),
parameters.Str(
'managedby_host',
label=_(u'Managed by'),
),
parameters.Str(
'managing_host',
label=_(u'Managing'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_user',
label=_(u'Users allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_group',
label=_(u'Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_host',
label=_(u'Hosts allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_hostgroup',
label=_(u'Host Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_user',
label=_(u'Users allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_group',
label=_(u'Groups allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_host',
label=_(u'Hosts allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_hostgroup',
label=_(u'Host Groups allowed to create keytab'),
),
)
@register()
class host_add(Method):
__doc__ = _("Add a new host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
cli_name='locality',
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
cli_name='location',
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
cli_name='password',
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random password to be used in bulk enrollment'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
no_convert=True,
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
exclude=('cli', 'webui'),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force host name even if not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'no_reverse',
doc=_(u'skip reverse DNS detection'),
default=False,
autofill=True,
),
parameters.Str(
'ip_address',
required=False,
label=_(u'IP Address'),
doc=_(u'Add the host to DNS with this IP address'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_add_cert(Method):
__doc__ = _("Add certificates to host entry")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
alwaysask=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_add_managedby(Method):
__doc__ = _("Add hosts that can manage this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class host_allow_create_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to create a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class host_allow_retrieve_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to retrieve a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class host_del(Method):
__doc__ = _("Delete a host.")
takes_args = (
parameters.Str(
'fqdn',
multivalue=True,
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Flag(
'updatedns',
required=False,
doc=_(u'Remove entries from DNS'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class host_disable(Method):
__doc__ = _("Disable the Kerberos key, SSL certificate and all services of a host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_disallow_create_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to create a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class host_disallow_retrieve_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to retrieve a keytab of this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class host_find(Method):
__doc__ = _("Search for hosts.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'fqdn',
required=False,
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
cli_name='locality',
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
cli_name='location',
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
cli_name='password',
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
no_convert=True,
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("hostname")'),
default=False,
autofill=True,
),
parameters.Str(
'in_hostgroup',
required=False,
multivalue=True,
cli_name='in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for hosts with these member of host groups.'),
),
parameters.Str(
'not_in_hostgroup',
required=False,
multivalue=True,
cli_name='not_in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for hosts without these member of host groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for hosts with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for hosts without these member of netgroups.'),
),
parameters.Str(
'in_role',
required=False,
multivalue=True,
cli_name='in_roles',
label=_(u'role'),
doc=_(u'Search for hosts with these member of roles.'),
),
parameters.Str(
'not_in_role',
required=False,
multivalue=True,
cli_name='not_in_roles',
label=_(u'role'),
doc=_(u'Search for hosts without these member of roles.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for hosts with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for hosts without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for hosts with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for hosts without these member of sudo rules.'),
),
parameters.Str(
'enroll_by_user',
required=False,
multivalue=True,
cli_name='enroll_by_users',
label=_(u'user'),
doc=_(u'Search for hosts with these enrolled by users.'),
),
parameters.Str(
'not_enroll_by_user',
required=False,
multivalue=True,
cli_name='not_enroll_by_users',
label=_(u'user'),
doc=_(u'Search for hosts without these enrolled by users.'),
),
parameters.Str(
'man_by_host',
required=False,
multivalue=True,
cli_name='man_by_hosts',
label=_(u'host'),
doc=_(u'Search for hosts with these managed by hosts.'),
),
parameters.Str(
'not_man_by_host',
required=False,
multivalue=True,
cli_name='not_man_by_hosts',
label=_(u'host'),
doc=_(u'Search for hosts without these managed by hosts.'),
),
parameters.Str(
'man_host',
required=False,
multivalue=True,
cli_name='man_hosts',
label=_(u'host'),
doc=_(u'Search for hosts with these managing hosts.'),
),
parameters.Str(
'not_man_host',
required=False,
multivalue=True,
cli_name='not_man_hosts',
label=_(u'host'),
doc=_(u'Search for hosts without these managing hosts.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class host_mod(Method):
__doc__ = _("Modify information about a host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host'),
),
parameters.Str(
'l',
required=False,
cli_name='locality',
label=_(u'Locality'),
doc=_(u'Host locality (e.g. "Baltimore, MD")'),
),
parameters.Str(
'nshostlocation',
required=False,
cli_name='location',
label=_(u'Location'),
doc=_(u'Host location (e.g. "Lab 2")'),
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
label=_(u'Platform'),
doc=_(u'Host hardware platform (e.g. "Lenovo T61")'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
label=_(u'Operating system'),
doc=_(u'Host operating system and version (e.g. "Fedora 9")'),
),
parameters.Str(
'userpassword',
required=False,
cli_name='password',
label=_(u'User password'),
doc=_(u'Password used in bulk enrollment'),
),
parameters.Flag(
'random',
required=False,
doc=_(u'Generate a random password to be used in bulk enrollment'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'macaddress',
required=False,
multivalue=True,
label=_(u'MAC address'),
doc=_(u'Hardware MAC address(es) on this host'),
no_convert=True,
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'userclass',
required=False,
multivalue=True,
cli_name='class',
label=_(u'Class'),
doc=_(u'Host category (semantics placed on this attribute are for local interpretation)'),
),
parameters.Str(
'ipaassignedidview',
required=False,
label=_(u'Assigned ID View'),
exclude=('cli', 'webui'),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principalname',
label=_(u'Principal name'),
doc=_(u'Kerberos principal name for this host'),
),
parameters.Flag(
'updatedns',
required=False,
doc=_(u'Update DNS entries'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_remove_cert(Method):
__doc__ = _("Remove certificates from host entry")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
alwaysask=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class host_remove_managedby(Method):
__doc__ = _("Remove hosts that can manage this host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class host_show(Method):
__doc__ = _("Display information about a host.")
takes_args = (
parameters.Str(
'fqdn',
cli_name='hostname',
label=_(u'Host name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'out',
required=False,
doc=_(u'file to store certificate in'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 48,912
|
Python
|
.py
| 1,613
| 19.508989
| 162
| 0.500191
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,059
|
netgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/netgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Netgroups
A netgroup is a group used for permission checking. It can contain both
user and host values.
EXAMPLES:
Add a new netgroup:
ipa netgroup-add --desc="NFS admins" admins
Add members to the netgroup:
ipa netgroup-add-member --users=tuser1 --users=tuser2 admins
Remove a member from the netgroup:
ipa netgroup-remove-member --users=tuser2 admins
Display information about a netgroup:
ipa netgroup-show admins
Delete a netgroup:
ipa netgroup-del admins
""")
register = Registry()
@register()
class netgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Netgroup name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
label=_(u'NIS domain name'),
),
parameters.Str(
'ipauniqueid',
required=False,
label=_(u'IPA unique ID'),
doc=_(u'IPA unique ID'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
),
parameters.Str(
'member_netgroup',
required=False,
label=_(u'Member netgroups'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberindirect_netgroup',
required=False,
label=_(u'Indirect Member netgroups'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Member User'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'Member Group'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Member Host'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Member Hostgroup'),
),
)
@register()
class netgroup_add(Method):
__doc__ = _("Add a new netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
cli_name='nisdomain',
label=_(u'NIS domain name'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class netgroup_add_member(Method):
__doc__ = _("Add members to a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
parameters.Str(
'netgroup',
required=False,
multivalue=True,
cli_name='netgroups',
label=_(u'member netgroup'),
doc=_(u'netgroups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class netgroup_del(Method):
__doc__ = _("Delete a netgroup.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class netgroup_find(Method):
__doc__ = _("Search for a netgroup.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
cli_name='nisdomain',
label=_(u'NIS domain name'),
),
parameters.Str(
'ipauniqueid',
required=False,
cli_name='uuid',
label=_(u'IPA unique ID'),
doc=_(u'IPA unique ID'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'private',
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'managed',
doc=_(u'search for managed groups'),
default=False,
default_from=DefaultFrom(lambda private: private),
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
parameters.Str(
'netgroup',
required=False,
multivalue=True,
cli_name='netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups with these member netgroups.'),
),
parameters.Str(
'no_netgroup',
required=False,
multivalue=True,
cli_name='no_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups without these member netgroups.'),
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'user'),
doc=_(u'Search for netgroups with these member users.'),
),
parameters.Str(
'no_user',
required=False,
multivalue=True,
cli_name='no_users',
label=_(u'user'),
doc=_(u'Search for netgroups without these member users.'),
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'group'),
doc=_(u'Search for netgroups with these member groups.'),
),
parameters.Str(
'no_group',
required=False,
multivalue=True,
cli_name='no_groups',
label=_(u'group'),
doc=_(u'Search for netgroups without these member groups.'),
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'host'),
doc=_(u'Search for netgroups with these member hosts.'),
),
parameters.Str(
'no_host',
required=False,
multivalue=True,
cli_name='no_hosts',
label=_(u'host'),
doc=_(u'Search for netgroups without these member hosts.'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'host group'),
doc=_(u'Search for netgroups with these member host groups.'),
),
parameters.Str(
'no_hostgroup',
required=False,
multivalue=True,
cli_name='no_hostgroups',
label=_(u'host group'),
doc=_(u'Search for netgroups without these member host groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for netgroups without these member of netgroups.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class netgroup_mod(Method):
__doc__ = _("Modify a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Netgroup description'),
),
parameters.Str(
'nisdomainname',
required=False,
cli_name='nisdomain',
label=_(u'NIS domain name'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class netgroup_remove_member(Method):
__doc__ = _("Remove members from a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
parameters.Str(
'netgroup',
required=False,
multivalue=True,
cli_name='netgroups',
label=_(u'member netgroup'),
doc=_(u'netgroups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class netgroup_show(Method):
__doc__ = _("Display information about a netgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Netgroup name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 24,373
|
Python
|
.py
| 830
| 18.554217
| 162
| 0.490769
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,060
|
pkinit.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/pkinit.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Kerberos pkinit options
Enable or disable anonymous pkinit using the principal
WELLKNOWN/ANONYMOUS@REALM. The server must have been installed with
pkinit support.
EXAMPLES:
Enable anonymous pkinit:
ipa pkinit-anonymous enable
Disable anonymous pkinit:
ipa pkinit-anonymous disable
For more information on anonymous pkinit see:
http://k5wiki.kerberos.org/wiki/Projects/Anonymous_pkinit
""")
register = Registry()
@register()
class pkinit(Object):
takes_params = (
)
@register()
class pkinit_anonymous(Command):
__doc__ = _("Enable or Disable Anonymous PKINIT.")
takes_args = (
parameters.Str(
'action',
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
| 1,198
|
Python
|
.py
| 47
| 21.978723
| 67
| 0.729515
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,061
|
trust.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/trust.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Cross-realm trusts
Manage trust relationship between IPA and Active Directory domains.
In order to allow users from a remote domain to access resources in IPA
domain, trust relationship needs to be established. Currently IPA supports
only trusts between IPA and Active Directory domains under control of Windows
Server 2008 or later, with functional level 2008 or later.
Please note that DNS on both IPA and Active Directory domain sides should be
configured properly to discover each other. Trust relationship relies on
ability to discover special resources in the other domain via DNS records.
Examples:
1. Establish cross-realm trust with Active Directory using AD administrator
credentials:
ipa trust-add --type=ad <ad.domain> --admin <AD domain administrator> --password
2. List all existing trust relationships:
ipa trust-find
3. Show details of the specific trust relationship:
ipa trust-show <ad.domain>
4. Delete existing trust relationship:
ipa trust-del <ad.domain>
Once trust relationship is established, remote users will need to be mapped
to local POSIX groups in order to actually use IPA resources. The mapping should
be done via use of external membership of non-POSIX group and then this group
should be included into one of local POSIX groups.
Example:
1. Create group for the trusted domain admins' mapping and their local POSIX group:
ipa group-add --desc='<ad.domain> admins external map' ad_admins_external --external
ipa group-add --desc='<ad.domain> admins' ad_admins
2. Add security identifier of Domain Admins of the <ad.domain> to the ad_admins_external
group:
ipa group-add-member ad_admins_external --external 'AD\Domain Admins'
3. Allow members of ad_admins_external group to be associated with ad_admins POSIX group:
ipa group-add-member ad_admins --groups ad_admins_external
4. List members of external members of ad_admins_external group to see their SIDs:
ipa group-show ad_admins_external
GLOBAL TRUST CONFIGURATION
When IPA AD trust subpackage is installed and ipa-adtrust-install is run,
a local domain configuration (SID, GUID, NetBIOS name) is generated. These
identifiers are then used when communicating with a trusted domain of the
particular type.
1. Show global trust configuration for Active Directory type of trusts:
ipa trustconfig-show --type ad
2. Modify global configuration for all trusts of Active Directory type and set
a different fallback primary group (fallback primary group GID is used as
a primary user GID if user authenticating to IPA domain does not have any other
primary GID already set):
ipa trustconfig-mod --type ad --fallback-primary-group "alternative AD group"
3. Change primary fallback group back to default hidden group (any group with
posixGroup object class is allowed):
ipa trustconfig-mod --type ad --fallback-primary-group "Default SMB Group"
""")
register = Registry()
@register()
class trust(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Realm name'),
),
parameters.Str(
'ipantflatname',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipantsidblacklistincoming',
required=False,
multivalue=True,
label=_(u'SID blacklist incoming'),
),
parameters.Str(
'ipantsidblacklistoutgoing',
required=False,
multivalue=True,
label=_(u'SID blacklist outgoing'),
),
)
@register()
class trustconfig(Object):
takes_params = (
parameters.Str(
'cn',
label=_(u'Domain'),
),
parameters.Str(
'ipantsecurityidentifier',
label=_(u'Security Identifier'),
),
parameters.Str(
'ipantflatname',
label=_(u'NetBIOS name'),
),
parameters.Str(
'ipantdomainguid',
label=_(u'Domain GUID'),
),
parameters.Str(
'ipantfallbackprimarygroup',
label=_(u'Fallback primary group'),
),
)
@register()
class trustdomain(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Domain name'),
),
parameters.Str(
'ipantflatname',
required=False,
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
),
)
@register()
class adtrust_is_enabled(Command):
__doc__ = _("Determine whether ipa-adtrust-install has been run on this system")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class compat_is_enabled(Command):
__doc__ = _("Determine whether Schema Compatibility plugin is configured to serve trusted domain users and groups")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class sidgen_was_run(Command):
__doc__ = _("Determine whether ipa-adtrust-install has been run with sidgen task")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class trust_add(Method):
__doc__ = _("""
Add new trust to use.
This command establishes trust relationship to another domain
which becomes 'trusted'. As result, users of the trusted domain
may access resources of this domain.
Only trusts to Active Directory domains are supported right now.
The command can be safely run multiple times against the same domain,
this will cause change to trust relationship credentials on both
sides.
""")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Str(
'realm_admin',
required=False,
cli_name='admin',
label=_(u'Active Directory domain administrator'),
),
parameters.Password(
'realm_passwd',
required=False,
cli_name='password',
label=_(u"Active Directory domain administrator's password"),
),
parameters.Str(
'realm_server',
required=False,
cli_name='server',
label=_(u'Domain controller for the Active Directory domain (optional)'),
),
parameters.Password(
'trust_secret',
required=False,
label=_(u'Shared secret for the trust'),
),
parameters.Int(
'base_id',
required=False,
label=_(u'First Posix ID of the range reserved for the trusted domain'),
),
parameters.Int(
'range_size',
required=False,
label=_(u'Size of the ID range reserved for the trusted domain'),
),
parameters.Str(
'range_type',
required=False,
cli_metavar="['ipa-ad-trust-posix', 'ipa-ad-trust']",
label=_(u'Range type'),
doc=_(u'Type of trusted domain ID range, one of ipa-ad-trust-posix, ipa-ad-trust'),
),
parameters.Bool(
'bidirectional',
required=False,
cli_name='two_way',
label=_(u'Two-way trust'),
doc=_(u'Establish bi-directional trust. By default trust is inbound one-way only.'),
default=False,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trust_del(Method):
__doc__ = _("Delete a trust.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class trust_fetch_domains(Method):
__doc__ = _("Refresh list of the domains associated with the trust")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'realm_server',
required=False,
cli_name='server',
label=_(u'Domain controller for the Active Directory domain (optional)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class trust_find(Method):
__doc__ = _("Search for trusts.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='realm',
label=_(u'Realm name'),
),
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipantsidblacklistincoming',
required=False,
multivalue=True,
cli_name='sid_blacklist_incoming',
label=_(u'SID blacklist incoming'),
),
parameters.Str(
'ipantsidblacklistoutgoing',
required=False,
multivalue=True,
cli_name='sid_blacklist_outgoing',
label=_(u'SID blacklist outgoing'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("realm")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class trust_mod(Method):
__doc__ = _("""
Modify a trust (for future use).
Currently only the default option to modify the LDAP attributes is
available. More specific options will be added in coming releases.
""")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Str(
'ipantsidblacklistincoming',
required=False,
multivalue=True,
cli_name='sid_blacklist_incoming',
label=_(u'SID blacklist incoming'),
),
parameters.Str(
'ipantsidblacklistoutgoing',
required=False,
multivalue=True,
cli_name='sid_blacklist_outgoing',
label=_(u'SID blacklist outgoing'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trust_resolve(Command):
__doc__ = _("Resolve security identifiers of users and groups in trusted domains")
NO_CLI = True
takes_options = (
parameters.Str(
'sids',
multivalue=True,
label=_(u'Security Identifiers (SIDs)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.ListOfEntries(
'result',
),
)
@register()
class trust_show(Method):
__doc__ = _("Display information about a trust.")
takes_args = (
parameters.Str(
'cn',
cli_name='realm',
label=_(u'Realm name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustconfig_mod(Method):
__doc__ = _("Modify global trust configuration.")
takes_options = (
parameters.Str(
'ipantfallbackprimarygroup',
required=False,
cli_name='fallback_primary_group',
label=_(u'Fallback primary group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustconfig_show(Method):
__doc__ = _("Show global trust configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_add(Method):
__doc__ = _("Allow access from the trusted domain")
NO_CLI = True
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_del(Method):
__doc__ = _("Remove information about the domain associated with the trust.")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
multivalue=True,
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class trustdomain_disable(Method):
__doc__ = _("Disable use of IPA resources by the domain of the trust")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_enable(Method):
__doc__ = _("Allow use of IPA resources by the domain of the trust")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class trustdomain_find(Method):
__doc__ = _("Search domains of the trust")
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='domain',
label=_(u'Domain name'),
),
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("domain")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class trustdomain_mod(Method):
__doc__ = _("Modify trustdomain of the trust")
NO_CLI = True
takes_args = (
parameters.Str(
'trustcn',
cli_name='trust',
label=_(u'Realm name'),
),
parameters.Str(
'cn',
cli_name='domain',
label=_(u'Domain name'),
),
)
takes_options = (
parameters.Str(
'ipantflatname',
required=False,
cli_name='flat_name',
label=_(u'Domain NetBIOS name'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='sid',
label=_(u'Domain Security Identifier'),
),
parameters.Str(
'ipanttrustpartner',
required=False,
label=_(u'Trusted domain partner'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'trust_type',
cli_name='type',
cli_metavar="['ad']",
label=_(u'Trust type (ad for Active Directory, default)'),
default=u'ad',
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 35,970
|
Python
|
.py
| 1,158
| 21.157168
| 162
| 0.533107
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,062
|
hbactest.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/hbactest.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Simulate use of Host-based access controls
HBAC rules control who can access what services on what hosts.
You can use HBAC to control which users or groups can access a service,
or group of services, on a target host.
Since applying HBAC rules implies use of a production environment,
this plugin aims to provide simulation of HBAC rules evaluation without
having access to the production environment.
Test user coming to a service on a named host against
existing enabled rules.
ipa hbactest --user= --host= --service=
[--rules=rules-list] [--nodetail] [--enabled] [--disabled]
[--sizelimit= ]
--user, --host, and --service are mandatory, others are optional.
If --rules is specified simulate enabling of the specified rules and test
the login of the user using only these rules.
If --enabled is specified, all enabled HBAC rules will be added to simulation
If --disabled is specified, all disabled HBAC rules will be added to simulation
If --nodetail is specified, do not return information about rules matched/not matched.
If both --rules and --enabled are specified, apply simulation to --rules _and_
all IPA enabled rules.
If no --rules specified, simulation is run against all IPA enabled rules.
By default there is a IPA-wide limit to number of entries fetched, you can change it
with --sizelimit option.
EXAMPLES:
1. Use all enabled HBAC rules in IPA database to simulate:
$ ipa hbactest --user=a1a --host=bar --service=sshd
--------------------
Access granted: True
--------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
Matched rules: allow_all
2. Disable detailed summary of how rules were applied:
$ ipa hbactest --user=a1a --host=bar --service=sshd --nodetail
--------------------
Access granted: True
--------------------
3. Test explicitly specified HBAC rules:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--rules=myrule --rules=my-second-rule
---------------------
Access granted: False
---------------------
Not matched rules: my-second-rule
Not matched rules: myrule
4. Use all enabled HBAC rules in IPA database + explicitly specified rules:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--rules=myrule --rules=my-second-rule --enabled
--------------------
Access granted: True
--------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
Matched rules: allow_all
5. Test all disabled HBAC rules in IPA database:
$ ipa hbactest --user=a1a --host=bar --service=sshd --disabled
---------------------
Access granted: False
---------------------
Not matched rules: new-rule
6. Test all disabled HBAC rules in IPA database + explicitly specified rules:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--rules=myrule --rules=my-second-rule --disabled
---------------------
Access granted: False
---------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
7. Test all (enabled and disabled) HBAC rules in IPA database:
$ ipa hbactest --user=a1a --host=bar --service=sshd \
--enabled --disabled
--------------------
Access granted: True
--------------------
Not matched rules: my-second-rule
Not matched rules: my-third-rule
Not matched rules: myrule
Not matched rules: new-rule
Matched rules: allow_all
HBACTEST AND TRUSTED DOMAINS
When an external trusted domain is configured in IPA, HBAC rules are also applied
on users accessing IPA resources from the trusted domain. Trusted domain users and
groups (and their SIDs) can be then assigned to external groups which can be
members of POSIX groups in IPA which can be used in HBAC rules and thus allowing
access to resources protected by the HBAC system.
hbactest plugin is capable of testing access for both local IPA users and users
from the trusted domains, either by a fully qualified user name or by user SID.
Such user names need to have a trusted domain specified as a short name
(DOMAIN\Administrator) or with a user principal name (UPN), Administrator@ad.test.
Please note that hbactest executed with a trusted domain user as --user parameter
can be only run by members of "trust admins" group.
EXAMPLES:
1. Test if a user from a trusted domain specified by its shortname matches any
rule:
$ ipa hbactest --user 'DOMAIN\Administrator' --host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Matched rules: can_login
2. Test if a user from a trusted domain specified by its domain name matches
any rule:
$ ipa hbactest --user 'Administrator@domain.com' --host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Matched rules: can_login
3. Test if a user from a trusted domain specified by its SID matches any rule:
$ ipa hbactest --user S-1-5-21-3035198329-144811719-1378114514-500 \
--host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Matched rules: can_login
4. Test if other user from a trusted domain specified by its SID matches any rule:
$ ipa hbactest --user S-1-5-21-3035198329-144811719-1378114514-1203 \
--host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Not matched rules: can_login
5. Test if other user from a trusted domain specified by its shortname matches
any rule:
$ ipa hbactest --user 'DOMAIN\Otheruser' --host `hostname` --service sshd
--------------------
Access granted: True
--------------------
Matched rules: allow_all
Not matched rules: can_login
""")
register = Registry()
@register()
class hbactest(Command):
__doc__ = _("Simulate use of Host-based access controls")
takes_options = (
parameters.Str(
'user',
label=_(u'User name'),
),
parameters.Str(
'sourcehost',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'targethost',
cli_name='host',
label=_(u'Target host'),
),
parameters.Str(
'service',
label=_(u'Service'),
),
parameters.Str(
'rules',
required=False,
multivalue=True,
label=_(u'Rules to test. If not specified, --enabled is assumed'),
),
parameters.Flag(
'nodetail',
required=False,
label=_(u'Hide details which rules are matched, not matched, or invalid'),
default=False,
autofill=True,
),
parameters.Flag(
'enabled',
required=False,
label=_(u'Include all enabled IPA rules into test [default]'),
default=False,
autofill=True,
),
parameters.Flag(
'disabled',
required=False,
label=_(u'Include all disabled IPA rules into test'),
default=False,
autofill=True,
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of rules to process when no --rules is specified'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'warning',
(list, tuple, type(None)),
doc=_(u'Warning'),
),
output.Output(
'matched',
(list, tuple, type(None)),
doc=_(u'Matched rules'),
),
output.Output(
'notmatched',
(list, tuple, type(None)),
doc=_(u'Not matched rules'),
),
output.Output(
'error',
(list, tuple, type(None)),
doc=_(u'Non-existent or invalid rules'),
),
output.Output(
'value',
bool,
doc=_(u'Result of simulation'),
),
)
| 9,123
|
Python
|
.py
| 241
| 30.751037
| 87
| 0.611947
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,063
|
internal.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/internal.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Plugins not accessible directly through the CLI, commands used internally
""")
register = Registry()
@register()
class i18n_messages(Command):
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'texts',
dict,
doc=_(u'Dict of I18N messages'),
),
)
@register()
class json_metadata(Command):
__doc__ = _("Export plugin meta-data for the webUI.")
NO_CLI = True
takes_args = (
parameters.Str(
'objname',
required=False,
doc=_(u'Name of object to export'),
),
parameters.Str(
'methodname',
required=False,
doc=_(u'Name of method to export'),
),
)
takes_options = (
parameters.Str(
'object',
required=False,
doc=_(u'Name of object to export'),
),
parameters.Str(
'method',
required=False,
doc=_(u'Name of method to export'),
),
parameters.Str(
'command',
required=False,
doc=_(u'Name of command to export'),
),
)
has_output = (
output.Output(
'objects',
dict,
doc=_(u'Dict of JSON encoded IPA Objects'),
),
output.Output(
'methods',
dict,
doc=_(u'Dict of JSON encoded IPA Methods'),
),
output.Output(
'commands',
dict,
doc=_(u'Dict of JSON encoded IPA Commands'),
),
)
| 2,019
|
Python
|
.py
| 80
| 17.5375
| 73
| 0.548521
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,064
|
batch.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/batch.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Plugin to make multiple ipa calls via one remote procedure call
To run this code in the lite-server
curl -H "Content-Type:application/json" -H "Accept:application/json" -H "Accept-Language:en" --negotiate -u : --cacert /etc/ipa/ca.crt -d @batch_request.json -X POST http://localhost:8888/ipa/json
where the contents of the file batch_request.json follow the below example
{"method":"batch","params":[[
{"method":"group_find","params":[[],{}]},
{"method":"user_find","params":[[],{"whoami":"true","all":"true"}]},
{"method":"user_show","params":[["admin"],{"all":true}]}
],{}],"id":1}
The format of the response is nested the same way. At the top you will see
"error": null,
"id": 1,
"result": {
"count": 3,
"results": [
And then a nested response for each IPA command method sent in the request
""")
register = Registry()
@register()
class batch(Command):
NO_CLI = True
takes_args = (
parameters.Any(
'methods',
required=False,
multivalue=True,
doc=_(u'Nested Methods to execute'),
),
)
takes_options = (
)
has_output = (
output.Output(
'count',
int,
),
output.Output(
'results',
(list, tuple),
),
)
| 1,806
|
Python
|
.py
| 56
| 26.732143
| 240
| 0.613256
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,065
|
__init__.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/__init__.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
from ..compat import CompatCommand, CompatMethod, CompatObject
Object = CompatObject
class Command(CompatCommand):
api_version = u'2.156'
class Method(Command, CompatMethod):
pass
| 265
|
Python
|
.py
| 9
| 26.888889
| 66
| 0.792
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,066
|
hbacsvcgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/hbacsvcgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
HBAC Service Groups
HBAC service groups can contain any number of individual services,
or "members". Every group must have a description.
EXAMPLES:
Add a new HBAC service group:
ipa hbacsvcgroup-add --desc="login services" login
Add members to an HBAC service group:
ipa hbacsvcgroup-add-member --hbacsvcs=sshd --hbacsvcs=login login
Display information about a named group:
ipa hbacsvcgroup-show login
Delete an HBAC service group:
ipa hbacsvcgroup-del login
""")
register = Registry()
@register()
class hbacsvcgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Service group name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Str(
'member_hbacsvc',
required=False,
label=_(u'Member HBAC service'),
),
)
@register()
class hbacsvcgroup_add(Method):
__doc__ = _("Add a new HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvcgroup_add_member(Method):
__doc__ = _("Add members to an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacsvcgroup_del(Method):
__doc__ = _("Delete an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hbacsvcgroup_find(Method):
__doc__ = _("Search for an HBAC service group.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hbacsvcgroup_mod(Method):
__doc__ = _("Modify an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'HBAC service group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacsvcgroup_remove_member(Method):
__doc__ = _("Remove members from an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacsvcgroup_show(Method):
__doc__ = _("Display information about an HBAC service group.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Service group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 14,633
|
Python
|
.py
| 494
| 19.516194
| 162
| 0.512017
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,067
|
certprofile.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/certprofile.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Manage Certificate Profiles
Certificate Profiles are used by Certificate Authority (CA) in the signing of
certificates to determine if a Certificate Signing Request (CSR) is acceptable,
and if so what features and extensions will be present on the certificate.
The Certificate Profile format is the property-list format understood by the
Dogtag or Red Hat Certificate System CA.
PROFILE ID SYNTAX:
A Profile ID is a string without spaces or punctuation starting with a letter
and followed by a sequence of letters, digits or underscore ("_").
EXAMPLES:
Import a profile that will not store issued certificates:
ipa certprofile-import ShortLivedUserCert \
--file UserCert.profile --desc "User Certificates" \
--store=false
Delete a certificate profile:
ipa certprofile-del ShortLivedUserCert
Show information about a profile:
ipa certprofile-show ShortLivedUserCert
Save profile configuration to a file:
ipa certprofile-show caIPAserviceCert --out caIPAserviceCert.cfg
Search for profiles that do not store certificates:
ipa certprofile-find --store=false
PROFILE CONFIGURATION FORMAT:
The profile configuration format is the raw property-list format
used by Dogtag Certificate System. The XML format is not supported.
The following restrictions apply to profiles managed by IPA:
- When importing a profile the "profileId" field, if present, must
match the ID given on the command line.
- The "classId" field must be set to "caEnrollImpl"
- The "auth.instance_id" field must be set to "raCertAuth"
- The "certReqInputImpl" input class and "certOutputImpl" output
class must be used.
""")
register = Registry()
@register()
class certprofile(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Profile ID'),
doc=_(u'Profile ID for referring to this profile'),
),
parameters.Str(
'description',
label=_(u'Profile description'),
doc=_(u'Brief description of this profile'),
),
parameters.Bool(
'ipacertprofilestoreissued',
label=_(u'Store issued certificates'),
doc=_(u'Whether to store certs issued using this profile'),
),
)
@register()
class certprofile_del(Method):
__doc__ = _("Delete a Certificate Profile.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='id',
label=_(u'Profile ID'),
doc=_(u'Profile ID for referring to this profile'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class certprofile_find(Method):
__doc__ = _("Search for Certificate Profiles.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='id',
label=_(u'Profile ID'),
doc=_(u'Profile ID for referring to this profile'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Profile description'),
doc=_(u'Brief description of this profile'),
),
parameters.Bool(
'ipacertprofilestoreissued',
required=False,
cli_name='store',
label=_(u'Store issued certificates'),
doc=_(u'Whether to store certs issued using this profile'),
default=True,
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("id")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class certprofile_import(Method):
__doc__ = _("Import a Certificate Profile.")
takes_args = (
parameters.Str(
'cn',
cli_name='id',
label=_(u'Profile ID'),
doc=_(u'Profile ID for referring to this profile'),
),
)
takes_options = (
parameters.Str(
'description',
cli_name='desc',
label=_(u'Profile description'),
doc=_(u'Brief description of this profile'),
),
parameters.Bool(
'ipacertprofilestoreissued',
cli_name='store',
label=_(u'Store issued certificates'),
doc=_(u'Whether to store certs issued using this profile'),
default=True,
),
parameters.Str(
'file',
label=_(u'Filename of a raw profile. The XML format is not supported.'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class certprofile_mod(Method):
__doc__ = _("Modify Certificate Profile configuration.")
takes_args = (
parameters.Str(
'cn',
cli_name='id',
label=_(u'Profile ID'),
doc=_(u'Profile ID for referring to this profile'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Profile description'),
doc=_(u'Brief description of this profile'),
),
parameters.Bool(
'ipacertprofilestoreissued',
required=False,
cli_name='store',
label=_(u'Store issued certificates'),
doc=_(u'Whether to store certs issued using this profile'),
default=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'file',
required=False,
label=_(u'File containing profile configuration'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class certprofile_show(Method):
__doc__ = _("Display the properties of a Certificate Profile.")
takes_args = (
parameters.Str(
'cn',
cli_name='id',
label=_(u'Profile ID'),
doc=_(u'Profile ID for referring to this profile'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'out',
required=False,
doc=_(u'Write profile configuration to file'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 12,586
|
Python
|
.py
| 392
| 22.543367
| 162
| 0.553846
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,068
|
realmdomains.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/realmdomains.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Realm domains
Manage the list of domains associated with IPA realm.
EXAMPLES:
Display the current list of realm domains:
ipa realmdomains-show
Replace the list of realm domains:
ipa realmdomains-mod --domain=example.com
ipa realmdomains-mod --domain={example1.com,example2.com,example3.com}
Add a domain to the list of realm domains:
ipa realmdomains-mod --add-domain=newdomain.com
Delete a domain from the list of realm domains:
ipa realmdomains-mod --del-domain=olddomain.com
""")
register = Registry()
@register()
class realmdomains(Object):
takes_params = (
parameters.Str(
'associateddomain',
multivalue=True,
label=_(u'Domain'),
),
parameters.Str(
'add_domain',
required=False,
label=_(u'Add domain'),
),
parameters.Str(
'del_domain',
required=False,
label=_(u'Delete domain'),
),
)
@register()
class realmdomains_mod(Method):
__doc__ = _("Modify realm domains.")
takes_options = (
parameters.Str(
'associateddomain',
required=False,
multivalue=True,
cli_name='domain',
label=_(u'Domain'),
no_convert=True,
),
parameters.Str(
'add_domain',
required=False,
label=_(u'Add domain'),
no_convert=True,
),
parameters.Str(
'del_domain',
required=False,
label=_(u'Delete domain'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'Force adding domain even if not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class realmdomains_show(Method):
__doc__ = _("Display the list of realm domains.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 5,425
|
Python
|
.py
| 176
| 21.517045
| 162
| 0.551052
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,069
|
hbacrule.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/hbacrule.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Host-based access control
Control who can access what services on what hosts. You
can use HBAC to control which users or groups can
access a service, or group of services, on a target host.
You can also specify a category of users and target hosts.
This is currently limited to "all", but might be expanded in the
future.
Target hosts in HBAC rules must be hosts managed by IPA.
The available services and groups of services are controlled by the
hbacsvc and hbacsvcgroup plug-ins respectively.
EXAMPLES:
Create a rule, "test1", that grants all users access to the host "server" from
anywhere:
ipa hbacrule-add --usercat=all test1
ipa hbacrule-add-host --hosts=server.example.com test1
Display the properties of a named HBAC rule:
ipa hbacrule-show test1
Create a rule for a specific service. This lets the user john access
the sshd service on any machine from any machine:
ipa hbacrule-add --hostcat=all john_sshd
ipa hbacrule-add-user --users=john john_sshd
ipa hbacrule-add-service --hbacsvcs=sshd john_sshd
Create a rule for a new service group. This lets the user john access
the FTP service on any machine from any machine:
ipa hbacsvcgroup-add ftpers
ipa hbacsvc-add sftp
ipa hbacsvcgroup-add-member --hbacsvcs=ftp --hbacsvcs=sftp ftpers
ipa hbacrule-add --hostcat=all john_ftp
ipa hbacrule-add-user --users=john john_ftp
ipa hbacrule-add-service --hbacsvcgroups=ftpers john_ftp
Disable a named HBAC rule:
ipa hbacrule-disable test1
Remove a named HBAC rule:
ipa hbacrule-del allow_server
""")
register = Registry()
@register()
class hbacrule(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Rule name'),
),
parameters.Str(
'accessruletype',
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
),
parameters.Str(
'servicecategory',
required=False,
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Users'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'User Groups'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Hosts'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Host Groups'),
),
parameters.Str(
'sourcehost_host',
required=False,
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
),
parameters.Str(
'memberservice_hbacsvc',
required=False,
label=_(u'Services'),
),
parameters.Str(
'memberservice_hbacsvcgroup',
required=False,
label=_(u'Service Groups'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
),
)
@register()
class hbacrule_add(Method):
__doc__ = _("Create a new HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'accessruletype',
cli_name='type',
cli_metavar="['allow', 'deny']",
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
default=u'allow',
autofill=True,
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_host',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_add_host(Method):
__doc__ = _("Add target hosts and hostgroups to an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_add_service(Method):
__doc__ = _("Add services to an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to add'),
alwaysask=True,
),
parameters.Str(
'hbacsvcgroup',
required=False,
multivalue=True,
cli_name='hbacsvcgroups',
label=_(u'member HBAC service group'),
doc=_(u'HBAC service groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_add_sourcehost(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_add_user(Method):
__doc__ = _("Add users and groups to an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hbacrule_del(Method):
__doc__ = _("Delete an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hbacrule_disable(Method):
__doc__ = _("Disable an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_enable(Method):
__doc__ = _("Enable an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_find(Method):
__doc__ = _("Search for HBAC rules.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Rule name'),
),
parameters.Str(
'accessruletype',
required=False,
cli_name='type',
cli_metavar="['allow', 'deny']",
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
default=u'allow',
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_host',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hbacrule_mod(Method):
__doc__ = _("Modify an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'accessruletype',
required=False,
cli_name='type',
cli_metavar="['allow', 'deny']",
label=_(u'Rule type'),
doc=_(u'Rule type (allow)'),
exclude=('webui', 'cli'),
default=u'allow',
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'sourcehostcategory',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_host',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'sourcehost_hostgroup',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'externalhost',
required=False,
multivalue=True,
label=_(u'External host'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hbacrule_remove_host(Method):
__doc__ = _("Remove target hosts and hostgroups from an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_remove_service(Method):
__doc__ = _("Remove service and service groups from an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'hbacsvc',
required=False,
multivalue=True,
cli_name='hbacsvcs',
label=_(u'member HBAC service'),
doc=_(u'HBAC services to remove'),
alwaysask=True,
),
parameters.Str(
'hbacsvcgroup',
required=False,
multivalue=True,
cli_name='hbacsvcgroups',
label=_(u'member HBAC service group'),
doc=_(u'HBAC service groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_remove_sourcehost(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_remove_user(Method):
__doc__ = _("Remove users and groups from an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hbacrule_show(Method):
__doc__ = _("Display the properties of an HBAC rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 35,779
|
Python
|
.py
| 1,242
| 18.311594
| 162
| 0.491153
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,070
|
sudocmdgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/sudocmdgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Groups of Sudo Commands
Manage groups of Sudo Commands.
EXAMPLES:
Add a new Sudo Command Group:
ipa sudocmdgroup-add --desc='administrators commands' admincmds
Remove a Sudo Command Group:
ipa sudocmdgroup-del admincmds
Manage Sudo Command Group membership, commands:
ipa sudocmdgroup-add-member --sudocmds=/usr/bin/less --sudocmds=/usr/bin/vim admincmds
Manage Sudo Command Group membership, commands:
ipa group-remove-member --sudocmds=/usr/bin/less admincmds
Show a Sudo Command Group:
ipa group-show localadmins
""")
register = Registry()
@register()
class sudocmdgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Sudo Command Group'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Str(
'membercmd_sudocmd',
required=False,
label=_(u'Commands'),
),
parameters.Str(
'membercmd_sudocmdgroup',
required=False,
label=_(u'Sudo Command Groups'),
),
parameters.Str(
'member_sudocmd',
required=False,
label=_(u'Member Sudo commands'),
),
)
@register()
class sudocmdgroup_add(Method):
__doc__ = _("Create new Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmdgroup_add_member(Method):
__doc__ = _("Add members to Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class sudocmdgroup_del(Method):
__doc__ = _("Delete Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class sudocmdgroup_find(Method):
__doc__ = _("Search for Sudo Command Groups.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("sudocmdgroup-name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class sudocmdgroup_mod(Method):
__doc__ = _("Modify Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmdgroup_remove_member(Method):
__doc__ = _("Remove members from Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'sudocmd',
required=False,
multivalue=True,
cli_name='sudocmds',
label=_(u'member sudo command'),
doc=_(u'sudo commands to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class sudocmdgroup_show(Method):
__doc__ = _("Display Sudo Command Group.")
takes_args = (
parameters.Str(
'cn',
cli_name='sudocmdgroup_name',
label=_(u'Sudo Command Group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 14,989
|
Python
|
.py
| 505
| 19.558416
| 162
| 0.513738
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,071
|
join.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/join.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Joining an IPA domain
""")
register = Registry()
@register()
class join(Command):
__doc__ = _("Join an IPA domain")
takes_args = (
parameters.Str(
'cn',
cli_name='hostname',
doc=_(u'The hostname to register as'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: unicode(installutils.get_fqdn())
autofill=True,
),
)
takes_options = (
parameters.Str(
'realm',
doc=_(u'The IPA realm'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# lambda: get_realm()
autofill=True,
),
parameters.Str(
'nshardwareplatform',
required=False,
cli_name='platform',
doc=_(u'Hardware platform of the host (e.g. Lenovo T61)'),
),
parameters.Str(
'nsosversion',
required=False,
cli_name='os',
doc=_(u'Operating System and version of the host (e.g. Fedora 9)'),
),
)
has_output = (
)
| 1,537
|
Python
|
.py
| 56
| 20.089286
| 79
| 0.576375
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,072
|
privilege.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/privilege.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Privileges
A privilege combines permissions into a logical task. A permission provides
the rights to do a single task. There are some IPA operations that require
multiple permissions to succeed. A privilege is where permissions are
combined in order to perform a specific task.
For example, adding a user requires the following permissions:
* Creating a new user entry
* Resetting a user password
* Adding the new user to the default IPA users group
Combining these three low-level tasks into a higher level task in the
form of a privilege named "Add User" makes it easier to manage Roles.
A privilege may not contain other privileges.
See role and permission for additional information.
""")
register = Registry()
@register()
class privilege(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Privilege name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Str(
'memberof_permission',
required=False,
label=_(u'Permissions'),
),
parameters.Str(
'member_role',
required=False,
label=_(u'Granting privilege to roles'),
),
)
@register()
class privilege_add(Method):
__doc__ = _("Add a new privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class privilege_add_member(Method):
__doc__ = _("Add members to a privilege.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'role',
required=False,
multivalue=True,
cli_name='roles',
label=_(u'member role'),
doc=_(u'roles to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class privilege_add_permission(Method):
__doc__ = _("Add permissions to a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'permission',
required=False,
multivalue=True,
cli_name='permissions',
label=_(u'permission'),
doc=_(u'permissions'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of permissions added'),
),
)
@register()
class privilege_del(Method):
__doc__ = _("Delete a privilege.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class privilege_find(Method):
__doc__ = _("Search for privileges.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Privilege name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class privilege_mod(Method):
__doc__ = _("Modify a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Privilege description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the privilege object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class privilege_remove_member(Method):
__doc__ = _("Remove members from a privilege")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'role',
required=False,
multivalue=True,
cli_name='roles',
label=_(u'member role'),
doc=_(u'roles to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class privilege_remove_permission(Method):
__doc__ = _("Remove permissions from a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'permission',
required=False,
multivalue=True,
cli_name='permissions',
label=_(u'permission'),
doc=_(u'permissions'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of permissions removed'),
),
)
@register()
class privilege_show(Method):
__doc__ = _("Display information about a privilege.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Privilege name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 17,919
|
Python
|
.py
| 615
| 19.011382
| 162
| 0.506285
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,073
|
caacl.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/caacl.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Manage CA ACL rules.
This plugin is used to define rules governing which principals are
permitted to have certificates issued using a given certificate
profile.
PROFILE ID SYNTAX:
A Profile ID is a string without spaces or punctuation starting with a letter
and followed by a sequence of letters, digits or underscore ("_").
EXAMPLES:
Create a CA ACL "test" that grants all users access to the
"UserCert" profile:
ipa caacl-add test --usercat=all
ipa caacl-add-profile test --certprofiles UserCert
Display the properties of a named CA ACL:
ipa caacl-show test
Create a CA ACL to let user "alice" use the "DNP3" profile:
ipa caacl-add-profile alice_dnp3 --certprofiles DNP3
ipa caacl-add-user alice_dnp3 --user=alice
Disable a CA ACL:
ipa caacl-disable test
Remove a CA ACL:
ipa caacl-del test
""")
register = Registry()
@register()
class caacl(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'ACL name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
),
parameters.Str(
'ipacertprofilecategory',
required=False,
label=_(u'Profile category'),
doc=_(u'Profile category the ACL applies to'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the ACL applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the ACL applies to'),
),
parameters.Str(
'servicecategory',
required=False,
label=_(u'Service category'),
doc=_(u'Service category the ACL applies to'),
),
parameters.Str(
'ipamembercertprofile_certprofile',
required=False,
label=_(u'Profiles'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Users'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'User Groups'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Hosts'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Host Groups'),
),
parameters.Str(
'memberservice_service',
required=False,
label=_(u'Services'),
),
)
@register()
class caacl_add(Method):
__doc__ = _("Create a new CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipacertprofilecategory',
required=False,
cli_name='profilecat',
cli_metavar="['all']",
label=_(u'Profile category'),
doc=_(u'Profile category the ACL applies to'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the ACL applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the ACL applies to'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the ACL applies to'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class caacl_add_host(Method):
__doc__ = _("Add target hosts and hostgroups to a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class caacl_add_profile(Method):
__doc__ = _("Add profiles to a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'certprofile',
required=False,
multivalue=True,
cli_name='certprofiles',
label=_(u'member Certificate Profile'),
doc=_(u'Certificate Profiles to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class caacl_add_service(Method):
__doc__ = _("Add services to a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'service',
required=False,
multivalue=True,
cli_name='services',
label=_(u'member service'),
doc=_(u'services to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class caacl_add_user(Method):
__doc__ = _("Add users and groups to a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class caacl_del(Method):
__doc__ = _("Delete a CA ACL.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class caacl_disable(Method):
__doc__ = _("Disable a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class caacl_enable(Method):
__doc__ = _("Enable a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class caacl_find(Method):
__doc__ = _("Search for CA ACLs.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'ACL name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipacertprofilecategory',
required=False,
cli_name='profilecat',
cli_metavar="['all']",
label=_(u'Profile category'),
doc=_(u'Profile category the ACL applies to'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the ACL applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the ACL applies to'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the ACL applies to'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class caacl_mod(Method):
__doc__ = _("Modify a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipacertprofilecategory',
required=False,
cli_name='profilecat',
cli_metavar="['all']",
label=_(u'Profile category'),
doc=_(u'Profile category the ACL applies to'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the ACL applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the ACL applies to'),
),
parameters.Str(
'servicecategory',
required=False,
cli_name='servicecat',
cli_metavar="['all']",
label=_(u'Service category'),
doc=_(u'Service category the ACL applies to'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class caacl_remove_host(Method):
__doc__ = _("Remove target hosts and hostgroups from a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class caacl_remove_profile(Method):
__doc__ = _("Remove profiles from a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'certprofile',
required=False,
multivalue=True,
cli_name='certprofiles',
label=_(u'member Certificate Profile'),
doc=_(u'Certificate Profiles to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class caacl_remove_service(Method):
__doc__ = _("Remove services from a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'service',
required=False,
multivalue=True,
cli_name='services',
label=_(u'member service'),
doc=_(u'services to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class caacl_remove_user(Method):
__doc__ = _("Remove users and groups from a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class caacl_show(Method):
__doc__ = _("Display the properties of a CA ACL.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ACL name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 31,324
|
Python
|
.py
| 1,094
| 18.198355
| 162
| 0.488415
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,074
|
service.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/service.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Services
A IPA service represents a service that runs on a host. The IPA service
record can store a Kerberos principal, an SSL certificate, or both.
An IPA service can be managed directly from a machine, provided that
machine has been given the correct permission. This is true even for
machines other than the one the service is associated with. For example,
requesting an SSL certificate using the host service principal credentials
of the host. To manage a service using host credentials you need to
kinit as the host:
# kinit -kt /etc/krb5.keytab host/ipa.example.com@EXAMPLE.COM
Adding an IPA service allows the associated service to request an SSL
certificate or keytab, but this is performed as a separate step; they
are not produced as a result of adding the service.
Only the public aspect of a certificate is stored in a service record;
the private key is not stored.
EXAMPLES:
Add a new IPA service:
ipa service-add HTTP/web.example.com
Allow a host to manage an IPA service certificate:
ipa service-add-host --hosts=web.example.com HTTP/web.example.com
ipa role-add-member --hosts=web.example.com certadmin
Override a default list of supported PAC types for the service:
ipa service-mod HTTP/web.example.com --pac-type=MS-PAC
A typical use case where overriding the PAC type is needed is NFS.
Currently the related code in the Linux kernel can only handle Kerberos
tickets up to a maximal size. Since the PAC data can become quite large it
is recommended to set --pac-type=NONE for NFS services.
Delete an IPA service:
ipa service-del HTTP/web.example.com
Find all IPA services associated with a host:
ipa service-find web.example.com
Find all HTTP services:
ipa service-find HTTP
Disable the service Kerberos key and SSL certificate:
ipa service-disable HTTP/web.example.com
Request a certificate for an IPA service:
ipa cert-request --principal=HTTP/web.example.com example.csr
Allow user to create a keytab:
ipa service-allow-create-keytab HTTP/web.example.com --users=tuser1
Generate and retrieve a keytab for an IPA service:
ipa-getkeytab -s ipa.example.com -p HTTP/web.example.com -k /etc/httpd/httpd.keytab
""")
register = Registry()
@register()
class service(Object):
takes_params = (
parameters.Str(
'krbprincipalname',
primary_key=True,
label=_(u'Principal'),
doc=_(u'Service principal'),
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Flag(
'has_keytab',
label=_(u'Keytab'),
),
parameters.Str(
'managedby_host',
label=_(u'Managed by'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_user',
label=_(u'Users allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_group',
label=_(u'Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_host',
label=_(u'Hosts allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_read_keys_hostgroup',
label=_(u'Host Groups allowed to retrieve keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_user',
label=_(u'Users allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_group',
label=_(u'Groups allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_host',
label=_(u'Hosts allowed to create keytab'),
),
parameters.Str(
'ipaallowedtoperform_write_keys_hostgroup',
label=_(u'Host Groups allowed to create keytab'),
),
)
@register()
class service_add(Method):
__doc__ = _("Add a new IPA new service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'NONE']",
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force principal name even if not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_add_cert(Method):
__doc__ = _("Add new certificates to a service")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
alwaysask=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_add_host(Method):
__doc__ = _("Add hosts that can manage this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class service_allow_create_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to create a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class service_allow_retrieve_keytab(Method):
__doc__ = _("Allow users, groups, hosts or host groups to retrieve a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class service_del(Method):
__doc__ = _("Delete an IPA service.")
takes_args = (
parameters.Str(
'krbprincipalname',
multivalue=True,
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class service_disable(Method):
__doc__ = _("Disable the Kerberos key and SSL certificate of a service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_disallow_create_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to create a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class service_disallow_retrieve_keytab(Method):
__doc__ = _("Disallow users, groups, hosts or host groups to retrieve a keytab of this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class service_find(Method):
__doc__ = _("Search for IPA services.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'krbprincipalname',
required=False,
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'NONE']",
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("principal")'),
default=False,
autofill=True,
),
parameters.Str(
'man_by_host',
required=False,
multivalue=True,
cli_name='man_by_hosts',
label=_(u'host'),
doc=_(u'Search for services with these managed by hosts.'),
),
parameters.Str(
'not_man_by_host',
required=False,
multivalue=True,
cli_name='not_man_by_hosts',
label=_(u'host'),
doc=_(u'Search for services without these managed by hosts.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class service_mod(Method):
__doc__ = _("Modify an existing IPA service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
),
parameters.Str(
'ipakrbauthzdata',
required=False,
multivalue=True,
cli_name='pac_type',
cli_metavar="['MS-PAC', 'PAD', 'NONE']",
label=_(u'PAC type'),
doc=_(u"Override default list of supported PAC types. Use 'NONE' to disable PAC support for this service, e.g. this might be necessary for NFS services."),
),
parameters.Bool(
'ipakrbrequirespreauth',
required=False,
cli_name='requires_pre_auth',
label=_(u'Requires pre-authentication'),
doc=_(u'Pre-authentication is required for the service'),
),
parameters.Bool(
'ipakrbokasdelegate',
required=False,
cli_name='ok_as_delegate',
label=_(u'Trusted for delegation'),
doc=_(u'Client credentials may be delegated to the service'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_remove_cert(Method):
__doc__ = _("Remove certificates from a service")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Bytes(
'usercertificate',
required=False,
multivalue=True,
cli_name='certificate',
label=_(u'Certificate'),
doc=_(u'Base-64 encoded server certificate'),
alwaysask=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class service_remove_host(Method):
__doc__ = _("Remove hosts that can manage this service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class service_show(Method):
__doc__ = _("Display information about an IPA service.")
takes_args = (
parameters.Str(
'krbprincipalname',
cli_name='principal',
label=_(u'Principal'),
doc=_(u'Service principal'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'out',
required=False,
doc=_(u'file to store certificate in'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 35,920
|
Python
|
.py
| 1,159
| 20.547886
| 167
| 0.518288
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,075
|
otptoken_yubikey.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/otptoken_yubikey.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
YubiKey Tokens
Manage YubiKey tokens.
This code is an extension to the otptoken plugin and provides support for
reading/writing YubiKey tokens directly.
EXAMPLES:
Add a new token:
ipa otptoken-add-yubikey --owner=jdoe --desc="My YubiKey"
""")
register = Registry()
| 690
|
Python
|
.py
| 24
| 27.041667
| 73
| 0.797565
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,076
|
selinuxusermap.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/selinuxusermap.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
SELinux User Mapping
Map IPA users to SELinux users by host.
Hosts, hostgroups, users and groups can be either defined within
the rule or it may point to an existing HBAC rule. When using
--hbacrule option to selinuxusermap-find an exact match is made on the
HBAC rule name, so only one or zero entries will be returned.
EXAMPLES:
Create a rule, "test1", that sets all users to xguest_u:s0 on the host "server":
ipa selinuxusermap-add --usercat=all --selinuxuser=xguest_u:s0 test1
ipa selinuxusermap-add-host --hosts=server.example.com test1
Create a rule, "test2", that sets all users to guest_u:s0 and uses an existing HBAC rule for users and hosts:
ipa selinuxusermap-add --usercat=all --hbacrule=webserver --selinuxuser=guest_u:s0 test2
Display the properties of a rule:
ipa selinuxusermap-show test2
Create a rule for a specific user. This sets the SELinux context for
user john to unconfined_u:s0-s0:c0.c1023 on any machine:
ipa selinuxusermap-add --hostcat=all --selinuxuser=unconfined_u:s0-s0:c0.c1023 john_unconfined
ipa selinuxusermap-add-user --users=john john_unconfined
Disable a rule:
ipa selinuxusermap-disable test1
Enable a rule:
ipa selinuxusermap-enable test1
Find a rule referencing a specific HBAC rule:
ipa selinuxusermap-find --hbacrule=allow_some
Remove a rule:
ipa selinuxusermap-del john_unconfined
SEEALSO:
The list controlling the order in which the SELinux user map is applied
and the default SELinux user are available in the config-show command.
""")
register = Registry()
@register()
class selinuxusermap(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Rule name'),
),
parameters.Str(
'ipaselinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
),
parameters.Str(
'memberuser_user',
required=False,
label=_(u'Users'),
),
parameters.Str(
'memberuser_group',
required=False,
label=_(u'User Groups'),
),
parameters.Str(
'memberhost_host',
required=False,
label=_(u'Hosts'),
),
parameters.Str(
'memberhost_hostgroup',
required=False,
label=_(u'Host Groups'),
),
)
@register()
class selinuxusermap_add(Method):
__doc__ = _("Create a new SELinux User Map.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'ipaselinuxuser',
cli_name='selinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
cli_name='hbacrule',
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_add_host(Method):
__doc__ = _("Add target hosts and hostgroups to an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class selinuxusermap_add_user(Method):
__doc__ = _("Add users and groups to an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class selinuxusermap_del(Method):
__doc__ = _("Delete a SELinux User Map.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class selinuxusermap_disable(Method):
__doc__ = _("Disable an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_enable(Method):
__doc__ = _("Enable an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_find(Method):
__doc__ = _("Search for SELinux User Maps.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Rule name'),
),
parameters.Str(
'ipaselinuxuser',
required=False,
cli_name='selinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
cli_name='hbacrule',
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class selinuxusermap_mod(Method):
__doc__ = _("Modify a SELinux User Map.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Str(
'ipaselinuxuser',
required=False,
cli_name='selinuxuser',
label=_(u'SELinux User'),
),
parameters.Str(
'seealso',
required=False,
cli_name='hbacrule',
label=_(u'HBAC Rule'),
doc=_(u'HBAC Rule that defines the users, groups and hostgroups'),
),
parameters.Str(
'usercategory',
required=False,
cli_name='usercat',
cli_metavar="['all']",
label=_(u'User category'),
doc=_(u'User category the rule applies to'),
),
parameters.Str(
'hostcategory',
required=False,
cli_name='hostcat',
cli_metavar="['all']",
label=_(u'Host category'),
doc=_(u'Host category the rule applies to'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Bool(
'ipaenabledflag',
required=False,
label=_(u'Enabled'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class selinuxusermap_remove_host(Method):
__doc__ = _("Remove target hosts and hostgroups from an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class selinuxusermap_remove_user(Method):
__doc__ = _("Remove users and groups from an SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class selinuxusermap_show(Method):
__doc__ = _("Display the properties of a SELinux User Map rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Rule name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 25,218
|
Python
|
.py
| 852
| 19.319249
| 162
| 0.505409
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,077
|
otpconfig.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/otpconfig.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
OTP configuration
Manage the default values that IPA uses for OTP tokens.
EXAMPLES:
Show basic OTP configuration:
ipa otpconfig-show
Show all OTP configuration options:
ipa otpconfig-show --all
Change maximum TOTP authentication window to 10 minutes:
ipa otpconfig-mod --totp-auth-window=600
Change maximum TOTP synchronization window to 12 hours:
ipa otpconfig-mod --totp-sync-window=43200
Change maximum HOTP authentication window to 5:
ipa hotpconfig-mod --hotp-auth-window=5
Change maximum HOTP synchronization window to 50:
ipa hotpconfig-mod --hotp-sync-window=50
""")
register = Registry()
@register()
class otpconfig(Object):
takes_params = (
parameters.Int(
'ipatokentotpauthwindow',
label=_(u'TOTP authentication Window'),
doc=_(u'TOTP authentication time variance (seconds)'),
),
parameters.Int(
'ipatokentotpsyncwindow',
label=_(u'TOTP Synchronization Window'),
doc=_(u'TOTP synchronization time variance (seconds)'),
),
parameters.Int(
'ipatokenhotpauthwindow',
label=_(u'HOTP Authentication Window'),
doc=_(u'HOTP authentication skip-ahead'),
),
parameters.Int(
'ipatokenhotpsyncwindow',
label=_(u'HOTP Synchronization Window'),
doc=_(u'HOTP synchronization skip-ahead'),
),
)
@register()
class otpconfig_mod(Method):
__doc__ = _("Modify OTP configuration options.")
takes_options = (
parameters.Int(
'ipatokentotpauthwindow',
required=False,
cli_name='totp_auth_window',
label=_(u'TOTP authentication Window'),
doc=_(u'TOTP authentication time variance (seconds)'),
),
parameters.Int(
'ipatokentotpsyncwindow',
required=False,
cli_name='totp_sync_window',
label=_(u'TOTP Synchronization Window'),
doc=_(u'TOTP synchronization time variance (seconds)'),
),
parameters.Int(
'ipatokenhotpauthwindow',
required=False,
cli_name='hotp_auth_window',
label=_(u'HOTP Authentication Window'),
doc=_(u'HOTP authentication skip-ahead'),
),
parameters.Int(
'ipatokenhotpsyncwindow',
required=False,
cli_name='hotp_sync_window',
label=_(u'HOTP Synchronization Window'),
doc=_(u'HOTP synchronization skip-ahead'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class otpconfig_show(Method):
__doc__ = _("Show the current OTP configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 6,184
|
Python
|
.py
| 185
| 24.140541
| 162
| 0.576614
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,078
|
cert.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/cert.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
IPA certificate operations
Implements a set of commands for managing server SSL certificates.
Certificate requests exist in the form of a Certificate Signing Request (CSR)
in PEM format.
The dogtag CA uses just the CN value of the CSR and forces the rest of the
subject to values configured in the server.
A certificate is stored with a service principal and a service principal
needs a host.
In order to request a certificate:
* The host must exist
* The service must exist (or you use the --add option to automatically add it)
SEARCHING:
Certificates may be searched on by certificate subject, serial number,
revocation reason, validity dates and the issued date.
When searching on dates the _from date does a >= search and the _to date
does a <= search. When combined these are done as an AND.
Dates are treated as GMT to match the dates in the certificates.
The date format is YYYY-mm-dd.
EXAMPLES:
Request a new certificate and add the principal:
ipa cert-request --add --principal=HTTP/lion.example.com example.csr
Retrieve an existing certificate:
ipa cert-show 1032
Revoke a certificate (see RFC 5280 for reason details):
ipa cert-revoke --revocation-reason=6 1032
Remove a certificate from revocation hold status:
ipa cert-remove-hold 1032
Check the status of a signing request:
ipa cert-status 10
Search for certificates by hostname:
ipa cert-find --subject=ipaserver.example.com
Search for revoked certificates by reason:
ipa cert-find --revocation-reason=5
Search for certificates based on issuance date
ipa cert-find --issuedon-from=2013-02-01 --issuedon-to=2013-02-07
IPA currently immediately issues (or declines) all certificate requests so
the status of a request is not normally useful. This is for future use
or the case where a CA does not immediately issue a certificate.
The following revocation reasons are supported:
* 0 - unspecified
* 1 - keyCompromise
* 2 - cACompromise
* 3 - affiliationChanged
* 4 - superseded
* 5 - cessationOfOperation
* 6 - certificateHold
* 8 - removeFromCRL
* 9 - privilegeWithdrawn
* 10 - aACompromise
Note that reason code 7 is not used. See RFC 5280 for more details:
http://www.ietf.org/rfc/rfc5280.txt
""")
register = Registry()
@register()
class ca_is_enabled(Command):
__doc__ = _("Checks if any of the servers has the CA service enabled.")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class cert_find(Command):
__doc__ = _("Search for existing certificates.")
takes_options = (
parameters.Str(
'subject',
required=False,
label=_(u'Match cn attribute in subject'),
),
parameters.Int(
'revocation_reason',
required=False,
label=_(u'Reason'),
doc=_(u'Reason for revoking the certificate (0-10)'),
),
parameters.Int(
'min_serial_number',
required=False,
doc=_(u'minimum serial number'),
),
parameters.Int(
'max_serial_number',
required=False,
doc=_(u'maximum serial number'),
),
parameters.Flag(
'exactly',
required=False,
doc=_(u'match the common name exactly'),
default=False,
autofill=True,
),
parameters.Str(
'validnotafter_from',
required=False,
doc=_(u'Valid not after from this date (YYYY-mm-dd)'),
),
parameters.Str(
'validnotafter_to',
required=False,
doc=_(u'Valid not after to this date (YYYY-mm-dd)'),
),
parameters.Str(
'validnotbefore_from',
required=False,
doc=_(u'Valid not before from this date (YYYY-mm-dd)'),
),
parameters.Str(
'validnotbefore_to',
required=False,
doc=_(u'Valid not before to this date (YYYY-mm-dd)'),
),
parameters.Str(
'issuedon_from',
required=False,
doc=_(u'Issued on from this date (YYYY-mm-dd)'),
),
parameters.Str(
'issuedon_to',
required=False,
doc=_(u'Issued on to this date (YYYY-mm-dd)'),
),
parameters.Str(
'revokedon_from',
required=False,
doc=_(u'Revoked on from this date (YYYY-mm-dd)'),
),
parameters.Str(
'revokedon_to',
required=False,
doc=_(u'Revoked on to this date (YYYY-mm-dd)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of certs returned'),
default=100,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class cert_remove_hold(Command):
__doc__ = _("Take a revoked certificate off hold.")
takes_args = (
parameters.Str(
'serial_number',
label=_(u'Serial number'),
doc=_(u'Serial number in decimal or if prefixed with 0x in hexadecimal'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
@register()
class cert_request(Command):
__doc__ = _("Submit a certificate signing request.")
takes_args = (
parameters.Str(
'csr',
cli_name='csr_file',
label=_(u'CSR'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'principal',
label=_(u'Principal'),
doc=_(u'Principal for this certificate (e.g. HTTP/test.example.com)'),
),
parameters.Str(
'request_type',
default=u'pkcs10',
autofill=True,
),
parameters.Flag(
'add',
doc=_(u"automatically add the principal if it doesn't exist"),
default=False,
autofill=True,
),
parameters.Str(
'profile_id',
required=False,
label=_(u'Profile ID'),
doc=_(u'Certificate Profile to use'),
),
)
has_output = (
output.Output(
'result',
dict,
doc=_(u'Dictionary mapping variable name to value'),
),
)
@register()
class cert_revoke(Command):
__doc__ = _("Revoke a certificate.")
takes_args = (
parameters.Str(
'serial_number',
label=_(u'Serial number'),
doc=_(u'Serial number in decimal or if prefixed with 0x in hexadecimal'),
no_convert=True,
),
)
takes_options = (
parameters.Int(
'revocation_reason',
label=_(u'Reason'),
doc=_(u'Reason for revoking the certificate (0-10)'),
default=0,
autofill=True,
),
)
has_output = (
output.Output(
'result',
),
)
@register()
class cert_show(Command):
__doc__ = _("Retrieve an existing certificate.")
takes_args = (
parameters.Str(
'serial_number',
label=_(u'Serial number'),
doc=_(u'Serial number in decimal or if prefixed with 0x in hexadecimal'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'out',
required=False,
label=_(u'Output filename'),
doc=_(u'File to store the certificate in.'),
exclude=('webui',),
),
)
has_output = (
output.Output(
'result',
),
)
@register()
class cert_status(Command):
__doc__ = _("Check the status of a certificate signing request.")
takes_args = (
parameters.Str(
'request_id',
label=_(u'Request id'),
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
| 9,940
|
Python
|
.py
| 330
| 21.775758
| 97
| 0.570203
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,079
|
hostgroup.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/hostgroup.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Groups of hosts.
Manage groups of hosts. This is useful for applying access control to a
number of hosts by using Host-based Access Control.
EXAMPLES:
Add a new host group:
ipa hostgroup-add --desc="Baltimore hosts" baltimore
Add another new host group:
ipa hostgroup-add --desc="Maryland hosts" maryland
Add members to the hostgroup (using Bash brace expansion):
ipa hostgroup-add-member --hosts={box1,box2,box3} baltimore
Add a hostgroup as a member of another hostgroup:
ipa hostgroup-add-member --hostgroups=baltimore maryland
Remove a host from the hostgroup:
ipa hostgroup-remove-member --hosts=box2 baltimore
Display a host group:
ipa hostgroup-show baltimore
Delete a hostgroup:
ipa hostgroup-del baltimore
""")
register = Registry()
@register()
class hostgroup(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Str(
'member_host',
required=False,
label=_(u'Member hosts'),
),
parameters.Str(
'member_hostgroup',
required=False,
label=_(u'Member host-groups'),
),
parameters.Str(
'memberof_hostgroup',
required=False,
label=_(u'Member of host-groups'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberindirect_host',
required=False,
label=_(u'Indirect Member hosts'),
),
parameters.Str(
'memberindirect_hostgroup',
required=False,
label=_(u'Indirect Member host-groups'),
),
parameters.Str(
'memberofindirect_hostgroup',
required=False,
label=_(u'Indirect Member of host-group'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
)
@register()
class hostgroup_add(Method):
__doc__ = _("Add a new hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hostgroup_add_member(Method):
__doc__ = _("Add members to a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to add'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class hostgroup_del(Method):
__doc__ = _("Delete a hostgroup.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class hostgroup_find(Method):
__doc__ = _("Search for hostgroups.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("hostgroup-name")'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'host'),
doc=_(u'Search for host groups with these member hosts.'),
),
parameters.Str(
'no_host',
required=False,
multivalue=True,
cli_name='no_hosts',
label=_(u'host'),
doc=_(u'Search for host groups without these member hosts.'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups with these member host groups.'),
),
parameters.Str(
'no_hostgroup',
required=False,
multivalue=True,
cli_name='no_hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups without these member host groups.'),
),
parameters.Str(
'in_hostgroup',
required=False,
multivalue=True,
cli_name='in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups with these member of host groups.'),
),
parameters.Str(
'not_in_hostgroup',
required=False,
multivalue=True,
cli_name='not_in_hostgroups',
label=_(u'host group'),
doc=_(u'Search for host groups without these member of host groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for host groups with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for host groups without these member of netgroups.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for host groups with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for host groups without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for host groups with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for host groups without these member of sudo rules.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class hostgroup_mod(Method):
__doc__ = _("Modify a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this host-group'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class hostgroup_remove_member(Method):
__doc__ = _("Remove members from a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'member host'),
doc=_(u'hosts to remove'),
alwaysask=True,
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'member host group'),
doc=_(u'host groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class hostgroup_show(Method):
__doc__ = _("Display information about a hostgroup.")
takes_args = (
parameters.Str(
'cn',
cli_name='hostgroup_name',
label=_(u'Host-group'),
doc=_(u'Name of host-group'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 20,373
|
Python
|
.py
| 672
| 19.815476
| 162
| 0.508544
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,080
|
servicedelegation.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/servicedelegation.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Service Constrained Delegation
Manage rules to allow constrained delegation of credentials so
that a service can impersonate a user when communicating with another
service without requiring the user to actually forward their TGT.
This makes for a much better method of delegating credentials as it
prevents exposure of the short term secret of the user.
The naming convention is to append the word "target" or "targets" to
a matching rule name. This is not mandatory but helps conceptually
to associate rules and targets.
A rule consists of two things:
- A list of targets the rule applies to
- A list of memberPrincipals that are allowed to delegate for
those targets
A target consists of a list of principals that can be delegated.
In English, a rule says that this principal can delegate as this
list of principals, as defined by these targets.
EXAMPLES:
Add a new constrained delegation rule:
ipa servicedelegationrule-add ftp-delegation
Add a new constrained delegation target:
ipa servicedelegationtarget-add ftp-delegation-target
Add a principal to the rule:
ipa servicedelegationrule-add-member --principals=ftp/ipa.example.com ftp-delegation
Add our target to the rule:
ipa servicedelegationrule-add-target --servicedelegationtargets=ftp-delegation-target ftp-delegation
Add a principal to the target:
ipa servicedelegationtarget-add-member --principals=ldap/ipa.example.com ftp-delegation-target
Display information about a named delegation rule and target:
ipa servicedelegationrule_show ftp-delegation
ipa servicedelegationtarget_show ftp-delegation-target
Remove a constrained delegation:
ipa servicedelegationrule-del ftp-delegation-target
ipa servicedelegationtarget-del ftp-delegation
In this example the ftp service can get a TGT for the ldap service on
the bound user's behalf.
It is strongly discouraged to modify the delegations that ship with
IPA, ipa-http-delegation and its targets ipa-cifs-delegation-targets and
ipa-ldap-delegation-targets. Incorrect changes can remove the ability
to delegate, causing the framework to stop functioning.
""")
register = Registry()
@register()
class servicedelegationrule(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Delegation name'),
),
parameters.Str(
'ipaallowedtarget_servicedelegationtarget',
label=_(u'Allowed Target'),
),
)
@register()
class servicedelegationtarget(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Delegation name'),
),
)
@register()
class servicedelegationrule_add(Method):
__doc__ = _("Create a new service delegation rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class servicedelegationrule_add_member(Method):
__doc__ = _("Add member to a named service delegation rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'principal',
required=False,
multivalue=True,
cli_name='principals',
label=_(u'member principal'),
doc=_(u'principal to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class servicedelegationrule_add_target(Method):
__doc__ = _("Add target to a named service delegation rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'servicedelegationtarget',
required=False,
multivalue=True,
cli_name='servicedelegationtargets',
label=_(u'member service delegation target'),
doc=_(u'service delegation targets to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class servicedelegationrule_del(Method):
__doc__ = _("Delete service delegation.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class servicedelegationrule_find(Method):
__doc__ = _("Search for service delegations rule.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='delegation_name',
label=_(u'Delegation name'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("delegation-name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class servicedelegationrule_remove_member(Method):
__doc__ = _("Remove member from a named service delegation rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'principal',
required=False,
multivalue=True,
cli_name='principals',
label=_(u'member principal'),
doc=_(u'principal to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class servicedelegationrule_remove_target(Method):
__doc__ = _("Remove target from a named service delegation rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'servicedelegationtarget',
required=False,
multivalue=True,
cli_name='servicedelegationtargets',
label=_(u'member service delegation target'),
doc=_(u'service delegation targets to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class servicedelegationrule_show(Method):
__doc__ = _("Display information about a named service delegation rule.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class servicedelegationtarget_add(Method):
__doc__ = _("Create a new service delegation target.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class servicedelegationtarget_add_member(Method):
__doc__ = _("Add member to a named service delegation target.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'principal',
required=False,
multivalue=True,
cli_name='principals',
label=_(u'member principal'),
doc=_(u'principal to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class servicedelegationtarget_del(Method):
__doc__ = _("Delete service delegation target.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class servicedelegationtarget_find(Method):
__doc__ = _("Search for service delegation target.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='delegation_name',
label=_(u'Delegation name'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("delegation-name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class servicedelegationtarget_remove_member(Method):
__doc__ = _("Remove member from a named service delegation target.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'principal',
required=False,
multivalue=True,
cli_name='principals',
label=_(u'member principal'),
doc=_(u'principal to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class servicedelegationtarget_show(Method):
__doc__ = _("Display information about a named service delegation target.")
takes_args = (
parameters.Str(
'cn',
cli_name='delegation_name',
label=_(u'Delegation name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 25,495
|
Python
|
.py
| 841
| 20.492271
| 162
| 0.532821
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,081
|
aci.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/aci.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Directory Server Access Control Instructions (ACIs)
ACIs are used to allow or deny access to information. This module is
currently designed to allow, not deny, access.
The aci commands are designed to grant permissions that allow updating
existing entries or adding or deleting new ones. The goal of the ACIs
that ship with IPA is to provide a set of low-level permissions that
grant access to special groups called taskgroups. These low-level
permissions can be combined into roles that grant broader access. These
roles are another type of group, roles.
For example, if you have taskgroups that allow adding and modifying users you
could create a role, useradmin. You would assign users to the useradmin
role to allow them to do the operations defined by the taskgroups.
You can create ACIs that delegate permission so users in group A can write
attributes on group B.
The type option is a map that applies to all entries in the users, groups or
host location. It is primarily designed to be used when granting add
permissions (to write new entries).
An ACI consists of three parts:
1. target
2. permissions
3. bind rules
The target is a set of rules that define which LDAP objects are being
targeted. This can include a list of attributes, an area of that LDAP
tree or an LDAP filter.
The targets include:
- attrs: list of attributes affected
- type: an object type (user, group, host, service, etc)
- memberof: members of a group
- targetgroup: grant access to modify a specific group. This is primarily
designed to enable users to add or remove members of a specific group.
- filter: A legal LDAP filter used to narrow the scope of the target.
- subtree: Used to apply a rule across an entire set of objects. For example,
to allow adding users you need to grant "add" permission to the subtree
ldap://uid=*,cn=users,cn=accounts,dc=example,dc=com. The subtree option
is a fail-safe for objects that may not be covered by the type option.
The permissions define what the ACI is allowed to do, and are one or
more of:
1. write - write one or more attributes
2. read - read one or more attributes
3. add - add a new entry to the tree
4. delete - delete an existing entry
5. all - all permissions are granted
Note the distinction between attributes and entries. The permissions are
independent, so being able to add a user does not mean that the user will
be editable.
The bind rule defines who this ACI grants permissions to. The LDAP server
allows this to be any valid LDAP entry but we encourage the use of
taskgroups so that the rights can be easily shared through roles.
For a more thorough description of access controls see
http://www.redhat.com/docs/manuals/dir-server/ag/8.0/Managing_Access_Control.html
EXAMPLES:
NOTE: ACIs are now added via the permission plugin. These examples are to
demonstrate how the various options work but this is done via the permission
command-line now (see last example).
Add an ACI so that the group "secretaries" can update the address on any user:
ipa group-add --desc="Office secretaries" secretaries
ipa aci-add --attrs=streetAddress --memberof=ipausers --group=secretaries --permissions=write --prefix=none "Secretaries write addresses"
Show the new ACI:
ipa aci-show --prefix=none "Secretaries write addresses"
Add an ACI that allows members of the "addusers" permission to add new users:
ipa aci-add --type=user --permission=addusers --permissions=add --prefix=none "Add new users"
Add an ACI that allows members of the editors manage members of the admins group:
ipa aci-add --permissions=write --attrs=member --targetgroup=admins --group=editors --prefix=none "Editors manage admins"
Add an ACI that allows members of the admins group to manage the street and zip code of those in the editors group:
ipa aci-add --permissions=write --memberof=editors --group=admins --attrs=street --attrs=postalcode --prefix=none "admins edit the address of editors"
Add an ACI that allows the admins group manage the street and zipcode of those who work for the boss:
ipa aci-add --permissions=write --group=admins --attrs=street --attrs=postalcode --filter="(manager=uid=boss,cn=users,cn=accounts,dc=example,dc=com)" --prefix=none "Edit the address of those who work for the boss"
Add an entirely new kind of record to IPA that isn't covered by any of the --type options, creating a permission:
ipa permission-add --permissions=add --subtree="cn=*,cn=orange,cn=accounts,dc=example,dc=com" --desc="Add Orange Entries" add_orange
The show command shows the raw 389-ds ACI.
IMPORTANT: When modifying the target attributes of an existing ACI you
must include all existing attributes as well. When doing an aci-mod the
targetattr REPLACES the current attributes, it does not add to them.
""")
register = Registry()
@register()
class aci(Object):
takes_params = (
parameters.Str(
'aciname',
primary_key=True,
label=_(u'ACI name'),
),
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
),
)
@register()
class aci_add(Method):
__doc__ = _("Create new ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
autofill=True,
),
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Flag(
'test',
required=False,
doc=_(u"Test the ACI syntax but don't write anything"),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_del(Method):
__doc__ = _("Delete ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_find(Method):
__doc__ = _("""
Search for ACIs.
Returns a list of ACIs
EXAMPLES:
To find all ACIs that apply directly to members of the group ipausers:
ipa aci-find --memberof=ipausers
To find all ACIs that grant add access:
ipa aci-find --permissions=add
Note that the find command only looks for the given text in the set of
ACIs, it does not evaluate the ACIs to see if something would apply.
For example, searching on memberof=ipausers will find all ACIs that
have ipausers as a memberof. There may be other ACIs that apply to
members of that group indirectly.
""")
NO_CLI = True
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'aciname',
required=False,
cli_name='name',
label=_(u'ACI name'),
),
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Bool(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
),
parameters.Str(
'aciprefix',
required=False,
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class aci_mod(Method):
__doc__ = _("Modify ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
autofill=True,
),
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_rename(Method):
__doc__ = _("Rename an ACI.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'permission',
required=False,
label=_(u'Permission'),
doc=_(u'Permission ACI grants access to'),
),
parameters.Str(
'group',
required=False,
label=_(u'User group'),
doc=_(u'User group ACI grants access to'),
),
parameters.Str(
'permissions',
required=False,
multivalue=True,
label=_(u'Permissions'),
doc=_(u'Permissions to grant(read, write, add, delete, all)'),
no_convert=True,
),
parameters.Str(
'attrs',
required=False,
multivalue=True,
label=_(u'Attributes to which the permission applies'),
doc=_(u'Attributes'),
),
parameters.Str(
'type',
required=False,
cli_metavar="['user', 'group', 'host', 'service', 'hostgroup', 'netgroup', 'dnsrecord']",
label=_(u'Type'),
doc=_(u'type of IPA object (user, group, host, hostgroup, service, netgroup)'),
),
parameters.Str(
'memberof',
required=False,
label=_(u'Member of'),
doc=_(u'Member of a group'),
),
parameters.Str(
'filter',
required=False,
label=_(u'Filter'),
doc=_(u'Legal LDAP filter (e.g. ou=Engineering)'),
),
parameters.Str(
'subtree',
required=False,
label=_(u'Subtree'),
doc=_(u'Subtree to apply ACI to'),
),
parameters.Str(
'targetgroup',
required=False,
label=_(u'Target group'),
doc=_(u'Group to apply ACI to'),
),
parameters.Flag(
'selfaci',
required=False,
cli_name='self',
label=_(u'Target your own entry (self)'),
doc=_(u'Apply ACI to your own entry (self)'),
default=False,
autofill=True,
),
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.Str(
'newname',
doc=_(u'New ACI name'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class aci_show(Method):
__doc__ = _("Display a single ACI given an ACI name.")
NO_CLI = True
takes_args = (
parameters.Str(
'aciname',
cli_name='name',
label=_(u'ACI name'),
),
)
takes_options = (
parameters.Str(
'aciprefix',
cli_name='prefix',
cli_metavar="['permission', 'delegation', 'selfservice', 'none']",
label=_(u'ACI prefix'),
doc=_(u'Prefix used to distinguish ACI types (permission, delegation, selfservice, none)'),
),
parameters.DNParam(
'location',
required=False,
label=_(u'Location of the ACI'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 25,449
|
Python
|
.py
| 752
| 24.06117
| 216
| 0.549499
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,082
|
pwpolicy.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/pwpolicy.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Password policy
A password policy sets limitations on IPA passwords, including maximum
lifetime, minimum lifetime, the number of passwords to save in
history, the number of character classes required (for stronger passwords)
and the minimum password length.
By default there is a single, global policy for all users. You can also
create a password policy to apply to a group. Each user is only subject
to one password policy, either the group policy or the global policy. A
group policy stands alone; it is not a super-set of the global policy plus
custom settings.
Each group password policy requires a unique priority setting. If a user
is in multiple groups that have password policies, this priority determines
which password policy is applied. A lower value indicates a higher priority
policy.
Group password policies are automatically removed when the groups they
are associated with are removed.
EXAMPLES:
Modify the global policy:
ipa pwpolicy-mod --minlength=10
Add a new group password policy:
ipa pwpolicy-add --maxlife=90 --minlife=1 --history=10 --minclasses=3 --minlength=8 --priority=10 localadmins
Display the global password policy:
ipa pwpolicy-show
Display a group password policy:
ipa pwpolicy-show localadmins
Display the policy that would be applied to a given user:
ipa pwpolicy-show --user=tuser1
Modify a group password policy:
ipa pwpolicy-mod --minclasses=2 localadmins
""")
register = Registry()
@register()
class cosentry(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
),
parameters.DNParam(
'krbpwdpolicyreference',
),
parameters.Int(
'cospriority',
),
)
@register()
class pwpolicy(Object):
takes_params = (
parameters.Str(
'cn',
required=False,
primary_key=True,
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
parameters.Int(
'krbmaxpwdlife',
required=False,
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
)
@register()
class cosentry_add(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
),
)
takes_options = (
parameters.DNParam(
'krbpwdpolicyreference',
),
parameters.Int(
'cospriority',
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class cosentry_del(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
multivalue=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class cosentry_find(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
),
parameters.DNParam(
'krbpwdpolicyreference',
required=False,
),
parameters.Int(
'cospriority',
required=False,
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("cn")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class cosentry_mod(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
),
)
takes_options = (
parameters.DNParam(
'krbpwdpolicyreference',
required=False,
),
parameters.Int(
'cospriority',
required=False,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class cosentry_show(Method):
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class pwpolicy_add(Method):
__doc__ = _("Add a new group password policy.")
takes_args = (
parameters.Str(
'cn',
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Int(
'krbmaxpwdlife',
required=False,
cli_name='maxlife',
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
cli_name='minlife',
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
cli_name='history',
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
cli_name='minclasses',
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
cli_name='minlength',
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
cli_name='priority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
cli_name='maxfail',
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
cli_name='failinterval',
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
cli_name='lockouttime',
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class pwpolicy_del(Method):
__doc__ = _("Delete a group password policy.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class pwpolicy_find(Method):
__doc__ = _("Search for group password policies.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
parameters.Int(
'krbmaxpwdlife',
required=False,
cli_name='maxlife',
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
cli_name='minlife',
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
cli_name='history',
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
cli_name='minclasses',
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
cli_name='minlength',
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
required=False,
cli_name='priority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
cli_name='maxfail',
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
cli_name='failinterval',
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
cli_name='lockouttime',
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("group")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class pwpolicy_mod(Method):
__doc__ = _("Modify a group password policy.")
takes_args = (
parameters.Str(
'cn',
required=False,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Int(
'krbmaxpwdlife',
required=False,
cli_name='maxlife',
label=_(u'Max lifetime (days)'),
doc=_(u'Maximum password lifetime (in days)'),
),
parameters.Int(
'krbminpwdlife',
required=False,
cli_name='minlife',
label=_(u'Min lifetime (hours)'),
doc=_(u'Minimum password lifetime (in hours)'),
),
parameters.Int(
'krbpwdhistorylength',
required=False,
cli_name='history',
label=_(u'History size'),
doc=_(u'Password history size'),
),
parameters.Int(
'krbpwdmindiffchars',
required=False,
cli_name='minclasses',
label=_(u'Character classes'),
doc=_(u'Minimum number of character classes'),
),
parameters.Int(
'krbpwdminlength',
required=False,
cli_name='minlength',
label=_(u'Min length'),
doc=_(u'Minimum length of password'),
),
parameters.Int(
'cospriority',
required=False,
cli_name='priority',
label=_(u'Priority'),
doc=_(u'Priority of the policy (higher number means lower priority'),
),
parameters.Int(
'krbpwdmaxfailure',
required=False,
cli_name='maxfail',
label=_(u'Max failures'),
doc=_(u'Consecutive failures before lockout'),
),
parameters.Int(
'krbpwdfailurecountinterval',
required=False,
cli_name='failinterval',
label=_(u'Failure reset interval'),
doc=_(u'Period after which failure count will be reset (seconds)'),
),
parameters.Int(
'krbpwdlockoutduration',
required=False,
cli_name='lockouttime',
label=_(u'Lockout duration'),
doc=_(u'Period for which lockout is enforced (seconds)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class pwpolicy_show(Method):
__doc__ = _("Display information about password policy.")
takes_args = (
parameters.Str(
'cn',
required=False,
cli_name='group',
label=_(u'Group'),
doc=_(u'Manage password policy for specific group'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
label=_(u'User'),
doc=_(u'Display effective policy for a specific user'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 27,506
|
Python
|
.py
| 887
| 20.700113
| 162
| 0.523542
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,083
|
misc.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/misc.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Misc plug-ins
""")
register = Registry()
@register()
class env(Command):
__doc__ = _("Show environment variables.")
takes_args = (
parameters.Str(
'variables',
required=False,
multivalue=True,
),
)
takes_options = (
parameters.Flag(
'server',
required=False,
doc=_(u'Forward to server instead of running locally'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=True,
autofill=True,
),
)
has_output = (
output.Output(
'result',
dict,
doc=_(u'Dictionary mapping variable name to value'),
),
output.Output(
'total',
int,
doc=_(u'Total number of variables env (>= count)'),
),
output.Output(
'count',
int,
doc=_(u'Number of variables returned (<= total)'),
),
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
)
@register()
class plugins(Command):
__doc__ = _("Show all loaded plugins.")
takes_options = (
parameters.Flag(
'server',
required=False,
doc=_(u'Forward to server instead of running locally'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=True,
autofill=True,
),
)
has_output = (
output.Output(
'result',
dict,
doc=_(u'Dictionary mapping plugin names to bases'),
),
output.Output(
'count',
int,
doc=_(u'Number of plugins loaded'),
),
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
)
| 2,753
|
Python
|
.py
| 102
| 18.313725
| 97
| 0.534091
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,084
|
sudocmd.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/sudocmd.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Sudo Commands
Commands used as building blocks for sudo
EXAMPLES:
Create a new command
ipa sudocmd-add --desc='For reading log files' /usr/bin/less
Remove a command
ipa sudocmd-del /usr/bin/less
""")
register = Registry()
@register()
class sudocmd(Object):
takes_params = (
parameters.Str(
'sudocmd',
primary_key=True,
label=_(u'Sudo Command'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Str(
'memberof_sudocmdgroup',
required=False,
label=_(u'Sudo Command Groups'),
),
)
@register()
class sudocmd_add(Method):
__doc__ = _("Create new Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmd_del(Method):
__doc__ = _("Delete Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
multivalue=True,
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class sudocmd_find(Method):
__doc__ = _("Search for Sudo Commands.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'sudocmd',
required=False,
cli_name='command',
label=_(u'Sudo Command'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("command")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class sudocmd_mod(Method):
__doc__ = _("Modify Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'A description of this command'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class sudocmd_show(Method):
__doc__ = _("Display Sudo Command.")
takes_args = (
parameters.Str(
'sudocmd',
cli_name='command',
label=_(u'Sudo Command'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 10,907
|
Python
|
.py
| 368
| 19.622283
| 162
| 0.512984
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,085
|
server.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/server.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
IPA servers
Get information about installed IPA servers.
EXAMPLES:
Find all servers:
ipa server-find
Show specific server:
ipa server-show ipa.example.com
""")
register = Registry()
@register()
class server(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Server name'),
doc=_(u'IPA server hostname'),
),
parameters.Str(
'iparepltopomanagedsuffix',
label=_(u'Managed suffix'),
),
parameters.Int(
'ipamindomainlevel',
label=_(u'Min domain level'),
doc=_(u'Minimum domain level'),
),
parameters.Int(
'ipamaxdomainlevel',
label=_(u'Max domain level'),
doc=_(u'Maximum domain level'),
),
)
@register()
class server_del(Method):
__doc__ = _("Delete IPA server.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Server name'),
doc=_(u'IPA server hostname'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class server_find(Method):
__doc__ = _("Search for IPA servers.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Server name'),
doc=_(u'IPA server hostname'),
),
parameters.Str(
'iparepltopomanagedsuffix',
required=False,
cli_name='suffix',
label=_(u'Managed suffix'),
),
parameters.Int(
'ipamindomainlevel',
required=False,
cli_name='minlevel',
label=_(u'Min domain level'),
doc=_(u'Minimum domain level'),
),
parameters.Int(
'ipamaxdomainlevel',
required=False,
cli_name='maxlevel',
label=_(u'Max domain level'),
doc=_(u'Maximum domain level'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class server_show(Method):
__doc__ = _("Show IPA server.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Server name'),
doc=_(u'IPA server hostname'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 6,296
|
Python
|
.py
| 225
| 18.444444
| 110
| 0.511901
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,086
|
idrange.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/idrange.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
ID ranges
Manage ID ranges used to map Posix IDs to SIDs and back.
There are two type of ID ranges which are both handled by this utility:
- the ID ranges of the local domain
- the ID ranges of trusted remote domains
Both types have the following attributes in common:
- base-id: the first ID of the Posix ID range
- range-size: the size of the range
With those two attributes a range object can reserve the Posix IDs starting
with base-id up to but not including base-id+range-size exclusively.
Additionally an ID range of the local domain may set
- rid-base: the first RID(*) of the corresponding RID range
- secondary-rid-base: first RID of the secondary RID range
and an ID range of a trusted domain must set
- rid-base: the first RID of the corresponding RID range
- sid: domain SID of the trusted domain
EXAMPLE: Add a new ID range for a trusted domain
Since there might be more than one trusted domain the domain SID must be given
while creating the ID range.
ipa idrange-add --base-id=1200000 --range-size=200000 --rid-base=0 \
--dom-sid=S-1-5-21-123-456-789 trusted_dom_range
This ID range is then used by the IPA server and the SSSD IPA provider to
assign Posix UIDs to users from the trusted domain.
If e.g. a range for a trusted domain is configured with the following values:
base-id = 1200000
range-size = 200000
rid-base = 0
the RIDs 0 to 199999 are mapped to the Posix ID from 1200000 to 13999999. So
RID 1000 <-> Posix ID 1201000
EXAMPLE: Add a new ID range for the local domain
To create an ID range for the local domain it is not necessary to specify a
domain SID. But since it is possible that a user and a group can have the same
value as Posix ID a second RID interval is needed to handle conflicts.
ipa idrange-add --base-id=1200000 --range-size=200000 --rid-base=1000 \
--secondary-rid-base=1000000 local_range
The data from the ID ranges of the local domain are used by the IPA server
internally to assign SIDs to IPA users and groups. The SID will then be stored
in the user or group objects.
If e.g. the ID range for the local domain is configured with the values from
the example above then a new user with the UID 1200007 will get the RID 1007.
If this RID is already used by a group the RID will be 1000007. This can only
happen if a user or a group object was created with a fixed ID because the
automatic assignment will not assign the same ID twice. Since there are only
users and groups sharing the same ID namespace it is sufficient to have only
one fallback range to handle conflicts.
To find the Posix ID for a given RID from the local domain it has to be
checked first if the RID falls in the primary or secondary RID range and
the rid-base or the secondary-rid-base has to be subtracted, respectively,
and the base-id has to be added to get the Posix ID.
Typically the creation of ID ranges happens behind the scenes and this CLI
must not be used at all. The ID range for the local domain will be created
during installation or upgrade from an older version. The ID range for a
trusted domain will be created together with the trust by 'ipa trust-add ...'.
USE CASES:
Add an ID range from a transitively trusted domain
If the trusted domain (A) trusts another domain (B) as well and this trust
is transitive 'ipa trust-add domain-A' will only create a range for
domain A. The ID range for domain B must be added manually.
Add an additional ID range for the local domain
If the ID range of the local domain is exhausted, i.e. no new IDs can be
assigned to Posix users or groups by the DNA plugin, a new range has to be
created to allow new users and groups to be added. (Currently there is no
connection between this range CLI and the DNA plugin, but a future version
might be able to modify the configuration of the DNS plugin as well)
In general it is not necessary to modify or delete ID ranges. If there is no
other way to achieve a certain configuration than to modify or delete an ID
range it should be done with great care. Because UIDs are stored in the file
system and are used for access control it might be possible that users are
allowed to access files of other users if an ID range got deleted and reused
for a different domain.
(*) The RID is typically the last integer of a user or group SID which follows
the domain SID. E.g. if the domain SID is S-1-5-21-123-456-789 and a user from
this domain has the SID S-1-5-21-123-456-789-1010 then 1010 is the RID of the
user. RIDs are unique in a domain, 32bit values and are used for users and
groups.
=======
WARNING:
DNA plugin in 389-ds will allocate IDs based on the ranges configured for the
local domain. Currently the DNA plugin *cannot* be reconfigured itself based
on the local ranges set via this family of commands.
Manual configuration change has to be done in the DNA plugin configuration for
the new local range. Specifically, The dnaNextRange attribute of 'cn=Posix
IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' has to be
modified to match the new range.
=======
""")
register = Registry()
@register()
class idrange(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Range name'),
),
parameters.Int(
'ipabaseid',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
label=_(u'Domain SID of the trusted domain'),
),
parameters.Str(
'ipanttrusteddomainname',
required=False,
label=_(u'Name of the trusted domain'),
),
parameters.Str(
'iparangetype',
required=False,
label=_(u'Range type'),
doc=_(u'ID range type, one of ipa-ad-trust-posix, ipa-ad-trust, ipa-local'),
),
)
@register()
class idrange_add(Method):
__doc__ = _("""
Add new ID range.
To add a new ID range you always have to specify
--base-id
--range-size
Additionally
--rid-base
--secondary-rid-base
may be given for a new ID range for the local domain while
--rid-base
--dom-sid
must be given to add a new range for a trusted AD domain.
=======
WARNING:
DNA plugin in 389-ds will allocate IDs based on the ranges configured for the
local domain. Currently the DNA plugin *cannot* be reconfigured itself based
on the local ranges set via this family of commands.
Manual configuration change has to be done in the DNA plugin configuration for
the new local range. Specifically, The dnaNextRange attribute of 'cn=Posix
IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' has to be
modified to match the new range.
=======
""")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Int(
'ipabaseid',
cli_name='base_id',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
cli_name='range_size',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
cli_name='rid_base',
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
cli_name='secondary_rid_base',
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='dom_sid',
label=_(u'Domain SID of the trusted domain'),
),
parameters.Str(
'ipanttrusteddomainname',
required=False,
cli_name='dom_name',
label=_(u'Name of the trusted domain'),
),
parameters.Str(
'iparangetype',
required=False,
cli_name='type',
cli_metavar="['ipa-ad-trust-posix', 'ipa-ad-trust', 'ipa-local']",
label=_(u'Range type'),
doc=_(u'ID range type, one of ipa-ad-trust-posix, ipa-ad-trust, ipa-local'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idrange_del(Method):
__doc__ = _("Delete an ID range.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idrange_find(Method):
__doc__ = _("Search for ranges.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Range name'),
),
parameters.Int(
'ipabaseid',
required=False,
cli_name='base_id',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
required=False,
cli_name='range_size',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
cli_name='rid_base',
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
cli_name='secondary_rid_base',
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
cli_name='dom_sid',
label=_(u'Domain SID of the trusted domain'),
),
parameters.Str(
'iparangetype',
required=False,
cli_name='type',
cli_metavar="['ipa-ad-trust-posix', 'ipa-ad-trust', 'ipa-local']",
label=_(u'Range type'),
doc=_(u'ID range type, one of ipa-ad-trust-posix, ipa-ad-trust, ipa-local'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idrange_mod(Method):
__doc__ = _("""
Modify ID range.
=======
WARNING:
DNA plugin in 389-ds will allocate IDs based on the ranges configured for the
local domain. Currently the DNA plugin *cannot* be reconfigured itself based
on the local ranges set via this family of commands.
Manual configuration change has to be done in the DNA plugin configuration for
the new local range. Specifically, The dnaNextRange attribute of 'cn=Posix
IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' has to be
modified to match the new range.
=======
""")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Int(
'ipabaseid',
required=False,
cli_name='base_id',
label=_(u'First Posix ID of the range'),
),
parameters.Int(
'ipaidrangesize',
required=False,
cli_name='range_size',
label=_(u'Number of IDs in the range'),
),
parameters.Int(
'ipabaserid',
required=False,
cli_name='rid_base',
label=_(u'First RID of the corresponding RID range'),
),
parameters.Int(
'ipasecondarybaserid',
required=False,
cli_name='secondary_rid_base',
label=_(u'First RID of the secondary RID range'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Str(
'ipanttrusteddomainsid',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipanttrusteddomainname',
required=False,
deprecated=True,
exclude=('cli', 'webui'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idrange_show(Method):
__doc__ = _("Display information about a range.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Range name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 20,053
|
Python
|
.py
| 570
| 26.363158
| 162
| 0.591841
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,087
|
idviews.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/idviews.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
ID Views
Manage ID Views
IPA allows to override certain properties of users and groups per each host.
This functionality is primarily used to allow migration from older systems or
other Identity Management solutions.
""")
register = Registry()
@register()
class idoverridegroup(Object):
takes_params = (
parameters.Str(
'ipaanchoruuid',
primary_key=True,
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
label=_(u'Group name'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
)
@register()
class idoverrideuser(Object):
takes_params = (
parameters.Str(
'ipaanchoruuid',
primary_key=True,
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
label=_(u'User login'),
),
parameters.Int(
'uidnumber',
required=False,
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
label=_(u'SSH public key'),
),
)
@register()
class idview(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'ID View Name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
),
)
@register()
class idoverridegroup_add(Method):
__doc__ = _("Add a new Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverridegroup_del(Method):
__doc__ = _("Delete an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
multivalue=True,
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idoverridegroup_find(Method):
__doc__ = _("Search for an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'ipaanchoruuid',
required=False,
cli_name='anchor',
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("anchor")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idoverridegroup_mod(Method):
__doc__ = _("Modify an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the Group ID override object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverridegroup_show(Method):
__doc__ = _("Display information about an Group ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverrideuser_add(Method):
__doc__ = _("Add a new User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
no_convert=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverrideuser_del(Method):
__doc__ = _("Delete an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
multivalue=True,
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idoverrideuser_find(Method):
__doc__ = _("Search for an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'ipaanchoruuid',
required=False,
cli_name='anchor',
label=_(u'Anchor to override'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
no_convert=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("anchor")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idoverrideuser_mod(Method):
__doc__ = _("Modify an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'uid',
required=False,
cli_name='login',
label=_(u'User login'),
no_convert=True,
),
parameters.Int(
'uidnumber',
required=False,
cli_name='uid',
label=_(u'UID'),
doc=_(u'User ID Number'),
),
parameters.Str(
'gecos',
required=False,
label=_(u'GECOS'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'Group ID Number'),
),
parameters.Str(
'homedirectory',
required=False,
cli_name='homedir',
label=_(u'Home directory'),
),
parameters.Str(
'loginshell',
required=False,
cli_name='shell',
label=_(u'Login shell'),
),
parameters.Str(
'ipaoriginaluid',
required=False,
exclude=('cli', 'webui'),
),
parameters.Str(
'ipasshpubkey',
required=False,
multivalue=True,
cli_name='sshpubkey',
label=_(u'SSH public key'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the User ID override object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idoverrideuser_show(Method):
__doc__ = _("Display information about an User ID override.")
takes_args = (
parameters.Str(
'idviewcn',
cli_name='idview',
label=_(u'ID View Name'),
),
parameters.Str(
'ipaanchoruuid',
cli_name='anchor',
label=_(u'Anchor to override'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'fallback_to_ldap',
required=False,
label=_(u'Fallback to AD DC LDAP'),
doc=_(u'Allow falling back to AD DC LDAP when resolving AD trusted objects. For two-way trusts only.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_add(Method):
__doc__ = _("Add a new ID View.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_apply(Method):
__doc__ = _("Applies ID View to specified hosts or current members of specified hostgroups. If any other ID View is applied to the host, it is overridden.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'hosts'),
doc=_(u'Hosts to apply the ID View to'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'hostgroups'),
doc=_(u'Hostgroups to whose hosts apply the ID View to. Please note that view is not applied automatically to any hosts added to the hostgroup after running the idview-apply command.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'succeeded',
dict,
doc=_(u'Hosts that this ID View was applied to.'),
),
output.Output(
'failed',
dict,
doc=_(u'Hosts or hostgroups that this ID View could not be applied to.'),
),
output.Output(
'completed',
int,
doc=_(u'Number of hosts the ID View was applied to:'),
),
)
@register()
class idview_del(Method):
__doc__ = _("Delete an ID View.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class idview_find(Method):
__doc__ = _("Search for an ID View.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'ID View Name'),
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class idview_mod(Method):
__doc__ = _("Modify an ID View.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the ID View object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_show(Method):
__doc__ = _("Display information about an ID View.")
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'ID View Name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'show_hosts',
required=False,
doc=_(u'Enumerate all the hosts the view applies to.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class idview_unapply(Method):
__doc__ = _("Clears ID View from specified hosts or current members of specified hostgroups.")
takes_options = (
parameters.Str(
'host',
required=False,
multivalue=True,
cli_name='hosts',
label=_(u'hosts'),
doc=_(u'Hosts to clear (any) ID View from.'),
),
parameters.Str(
'hostgroup',
required=False,
multivalue=True,
cli_name='hostgroups',
label=_(u'hostgroups'),
doc=_(u'Hostgroups whose hosts should have ID Views cleared. Note that view is not cleared automatically from any host added to the hostgroup after running idview-unapply command.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'succeeded',
dict,
doc=_(u'Hosts that ID View was cleared from.'),
),
output.Output(
'failed',
dict,
doc=_(u'Hosts or hostgroups that ID View could not be cleared from.'),
),
output.Output(
'completed',
int,
doc=_(u'Number of hosts that had a ID View was unset:'),
),
)
| 42,287
|
Python
|
.py
| 1,429
| 18.951714
| 197
| 0.493528
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,088
|
topology.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/topology.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Topology
Management of a replication topology.
Requires minimum domain level 1.
""")
register = Registry()
@register()
class topologysegment(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Segment name'),
doc=_(u'Arbitrary string identifying the segment'),
),
parameters.Str(
'iparepltoposegmentleftnode',
label=_(u'Left node'),
doc=_(u'Left replication node - an IPA server'),
),
parameters.Str(
'iparepltoposegmentrightnode',
label=_(u'Right node'),
doc=_(u'Right replication node - an IPA server'),
),
parameters.Str(
'iparepltoposegmentdirection',
label=_(u'Connectivity'),
doc=_(u'Direction of replication between left and right replication node'),
),
parameters.Str(
'nsds5replicastripattrs',
required=False,
label=_(u'Attributes to strip'),
doc=_(u'A space separated list of attributes which are removed from replication updates.'),
),
parameters.Str(
'nsds5replicatedattributelist',
required=False,
label=_(u'Attributes to replicate'),
doc=_(u'Attributes that are not replicated to a consumer server during a fractional update. E.g., `(objectclass=*) $ EXCLUDE accountlockout memberof'),
),
parameters.Str(
'nsds5replicatedattributelisttotal',
required=False,
label=_(u'Attributes for total update'),
doc=_(u'Attributes that are not replicated to a consumer server during a total update. E.g. (objectclass=*) $ EXCLUDE accountlockout'),
),
parameters.Int(
'nsds5replicatimeout',
required=False,
label=_(u'Session timeout'),
doc=_(u'Number of seconds outbound LDAP operations waits for a response from the remote replica before timing out and failing'),
),
parameters.Str(
'nsds5replicaenabled',
required=False,
label=_(u'Replication agreement enabled'),
doc=_(u'Whether a replication agreement is active, meaning whether replication is occurring per that agreement'),
),
)
@register()
class topologysuffix(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Suffix name'),
),
parameters.Str(
'iparepltopoconfroot',
label=_(u'LDAP suffix to be managed'),
),
)
@register()
class topologysegment_add(Method):
__doc__ = _("Add a new segment.")
NO_CLI = True
takes_args = (
parameters.Str(
'topologysuffixcn',
cli_name='topologysuffix',
label=_(u'Suffix name'),
),
parameters.Str(
'cn',
cli_name='name',
label=_(u'Segment name'),
doc=_(u'Arbitrary string identifying the segment'),
default_from=DefaultFrom(lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode: None, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
# FIXME:
# lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode:
no_convert=True,
),
)
takes_options = (
parameters.Str(
'iparepltoposegmentleftnode',
cli_name='leftnode',
label=_(u'Left node'),
doc=_(u'Left replication node - an IPA server'),
no_convert=True,
),
parameters.Str(
'iparepltoposegmentrightnode',
cli_name='rightnode',
label=_(u'Right node'),
doc=_(u'Right replication node - an IPA server'),
no_convert=True,
),
parameters.Str(
'iparepltoposegmentdirection',
cli_name='direction',
cli_metavar="['both', 'left-right', 'right-left']",
label=_(u'Connectivity'),
doc=_(u'Direction of replication between left and right replication node'),
exclude=('cli', 'webui'),
default=u'both',
),
parameters.Str(
'nsds5replicastripattrs',
required=False,
cli_name='stripattrs',
label=_(u'Attributes to strip'),
doc=_(u'A space separated list of attributes which are removed from replication updates.'),
no_convert=True,
),
parameters.Str(
'nsds5replicatedattributelist',
required=False,
cli_name='replattrs',
label=_(u'Attributes to replicate'),
doc=_(u'Attributes that are not replicated to a consumer server during a fractional update. E.g., `(objectclass=*) $ EXCLUDE accountlockout memberof'),
),
parameters.Str(
'nsds5replicatedattributelisttotal',
required=False,
cli_name='replattrstotal',
label=_(u'Attributes for total update'),
doc=_(u'Attributes that are not replicated to a consumer server during a total update. E.g. (objectclass=*) $ EXCLUDE accountlockout'),
),
parameters.Int(
'nsds5replicatimeout',
required=False,
cli_name='timeout',
label=_(u'Session timeout'),
doc=_(u'Number of seconds outbound LDAP operations waits for a response from the remote replica before timing out and failing'),
),
parameters.Str(
'nsds5replicaenabled',
required=False,
cli_name='enabled',
cli_metavar="['on', 'off']",
label=_(u'Replication agreement enabled'),
doc=_(u'Whether a replication agreement is active, meaning whether replication is occurring per that agreement'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class topologysegment_del(Method):
__doc__ = _("Delete a segment.")
NO_CLI = True
takes_args = (
parameters.Str(
'topologysuffixcn',
cli_name='topologysuffix',
label=_(u'Suffix name'),
),
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Segment name'),
doc=_(u'Arbitrary string identifying the segment'),
default_from=DefaultFrom(lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode: None, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
# FIXME:
# lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode:
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class topologysegment_find(Method):
__doc__ = _("Search for topology segments.")
NO_CLI = True
takes_args = (
parameters.Str(
'topologysuffixcn',
cli_name='topologysuffix',
label=_(u'Suffix name'),
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Segment name'),
doc=_(u'Arbitrary string identifying the segment'),
default_from=DefaultFrom(lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode: None, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
# FIXME:
# lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode:
no_convert=True,
),
parameters.Str(
'iparepltoposegmentleftnode',
required=False,
cli_name='leftnode',
label=_(u'Left node'),
doc=_(u'Left replication node - an IPA server'),
no_convert=True,
),
parameters.Str(
'iparepltoposegmentrightnode',
required=False,
cli_name='rightnode',
label=_(u'Right node'),
doc=_(u'Right replication node - an IPA server'),
no_convert=True,
),
parameters.Str(
'iparepltoposegmentdirection',
required=False,
cli_name='direction',
cli_metavar="['both', 'left-right', 'right-left']",
label=_(u'Connectivity'),
doc=_(u'Direction of replication between left and right replication node'),
exclude=('cli', 'webui'),
default=u'both',
),
parameters.Str(
'nsds5replicastripattrs',
required=False,
cli_name='stripattrs',
label=_(u'Attributes to strip'),
doc=_(u'A space separated list of attributes which are removed from replication updates.'),
no_convert=True,
),
parameters.Str(
'nsds5replicatedattributelist',
required=False,
cli_name='replattrs',
label=_(u'Attributes to replicate'),
doc=_(u'Attributes that are not replicated to a consumer server during a fractional update. E.g., `(objectclass=*) $ EXCLUDE accountlockout memberof'),
),
parameters.Str(
'nsds5replicatedattributelisttotal',
required=False,
cli_name='replattrstotal',
label=_(u'Attributes for total update'),
doc=_(u'Attributes that are not replicated to a consumer server during a total update. E.g. (objectclass=*) $ EXCLUDE accountlockout'),
),
parameters.Int(
'nsds5replicatimeout',
required=False,
cli_name='timeout',
label=_(u'Session timeout'),
doc=_(u'Number of seconds outbound LDAP operations waits for a response from the remote replica before timing out and failing'),
),
parameters.Str(
'nsds5replicaenabled',
required=False,
cli_name='enabled',
cli_metavar="['on', 'off']",
label=_(u'Replication agreement enabled'),
doc=_(u'Whether a replication agreement is active, meaning whether replication is occurring per that agreement'),
exclude=('cli', 'webui'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class topologysegment_mod(Method):
__doc__ = _("Modify a segment.")
NO_CLI = True
takes_args = (
parameters.Str(
'topologysuffixcn',
cli_name='topologysuffix',
label=_(u'Suffix name'),
),
parameters.Str(
'cn',
cli_name='name',
label=_(u'Segment name'),
doc=_(u'Arbitrary string identifying the segment'),
default_from=DefaultFrom(lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode: None, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
# FIXME:
# lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode:
no_convert=True,
),
)
takes_options = (
parameters.Str(
'nsds5replicastripattrs',
required=False,
cli_name='stripattrs',
label=_(u'Attributes to strip'),
doc=_(u'A space separated list of attributes which are removed from replication updates.'),
no_convert=True,
),
parameters.Str(
'nsds5replicatedattributelist',
required=False,
cli_name='replattrs',
label=_(u'Attributes to replicate'),
doc=_(u'Attributes that are not replicated to a consumer server during a fractional update. E.g., `(objectclass=*) $ EXCLUDE accountlockout memberof'),
),
parameters.Str(
'nsds5replicatedattributelisttotal',
required=False,
cli_name='replattrstotal',
label=_(u'Attributes for total update'),
doc=_(u'Attributes that are not replicated to a consumer server during a total update. E.g. (objectclass=*) $ EXCLUDE accountlockout'),
),
parameters.Int(
'nsds5replicatimeout',
required=False,
cli_name='timeout',
label=_(u'Session timeout'),
doc=_(u'Number of seconds outbound LDAP operations waits for a response from the remote replica before timing out and failing'),
),
parameters.Str(
'nsds5replicaenabled',
required=False,
cli_name='enabled',
cli_metavar="['on', 'off']",
label=_(u'Replication agreement enabled'),
doc=_(u'Whether a replication agreement is active, meaning whether replication is occurring per that agreement'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class topologysegment_reinitialize(Method):
__doc__ = _("Request a full re-initialization of the node retrieving data from the other node.")
NO_CLI = True
takes_args = (
parameters.Str(
'topologysuffixcn',
cli_name='topologysuffix',
label=_(u'Suffix name'),
),
parameters.Str(
'cn',
cli_name='name',
label=_(u'Segment name'),
doc=_(u'Arbitrary string identifying the segment'),
default_from=DefaultFrom(lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode: None, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
# FIXME:
# lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode:
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'left',
required=False,
doc=_(u'Initialize left node'),
default=False,
autofill=True,
),
parameters.Flag(
'right',
required=False,
doc=_(u'Initialize right node'),
default=False,
autofill=True,
),
parameters.Flag(
'stop',
required=False,
doc=_(u'Stop already started refresh of chosen node(s)'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class topologysegment_show(Method):
__doc__ = _("Display a segment.")
NO_CLI = True
takes_args = (
parameters.Str(
'topologysuffixcn',
cli_name='topologysuffix',
label=_(u'Suffix name'),
),
parameters.Str(
'cn',
cli_name='name',
label=_(u'Segment name'),
doc=_(u'Arbitrary string identifying the segment'),
default_from=DefaultFrom(lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode: None, 'iparepltoposegmentleftnode', 'iparepltoposegmentrightnode'),
# FIXME:
# lambda iparepltoposegmentleftnode, iparepltoposegmentrightnode:
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class topologysuffix_add(Method):
__doc__ = _("Add a new topology suffix to be managed.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Suffix name'),
),
)
takes_options = (
parameters.Str(
'iparepltopoconfroot',
cli_name='suffix',
label=_(u'LDAP suffix to be managed'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class topologysuffix_del(Method):
__doc__ = _("Delete a topology suffix.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='name',
label=_(u'Suffix name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class topologysuffix_find(Method):
__doc__ = _("Search for topology suffices.")
NO_CLI = True
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='name',
label=_(u'Suffix name'),
),
parameters.Str(
'iparepltopoconfroot',
required=False,
cli_name='suffix',
label=_(u'LDAP suffix to be managed'),
no_convert=True,
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class topologysuffix_mod(Method):
__doc__ = _("Modify a topology suffix.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Suffix name'),
),
)
takes_options = (
parameters.Str(
'iparepltopoconfroot',
required=False,
cli_name='suffix',
label=_(u'LDAP suffix to be managed'),
no_convert=True,
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class topologysuffix_show(Method):
__doc__ = _("Show managed suffix.")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Suffix name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class topologysuffix_verify(Method):
__doc__ = _("""
Verify replication topology for suffix.
Checks done:
1. check if a topology is not disconnected. In other words if there are
replication paths between all servers.
2. check if servers don't have more than the recommended number of
replication agreements
""")
NO_CLI = True
takes_args = (
parameters.Str(
'cn',
cli_name='name',
label=_(u'Suffix name'),
),
)
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
| 32,297
|
Python
|
.py
| 966
| 22.953416
| 168
| 0.541684
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,089
|
session.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/session.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
register = Registry()
@register()
class session_logout(Command):
__doc__ = _("RPC command used to log the current user out of their session.")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'result',
),
)
| 678
|
Python
|
.py
| 26
| 22.615385
| 81
| 0.720497
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,090
|
group.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/group.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _(r"""
Groups of users
Manage groups of users. By default, new groups are POSIX groups. You
can add the --nonposix option to the group-add command to mark a new group
as non-POSIX. You can use the --posix argument with the group-mod command
to convert a non-POSIX group into a POSIX group. POSIX groups cannot be
converted to non-POSIX groups.
Every group must have a description.
POSIX groups must have a Group ID (GID) number. Changing a GID is
supported but can have an impact on your file permissions. It is not necessary
to supply a GID when creating a group. IPA will generate one automatically
if it is not provided.
EXAMPLES:
Add a new group:
ipa group-add --desc='local administrators' localadmins
Add a new non-POSIX group:
ipa group-add --nonposix --desc='remote administrators' remoteadmins
Convert a non-POSIX group to posix:
ipa group-mod --posix remoteadmins
Add a new POSIX group with a specific Group ID number:
ipa group-add --gid=500 --desc='unix admins' unixadmins
Add a new POSIX group and let IPA assign a Group ID number:
ipa group-add --desc='printer admins' printeradmins
Remove a group:
ipa group-del unixadmins
To add the "remoteadmins" group to the "localadmins" group:
ipa group-add-member --groups=remoteadmins localadmins
Add multiple users to the "localadmins" group:
ipa group-add-member --users=test1 --users=test2 localadmins
Remove a user from the "localadmins" group:
ipa group-remove-member --users=test2 localadmins
Display information about a named group.
ipa group-show localadmins
External group membership is designed to allow users from trusted domains
to be mapped to local POSIX groups in order to actually use IPA resources.
External members should be added to groups that specifically created as
external and non-POSIX. Such group later should be included into one of POSIX
groups.
An external group member is currently a Security Identifier (SID) as defined by
the trusted domain. When adding external group members, it is possible to
specify them in either SID, or DOM\name, or name@domain format. IPA will attempt
to resolve passed name to SID with the use of Global Catalog of the trusted domain.
Example:
1. Create group for the trusted domain admins' mapping and their local POSIX group:
ipa group-add --desc='<ad.domain> admins external map' ad_admins_external --external
ipa group-add --desc='<ad.domain> admins' ad_admins
2. Add security identifier of Domain Admins of the <ad.domain> to the ad_admins_external
group:
ipa group-add-member ad_admins_external --external 'AD\Domain Admins'
3. Allow members of ad_admins_external group to be associated with ad_admins POSIX group:
ipa group-add-member ad_admins --groups ad_admins_external
4. List members of external members of ad_admins_external group to see their SIDs:
ipa group-show ad_admins_external
""")
register = Registry()
@register()
class group(Object):
takes_params = (
parameters.Str(
'cn',
primary_key=True,
label=_(u'Group name'),
),
parameters.Str(
'description',
required=False,
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Str(
'member_user',
required=False,
label=_(u'Member users'),
),
parameters.Str(
'member_group',
required=False,
label=_(u'Member groups'),
),
parameters.Str(
'memberof_group',
required=False,
label=_(u'Member of groups'),
),
parameters.Str(
'memberof_role',
required=False,
label=_(u'Roles'),
),
parameters.Str(
'memberof_netgroup',
required=False,
label=_(u'Member of netgroups'),
),
parameters.Str(
'memberof_sudorule',
required=False,
label=_(u'Member of Sudo rule'),
),
parameters.Str(
'memberof_hbacrule',
required=False,
label=_(u'Member of HBAC rule'),
),
parameters.Str(
'memberindirect_user',
required=False,
label=_(u'Indirect Member users'),
),
parameters.Str(
'memberindirect_group',
required=False,
label=_(u'Indirect Member groups'),
),
parameters.Str(
'memberofindirect_group',
required=False,
label=_(u'Indirect Member of group'),
),
parameters.Str(
'memberofindirect_netgroup',
required=False,
label=_(u'Indirect Member of netgroup'),
),
parameters.Str(
'memberofindirect_role',
required=False,
label=_(u'Indirect Member of role'),
),
parameters.Str(
'memberofindirect_sudorule',
required=False,
label=_(u'Indirect Member of Sudo rule'),
),
parameters.Str(
'memberofindirect_hbacrule',
required=False,
label=_(u'Indirect Member of HBAC rule'),
),
)
@register()
class group_add(Method):
__doc__ = _("Create a new group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'nonposix',
doc=_(u'Create as a non-POSIX group'),
default=False,
autofill=True,
),
parameters.Flag(
'external',
doc=_(u'Allow adding external non-IPA members from trusted domains'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class group_add_member(Method):
__doc__ = _("Add members to a group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'ipaexternalmember',
required=False,
multivalue=True,
cli_name='external',
label=_(u'External member'),
doc=_(u'Members of a trusted domain in DOM\\name or name@domain form'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to add'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to add'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be added'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members added'),
),
)
@register()
class group_del(Method):
__doc__ = _("Delete group.")
takes_args = (
parameters.Str(
'cn',
multivalue=True,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class group_detach(Method):
__doc__ = _("Detach a managed group from a user.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class group_find(Method):
__doc__ = _("Search for groups.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.Str(
'cn',
required=False,
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'private',
doc=_(u'search for private groups'),
default=False,
autofill=True,
),
parameters.Flag(
'posix',
doc=_(u'search for POSIX groups'),
default=False,
autofill=True,
),
parameters.Flag(
'external',
doc=_(u'search for groups with support of external non-IPA members from trusted domains'),
default=False,
autofill=True,
),
parameters.Flag(
'nonposix',
doc=_(u'search for non-POSIX groups'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("group-name")'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'user'),
doc=_(u'Search for groups with these member users.'),
),
parameters.Str(
'no_user',
required=False,
multivalue=True,
cli_name='no_users',
label=_(u'user'),
doc=_(u'Search for groups without these member users.'),
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'group'),
doc=_(u'Search for groups with these member groups.'),
),
parameters.Str(
'no_group',
required=False,
multivalue=True,
cli_name='no_groups',
label=_(u'group'),
doc=_(u'Search for groups without these member groups.'),
),
parameters.Str(
'in_group',
required=False,
multivalue=True,
cli_name='in_groups',
label=_(u'group'),
doc=_(u'Search for groups with these member of groups.'),
),
parameters.Str(
'not_in_group',
required=False,
multivalue=True,
cli_name='not_in_groups',
label=_(u'group'),
doc=_(u'Search for groups without these member of groups.'),
),
parameters.Str(
'in_netgroup',
required=False,
multivalue=True,
cli_name='in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for groups with these member of netgroups.'),
),
parameters.Str(
'not_in_netgroup',
required=False,
multivalue=True,
cli_name='not_in_netgroups',
label=_(u'netgroup'),
doc=_(u'Search for groups without these member of netgroups.'),
),
parameters.Str(
'in_role',
required=False,
multivalue=True,
cli_name='in_roles',
label=_(u'role'),
doc=_(u'Search for groups with these member of roles.'),
),
parameters.Str(
'not_in_role',
required=False,
multivalue=True,
cli_name='not_in_roles',
label=_(u'role'),
doc=_(u'Search for groups without these member of roles.'),
),
parameters.Str(
'in_hbacrule',
required=False,
multivalue=True,
cli_name='in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for groups with these member of HBAC rules.'),
),
parameters.Str(
'not_in_hbacrule',
required=False,
multivalue=True,
cli_name='not_in_hbacrules',
label=_(u'HBAC rule'),
doc=_(u'Search for groups without these member of HBAC rules.'),
),
parameters.Str(
'in_sudorule',
required=False,
multivalue=True,
cli_name='in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for groups with these member of sudo rules.'),
),
parameters.Str(
'not_in_sudorule',
required=False,
multivalue=True,
cli_name='not_in_sudorules',
label=_(u'sudo rule'),
doc=_(u'Search for groups without these member of sudo rules.'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class group_mod(Method):
__doc__ = _("Modify a group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'description',
required=False,
cli_name='desc',
label=_(u'Description'),
doc=_(u'Group description'),
),
parameters.Int(
'gidnumber',
required=False,
cli_name='gid',
label=_(u'GID'),
doc=_(u'GID (use this option to set it manually)'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'posix',
doc=_(u'change to a POSIX group'),
default=False,
autofill=True,
),
parameters.Flag(
'external',
doc=_(u'change to support external non-IPA members from trusted domains'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the group object'),
no_convert=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class group_remove_member(Method):
__doc__ = _("Remove members from a group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Str(
'ipaexternalmember',
required=False,
multivalue=True,
cli_name='external',
label=_(u'External member'),
doc=_(u'Members of a trusted domain in DOM\\name or name@domain form'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
parameters.Str(
'user',
required=False,
multivalue=True,
cli_name='users',
label=_(u'member user'),
doc=_(u'users to remove'),
alwaysask=True,
),
parameters.Str(
'group',
required=False,
multivalue=True,
cli_name='groups',
label=_(u'member group'),
doc=_(u'groups to remove'),
alwaysask=True,
),
)
has_output = (
output.Entry(
'result',
),
output.Output(
'failed',
dict,
doc=_(u'Members that could not be removed'),
),
output.Output(
'completed',
int,
doc=_(u'Number of members removed'),
),
)
@register()
class group_show(Method):
__doc__ = _("Display information about a named group.")
takes_args = (
parameters.Str(
'cn',
cli_name='group_name',
label=_(u'Group name'),
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'no_members',
doc=_(u'Suppress processing of membership attributes.'),
exclude=('webui', 'cli'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 26,515
|
Python
|
.py
| 856
| 20.674065
| 162
| 0.521931
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,091
|
dns.py
|
freeipa_freeipa/ipaclient/remote_plugins/2_156/dns.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
# pylint: disable=unused-import
import six
from . import Command, Method, Object
from ipalib import api, parameters, output
from ipalib.parameters import DefaultFrom
from ipalib.plugable import Registry
from ipalib.text import _
from ipapython.dn import DN
from ipapython.dnsutil import DNSName
if six.PY3:
unicode = str
__doc__ = _("""
Domain Name System (DNS)
Manage DNS zone and resource records.
SUPPORTED ZONE TYPES
* Master zone (dnszone-*), contains authoritative data.
* Forward zone (dnsforwardzone-*), forwards queries to configured forwarders
(a set of DNS servers).
USING STRUCTURED PER-TYPE OPTIONS
There are many structured DNS RR types where DNS data stored in LDAP server
is not just a scalar value, for example an IP address or a domain name, but
a data structure which may be often complex. A good example is a LOC record
[RFC1876] which consists of many mandatory and optional parts (degrees,
minutes, seconds of latitude and longitude, altitude or precision).
It may be difficult to manipulate such DNS records without making a mistake
and entering an invalid value. DNS module provides an abstraction over these
raw records and allows to manipulate each RR type with specific options. For
each supported RR type, DNS module provides a standard option to manipulate
a raw records with format --<rrtype>-rec, e.g. --mx-rec, and special options
for every part of the RR structure with format --<rrtype>-<partname>, e.g.
--mx-preference and --mx-exchanger.
When adding a record, either RR specific options or standard option for a raw
value can be used, they just should not be combined in one add operation. When
modifying an existing entry, new RR specific options can be used to change
one part of a DNS record, where the standard option for raw value is used
to specify the modified value. The following example demonstrates
a modification of MX record preference from 0 to 1 in a record without
modifying the exchanger:
ipa dnsrecord-mod --mx-rec="0 mx.example.com." --mx-preference=1
EXAMPLES:
Add new zone:
ipa dnszone-add example.com --admin-email=admin@example.com
Add system permission that can be used for per-zone privilege delegation:
ipa dnszone-add-permission example.com
Modify the zone to allow dynamic updates for hosts own records in realm EXAMPLE.COM:
ipa dnszone-mod example.com --dynamic-update=TRUE
This is the equivalent of:
ipa dnszone-mod example.com --dynamic-update=TRUE \
--update-policy="grant EXAMPLE.COM krb5-self * A; grant EXAMPLE.COM krb5-self * AAAA; grant EXAMPLE.COM krb5-self * SSHFP;"
Modify the zone to allow zone transfers for local network only:
ipa dnszone-mod example.com --allow-transfer=192.0.2.0/24
Add new reverse zone specified by network IP address:
ipa dnszone-add --name-from-ip=192.0.2.0/24
Add second nameserver for example.com:
ipa dnsrecord-add example.com @ --ns-rec=nameserver2.example.com
Add a mail server for example.com:
ipa dnsrecord-add example.com @ --mx-rec="10 mail1"
Add another record using MX record specific options:
ipa dnsrecord-add example.com @ --mx-preference=20 --mx-exchanger=mail2
Add another record using interactive mode (started when dnsrecord-add, dnsrecord-mod,
or dnsrecord-del are executed with no options):
ipa dnsrecord-add example.com @
Please choose a type of DNS resource record to be added
The most common types for this type of zone are: NS, MX, LOC
DNS resource record type: MX
MX Preference: 30
MX Exchanger: mail3
Record name: example.com
MX record: 10 mail1, 20 mail2, 30 mail3
NS record: nameserver.example.com., nameserver2.example.com.
Delete previously added nameserver from example.com:
ipa dnsrecord-del example.com @ --ns-rec=nameserver2.example.com.
Add LOC record for example.com:
ipa dnsrecord-add example.com @ --loc-rec="49 11 42.4 N 16 36 29.6 E 227.64m"
Add new A record for www.example.com. Create a reverse record in appropriate
reverse zone as well. In this case a PTR record "2" pointing to www.example.com
will be created in zone 2.0.192.in-addr.arpa.
ipa dnsrecord-add example.com www --a-rec=192.0.2.2 --a-create-reverse
Add new PTR record for www.example.com
ipa dnsrecord-add 2.0.192.in-addr.arpa. 2 --ptr-rec=www.example.com.
Add new SRV records for LDAP servers. Three quarters of the requests
should go to fast.example.com, one quarter to slow.example.com. If neither
is available, switch to backup.example.com.
ipa dnsrecord-add example.com _ldap._tcp --srv-rec="0 3 389 fast.example.com"
ipa dnsrecord-add example.com _ldap._tcp --srv-rec="0 1 389 slow.example.com"
ipa dnsrecord-add example.com _ldap._tcp --srv-rec="1 1 389 backup.example.com"
The interactive mode can be used for easy modification:
ipa dnsrecord-mod example.com _ldap._tcp
No option to modify specific record provided.
Current DNS record contents:
SRV record: 0 3 389 fast.example.com, 0 1 389 slow.example.com, 1 1 389 backup.example.com
Modify SRV record '0 3 389 fast.example.com'? Yes/No (default No):
Modify SRV record '0 1 389 slow.example.com'? Yes/No (default No): y
SRV Priority [0]: (keep the default value)
SRV Weight [1]: 2 (modified value)
SRV Port [389]: (keep the default value)
SRV Target [slow.example.com]: (keep the default value)
1 SRV record skipped. Only one value per DNS record type can be modified at one time.
Record name: _ldap._tcp
SRV record: 0 3 389 fast.example.com, 1 1 389 backup.example.com, 0 2 389 slow.example.com
After this modification, three fifths of the requests should go to
fast.example.com and two fifths to slow.example.com.
An example of the interactive mode for dnsrecord-del command:
ipa dnsrecord-del example.com www
No option to delete specific record provided.
Delete all? Yes/No (default No): (do not delete all records)
Current DNS record contents:
A record: 192.0.2.2, 192.0.2.3
Delete A record '192.0.2.2'? Yes/No (default No):
Delete A record '192.0.2.3'? Yes/No (default No): y
Record name: www
A record: 192.0.2.2 (A record 192.0.2.3 has been deleted)
Show zone example.com:
ipa dnszone-show example.com
Find zone with "example" in its domain name:
ipa dnszone-find example
Find records for resources with "www" in their name in zone example.com:
ipa dnsrecord-find example.com www
Find A records with value 192.0.2.2 in zone example.com
ipa dnsrecord-find example.com --a-rec=192.0.2.2
Show records for resource www in zone example.com
ipa dnsrecord-show example.com www
Delegate zone sub.example to another nameserver:
ipa dnsrecord-add example.com ns.sub --a-rec=203.0.113.1
ipa dnsrecord-add example.com sub --ns-rec=ns.sub.example.com.
Delete zone example.com with all resource records:
ipa dnszone-del example.com
If a global forwarder is configured, all queries for which this server is not
authoritative (e.g. sub.example.com) will be routed to the global forwarder.
Global forwarding configuration can be overridden per-zone.
Semantics of forwarding in IPA matches BIND semantics and depends on the type
of zone:
* Master zone: local BIND replies authoritatively to queries for data in
the given zone (including authoritative NXDOMAIN answers) and forwarding
affects only queries for names below zone cuts (NS records) of locally
served zones.
* Forward zone: forward zone contains no authoritative data. BIND forwards
queries, which cannot be answered from its local cache, to configured
forwarders.
Semantics of the --forward-policy option:
* none - disable forwarding for the given zone.
* first - forward all queries to configured forwarders. If they fail,
do resolution using DNS root servers.
* only - forward all queries to configured forwarders and if they fail,
return failure.
Disable global forwarding for given sub-tree:
ipa dnszone-mod example.com --forward-policy=none
This configuration forwards all queries for names outside the example.com
sub-tree to global forwarders. Normal recursive resolution process is used
for names inside the example.com sub-tree (i.e. NS records are followed etc.).
Forward all requests for the zone external.example.com to another forwarder
using a "first" policy (it will send the queries to the selected forwarder
and if not answered it will use global root servers):
ipa dnsforwardzone-add external.example.com --forward-policy=first \
--forwarder=203.0.113.1
Change forward-policy for external.example.com:
ipa dnsforwardzone-mod external.example.com --forward-policy=only
Show forward zone external.example.com:
ipa dnsforwardzone-show external.example.com
List all forward zones:
ipa dnsforwardzone-find
Delete forward zone external.example.com:
ipa dnsforwardzone-del external.example.com
Resolve a host name to see if it exists (will add default IPA domain
if one is not included):
ipa dns-resolve www.example.com
ipa dns-resolve www
GLOBAL DNS CONFIGURATION
DNS configuration passed to command line install script is stored in a local
configuration file on each IPA server where DNS service is configured. These
local settings can be overridden with a common configuration stored in LDAP
server:
Show global DNS configuration:
ipa dnsconfig-show
Modify global DNS configuration and set a list of global forwarders:
ipa dnsconfig-mod --forwarder=203.0.113.113
""")
register = Registry()
@register()
class dnsconfig(Object):
takes_params = (
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
label=_(u'Global forwarders'),
doc=_(u'Global forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
label=_(u'Forward policy'),
doc=_(u'Global forwarding policy. Set to "none" to disable any configured global forwarders.'),
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records'),
),
parameters.Int(
'idnszonerefresh',
required=False,
label=_(u'Zone refresh interval'),
),
)
@register()
class dnsforwardzone(Object):
takes_params = (
parameters.DNSNameParam(
'idnsname',
primary_key=True,
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
)
@register()
class dnsrecord(Object):
takes_params = (
parameters.DNSNameParam(
'idnsname',
primary_key=True,
label=_(u'Record name'),
),
parameters.Int(
'dnsttl',
required=False,
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
),
parameters.Any(
'dnsrecords',
required=False,
label=_(u'Records'),
),
parameters.Str(
'dnstype',
required=False,
label=_(u'Record type'),
),
parameters.Str(
'dnsdata',
required=False,
label=_(u'Record data'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'a_part_ip_address',
required=False,
label=_(u'A IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'a_extra_create_reverse',
required=False,
label=_(u'A Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'aaaa_part_ip_address',
required=False,
label=_(u'AAAA IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'aaaa_extra_create_reverse',
required=False,
label=_(u'AAAA Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'a6_part_data',
required=False,
label=_(u'A6 Record data'),
doc=_(u'Record data'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Int(
'afsdb_part_subtype',
required=False,
label=_(u'AFSDB Subtype'),
doc=_(u'Subtype'),
),
parameters.DNSNameParam(
'afsdb_part_hostname',
required=False,
label=_(u'AFSDB Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
label=_(u'APL record'),
doc=_(u'Raw APL records'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Int(
'cert_part_type',
required=False,
label=_(u'CERT Certificate Type'),
doc=_(u'Certificate Type'),
),
parameters.Int(
'cert_part_key_tag',
required=False,
label=_(u'CERT Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'cert_part_algorithm',
required=False,
label=_(u'CERT Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Str(
'cert_part_certificate_or_crl',
required=False,
label=_(u'CERT Certificate/CRL'),
doc=_(u'Certificate/CRL'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.DNSNameParam(
'cname_part_hostname',
required=False,
label=_(u'CNAME Hostname'),
doc=_(u'A hostname which this alias hostname points to'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Int(
'dlv_part_key_tag',
required=False,
label=_(u'DLV Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'dlv_part_algorithm',
required=False,
label=_(u'DLV Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'dlv_part_digest_type',
required=False,
label=_(u'DLV Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'dlv_part_digest',
required=False,
label=_(u'DLV Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.DNSNameParam(
'dname_part_target',
required=False,
label=_(u'DNAME Target'),
doc=_(u'Target'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Int(
'ds_part_key_tag',
required=False,
label=_(u'DS Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'ds_part_algorithm',
required=False,
label=_(u'DS Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'ds_part_digest_type',
required=False,
label=_(u'DS Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'ds_part_digest',
required=False,
label=_(u'DS Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Int(
'kx_part_preference',
required=False,
label=_(u'KX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'kx_part_exchanger',
required=False,
label=_(u'KX Exchanger'),
doc=_(u'A host willing to act as a key exchanger'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Int(
'loc_part_lat_deg',
required=False,
label=_(u'LOC Degrees Latitude'),
doc=_(u'Degrees Latitude'),
),
parameters.Int(
'loc_part_lat_min',
required=False,
label=_(u'LOC Minutes Latitude'),
doc=_(u'Minutes Latitude'),
),
parameters.Decimal(
'loc_part_lat_sec',
required=False,
label=_(u'LOC Seconds Latitude'),
doc=_(u'Seconds Latitude'),
),
parameters.Str(
'loc_part_lat_dir',
required=False,
label=_(u'LOC Direction Latitude'),
doc=_(u'Direction Latitude'),
),
parameters.Int(
'loc_part_lon_deg',
required=False,
label=_(u'LOC Degrees Longitude'),
doc=_(u'Degrees Longitude'),
),
parameters.Int(
'loc_part_lon_min',
required=False,
label=_(u'LOC Minutes Longitude'),
doc=_(u'Minutes Longitude'),
),
parameters.Decimal(
'loc_part_lon_sec',
required=False,
label=_(u'LOC Seconds Longitude'),
doc=_(u'Seconds Longitude'),
),
parameters.Str(
'loc_part_lon_dir',
required=False,
label=_(u'LOC Direction Longitude'),
doc=_(u'Direction Longitude'),
),
parameters.Decimal(
'loc_part_altitude',
required=False,
label=_(u'LOC Altitude'),
doc=_(u'Altitude'),
),
parameters.Decimal(
'loc_part_size',
required=False,
label=_(u'LOC Size'),
doc=_(u'Size'),
),
parameters.Decimal(
'loc_part_h_precision',
required=False,
label=_(u'LOC Horizontal Precision'),
doc=_(u'Horizontal Precision'),
),
parameters.Decimal(
'loc_part_v_precision',
required=False,
label=_(u'LOC Vertical Precision'),
doc=_(u'Vertical Precision'),
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Int(
'mx_part_preference',
required=False,
label=_(u'MX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'mx_part_exchanger',
required=False,
label=_(u'MX Exchanger'),
doc=_(u'A host willing to act as a mail exchanger'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Int(
'naptr_part_order',
required=False,
label=_(u'NAPTR Order'),
doc=_(u'Order'),
),
parameters.Int(
'naptr_part_preference',
required=False,
label=_(u'NAPTR Preference'),
doc=_(u'Preference'),
),
parameters.Str(
'naptr_part_flags',
required=False,
label=_(u'NAPTR Flags'),
doc=_(u'Flags'),
),
parameters.Str(
'naptr_part_service',
required=False,
label=_(u'NAPTR Service'),
doc=_(u'Service'),
),
parameters.Str(
'naptr_part_regexp',
required=False,
label=_(u'NAPTR Regular Expression'),
doc=_(u'Regular Expression'),
),
parameters.Str(
'naptr_part_replacement',
required=False,
label=_(u'NAPTR Replacement'),
doc=_(u'Replacement'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.DNSNameParam(
'ns_part_hostname',
required=False,
label=_(u'NS Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.DNSNameParam(
'ptr_part_hostname',
required=False,
label=_(u'PTR Hostname'),
doc=_(u'The hostname this reverse record points to'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
label=_(u'RP record'),
doc=_(u'Raw RP records'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Int(
'srv_part_priority',
required=False,
label=_(u'SRV Priority'),
doc=_(u'Priority'),
),
parameters.Int(
'srv_part_weight',
required=False,
label=_(u'SRV Weight'),
doc=_(u'Weight'),
),
parameters.Int(
'srv_part_port',
required=False,
label=_(u'SRV Port'),
doc=_(u'Port'),
),
parameters.DNSNameParam(
'srv_part_target',
required=False,
label=_(u'SRV Target'),
doc=_(u"The domain name of the target host or '.' if the service is decidedly not available at this domain"),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Int(
'sshfp_part_algorithm',
required=False,
label=_(u'SSHFP Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'sshfp_part_fp_type',
required=False,
label=_(u'SSHFP Fingerprint Type'),
doc=_(u'Fingerprint Type'),
),
parameters.Str(
'sshfp_part_fingerprint',
required=False,
label=_(u'SSHFP Fingerprint'),
doc=_(u'Fingerprint'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Int(
'tlsa_part_cert_usage',
required=False,
label=_(u'TLSA Certificate Usage'),
doc=_(u'Certificate Usage'),
),
parameters.Int(
'tlsa_part_selector',
required=False,
label=_(u'TLSA Selector'),
doc=_(u'Selector'),
),
parameters.Int(
'tlsa_part_matching_type',
required=False,
label=_(u'TLSA Matching Type'),
doc=_(u'Matching Type'),
),
parameters.Str(
'tlsa_part_cert_association_data',
required=False,
label=_(u'TLSA Certificate Association Data'),
doc=_(u'Certificate Association Data'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Str(
'txt_part_data',
required=False,
label=_(u'TXT Text Data'),
doc=_(u'Text Data'),
),
)
@register()
class dnszone(Object):
takes_params = (
parameters.DNSNameParam(
'idnsname',
primary_key=True,
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
label=_(u'Administrator e-mail address'),
),
parameters.Int(
'idnssoaserial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
),
parameters.Int(
'idnssoarefresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
),
parameters.Int(
'idnssoaretry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
),
parameters.Int(
'idnssoaexpire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
),
parameters.Int(
'idnssoaminimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
),
parameters.Int(
'dnsttl',
required=False,
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
),
parameters.Str(
'idnsupdatepolicy',
required=False,
label=_(u'BIND update policy'),
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
),
parameters.Str(
'idnsallowquery',
required=False,
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
),
parameters.Str(
'idnsallowtransfer',
required=False,
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
),
parameters.Str(
'nsec3paramrecord',
required=False,
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
)
@register()
class dns_is_enabled(Command):
__doc__ = _("Checks if any of the servers has the DNS service enabled.")
NO_CLI = True
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dns_resolve(Command):
__doc__ = _("Resolve a host name in DNS.")
takes_args = (
parameters.Str(
'hostname',
label=_(u'Hostname'),
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsconfig_mod(Method):
__doc__ = _("Modify global DNS configuration.")
takes_options = (
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Global forwarders'),
doc=_(u'Global forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Global forwarding policy. Set to "none" to disable any configured global forwarders.'),
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records'),
),
parameters.Int(
'idnszonerefresh',
required=False,
deprecated=True,
cli_name='zone_refresh',
label=_(u'Zone refresh interval'),
exclude=('cli', 'webui'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsconfig_show(Method):
__doc__ = _("Show the current global DNS configuration.")
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_add(Method):
__doc__ = _("Create new DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_add_permission(Method):
__doc__ = _("Add a permission for per-forward zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnsforwardzone_del(Method):
__doc__ = _("Delete DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
multivalue=True,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnsforwardzone_disable(Method):
__doc__ = _("Disable DNS Forward Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_enable(Method):
__doc__ = _("Enable DNS Forward Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_find(Method):
__doc__ = _("Search for DNS forward zones.")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.DNSNameParam(
'idnsname',
required=False,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
cli_name='zone_active',
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class dnsforwardzone_mod(Method):
__doc__ = _("Modify DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsforwardzone_remove_permission(Method):
__doc__ = _("Remove a permission for per-forward zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnsforwardzone_show(Method):
__doc__ = _("Display information about a DNS forward zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsrecord_add(Method):
__doc__ = _("Add new DNS resource record.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
option_group=u'A Record',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'a_part_ip_address',
required=False,
cli_name='a_ip_address',
option_group=u'A Record',
label=_(u'A IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'a_extra_create_reverse',
required=False,
cli_name='a_create_reverse',
option_group=u'A Record',
label=_(u'A Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
default=False,
autofill=True,
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
option_group=u'AAAA Record',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'aaaa_part_ip_address',
required=False,
cli_name='aaaa_ip_address',
option_group=u'AAAA Record',
label=_(u'AAAA IP Address'),
doc=_(u'IP Address'),
),
parameters.Flag(
'aaaa_extra_create_reverse',
required=False,
cli_name='aaaa_create_reverse',
option_group=u'AAAA Record',
label=_(u'AAAA Create reverse'),
doc=_(u'Create reverse record for this IP Address'),
default=False,
autofill=True,
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
option_group=u'A6 Record',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'a6_part_data',
required=False,
cli_name='a6_data',
option_group=u'A6 Record',
label=_(u'A6 Record data'),
doc=_(u'Record data'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
option_group=u'AFSDB Record',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Int(
'afsdb_part_subtype',
required=False,
cli_name='afsdb_subtype',
option_group=u'AFSDB Record',
label=_(u'AFSDB Subtype'),
doc=_(u'Subtype'),
),
parameters.DNSNameParam(
'afsdb_part_hostname',
required=False,
cli_name='afsdb_hostname',
option_group=u'AFSDB Record',
label=_(u'AFSDB Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
option_group=u'APL Record',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
option_group=u'CERT Record',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Int(
'cert_part_type',
required=False,
cli_name='cert_type',
option_group=u'CERT Record',
label=_(u'CERT Certificate Type'),
doc=_(u'Certificate Type'),
),
parameters.Int(
'cert_part_key_tag',
required=False,
cli_name='cert_key_tag',
option_group=u'CERT Record',
label=_(u'CERT Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'cert_part_algorithm',
required=False,
cli_name='cert_algorithm',
option_group=u'CERT Record',
label=_(u'CERT Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Str(
'cert_part_certificate_or_crl',
required=False,
cli_name='cert_certificate_or_crl',
option_group=u'CERT Record',
label=_(u'CERT Certificate/CRL'),
doc=_(u'Certificate/CRL'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
option_group=u'CNAME Record',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.DNSNameParam(
'cname_part_hostname',
required=False,
cli_name='cname_hostname',
option_group=u'CNAME Record',
label=_(u'CNAME Hostname'),
doc=_(u'A hostname which this alias hostname points to'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
option_group=u'DHCID Record',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
option_group=u'DLV Record',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Int(
'dlv_part_key_tag',
required=False,
cli_name='dlv_key_tag',
option_group=u'DLV Record',
label=_(u'DLV Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'dlv_part_algorithm',
required=False,
cli_name='dlv_algorithm',
option_group=u'DLV Record',
label=_(u'DLV Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'dlv_part_digest_type',
required=False,
cli_name='dlv_digest_type',
option_group=u'DLV Record',
label=_(u'DLV Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'dlv_part_digest',
required=False,
cli_name='dlv_digest',
option_group=u'DLV Record',
label=_(u'DLV Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
option_group=u'DNAME Record',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.DNSNameParam(
'dname_part_target',
required=False,
cli_name='dname_target',
option_group=u'DNAME Record',
label=_(u'DNAME Target'),
doc=_(u'Target'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
option_group=u'DS Record',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Int(
'ds_part_key_tag',
required=False,
cli_name='ds_key_tag',
option_group=u'DS Record',
label=_(u'DS Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'ds_part_algorithm',
required=False,
cli_name='ds_algorithm',
option_group=u'DS Record',
label=_(u'DS Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'ds_part_digest_type',
required=False,
cli_name='ds_digest_type',
option_group=u'DS Record',
label=_(u'DS Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'ds_part_digest',
required=False,
cli_name='ds_digest',
option_group=u'DS Record',
label=_(u'DS Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
option_group=u'HIP Record',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
option_group=u'IPSECKEY Record',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
option_group=u'KEY Record',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
option_group=u'KX Record',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Int(
'kx_part_preference',
required=False,
cli_name='kx_preference',
option_group=u'KX Record',
label=_(u'KX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'kx_part_exchanger',
required=False,
cli_name='kx_exchanger',
option_group=u'KX Record',
label=_(u'KX Exchanger'),
doc=_(u'A host willing to act as a key exchanger'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
option_group=u'LOC Record',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Int(
'loc_part_lat_deg',
required=False,
cli_name='loc_lat_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Latitude'),
doc=_(u'Degrees Latitude'),
),
parameters.Int(
'loc_part_lat_min',
required=False,
cli_name='loc_lat_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Latitude'),
doc=_(u'Minutes Latitude'),
),
parameters.Decimal(
'loc_part_lat_sec',
required=False,
cli_name='loc_lat_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Latitude'),
doc=_(u'Seconds Latitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lat_dir',
required=False,
cli_name='loc_lat_dir',
option_group=u'LOC Record',
cli_metavar="['N', 'S']",
label=_(u'LOC Direction Latitude'),
doc=_(u'Direction Latitude'),
),
parameters.Int(
'loc_part_lon_deg',
required=False,
cli_name='loc_lon_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Longitude'),
doc=_(u'Degrees Longitude'),
),
parameters.Int(
'loc_part_lon_min',
required=False,
cli_name='loc_lon_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Longitude'),
doc=_(u'Minutes Longitude'),
),
parameters.Decimal(
'loc_part_lon_sec',
required=False,
cli_name='loc_lon_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Longitude'),
doc=_(u'Seconds Longitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lon_dir',
required=False,
cli_name='loc_lon_dir',
option_group=u'LOC Record',
cli_metavar="['E', 'W']",
label=_(u'LOC Direction Longitude'),
doc=_(u'Direction Longitude'),
),
parameters.Decimal(
'loc_part_altitude',
required=False,
cli_name='loc_altitude',
option_group=u'LOC Record',
label=_(u'LOC Altitude'),
doc=_(u'Altitude'),
no_convert=True,
),
parameters.Decimal(
'loc_part_size',
required=False,
cli_name='loc_size',
option_group=u'LOC Record',
label=_(u'LOC Size'),
doc=_(u'Size'),
no_convert=True,
),
parameters.Decimal(
'loc_part_h_precision',
required=False,
cli_name='loc_h_precision',
option_group=u'LOC Record',
label=_(u'LOC Horizontal Precision'),
doc=_(u'Horizontal Precision'),
no_convert=True,
),
parameters.Decimal(
'loc_part_v_precision',
required=False,
cli_name='loc_v_precision',
option_group=u'LOC Record',
label=_(u'LOC Vertical Precision'),
doc=_(u'Vertical Precision'),
no_convert=True,
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
option_group=u'MX Record',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Int(
'mx_part_preference',
required=False,
cli_name='mx_preference',
option_group=u'MX Record',
label=_(u'MX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'mx_part_exchanger',
required=False,
cli_name='mx_exchanger',
option_group=u'MX Record',
label=_(u'MX Exchanger'),
doc=_(u'A host willing to act as a mail exchanger'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
option_group=u'NAPTR Record',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Int(
'naptr_part_order',
required=False,
cli_name='naptr_order',
option_group=u'NAPTR Record',
label=_(u'NAPTR Order'),
doc=_(u'Order'),
),
parameters.Int(
'naptr_part_preference',
required=False,
cli_name='naptr_preference',
option_group=u'NAPTR Record',
label=_(u'NAPTR Preference'),
doc=_(u'Preference'),
),
parameters.Str(
'naptr_part_flags',
required=False,
cli_name='naptr_flags',
option_group=u'NAPTR Record',
label=_(u'NAPTR Flags'),
doc=_(u'Flags'),
no_convert=True,
),
parameters.Str(
'naptr_part_service',
required=False,
cli_name='naptr_service',
option_group=u'NAPTR Record',
label=_(u'NAPTR Service'),
doc=_(u'Service'),
),
parameters.Str(
'naptr_part_regexp',
required=False,
cli_name='naptr_regexp',
option_group=u'NAPTR Record',
label=_(u'NAPTR Regular Expression'),
doc=_(u'Regular Expression'),
),
parameters.Str(
'naptr_part_replacement',
required=False,
cli_name='naptr_replacement',
option_group=u'NAPTR Record',
label=_(u'NAPTR Replacement'),
doc=_(u'Replacement'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
option_group=u'NS Record',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.DNSNameParam(
'ns_part_hostname',
required=False,
cli_name='ns_hostname',
option_group=u'NS Record',
label=_(u'NS Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
option_group=u'NSEC Record',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
option_group=u'PTR Record',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.DNSNameParam(
'ptr_part_hostname',
required=False,
cli_name='ptr_hostname',
option_group=u'PTR Record',
label=_(u'PTR Hostname'),
doc=_(u'The hostname this reverse record points to'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
option_group=u'RRSIG Record',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
option_group=u'RP Record',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
option_group=u'SIG Record',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
option_group=u'SPF Record',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
option_group=u'SRV Record',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Int(
'srv_part_priority',
required=False,
cli_name='srv_priority',
option_group=u'SRV Record',
label=_(u'SRV Priority'),
doc=_(u'Priority'),
),
parameters.Int(
'srv_part_weight',
required=False,
cli_name='srv_weight',
option_group=u'SRV Record',
label=_(u'SRV Weight'),
doc=_(u'Weight'),
),
parameters.Int(
'srv_part_port',
required=False,
cli_name='srv_port',
option_group=u'SRV Record',
label=_(u'SRV Port'),
doc=_(u'Port'),
),
parameters.DNSNameParam(
'srv_part_target',
required=False,
cli_name='srv_target',
option_group=u'SRV Record',
label=_(u'SRV Target'),
doc=_(u"The domain name of the target host or '.' if the service is decidedly not available at this domain"),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
option_group=u'SSHFP Record',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Int(
'sshfp_part_algorithm',
required=False,
cli_name='sshfp_algorithm',
option_group=u'SSHFP Record',
label=_(u'SSHFP Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'sshfp_part_fp_type',
required=False,
cli_name='sshfp_fp_type',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint Type'),
doc=_(u'Fingerprint Type'),
),
parameters.Str(
'sshfp_part_fingerprint',
required=False,
cli_name='sshfp_fingerprint',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint'),
doc=_(u'Fingerprint'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
option_group=u'TLSA Record',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Int(
'tlsa_part_cert_usage',
required=False,
cli_name='tlsa_cert_usage',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Usage'),
doc=_(u'Certificate Usage'),
),
parameters.Int(
'tlsa_part_selector',
required=False,
cli_name='tlsa_selector',
option_group=u'TLSA Record',
label=_(u'TLSA Selector'),
doc=_(u'Selector'),
),
parameters.Int(
'tlsa_part_matching_type',
required=False,
cli_name='tlsa_matching_type',
option_group=u'TLSA Record',
label=_(u'TLSA Matching Type'),
doc=_(u'Matching Type'),
),
parameters.Str(
'tlsa_part_cert_association_data',
required=False,
cli_name='tlsa_cert_association_data',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Association Data'),
doc=_(u'Certificate Association Data'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
option_group=u'TXT Record',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Str(
'txt_part_data',
required=False,
cli_name='txt_data',
option_group=u'TXT Record',
label=_(u'TXT Text Data'),
doc=_(u'Text Data'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'force NS record creation even if its hostname is not in DNS'),
exclude=('cli', 'webui'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsrecord_del(Method):
__doc__ = _("Delete DNS resource record.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Flag(
'del_all',
label=_(u'Delete all associated records'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnsrecord_delentry(Method):
__doc__ = _("Delete DNS record entry.")
NO_CLI = True
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
multivalue=True,
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnsrecord_find(Method):
__doc__ = _("Search for DNS resources.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.DNSNameParam(
'idnsname',
required=False,
cli_name='name',
label=_(u'Record name'),
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class dnsrecord_mod(Method):
__doc__ = _("Modify a DNS resource record.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'arecord',
required=False,
multivalue=True,
cli_name='a_rec',
option_group=u'A Record',
label=_(u'A record'),
doc=_(u'Raw A records'),
),
parameters.Str(
'a_part_ip_address',
required=False,
cli_name='a_ip_address',
option_group=u'A Record',
label=_(u'A IP Address'),
doc=_(u'IP Address'),
),
parameters.Str(
'aaaarecord',
required=False,
multivalue=True,
cli_name='aaaa_rec',
option_group=u'AAAA Record',
label=_(u'AAAA record'),
doc=_(u'Raw AAAA records'),
),
parameters.Str(
'aaaa_part_ip_address',
required=False,
cli_name='aaaa_ip_address',
option_group=u'AAAA Record',
label=_(u'AAAA IP Address'),
doc=_(u'IP Address'),
),
parameters.Str(
'a6record',
required=False,
multivalue=True,
cli_name='a6_rec',
option_group=u'A6 Record',
label=_(u'A6 record'),
doc=_(u'Raw A6 records'),
),
parameters.Str(
'a6_part_data',
required=False,
cli_name='a6_data',
option_group=u'A6 Record',
label=_(u'A6 Record data'),
doc=_(u'Record data'),
),
parameters.Str(
'afsdbrecord',
required=False,
multivalue=True,
cli_name='afsdb_rec',
option_group=u'AFSDB Record',
label=_(u'AFSDB record'),
doc=_(u'Raw AFSDB records'),
),
parameters.Int(
'afsdb_part_subtype',
required=False,
cli_name='afsdb_subtype',
option_group=u'AFSDB Record',
label=_(u'AFSDB Subtype'),
doc=_(u'Subtype'),
),
parameters.DNSNameParam(
'afsdb_part_hostname',
required=False,
cli_name='afsdb_hostname',
option_group=u'AFSDB Record',
label=_(u'AFSDB Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'aplrecord',
required=False,
multivalue=True,
cli_name='apl_rec',
option_group=u'APL Record',
label=_(u'APL record'),
doc=_(u'Raw APL records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'certrecord',
required=False,
multivalue=True,
cli_name='cert_rec',
option_group=u'CERT Record',
label=_(u'CERT record'),
doc=_(u'Raw CERT records'),
),
parameters.Int(
'cert_part_type',
required=False,
cli_name='cert_type',
option_group=u'CERT Record',
label=_(u'CERT Certificate Type'),
doc=_(u'Certificate Type'),
),
parameters.Int(
'cert_part_key_tag',
required=False,
cli_name='cert_key_tag',
option_group=u'CERT Record',
label=_(u'CERT Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'cert_part_algorithm',
required=False,
cli_name='cert_algorithm',
option_group=u'CERT Record',
label=_(u'CERT Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Str(
'cert_part_certificate_or_crl',
required=False,
cli_name='cert_certificate_or_crl',
option_group=u'CERT Record',
label=_(u'CERT Certificate/CRL'),
doc=_(u'Certificate/CRL'),
),
parameters.Str(
'cnamerecord',
required=False,
multivalue=True,
cli_name='cname_rec',
option_group=u'CNAME Record',
label=_(u'CNAME record'),
doc=_(u'Raw CNAME records'),
),
parameters.DNSNameParam(
'cname_part_hostname',
required=False,
cli_name='cname_hostname',
option_group=u'CNAME Record',
label=_(u'CNAME Hostname'),
doc=_(u'A hostname which this alias hostname points to'),
),
parameters.Str(
'dhcidrecord',
required=False,
multivalue=True,
cli_name='dhcid_rec',
option_group=u'DHCID Record',
label=_(u'DHCID record'),
doc=_(u'Raw DHCID records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'dlvrecord',
required=False,
multivalue=True,
cli_name='dlv_rec',
option_group=u'DLV Record',
label=_(u'DLV record'),
doc=_(u'Raw DLV records'),
),
parameters.Int(
'dlv_part_key_tag',
required=False,
cli_name='dlv_key_tag',
option_group=u'DLV Record',
label=_(u'DLV Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'dlv_part_algorithm',
required=False,
cli_name='dlv_algorithm',
option_group=u'DLV Record',
label=_(u'DLV Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'dlv_part_digest_type',
required=False,
cli_name='dlv_digest_type',
option_group=u'DLV Record',
label=_(u'DLV Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'dlv_part_digest',
required=False,
cli_name='dlv_digest',
option_group=u'DLV Record',
label=_(u'DLV Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'dnamerecord',
required=False,
multivalue=True,
cli_name='dname_rec',
option_group=u'DNAME Record',
label=_(u'DNAME record'),
doc=_(u'Raw DNAME records'),
),
parameters.DNSNameParam(
'dname_part_target',
required=False,
cli_name='dname_target',
option_group=u'DNAME Record',
label=_(u'DNAME Target'),
doc=_(u'Target'),
),
parameters.Str(
'dsrecord',
required=False,
multivalue=True,
cli_name='ds_rec',
option_group=u'DS Record',
label=_(u'DS record'),
doc=_(u'Raw DS records'),
),
parameters.Int(
'ds_part_key_tag',
required=False,
cli_name='ds_key_tag',
option_group=u'DS Record',
label=_(u'DS Key Tag'),
doc=_(u'Key Tag'),
),
parameters.Int(
'ds_part_algorithm',
required=False,
cli_name='ds_algorithm',
option_group=u'DS Record',
label=_(u'DS Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'ds_part_digest_type',
required=False,
cli_name='ds_digest_type',
option_group=u'DS Record',
label=_(u'DS Digest Type'),
doc=_(u'Digest Type'),
),
parameters.Str(
'ds_part_digest',
required=False,
cli_name='ds_digest',
option_group=u'DS Record',
label=_(u'DS Digest'),
doc=_(u'Digest'),
),
parameters.Str(
'hiprecord',
required=False,
multivalue=True,
cli_name='hip_rec',
option_group=u'HIP Record',
label=_(u'HIP record'),
doc=_(u'Raw HIP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ipseckeyrecord',
required=False,
multivalue=True,
cli_name='ipseckey_rec',
option_group=u'IPSECKEY Record',
label=_(u'IPSECKEY record'),
doc=_(u'Raw IPSECKEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'keyrecord',
required=False,
multivalue=True,
cli_name='key_rec',
option_group=u'KEY Record',
label=_(u'KEY record'),
doc=_(u'Raw KEY records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'kxrecord',
required=False,
multivalue=True,
cli_name='kx_rec',
option_group=u'KX Record',
label=_(u'KX record'),
doc=_(u'Raw KX records'),
),
parameters.Int(
'kx_part_preference',
required=False,
cli_name='kx_preference',
option_group=u'KX Record',
label=_(u'KX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'kx_part_exchanger',
required=False,
cli_name='kx_exchanger',
option_group=u'KX Record',
label=_(u'KX Exchanger'),
doc=_(u'A host willing to act as a key exchanger'),
),
parameters.Str(
'locrecord',
required=False,
multivalue=True,
cli_name='loc_rec',
option_group=u'LOC Record',
label=_(u'LOC record'),
doc=_(u'Raw LOC records'),
),
parameters.Int(
'loc_part_lat_deg',
required=False,
cli_name='loc_lat_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Latitude'),
doc=_(u'Degrees Latitude'),
),
parameters.Int(
'loc_part_lat_min',
required=False,
cli_name='loc_lat_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Latitude'),
doc=_(u'Minutes Latitude'),
),
parameters.Decimal(
'loc_part_lat_sec',
required=False,
cli_name='loc_lat_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Latitude'),
doc=_(u'Seconds Latitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lat_dir',
required=False,
cli_name='loc_lat_dir',
option_group=u'LOC Record',
cli_metavar="['N', 'S']",
label=_(u'LOC Direction Latitude'),
doc=_(u'Direction Latitude'),
),
parameters.Int(
'loc_part_lon_deg',
required=False,
cli_name='loc_lon_deg',
option_group=u'LOC Record',
label=_(u'LOC Degrees Longitude'),
doc=_(u'Degrees Longitude'),
),
parameters.Int(
'loc_part_lon_min',
required=False,
cli_name='loc_lon_min',
option_group=u'LOC Record',
label=_(u'LOC Minutes Longitude'),
doc=_(u'Minutes Longitude'),
),
parameters.Decimal(
'loc_part_lon_sec',
required=False,
cli_name='loc_lon_sec',
option_group=u'LOC Record',
label=_(u'LOC Seconds Longitude'),
doc=_(u'Seconds Longitude'),
no_convert=True,
),
parameters.Str(
'loc_part_lon_dir',
required=False,
cli_name='loc_lon_dir',
option_group=u'LOC Record',
cli_metavar="['E', 'W']",
label=_(u'LOC Direction Longitude'),
doc=_(u'Direction Longitude'),
),
parameters.Decimal(
'loc_part_altitude',
required=False,
cli_name='loc_altitude',
option_group=u'LOC Record',
label=_(u'LOC Altitude'),
doc=_(u'Altitude'),
no_convert=True,
),
parameters.Decimal(
'loc_part_size',
required=False,
cli_name='loc_size',
option_group=u'LOC Record',
label=_(u'LOC Size'),
doc=_(u'Size'),
no_convert=True,
),
parameters.Decimal(
'loc_part_h_precision',
required=False,
cli_name='loc_h_precision',
option_group=u'LOC Record',
label=_(u'LOC Horizontal Precision'),
doc=_(u'Horizontal Precision'),
no_convert=True,
),
parameters.Decimal(
'loc_part_v_precision',
required=False,
cli_name='loc_v_precision',
option_group=u'LOC Record',
label=_(u'LOC Vertical Precision'),
doc=_(u'Vertical Precision'),
no_convert=True,
),
parameters.Str(
'mxrecord',
required=False,
multivalue=True,
cli_name='mx_rec',
option_group=u'MX Record',
label=_(u'MX record'),
doc=_(u'Raw MX records'),
),
parameters.Int(
'mx_part_preference',
required=False,
cli_name='mx_preference',
option_group=u'MX Record',
label=_(u'MX Preference'),
doc=_(u'Preference given to this exchanger. Lower values are more preferred'),
),
parameters.DNSNameParam(
'mx_part_exchanger',
required=False,
cli_name='mx_exchanger',
option_group=u'MX Record',
label=_(u'MX Exchanger'),
doc=_(u'A host willing to act as a mail exchanger'),
),
parameters.Str(
'naptrrecord',
required=False,
multivalue=True,
cli_name='naptr_rec',
option_group=u'NAPTR Record',
label=_(u'NAPTR record'),
doc=_(u'Raw NAPTR records'),
),
parameters.Int(
'naptr_part_order',
required=False,
cli_name='naptr_order',
option_group=u'NAPTR Record',
label=_(u'NAPTR Order'),
doc=_(u'Order'),
),
parameters.Int(
'naptr_part_preference',
required=False,
cli_name='naptr_preference',
option_group=u'NAPTR Record',
label=_(u'NAPTR Preference'),
doc=_(u'Preference'),
),
parameters.Str(
'naptr_part_flags',
required=False,
cli_name='naptr_flags',
option_group=u'NAPTR Record',
label=_(u'NAPTR Flags'),
doc=_(u'Flags'),
no_convert=True,
),
parameters.Str(
'naptr_part_service',
required=False,
cli_name='naptr_service',
option_group=u'NAPTR Record',
label=_(u'NAPTR Service'),
doc=_(u'Service'),
),
parameters.Str(
'naptr_part_regexp',
required=False,
cli_name='naptr_regexp',
option_group=u'NAPTR Record',
label=_(u'NAPTR Regular Expression'),
doc=_(u'Regular Expression'),
),
parameters.Str(
'naptr_part_replacement',
required=False,
cli_name='naptr_replacement',
option_group=u'NAPTR Record',
label=_(u'NAPTR Replacement'),
doc=_(u'Replacement'),
),
parameters.Str(
'nsrecord',
required=False,
multivalue=True,
cli_name='ns_rec',
option_group=u'NS Record',
label=_(u'NS record'),
doc=_(u'Raw NS records'),
),
parameters.DNSNameParam(
'ns_part_hostname',
required=False,
cli_name='ns_hostname',
option_group=u'NS Record',
label=_(u'NS Hostname'),
doc=_(u'Hostname'),
),
parameters.Str(
'nsecrecord',
required=False,
multivalue=True,
cli_name='nsec_rec',
option_group=u'NSEC Record',
label=_(u'NSEC record'),
doc=_(u'Raw NSEC records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'ptrrecord',
required=False,
multivalue=True,
cli_name='ptr_rec',
option_group=u'PTR Record',
label=_(u'PTR record'),
doc=_(u'Raw PTR records'),
),
parameters.DNSNameParam(
'ptr_part_hostname',
required=False,
cli_name='ptr_hostname',
option_group=u'PTR Record',
label=_(u'PTR Hostname'),
doc=_(u'The hostname this reverse record points to'),
),
parameters.Str(
'rrsigrecord',
required=False,
multivalue=True,
cli_name='rrsig_rec',
option_group=u'RRSIG Record',
label=_(u'RRSIG record'),
doc=_(u'Raw RRSIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'rprecord',
required=False,
multivalue=True,
cli_name='rp_rec',
option_group=u'RP Record',
label=_(u'RP record'),
doc=_(u'Raw RP records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'sigrecord',
required=False,
multivalue=True,
cli_name='sig_rec',
option_group=u'SIG Record',
label=_(u'SIG record'),
doc=_(u'Raw SIG records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'spfrecord',
required=False,
multivalue=True,
cli_name='spf_rec',
option_group=u'SPF Record',
label=_(u'SPF record'),
doc=_(u'Raw SPF records'),
exclude=('cli', 'webui'),
),
parameters.Str(
'srvrecord',
required=False,
multivalue=True,
cli_name='srv_rec',
option_group=u'SRV Record',
label=_(u'SRV record'),
doc=_(u'Raw SRV records'),
),
parameters.Int(
'srv_part_priority',
required=False,
cli_name='srv_priority',
option_group=u'SRV Record',
label=_(u'SRV Priority'),
doc=_(u'Priority'),
),
parameters.Int(
'srv_part_weight',
required=False,
cli_name='srv_weight',
option_group=u'SRV Record',
label=_(u'SRV Weight'),
doc=_(u'Weight'),
),
parameters.Int(
'srv_part_port',
required=False,
cli_name='srv_port',
option_group=u'SRV Record',
label=_(u'SRV Port'),
doc=_(u'Port'),
),
parameters.DNSNameParam(
'srv_part_target',
required=False,
cli_name='srv_target',
option_group=u'SRV Record',
label=_(u'SRV Target'),
doc=_(u"The domain name of the target host or '.' if the service is decidedly not available at this domain"),
),
parameters.Str(
'sshfprecord',
required=False,
multivalue=True,
cli_name='sshfp_rec',
option_group=u'SSHFP Record',
label=_(u'SSHFP record'),
doc=_(u'Raw SSHFP records'),
),
parameters.Int(
'sshfp_part_algorithm',
required=False,
cli_name='sshfp_algorithm',
option_group=u'SSHFP Record',
label=_(u'SSHFP Algorithm'),
doc=_(u'Algorithm'),
),
parameters.Int(
'sshfp_part_fp_type',
required=False,
cli_name='sshfp_fp_type',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint Type'),
doc=_(u'Fingerprint Type'),
),
parameters.Str(
'sshfp_part_fingerprint',
required=False,
cli_name='sshfp_fingerprint',
option_group=u'SSHFP Record',
label=_(u'SSHFP Fingerprint'),
doc=_(u'Fingerprint'),
),
parameters.Str(
'tlsarecord',
required=False,
multivalue=True,
cli_name='tlsa_rec',
option_group=u'TLSA Record',
label=_(u'TLSA record'),
doc=_(u'Raw TLSA records'),
),
parameters.Int(
'tlsa_part_cert_usage',
required=False,
cli_name='tlsa_cert_usage',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Usage'),
doc=_(u'Certificate Usage'),
),
parameters.Int(
'tlsa_part_selector',
required=False,
cli_name='tlsa_selector',
option_group=u'TLSA Record',
label=_(u'TLSA Selector'),
doc=_(u'Selector'),
),
parameters.Int(
'tlsa_part_matching_type',
required=False,
cli_name='tlsa_matching_type',
option_group=u'TLSA Record',
label=_(u'TLSA Matching Type'),
doc=_(u'Matching Type'),
),
parameters.Str(
'tlsa_part_cert_association_data',
required=False,
cli_name='tlsa_cert_association_data',
option_group=u'TLSA Record',
label=_(u'TLSA Certificate Association Data'),
doc=_(u'Certificate Association Data'),
),
parameters.Str(
'txtrecord',
required=False,
multivalue=True,
cli_name='txt_rec',
option_group=u'TXT Record',
label=_(u'TXT record'),
doc=_(u'Raw TXT records'),
),
parameters.Str(
'txt_part_data',
required=False,
cli_name='txt_data',
option_group=u'TXT Record',
label=_(u'TXT Text Data'),
doc=_(u'Text Data'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.DNSNameParam(
'rename',
required=False,
label=_(u'Rename'),
doc=_(u'Rename the DNS resource record object'),
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnsrecord_show(Method):
__doc__ = _("Display DNS resource.")
takes_args = (
parameters.DNSNameParam(
'dnszoneidnsname',
cli_name='dnszone',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Record name'),
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'structured',
label=_(u'Structured'),
doc=_(u'Parse all raw DNS records and return them in a structured way'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_add(Method):
__doc__ = _("Create new DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
cli_name='name_server',
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
cli_name='admin_email',
label=_(u'Administrator e-mail address'),
default=DNSName(u'hostmaster'),
autofill=True,
no_convert=True,
),
parameters.Int(
'idnssoaserial',
cli_name='serial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# def _create_zone_serial():
# """
# Generate serial number for zones. bind-dyndb-ldap expects unix time in
# to be used for SOA serial.
#
# SOA serial in a date format would also work, but it may be set to far
# future when many DNS updates are done per day (more than 100). Unix
# timestamp is more resilient to this issue.
# """
# return int(time.time())
autofill=True,
),
parameters.Int(
'idnssoarefresh',
cli_name='refresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
default=3600,
autofill=True,
),
parameters.Int(
'idnssoaretry',
cli_name='retry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
default=900,
autofill=True,
),
parameters.Int(
'idnssoaexpire',
cli_name='expire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
default=1209600,
autofill=True,
),
parameters.Int(
'idnssoaminimum',
cli_name='minimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
default=3600,
autofill=True,
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'idnsupdatepolicy',
required=False,
cli_name='update_policy',
label=_(u'BIND update policy'),
default_from=DefaultFrom(lambda idnsname: None, 'idnsname'),
# FIXME:
# lambda idnsname: default_zone_update_policy(idnsname)
autofill=True,
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
cli_name='dynamic_update',
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
default=False,
autofill=True,
),
parameters.Str(
'idnsallowquery',
required=False,
cli_name='allow_query',
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
default=u'any;',
autofill=True,
no_convert=True,
),
parameters.Str(
'idnsallowtransfer',
required=False,
cli_name='allow_transfer',
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
default=u'none;',
autofill=True,
no_convert=True,
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
cli_name='dnssec',
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
default=False,
),
parameters.Str(
'nsec3paramrecord',
required=False,
cli_name='nsec3param_rec',
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'Force DNS zone creation even if nameserver is not resolvable.'),
default=False,
autofill=True,
),
parameters.Str(
'ip_address',
required=False,
exclude=('cli', 'webui'),
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_add_permission(Method):
__doc__ = _("Add a permission for per-zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnszone_del(Method):
__doc__ = _("Delete DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
multivalue=True,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'continue',
doc=_(u"Continuous mode: Don't stop on errors."),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
dict,
doc=_(u'List of deletions that failed'),
),
output.ListOfPrimaryKeys(
'value',
),
)
@register()
class dnszone_disable(Method):
__doc__ = _("Disable DNS Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_enable(Method):
__doc__ = _("Enable DNS Zone.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_find(Method):
__doc__ = _("Search for DNS zones (SOA records).")
takes_args = (
parameters.Str(
'criteria',
required=False,
doc=_(u'A string searched in all relevant object attributes'),
),
)
takes_options = (
parameters.DNSNameParam(
'idnsname',
required=False,
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Bool(
'idnszoneactive',
required=False,
cli_name='zone_active',
label=_(u'Active zone'),
doc=_(u'Is zone active?'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
cli_name='name_server',
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
required=False,
cli_name='admin_email',
label=_(u'Administrator e-mail address'),
default=DNSName(u'hostmaster'),
no_convert=True,
),
parameters.Int(
'idnssoaserial',
required=False,
cli_name='serial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# def _create_zone_serial():
# """
# Generate serial number for zones. bind-dyndb-ldap expects unix time in
# to be used for SOA serial.
#
# SOA serial in a date format would also work, but it may be set to far
# future when many DNS updates are done per day (more than 100). Unix
# timestamp is more resilient to this issue.
# """
# return int(time.time())
),
parameters.Int(
'idnssoarefresh',
required=False,
cli_name='refresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
default=3600,
),
parameters.Int(
'idnssoaretry',
required=False,
cli_name='retry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
default=900,
),
parameters.Int(
'idnssoaexpire',
required=False,
cli_name='expire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
default=1209600,
),
parameters.Int(
'idnssoaminimum',
required=False,
cli_name='minimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
default=3600,
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'idnsupdatepolicy',
required=False,
cli_name='update_policy',
label=_(u'BIND update policy'),
default_from=DefaultFrom(lambda idnsname: None, 'idnsname'),
# FIXME:
# lambda idnsname: default_zone_update_policy(idnsname)
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
cli_name='dynamic_update',
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
default=False,
),
parameters.Str(
'idnsallowquery',
required=False,
cli_name='allow_query',
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
default=u'any;',
no_convert=True,
),
parameters.Str(
'idnsallowtransfer',
required=False,
cli_name='allow_transfer',
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
default=u'none;',
no_convert=True,
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
cli_name='dnssec',
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
default=False,
),
parameters.Str(
'nsec3paramrecord',
required=False,
cli_name='nsec3param_rec',
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
parameters.Int(
'timelimit',
required=False,
label=_(u'Time Limit'),
doc=_(u'Time limit of search in seconds (0 is unlimited)'),
),
parameters.Int(
'sizelimit',
required=False,
label=_(u'Size Limit'),
doc=_(u'Maximum number of entries returned (0 is unlimited)'),
),
parameters.Flag(
'forward_only',
label=_(u'Forward zones only'),
doc=_(u'Search for forward zones only'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'pkey_only',
required=False,
label=_(u'Primary key only'),
doc=_(u'Results should contain primary key attribute only ("name")'),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.ListOfEntries(
'result',
),
output.Output(
'count',
int,
doc=_(u'Number of entries returned'),
),
output.Output(
'truncated',
bool,
doc=_(u'True if not all results were returned'),
),
)
@register()
class dnszone_mod(Method):
__doc__ = _("Modify DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Str(
'name_from_ip',
required=False,
label=_(u'Reverse zone IP network'),
doc=_(u'IP network to create reverse zone name from'),
),
parameters.Str(
'idnsforwarders',
required=False,
multivalue=True,
cli_name='forwarder',
label=_(u'Zone forwarders'),
doc=_(u'Per-zone forwarders. A custom port can be specified for each forwarder using a standard format "IP_ADDRESS port PORT"'),
),
parameters.Str(
'idnsforwardpolicy',
required=False,
cli_name='forward_policy',
cli_metavar="['only', 'first', 'none']",
label=_(u'Forward policy'),
doc=_(u'Per-zone conditional forwarding policy. Set to "none" to disable forwarding to global forwarder for this zone. In that case, conditional zone forwarders are disregarded.'),
),
parameters.DNSNameParam(
'idnssoamname',
required=False,
cli_name='name_server',
label=_(u'Authoritative nameserver'),
doc=_(u'Authoritative nameserver domain name'),
),
parameters.DNSNameParam(
'idnssoarname',
required=False,
cli_name='admin_email',
label=_(u'Administrator e-mail address'),
default=DNSName(u'hostmaster'),
no_convert=True,
),
parameters.Int(
'idnssoaserial',
required=False,
cli_name='serial',
label=_(u'SOA serial'),
doc=_(u'SOA record serial number'),
default_from=DefaultFrom(lambda : None),
# FIXME:
# def _create_zone_serial():
# """
# Generate serial number for zones. bind-dyndb-ldap expects unix time in
# to be used for SOA serial.
#
# SOA serial in a date format would also work, but it may be set to far
# future when many DNS updates are done per day (more than 100). Unix
# timestamp is more resilient to this issue.
# """
# return int(time.time())
),
parameters.Int(
'idnssoarefresh',
required=False,
cli_name='refresh',
label=_(u'SOA refresh'),
doc=_(u'SOA record refresh time'),
default=3600,
),
parameters.Int(
'idnssoaretry',
required=False,
cli_name='retry',
label=_(u'SOA retry'),
doc=_(u'SOA record retry time'),
default=900,
),
parameters.Int(
'idnssoaexpire',
required=False,
cli_name='expire',
label=_(u'SOA expire'),
doc=_(u'SOA record expire time'),
default=1209600,
),
parameters.Int(
'idnssoaminimum',
required=False,
cli_name='minimum',
label=_(u'SOA minimum'),
doc=_(u'How long should negative responses be cached'),
default=3600,
),
parameters.Int(
'dnsttl',
required=False,
cli_name='ttl',
label=_(u'Time to live'),
doc=_(u'Time to live for records at zone apex'),
),
parameters.Str(
'dnsclass',
required=False,
cli_name='class',
cli_metavar="['IN', 'CS', 'CH', 'HS']",
exclude=('cli', 'webui'),
),
parameters.Str(
'idnsupdatepolicy',
required=False,
cli_name='update_policy',
label=_(u'BIND update policy'),
default_from=DefaultFrom(lambda idnsname: None, 'idnsname'),
# FIXME:
# lambda idnsname: default_zone_update_policy(idnsname)
),
parameters.Bool(
'idnsallowdynupdate',
required=False,
cli_name='dynamic_update',
label=_(u'Dynamic update'),
doc=_(u'Allow dynamic updates.'),
default=False,
),
parameters.Str(
'idnsallowquery',
required=False,
cli_name='allow_query',
label=_(u'Allow query'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to issue queries'),
default=u'any;',
no_convert=True,
),
parameters.Str(
'idnsallowtransfer',
required=False,
cli_name='allow_transfer',
label=_(u'Allow transfer'),
doc=_(u'Semicolon separated list of IP addresses or networks which are allowed to transfer the zone'),
default=u'none;',
no_convert=True,
),
parameters.Bool(
'idnsallowsyncptr',
required=False,
cli_name='allow_sync_ptr',
label=_(u'Allow PTR sync'),
doc=_(u'Allow synchronization of forward (A, AAAA) and reverse (PTR) records in the zone'),
),
parameters.Bool(
'idnssecinlinesigning',
required=False,
cli_name='dnssec',
label=_(u'Allow in-line DNSSEC signing'),
doc=_(u'Allow inline DNSSEC signing of records in the zone'),
default=False,
),
parameters.Str(
'nsec3paramrecord',
required=False,
cli_name='nsec3param_rec',
label=_(u'NSEC3PARAM record'),
doc=_(u'NSEC3PARAM record for zone in format: hash_algorithm flags iterations salt'),
),
parameters.Str(
'setattr',
required=False,
multivalue=True,
doc=_(u'Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.'),
exclude=('webui',),
),
parameters.Str(
'addattr',
required=False,
multivalue=True,
doc=_(u'Add an attribute/value pair. Format is attr=value. The attribute\nmust be part of the schema.'),
exclude=('webui',),
),
parameters.Str(
'delattr',
required=False,
multivalue=True,
doc=_(u'Delete an attribute/value pair. The option will be evaluated\nlast, after all sets and adds.'),
exclude=('webui',),
),
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'force',
label=_(u'Force'),
doc=_(u'Force nameserver change even if nameserver not in DNS'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
@register()
class dnszone_remove_permission(Method):
__doc__ = _("Remove a permission for per-zone access delegation.")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Output(
'result',
bool,
doc=_(u'True means the operation was successful'),
),
output.Output(
'value',
unicode,
doc=_(u'Permission value'),
),
)
@register()
class dnszone_show(Method):
__doc__ = _("Display information about a DNS zone (SOA record).")
takes_args = (
parameters.DNSNameParam(
'idnsname',
cli_name='name',
label=_(u'Zone name'),
doc=_(u'Zone name (FQDN)'),
default_from=DefaultFrom(lambda name_from_ip: None, 'name_from_ip'),
# FIXME:
# lambda name_from_ip: _reverse_zone_name(name_from_ip)
no_convert=True,
),
)
takes_options = (
parameters.Flag(
'rights',
label=_(u'Rights'),
doc=_(u'Display the access rights of this entry (requires --all). See ipa man page for details.'),
default=False,
autofill=True,
),
parameters.Flag(
'all',
doc=_(u'Retrieve and print all attributes from the server. Affects command output.'),
exclude=('webui',),
default=False,
autofill=True,
),
parameters.Flag(
'raw',
doc=_(u'Print entries as stored on the server. Only affects output format.'),
exclude=('webui',),
default=False,
autofill=True,
),
)
has_output = (
output.Output(
'summary',
(unicode, type(None)),
doc=_(u'User-friendly description of action performed'),
),
output.Entry(
'result',
),
output.PrimaryKey(
'value',
doc=_(u"The primary_key value of the entry, e.g. 'jdoe' for a user"),
),
)
| 161,194
|
Python
|
.py
| 4,993
| 21.105548
| 192
| 0.505274
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,092
|
client.py
|
freeipa_freeipa/ipaclient/install/client.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
"""
IPA client install module
Provides methods for installation, uninstallation of IPA client
"""
from __future__ import (
print_function,
absolute_import,
)
import logging
import dns
import getpass
import gssapi
import ifaddr
import os
import re
import SSSDConfig
import shutil
import socket
import sys
import tempfile
import textwrap
import time
import traceback
import warnings
from configparser import RawConfigParser
from urllib.parse import urlparse, urlunparse
from ipalib import api, errors, x509
from ipalib import sysrestore
from ipalib.constants import FQDN, IPAAPI_USER, MAXHOSTNAMELEN
from ipalib.install import certmonger, certstore, service
from ipalib.install import hostname as hostname_
from ipalib.facts import is_ipa_client_configured, is_ipa_configured
from ipalib.kinit import kinit_keytab, kinit_password, kinit_pkinit
from ipalib.install.service import enroll_only, prepare_only
from ipalib.rpc import delete_persistent_client_session_data
from ipalib.util import (
normalize_hostname,
no_matching_interface_for_ip_address_warning,
validate_hostname,
verify_host_resolvable,
)
from ipaplatform import services
from ipaplatform.constants import constants
from ipaplatform.paths import paths
from ipaplatform.tasks import tasks
from ipapython import certdb, kernel_keyring, ipaldap, ipautil, dnsutil
from ipapython.admintool import ScriptError
from ipapython.dn import DN
from ipapython.install import typing
from ipapython.install.core import group, knob, extend_knob
from ipapython.install.common import step
from ipapython.ipautil import (
CalledProcessError,
realm_to_suffix,
run,
user_input,
)
from ipapython.ssh import SSHPublicKey
from ipapython import version
from ipapython.errors import SetseboolError
from . import automount, timeconf, sssd
from ipaclient import discovery
from ipapython.ipachangeconf import IPAChangeConf
NoneType = type(None)
logger = logging.getLogger(__name__)
SUCCESS = 0
CLIENT_INSTALL_ERROR = 1
CLIENT_NOT_CONFIGURED = 2
CLIENT_ALREADY_CONFIGURED = 3
CLIENT_UNINSTALL_ERROR = 4 # error after restoring files/state
SECURE_PATH = (
"/bin:/sbin:/usr/kerberos/bin:/usr/kerberos/sbin:/usr/bin:/usr/sbin"
)
# global variables
hostname = None
hostname_source = None
nosssd_files = None
dnsok = False
cli_domain = None
cli_server = None
subject_base = None
cli_realm = None
cli_kdc = None
client_domain = None
cli_basedn = None
selinux_works = None
# end of global variables
def cleanup(func):
def inner(options, tdict):
# Add some additional options which contain the temporary files
# needed during installation.
fd, krb_name = tempfile.mkstemp()
os.close(fd)
ccache_dir = tempfile.mkdtemp(prefix='krbcc')
tdict['krb_name'] = krb_name
tdict['ccache_dir'] = ccache_dir
func(options, tdict)
os.environ.pop('KRB5_CONFIG', None)
try:
os.remove(krb_name)
except OSError:
logger.error("Could not remove %s", krb_name)
try:
os.rmdir(ccache_dir)
except OSError:
pass
# During master installation, the .ipabkp file is not created
# Ignore the delete error if it is "file does not exist"
remove_file(krb_name + ".ipabkp")
return inner
def remove_file(filename):
"""
Deletes a file. If the file does not exist (OSError 2) does nothing.
Otherwise logs an error message and instructs the user to remove the
offending file manually
:param filename: name of the file to be removed
"""
try:
os.remove(filename)
except OSError as e:
if e.errno == 2:
return
logger.error("Failed to remove file %s: %s", filename, e)
logger.error('Please remove %s manually, as it can cause '
'subsequent installation to fail.', filename)
def log_service_error(name, action, error):
logger.error("%s failed to %s: %s", name, action, str(error))
def get_cert_path(cert_path):
"""
If a CA certificate is passed in on the command line, use that.
Else if a CA file exists in paths.IPA_CA_CRT then use that.
Otherwise return None.
"""
if cert_path is not None:
return cert_path
if os.path.exists(paths.IPA_CA_CRT) and \
os.stat(paths.IPA_CA_CRT).st_size != 0:
return paths.IPA_CA_CRT
return None
def save_state(service, statestore):
enabled = service.is_enabled()
running = service.is_running()
if enabled or running:
statestore.backup_state(service.service_name, 'enabled', enabled)
statestore.backup_state(service.service_name, 'running', running)
def restore_state(service, statestore):
enabled = statestore.restore_state(service.service_name, 'enabled')
running = statestore.restore_state(service.service_name, 'running')
if enabled:
try:
service.enable()
except Exception:
logger.warning(
"Failed to configure automatic startup of the %s daemon",
service.service_name
)
if running:
try:
service.start()
except Exception:
logger.warning(
"Failed to restart the %s daemon",
service.service_name
)
def nssldap_exists():
"""Checks whether nss_ldap or nss-pam-ldapd is installed.
If anyone of mandatory files was found returns True and list of all files
found.
"""
files_to_check = [
{
'function': 'configure_ldap_conf',
'mandatory': [
paths.LDAP_CONF,
paths.NSS_LDAP_CONF,
paths.LIBNSS_LDAP_CONF],
'optional':[paths.PAM_LDAP_CONF]
},
{
'function': 'configure_nslcd_conf',
'mandatory': [paths.NSLCD_CONF]
}
]
files_found = {}
retval = False
for function in files_to_check:
files_found[function['function']] = []
for file_type in ['mandatory', 'optional']:
try:
for filename in function[file_type]:
if os.path.isfile(filename):
files_found[function['function']].append(filename)
if file_type == 'mandatory':
retval = True
except KeyError:
pass
return (retval, files_found)
def check_ldap_conf(conf=paths.OPENLDAP_LDAP_CONF,
error_rval=CLIENT_INSTALL_ERROR):
if not os.path.isfile(conf):
return False
pat = re.compile(r"^\s*(PORT|HOST).*")
unsupported = set()
with open(conf) as f:
for line in f:
mo = pat.match(line)
if mo is not None:
unsupported.add(mo.group(1))
if unsupported:
raise ScriptError(
"'{}' contains deprecated and unsupported entries: {}".format(
conf, ", ".join(sorted(unsupported))
),
rval=error_rval
)
else:
return True
def delete_ipa_domain():
"""Helper function for uninstall.
Deletes IPA domain from sssd.conf
"""
try:
sssdconfig = SSSDConfig.SSSDConfig()
sssdconfig.import_config()
domains = sssdconfig.list_active_domains()
ipa_domain_name = None
for name in domains:
domain = sssdconfig.get_domain(name)
try:
provider = domain.get_option('id_provider')
if provider == "ipa":
ipa_domain_name = name
break
except SSSDConfig.NoOptionError:
continue
if ipa_domain_name is not None:
sssdconfig.delete_domain(ipa_domain_name)
sssdconfig.write()
else:
logger.warning(
"IPA domain could not be found in "
"/etc/sssd/sssd.conf and therefore not deleted")
except IOError:
logger.warning(
"IPA domain could not be deleted. "
"No access to the /etc/sssd/sssd.conf file.")
def is_ipa_client_installed(on_master=False):
"""
Consider IPA client not installed if nothing is backed up
and default.conf file does not exist. If on_master is set to True,
the existence of default.conf file is not taken into consideration,
since it has been already created by ipa-server-install.
"""
warnings.warn(
"Use 'ipalib.facts.is_ipa_client_configured'",
DeprecationWarning,
stacklevel=2
)
return is_ipa_client_configured(on_master)
def configure_nsswitch_database(fstore, database, services, preserve=True,
append=True, default_value=()):
"""
This function was deprecated. Use ipaplatform.tasks.
Edits the specified nsswitch.conf database (e.g. passwd, group, sudoers)
to use the specified service(s).
Arguments:
fstore - FileStore to backup the nsswitch.conf
database - database configuration that should be ammended,
e.g. 'sudoers'
service - list of services that should be added, e.g. ['sss']
preserve - if True, the already configured services will be preserved
The next arguments modify the behaviour if preserve=True:
append - if True, the services will be appended, if False, prepended
default_value - list of services that are considered as default (if
the database is not mentioned in nsswitch.conf), e.g.
['files']
"""
warnings.warn(
"Use ipaplatform.tasks.tasks.configure_nsswitch_database",
DeprecationWarning,
stacklevel=2
)
return tasks.configure_nsswitch_database(fstore, database, services,
preserve, append, default_value)
def configure_ipa_conf(
fstore, cli_basedn, cli_realm, cli_domain, cli_server, hostname):
ipaconf = IPAChangeConf("IPA Installer")
ipaconf.setOptionAssignment(" = ")
ipaconf.setSectionNameDelimiters(("[", "]"))
opts = [
{
'name': 'comment',
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
ipaconf.emptyLine(),
]
# [global]
defopts = [
ipaconf.setOption('basedn', cli_basedn),
ipaconf.setOption('realm', cli_realm),
ipaconf.setOption('domain', cli_domain),
ipaconf.setOption('server', cli_server[0]),
ipaconf.setOption('host', hostname),
ipaconf.setOption('xmlrpc_uri',
'https://{}/ipa/xml'.format(
ipautil.format_netloc(cli_server[0]))),
ipaconf.setOption('enable_ra', 'True')
]
opts.extend([
ipaconf.setSection('global', defopts),
ipaconf.emptyLine(),
])
target_fname = paths.IPA_DEFAULT_CONF
fstore.backup_file(target_fname)
ipaconf.newConf(target_fname, opts)
# umask applies when creating a new file but we want 0o644 here
os.chmod(target_fname, 0o644)
def disable_ra():
"""Set the enable_ra option in /etc/ipa/default.conf to False
Note that api.env will retain the old value (it is readonly).
"""
parser = RawConfigParser()
parser.read(paths.IPA_DEFAULT_CONF)
parser.set('global', 'enable_ra', 'False')
fp = open(paths.IPA_DEFAULT_CONF, 'w')
parser.write(fp)
fp.close()
def configure_ldap_conf(
fstore, cli_basedn, cli_realm, cli_domain, cli_server, dnsok, options,
files):
ldapconf = IPAChangeConf("IPA Installer")
ldapconf.setOptionAssignment(" ")
opts = [
{
'name': 'comment',
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
ldapconf.emptyLine(),
ldapconf.setOption('ldap_version', '3'),
ldapconf.setOption('base', cli_basedn),
ldapconf.emptyLine(),
ldapconf.setOption(
'nss_base_passwd', '{dn}{suffix}'
.format(dn=DN(('cn', 'users'), ('cn', 'accounts'), cli_basedn),
suffix='?sub')),
ldapconf.setOption(
'nss_base_group', '{dn}{suffix}'
.format(dn=DN(('cn', 'groups'), ('cn', 'accounts'), cli_basedn),
suffix='?sub')),
ldapconf.setOption('nss_schema', 'rfc2307bis'),
ldapconf.setOption('nss_map_attribute', 'uniqueMember member'),
ldapconf.setOption('nss_initgroups_ignoreusers', 'root,dirsrv'),
ldapconf.emptyLine(),
ldapconf.setOption('nss_reconnect_maxsleeptime', '8'),
ldapconf.setOption('nss_reconnect_sleeptime', '1'),
ldapconf.setOption('bind_timelimit', '5'),
ldapconf.setOption('timelimit', '15'),
ldapconf.emptyLine(),
]
if not dnsok or options.force or options.on_master:
if options.on_master:
opts.append(ldapconf.setOption('uri', 'ldap://localhost'))
else:
opts.append(ldapconf.setOption('uri', 'ldap://{}'.format(
ipautil.format_netloc(cli_server[0]))))
else:
opts.append(ldapconf.setOption('nss_srv_domain', cli_domain))
opts.append(ldapconf.emptyLine())
# Depending on the release and distribution this may exist in any
# number of different file names, update what we find
for filename in files:
try:
fstore.backup_file(filename)
ldapconf.newConf(filename, opts)
except Exception as e:
logger.error("Creation of %s failed: %s", filename, str(e))
return (1, 'LDAP', filename)
if files:
return (0, 'LDAP', ', '.join(files))
return 0, None, None
def configure_nslcd_conf(
fstore, cli_basedn, cli_realm, cli_domain, cli_server, dnsok, options,
files):
nslcdconf = IPAChangeConf("IPA Installer")
nslcdconf.setOptionAssignment(" ")
opts = [
{
'name': 'comment',
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
nslcdconf.emptyLine(),
nslcdconf.setOption('ldap_version', '3'),
nslcdconf.setOption('base', cli_basedn),
nslcdconf.emptyLine(),
nslcdconf.setOption('base passwd', str(
DN(('cn', 'users'), ('cn', 'accounts'), cli_basedn))),
nslcdconf.setOption('base group', str(
DN(('cn', 'groups'), ('cn', 'accounts'), cli_basedn))),
nslcdconf.setOption('timelimit', '15'),
nslcdconf.emptyLine(),
]
if not dnsok or options.force or options.on_master:
if options.on_master:
opts.append(nslcdconf.setOption('uri', 'ldap://localhost'))
else:
opts.append(nslcdconf.setOption('uri', 'ldap://{}'.format(
ipautil.format_netloc(cli_server[0]))))
else:
opts.append(nslcdconf.setOption('uri', 'DNS'))
opts.append(nslcdconf.emptyLine())
for filename in files:
try:
fstore.backup_file(filename)
nslcdconf.newConf(filename, opts)
except Exception as e:
logger.error("Creation of %s failed: %s", filename, str(e))
return (1, None, None)
nslcd = services.knownservices.nslcd
if nslcd.is_installed():
try:
nslcd.restart()
except Exception as e:
log_service_error(nslcd.service_name, 'restart', e)
try:
nslcd.enable()
except Exception as e:
logger.error(
"Failed to enable automatic startup of the %s daemon: %s",
nslcd.service_name, str(e))
else:
logger.debug(
"%s daemon is not installed, skip configuration",
nslcd.service_name)
return (0, None, None)
return (0, 'NSLCD', ', '.join(files))
def configure_openldap_conf(fstore, cli_basedn, cli_server):
ldapconf = IPAChangeConf("IPA Installer")
ldapconf.setOptionAssignment((" ", "\t"))
opts = [
{
'name': 'comment',
'type': 'comment',
'value': ' File modified by ipa-client-install'
},
ldapconf.emptyLine(),
{
'name': 'comment',
'type': 'comment',
'value': ' We do not want to break your existing configuration, '
'hence:'
},
# this needs to be kept updated if we change more options
{
'name': 'comment',
'type': 'comment',
'value': ' URI, BASE, and SASL_MECH'
},
{
'name': 'comment',
'type': 'comment',
'value': ' have been added if they were not set.'
},
{
'name': 'comment',
'type': 'comment',
'value': ' In case any of them were set, a comment has been '
'inserted and'
},
{
'name': 'comment',
'type': 'comment',
'value': ' "# CONF_NAME modified by IPA" added to the line '
'above.'
},
{
'name': 'comment',
'type': 'comment',
'value': ' To use IPA server with openLDAP tools, please comment '
'out your'
},
{
'name': 'comment',
'type': 'comment',
'value': ' existing configuration for these options and '
'uncomment the'
},
{
'name': 'comment',
'type': 'comment',
'value': ' corresponding lines generated by IPA.'
},
ldapconf.emptyLine(),
ldapconf.emptyLine(),
{
'action': 'addifnotset',
'name': 'URI',
'type': 'option',
'value': 'ldaps://{}'.format(cli_server[0])
},
{
'action': 'addifnotset',
'name': 'BASE',
'type': 'option',
'value': str(cli_basedn)
},
{
'action': 'addifnotset',
'name': 'SASL_MECH',
'type': 'option',
'value': 'GSSAPI'
},
]
target_fname = paths.OPENLDAP_LDAP_CONF
fstore.backup_file(target_fname)
error_msg = "Configuring {path} failed with: {err}"
try:
ldapconf.changeConf(target_fname, opts)
except SyntaxError as e:
logger.info("Could not parse %s", target_fname)
logger.debug('%s', error_msg.format(path=target_fname, err=str(e)))
return False
except IOError as e:
logger.info("%s does not exist.", target_fname)
logger.debug('%s', error_msg.format(path=target_fname, err=str(e)))
return False
except Exception as e: # we do not want to fail in an optional step
logger.debug('%s', error_msg.format(path=target_fname, err=str(e)))
return False
os.chmod(target_fname, 0o644)
return True
def hardcode_ldap_server(cli_server):
"""
DNS Discovery didn't return a valid IPA server, hardcode a value into
the file instead.
"""
if not os.path.isfile(paths.LDAP_CONF):
return
ldapconf = IPAChangeConf("IPA Installer")
ldapconf.setOptionAssignment(" ")
opts = [
ldapconf.setOption('uri', 'ldap://{}'.format(
ipautil.format_netloc(cli_server[0]))),
ldapconf.emptyLine(),
]
# Errors raised by this should be caught by the caller
ldapconf.changeConf(paths.LDAP_CONF, opts)
logger.info(
"Changed configuration of /etc/ldap.conf to use "
"hardcoded server name: %s", cli_server[0])
# Currently this doesn't support templating, but that could be changed in the
# future. Note that this function is also called from %post.
def configure_krb5_snippet():
template = os.path.join(
paths.USR_SHARE_IPA_CLIENT_DIR,
os.path.basename(paths.KRB5_FREEIPA) + ".template"
)
shutil.copy(template, paths.KRB5_FREEIPA)
os.chmod(paths.KRB5_FREEIPA, 0o644)
tasks.restore_context(paths.KRB5_FREEIPA)
def configure_krb5_conf(
cli_realm, cli_domain, cli_server, cli_kdc, dnsok,
filename, client_domain, client_hostname, force=False,
configure_sssd=True):
# First, write a snippet to krb5.conf.d.
configure_krb5_snippet()
# Then, perform the rest of our configuration into krb5.conf itself.
krbconf = IPAChangeConf("IPA Installer")
krbconf.setOptionAssignment((" = ", " "))
krbconf.setSectionNameDelimiters(("[", "]"))
krbconf.setSubSectionDelimiters(("{", "}"))
krbconf.setIndent(("", " ", " "))
opts = [
{
'name': 'comment',
'type': 'comment',
'value': 'File modified by ipa-client-install'
},
krbconf.emptyLine(),
]
if os.path.exists(paths.COMMON_KRB5_CONF_DIR):
opts.extend([
{
'name': 'includedir',
'type': 'option',
'value': paths.COMMON_KRB5_CONF_DIR,
'delim': ' '
}
])
# [libdefaults]
libopts = [
krbconf.setOption('default_realm', cli_realm)
]
if not dnsok or not cli_kdc or force:
libopts.extend([
krbconf.setOption('dns_lookup_realm', 'false'),
])
else:
libopts.extend([
krbconf.setOption('dns_lookup_realm', 'true'),
])
libopts.extend([
krbconf.setOption('rdns', 'false'),
krbconf.setOption('dns_canonicalize_hostname', 'false'),
krbconf.setOption('dns_lookup_kdc', 'true'),
krbconf.setOption('ticket_lifetime', '24h'),
krbconf.setOption('forwardable', 'true'),
krbconf.setOption('udp_preference_limit', '0')
])
# Configure KEYRING CCACHE if supported
if kernel_keyring.is_persistent_keyring_supported():
logger.debug("Enabling persistent keyring CCACHE")
libopts.append(krbconf.setOption('default_ccache_name',
'KEYRING:persistent:%{uid}'))
opts.extend([
krbconf.setSection('libdefaults', libopts),
krbconf.emptyLine()
])
# the following are necessary only if DNS discovery does not work
kropts = []
if not dnsok or not cli_kdc or force:
# [realms]
for server in cli_server:
kropts.extend([
krbconf.setOption('kdc', ipautil.format_netloc(server, 88)),
krbconf.setOption('master_kdc',
ipautil.format_netloc(server, 88)),
krbconf.setOption('admin_server',
ipautil.format_netloc(server, 749)),
krbconf.setOption('kpasswd_server',
ipautil.format_netloc(server, 464))
])
kropts.append(krbconf.setOption('default_domain', cli_domain))
kropts.append(
krbconf.setOption('pkinit_anchors',
'FILE:%s' % paths.KDC_CA_BUNDLE_PEM))
kropts.append(
krbconf.setOption('pkinit_pool',
'FILE:%s' % paths.CA_BUNDLE_PEM))
ropts = [{
'name': cli_realm,
'type': 'subsection',
'value': kropts
}]
opts.append(krbconf.setSection('realms', ropts))
opts.append(krbconf.emptyLine())
# [domain_realm]
dropts = [
krbconf.setOption('.{}'.format(cli_domain), cli_realm),
krbconf.setOption(cli_domain, cli_realm),
krbconf.setOption(client_hostname, cli_realm)
]
# add client domain mapping if different from server domain
if cli_domain != client_domain:
dropts.extend([
krbconf.setOption('.{}'.format(client_domain), cli_realm),
krbconf.setOption(client_domain, cli_realm)
])
opts.extend([
krbconf.setSection('domain_realm', dropts),
krbconf.emptyLine()
])
logger.debug("Writing Kerberos configuration to %s:", filename)
logger.debug("%s", krbconf.dump(opts))
krbconf.newConf(filename, opts)
# umask applies when creating a new file but we want 0o644 here
os.chmod(filename, 0o644)
def configure_certmonger(
fstore, subject_base, cli_realm, hostname, options, ca_enabled):
cmonger = services.knownservices.certmonger
if not options.request_cert:
# Conditionally restart certmonger to pick up the new IPA
# configuration.
try:
cmonger.try_restart()
except Exception as e:
logger.error(
"Failed to conditionally restart the %s daemon: %s",
cmonger.service_name, str(e))
return
if not ca_enabled:
logger.warning("An RA is not configured on the server. "
"Not requesting host certificate.")
return
principal = 'host/%s@%s' % (hostname, cli_realm)
if options.hostname:
# If the hostname is explicitly set then we need to tell certmonger
# which principal name to use when requesting certs.
certmonger.add_principal_to_cas(principal)
try:
cmonger.enable()
cmonger.start()
except Exception as e:
logger.error(
"Failed to configure automatic startup of the %s daemon: %s",
cmonger.service_name, str(e))
logger.warning(
"Automatic certificate management will not be available")
# Request our host cert
subject = str(DN(('CN', hostname), subject_base))
passwd_fname = os.path.join(paths.IPA_NSSDB_DIR, 'pwdfile.txt')
try:
certmonger.request_and_wait_for_cert(
certpath=paths.IPA_NSSDB_DIR,
storage='NSSDB',
nickname='Local IPA host',
subject=subject,
dns=[hostname],
principal=principal,
passwd_fname=passwd_fname,
resubmit_timeout=120,
)
except Exception as e:
logger.exception("certmonger request failed")
raise ScriptError(
"{} request for host certificate failed: {}".format(
cmonger.service_name, e
),
rval=CLIENT_INSTALL_ERROR
)
def configure_sssd_conf(
fstore, cli_realm, cli_domain, cli_server, options,
client_domain, client_hostname):
try:
sssdconfig = SSSDConfig.SSSDConfig()
sssdconfig.import_config()
except Exception as e:
if os.path.exists(paths.SSSD_CONF) and options.preserve_sssd:
# SSSD config is in place but we are unable to read it
# In addition, we are instructed to preserve it
# This all means we can't use it and have to bail out
logger.error(
"SSSD config exists but cannot be parsed: %s", str(e))
logger.error(
"Was instructed to preserve existing SSSD config")
logger.info(
"Correct errors in /etc/sssd/sssd.conf and re-run "
"installation")
return 1
# SSSD configuration does not exist or we are not asked to preserve it,
# create new one
# We do make new SSSDConfig instance because IPAChangeConf-derived
# classes have no means to reset their state and ParseError exception
# could come due to parsing error from older version which cannot be
# upgraded anymore, leaving sssdconfig instance practically unusable
# Note that we already backed up sssd.conf before going into this
# routine
if isinstance(e, IOError):
pass
else:
# It was not IOError so it must have been parsing error
logger.error(
"Unable to parse existing SSSD config. "
"As option --preserve-sssd was not specified, new config "
"will override the old one.")
logger.info(
"The old /etc/sssd/sssd.conf is backed up and "
"will be restored during uninstall.")
logger.debug("New SSSD config will be created")
sssdconfig = SSSDConfig.SSSDConfig()
sssdconfig.new_config()
try:
domain = sssdconfig.new_domain(cli_domain)
except SSSDConfig.DomainAlreadyExistsError:
logger.info(
"Domain %s is already configured in existing SSSD "
"config, creating a new one.",
cli_domain)
logger.info(
"The old /etc/sssd/sssd.conf is backed up and will be restored "
"during uninstall.")
sssdconfig = SSSDConfig.SSSDConfig()
sssdconfig.new_config()
domain = sssdconfig.new_domain(cli_domain)
if options.on_master:
sssd_enable_ifp(sssdconfig)
if (
(options.conf_ssh and os.path.isfile(paths.SSH_CONFIG)) or
(options.conf_sshd and os.path.isfile(paths.SSHD_CONFIG))
):
try:
sssdconfig.new_service('ssh')
except SSSDConfig.ServiceAlreadyExists:
pass
except SSSDConfig.ServiceNotRecognizedError:
logger.error(
"Unable to activate the SSH service in SSSD config.")
logger.info(
"Please make sure you have SSSD built with SSH support "
"installed.")
logger.info(
"Configure SSH support manually in /etc/sssd/sssd.conf.")
sssdconfig.activate_service('ssh')
if options.conf_sudo:
# Activate the service in the SSSD config
try:
sssdconfig.new_service('sudo')
except SSSDConfig.ServiceAlreadyExists:
pass
except SSSDConfig.ServiceNotRecognizedError:
logger.error(
"Unable to activate the SUDO service in SSSD config.")
sssdconfig.activate_service('sudo')
tasks.enable_sssd_sudo(fstore)
domain.add_provider('ipa', 'id')
# add discovery domain if client domain different from server domain
# do not set this config in server mode (#3947)
if not options.on_master and cli_domain != client_domain:
domain.set_option('dns_discovery_domain', cli_domain)
if not options.on_master:
if options.primary:
domain.set_option('ipa_server', ', '.join(cli_server))
else:
domain.set_option(
'ipa_server', '_srv_, %s' % ', '.join(cli_server))
else:
domain.set_option('ipa_server_mode', 'True')
# the master should only use itself for Kerberos
domain.set_option('ipa_server', cli_server[0])
# increase memcache timeout to 10 minutes when in server mode
try:
nss_service = sssdconfig.get_service('nss')
except SSSDConfig.NoServiceError:
nss_service = sssdconfig.new_service('nss')
nss_service.set_option('memcache_timeout', 600)
sssdconfig.save_service(nss_service)
sssd_enable_service(sssdconfig, 'nss')
sssd_enable_service(sssdconfig, 'pam')
if options.conf_ssh:
sssd_enable_service(sssdconfig, 'ssh')
domain.set_option('ipa_domain', cli_domain)
domain.set_option('ipa_hostname', client_hostname)
if cli_domain.lower() != cli_realm.lower():
domain.set_option('krb5_realm', cli_realm)
# Might need this if /bin/hostname doesn't return a FQDN
# domain.set_option('ipa_hostname', 'client.example.com')
domain.add_provider('ipa', 'auth')
domain.add_provider('ipa', 'chpass')
if not options.permit:
domain.add_provider('ipa', 'access')
else:
domain.add_provider('permit', 'access')
domain.set_option('cache_credentials', True)
# SSSD will need TLS for checking if ipaMigrationEnabled attribute is set
# Note that SSSD will force StartTLS because the channel is later used for
# authentication as well if password migration is enabled. Thus set
# the option unconditionally.
domain.set_option('ldap_tls_cacert', paths.IPA_CA_CRT)
if options.dns_updates:
domain.set_option('dyndns_update', True)
if options.all_ip_addresses:
domain.set_option('dyndns_iface', '*')
else:
iface = get_server_connection_interface(cli_server[0])
domain.set_option('dyndns_iface', iface)
if options.krb5_offline_passwords:
domain.set_option('krb5_store_password_if_offline', True)
domain.set_active(True)
sssdconfig.save_domain(domain)
sssdconfig.write(paths.SSSD_CONF)
return 0
def sssd_enable_service(sssdconfig, name):
try:
sssdconfig.new_service(name)
except SSSDConfig.ServiceAlreadyExists:
pass
except SSSDConfig.ServiceNotRecognizedError:
logger.error(
"Unable to activate the '%s' service in SSSD config.", name)
logger.info(
"Please make sure you have SSSD built with %s support "
"installed.", name)
logger.info(
"Configure %s support manually in /etc/sssd/sssd.conf.", name)
return None
sssdconfig.activate_service(name)
return sssdconfig.get_service(name)
def sssd_enable_ifp(sssdconfig, allow_httpd=False):
"""Enable and configure libsss_simpleifp plugin
Allow the ``ipaapi`` user to access IFP. In case allow_httpd is true,
the Apache HTTPd user is also allowed to access IFP. For smart card
authentication, mod_lookup_identity must be allowed to access user
information.
"""
service = sssd_enable_service(sssdconfig, 'ifp')
if service is None:
# unrecognized service
return
try:
uids = service.get_option('allowed_uids')
except SSSDConfig.NoOptionError:
uids = set()
else:
uids = {s.strip() for s in uids.split(',') if s.strip()}
# SSSD supports numeric and string UIDs
# ensure that root is allowed to access IFP, might be 0 or root
if uids.isdisjoint({'0', 'root'}):
uids.add('root')
# allow IPA API to access IFP
uids.add(IPAAPI_USER)
if allow_httpd:
uids.add(constants.HTTPD_USER)
service.set_option('allowed_uids', ', '.join(sorted(uids)))
sssdconfig.save_service(service)
def change_ssh_config(filename, changes, sections):
if not changes:
return True
try:
f = open(filename, 'r')
except IOError as e:
logger.error("Failed to open '%s': %s", filename, str(e))
return False
change_keys = tuple(key.lower() for key in changes)
section_keys = tuple(key.lower() for key in sections)
lines = []
in_section = False
for line in f:
line = line.rstrip('\n')
pline = line.strip()
if not pline or pline.startswith('#'):
lines.append(line)
continue
option = pline.split()[0].lower()
if option in section_keys:
in_section = True
break
if option in change_keys:
line = '#' + line
lines.append(line)
for option, value in changes.items():
if value is not None:
lines.append('%s %s' % (option, value))
if in_section:
lines.append('')
lines.append(line)
for line in f:
line = line.rstrip('\n')
lines.append(line)
lines.append('')
f.close()
try:
f = open(filename, 'w')
except IOError as e:
logger.error("Failed to open '%s': %s", filename, str(e))
return False
f.write('\n'.join(lines))
f.close()
return True
def configure_ssh_config(fstore, options):
if not os.path.isfile(paths.SSH_CONFIG):
logger.info("%s not found, skipping configuration", paths.SSH_CONFIG)
return
fstore.backup_file(paths.SSH_CONFIG)
def ssh_version_supports_include():
with open(paths.SSH_CONFIG, 'r') as f:
for line in f:
if re.match(r"^Include\s", line):
return True
return False
if ssh_version_supports_include():
create_ssh_ipa_config(options)
else:
modify_ssh_config(options)
logger.info('Configured %s', paths.SSH_CONFIG)
def modify_ssh_config(options):
changes = {'PubkeyAuthentication': 'yes'}
# sss_ssh_knownhostsproxy is deprecated in favor of sss_ssh_knownhosts
# use sss_ssh_knownhosts when possible
enableknownhosts = bool(
options.sssd and os.path.isfile(paths.SSS_SSH_KNOWNHOSTS)
)
enableproxy = bool(
options.sssd and os.path.isfile(paths.SSS_SSH_KNOWNHOSTSPROXY)
and not enableknownhosts
)
if options.sssd and enableknownhosts:
changes[
'KnownHostsCommand'] = '%s %%H' % paths.SSS_SSH_KNOWNHOSTS
if options.sssd and enableproxy:
changes[
'ProxyCommand'] = '%s -p %%p %%h' % paths.SSS_SSH_KNOWNHOSTSPROXY
changes['GlobalKnownHostsFile'] = paths.SSSD_PUBCONF_KNOWN_HOSTS
if options.trust_sshfp:
changes['VerifyHostKeyDNS'] = 'yes'
change_ssh_config(paths.SSH_CONFIG, changes, ['Host', 'Match'])
def create_ssh_ipa_config(options):
"""Add the IPA snippet for ssh"""
# sss_ssh_knownhostsproxy is deprecated in favor of sss_ssh_knownhosts
# use sss_ssh_knownhosts when possible
enableknownhosts = bool(
options.sssd and os.path.isfile(paths.SSS_SSH_KNOWNHOSTS)
)
enableproxy = bool(
options.sssd and os.path.isfile(paths.SSS_SSH_KNOWNHOSTSPROXY)
and not enableknownhosts
)
ipautil.copy_template_file(
os.path.join(paths.SSH_IPA_CONFIG_TEMPLATE),
paths.SSH_IPA_CONFIG,
dict(
ENABLEKNOWNHOSTS='' if enableknownhosts else '#',
KNOWNHOSTSCOMMAND=paths.SSS_SSH_KNOWNHOSTS,
ENABLEPROXY='' if enableproxy else '#',
KNOWNHOSTSPROXY=paths.SSS_SSH_KNOWNHOSTSPROXY,
KNOWNHOSTS=paths.SSSD_PUBCONF_KNOWN_HOSTS,
VERIFYHOSTKEYDNS='' if options.trust_sshfp else '#'
)
)
os.chmod(paths.SSH_IPA_CONFIG, 0o644)
def configure_sshd_config(fstore, options):
sshd = services.knownservices.sshd
if not os.path.isfile(paths.SSHD_CONFIG):
logger.info("%s not found, skipping configuration", paths.SSHD_CONFIG)
return
fstore.backup_file(paths.SSHD_CONFIG)
# If openssh-server >= 8.2, the config needs to go in a new snippet
# in /etc/ssh/sshd_config.d/04-ipa.conf
# instead of /etc/ssh/sshd_config file
def sshd_version_supports_include():
with open(paths.SSHD_CONFIG, 'r') as f:
for line in f:
if re.match(r"^Include\s", line):
return True
return False
if sshd_version_supports_include():
create_sshd_ipa_config(options)
else:
modify_sshd_config(options)
if sshd.is_running():
try:
sshd.restart()
except Exception as e:
log_service_error(sshd.service_name, 'restart', e)
def modify_sshd_config(options):
changes = {
'PubkeyAuthentication': 'yes',
'KerberosAuthentication': 'no',
'GSSAPIAuthentication': 'yes',
'UsePAM': 'yes',
'ChallengeResponseAuthentication': 'yes',
}
if options.sssd and os.path.isfile(paths.SSS_SSH_AUTHORIZEDKEYS):
authorized_keys_changes = None
candidates = (
{
'AuthorizedKeysCommand': paths.SSS_SSH_AUTHORIZEDKEYS,
'AuthorizedKeysCommandUser': 'nobody',
},
{
'AuthorizedKeysCommand': paths.SSS_SSH_AUTHORIZEDKEYS,
'AuthorizedKeysCommandRunAs': 'nobody',
},
{
'PubKeyAgent': '%s %%u' % paths.SSS_SSH_AUTHORIZEDKEYS,
'PubKeyAgentRunAs': 'nobody',
},
)
for candidate in candidates:
args = [paths.SSHD, '-t', '-f', os.devnull]
for item in candidate.items():
args.append('-o')
args.append('%s=%s' % item)
result = ipautil.run(args, raiseonerr=False)
if result.returncode == 0:
authorized_keys_changes = candidate
break
if authorized_keys_changes is not None:
changes.update(authorized_keys_changes)
else:
logger.warning(
"Installed OpenSSH server does not support dynamically "
"loading authorized user keys. Public key authentication of "
"IPA users will not be available.")
change_ssh_config(paths.SSHD_CONFIG, changes, ['Match'])
logger.info('Configured %s', paths.SSHD_CONFIG)
def create_sshd_ipa_config(options):
"""Add the IPA snippet for sshd"""
sssd_sshd_options = ""
if options.sssd and os.path.isfile(paths.SSS_SSH_AUTHORIZEDKEYS):
sssd_sshd_options = textwrap.dedent("""\
AuthorizedKeysCommand {}
AuthorizedKeysCommandUser nobody
""").format(paths.SSS_SSH_AUTHORIZEDKEYS)
ipautil.copy_template_file(
os.path.join(paths.SSHD_IPA_CONFIG_TEMPLATE),
paths.SSHD_IPA_CONFIG,
dict(
SSSD_SSHD_OPTIONS=sssd_sshd_options,
)
)
logger.info('Configured %s', paths.SSHD_IPA_CONFIG)
def configure_automount(options, statestore):
logger.info('\nConfiguring automount:')
args = [
paths.IPA_CLIENT_AUTOMOUNT, '--debug', '-U', '--location',
options.location
]
if options.server:
args.extend(['--server', options.server[0]])
if not options.sssd:
args.append('--no-sssd')
statestore.backup_state('installation', 'automount', True)
try:
result = run(args)
except Exception as e:
logger.error('Automount configuration failed: %s', str(e))
else:
logger.info('%s', result.output_log)
finally:
statestore.delete_state('installation', 'automount')
def configure_nisdomain(options, domain, statestore):
domain = options.nisdomain or domain
logger.info('Configuring %s as NIS domain.', domain)
nis_domain_name = ''
# First backup the old NIS domain name
if os.path.exists(paths.BIN_NISDOMAINNAME):
try:
result = ipautil.run(
[paths.BIN_NISDOMAINNAME],
capture_output=True)
except CalledProcessError:
pass
else:
nis_domain_name = result.output
statestore.backup_state('network', 'nisdomain', nis_domain_name)
# Backup the state of the domainname service
statestore.backup_state(
"domainname", "enabled",
services.knownservices.domainname.is_enabled())
# Set the new NIS domain name
tasks.set_nisdomain(domain)
# Enable and start the domainname service
services.knownservices.domainname.enable()
# Restart rather than start so that new NIS domain name is loaded
# if the service is already running
services.knownservices.domainname.restart()
def unconfigure_nisdomain(statestore):
# Set the nisdomain permanent and current nisdomain configuration as it was
if statestore.has_state('network'):
old_nisdomain = statestore.restore_state('network', 'nisdomain') or ''
if old_nisdomain:
logger.info('Restoring %s as NIS domain.', old_nisdomain)
else:
logger.info('Unconfiguring the NIS domain.')
tasks.set_nisdomain(old_nisdomain)
# Restore the configuration of the domainname service
enabled = statestore.restore_state('domainname', 'enabled')
if not enabled:
services.knownservices.domainname.disable()
def get_iface_from_ip(ip_addr):
for adapter in ifaddr.get_adapters():
for ips in adapter.ips:
# IPv6 is reported as a tuple, IPv4 is reported as str
if ip_addr in (ips.ip[0], ips.ip):
return adapter.name
raise RuntimeError("IP %s not assigned to any interface." % ip_addr)
def __get_ifaddr_adapters(iface=None):
if iface:
interfaces = set(iface if isinstance(iface, (list, tuple)) else [iface])
else:
interfaces = set(adapter.name for adapter in ifaddr.get_adapters())
return [
adapter
for adapter in ifaddr.get_adapters()
if adapter.name in interfaces or adapter.nice_name in interfaces
]
def get_local_ipaddresses(iface=None):
ips = []
for adapter in __get_ifaddr_adapters(iface):
for ifip in adapter.ips:
try:
ip_addr = ifip.ip[0] if isinstance(ifip.ip, tuple) else ifip.ip
ips.append(ipautil.CheckedIPAddress(ip_addr))
logger.debug('IP check successful: %s', ip_addr)
except ValueError as e:
logger.debug('IP check failed: %s', e)
return ips
def do_nsupdate(update_txt):
logger.debug("Writing nsupdate commands to %s:", UPDATE_FILE)
logger.debug("%s", update_txt)
with open(UPDATE_FILE, "w") as f:
f.write(update_txt)
result = False
try:
ipautil.run([paths.NSUPDATE, '-g', UPDATE_FILE])
result = True
except CalledProcessError as e:
logger.debug('nsupdate (GSS-TSIG) failed: %s', str(e))
try:
ipautil.run([paths.NSUPDATE, UPDATE_FILE])
try:
sssdconfig = SSSDConfig.SSSDConfig()
sssdconfig.import_config()
domains = sssdconfig.list_active_domains()
for name in domains:
domain = sssdconfig.get_domain(name)
try:
provider = domain.get_option('id_provider')
except SSSDConfig.NoOptionError:
continue
if name == api.env.domain and provider == "ipa":
try:
if domain.get_option('dyndns_update') is True:
domain.set_option('dyndns_auth', 'none')
sssdconfig.save_domain(domain)
sssdconfig.write(paths.SSSD_CONF)
break
except SSSDConfig.NoOptionError:
break
except Exception as e:
logger.debug('Unable to update SSSD configuration: %s', str(e))
logger.info(
'Failed to configure SSSD for unauthenticated DNS '
'dynamic updates. SSSD might be unable to update DNS '
'entries for this host.'
)
result = True
except CalledProcessError as e:
logger.debug('Unauthenticated nsupdate failed: %s', str(e))
try:
os.remove(UPDATE_FILE)
except Exception:
pass
return result
DELETE_TEMPLATE_A = """
update delete $HOSTNAME. IN A
show
send
"""
DELETE_TEMPLATE_AAAA = """
update delete $HOSTNAME. IN AAAA
show
send
"""
ADD_TEMPLATE_A = """
update add $HOSTNAME. $TTL IN A $IPADDRESS
show
send
"""
ADD_TEMPLATE_AAAA = """
update add $HOSTNAME. $TTL IN AAAA $IPADDRESS
show
send
"""
UPDATE_FILE = paths.IPA_DNS_UPDATE_TXT
CCACHE_FILE = paths.IPA_DNS_CCACHE
def update_dns(server, hostname, options):
try:
ips = get_local_ipaddresses()
except CalledProcessError as e:
logger.error("Cannot update DNS records. %s", e)
ips = None
if options.all_ip_addresses:
if ips is None:
raise RuntimeError("Unable to get local IP addresses.")
update_ips = ips
elif options.ip_addresses:
update_ips = []
for ip in options.ip_addresses:
update_ips.append(ipautil.CheckedIPAddress(ip))
else:
try:
iface = get_server_connection_interface(server)
except RuntimeError as e:
logger.error("Cannot update DNS records. %s", e)
return
try:
update_ips = get_local_ipaddresses(iface)
except CalledProcessError as e:
logger.error("Cannot update DNS records. %s", e)
return
if not update_ips:
logger.info("Failed to determine this machine's ip address(es).")
return
no_matching_interface_for_ip_address_warning(update_ips)
update_txt = "debug\n"
update_txt += ipautil.template_str(DELETE_TEMPLATE_A,
dict(HOSTNAME=hostname))
update_txt += ipautil.template_str(DELETE_TEMPLATE_AAAA,
dict(HOSTNAME=hostname))
for ip in update_ips:
sub_dict = dict(HOSTNAME=hostname, IPADDRESS=ip, TTL=1200)
if ip.version == 4:
template = ADD_TEMPLATE_A
elif ip.version == 6:
template = ADD_TEMPLATE_AAAA
update_txt += ipautil.template_str(template, sub_dict)
if not do_nsupdate(update_txt):
logger.error("Failed to update DNS records.")
verify_dns_update(hostname, update_ips)
def verify_dns_update(fqdn, ips):
"""
Verify that the fqdn resolves to all IP addresses and
that there's matching PTR record for every IP address.
"""
# verify A/AAAA records
missing_ips = [str(ip) for ip in ips]
extra_ips = []
for record_type in [dns.rdatatype.A, dns.rdatatype.AAAA]:
logger.debug('DNS resolver: Query: %s IN %s',
fqdn, dns.rdatatype.to_text(record_type))
try:
answers = dnsutil.resolve(fqdn, record_type)
except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN):
logger.debug('DNS resolver: No record.')
except dns.resolver.NoNameservers:
logger.debug('DNS resolver: No nameservers answered the query.')
except dns.exception.DNSException:
logger.debug('DNS resolver error.')
else:
for rdata in answers:
try:
missing_ips.remove(rdata.address)
except ValueError:
extra_ips.append(rdata.address)
# verify PTR records
fqdn_name = dns.name.from_text(fqdn)
wrong_reverse = {}
missing_reverse = [str(ip) for ip in ips]
for ip in ips:
ip_str = str(ip)
logger.debug('DNS resolver: Query: %s IN PTR', ip_str)
try:
answers = dnsutil.resolve_address(ip_str)
except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN):
logger.debug('DNS resolver: No record.')
except dns.resolver.NoNameservers:
logger.debug('DNS resolver: No nameservers answered thequery.')
except dns.exception.DNSException:
logger.debug('DNS resolver error.')
else:
missing_reverse.remove(ip_str)
for rdata in answers:
if not rdata.target == fqdn_name:
wrong_reverse.setdefault(ip_str, []).append(rdata.target)
if missing_ips:
logger.warning('Missing A/AAAA record(s) for host %s: %s.',
fqdn, ', '.join(missing_ips))
if extra_ips:
logger.warning('Extra A/AAAA record(s) for host %s: %s.',
fqdn, ', '.join(extra_ips))
if missing_reverse:
logger.warning('Missing reverse record(s) for address(es): %s.',
', '.join(missing_reverse))
if wrong_reverse:
logger.warning('Incorrect reverse record(s):')
for ip, targets in wrong_reverse.items():
for target in targets:
logger.warning('%s is pointing to %s instead of %s',
ip, target, fqdn_name)
def get_server_connection_interface(server):
"""Connect to IPA server, get all ip addresses of interface used to connect
"""
last_error = None
for res in socket.getaddrinfo(
server, 389, socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, _canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
except socket.error as e:
last_error = e
continue
try:
s.connect(sa)
sockname = s.getsockname()
ip = sockname[0]
except socket.error as e:
last_error = e
continue
finally:
if s:
s.close()
try:
return get_iface_from_ip(ip)
except (CalledProcessError, RuntimeError) as e:
last_error = e
msg = "Cannot get server connection interface"
if last_error:
msg += ": %s" % last_error
raise RuntimeError(msg)
def client_dns(server, hostname, options):
try:
verify_host_resolvable(hostname)
dns_ok = True
except errors.DNSNotARecordError:
logger.warning("Hostname (%s) does not have A/AAAA record.",
hostname)
dns_ok = False
except errors.DNSResolverError as ex:
logger.warning("DNS resolution for hostname %s failed: %s",
hostname, ex)
dns_ok = False
if (
options.dns_updates or options.all_ip_addresses or
options.ip_addresses or not dns_ok
):
update_dns(server, hostname, options)
def check_ip_addresses(options):
if options.ip_addresses:
for ip in options.ip_addresses:
try:
ipautil.CheckedIPAddress(ip)
except ValueError as e:
logger.error('%s', e)
return False
return True
def update_ssh_keys(hostname, ssh_dir, create_sshfp):
if not os.path.isdir(ssh_dir):
return
pubkeys = []
for basename in os.listdir(ssh_dir):
if not basename.endswith('.pub'):
continue
filename = os.path.join(ssh_dir, basename)
try:
f = open(filename, 'r')
except IOError as e:
logger.warning("Failed to open '%s': %s", filename, str(e))
continue
for line in f:
line = line.strip()
if not line or line.startswith('#'):
continue
try:
pubkey = SSHPublicKey(line)
except (ValueError, UnicodeDecodeError) as e:
logger.debug("Decoding line '%s' failed: %s", line, e)
continue
logger.info("Adding SSH public key from %s", filename)
pubkeys.append(pubkey)
f.close()
try:
# Use the RPC directly so older servers are supported
api.Backend.rpcclient.forward(
'host_mod',
ipautil.fsdecode(hostname),
ipasshpubkey=[pk.openssh() for pk in pubkeys],
updatedns=False,
version=u'2.26', # this version adds support for SSH public keys
)
except errors.EmptyModlist:
pass
except Exception as e:
logger.info("host_mod: %s", str(e))
logger.warning("Failed to upload host SSH public keys.")
return
if create_sshfp:
ttl = 1200
update_txt = 'debug\n'
update_txt += 'update delete %s. IN SSHFP\nshow\nsend\n' % hostname
for pubkey in pubkeys:
sshfp = pubkey.fingerprint_dns_sha1()
if sshfp is not None:
update_txt += 'update add %s. %s IN SSHFP %s\n' % (
hostname, ttl, sshfp)
sshfp = pubkey.fingerprint_dns_sha256()
if sshfp is not None:
update_txt += 'update add %s. %s IN SSHFP %s\n' % (
hostname, ttl, sshfp)
update_txt += 'show\nsend\n'
if not do_nsupdate(update_txt):
logger.warning("Could not update DNS SSHFP records.")
def print_port_conf_info():
logger.info(
"Please make sure the following ports are opened "
"in the firewall settings:\n"
" TCP: 80, 88, 389\n"
" UDP: 88 (at least one of TCP/UDP ports 88 has to be open)\n"
"Also note that following ports are necessary for ipa-client "
"working properly after enrollment:\n"
" TCP: 464\n"
" UDP: 464, 123 (if NTP enabled)")
def cert_summary(msg, certs, indent=' '):
if msg:
s = '%s\n' % msg
else:
s = ''
for cert in certs:
s += '%sSubject: %s\n' % (indent, DN(cert.subject))
s += '%sIssuer: %s\n' % (indent, DN(cert.issuer))
s += '%sValid From: %s\n' % (indent, cert.not_valid_before_utc)
s += '%sValid Until: %s\n' % (indent, cert.not_valid_after_utc)
s += '\n'
s = s[:-1]
return s
def get_certs_from_ldap(server, base_dn, realm, ca_enabled):
conn = ipaldap.LDAPClient.from_hostname_plain(server)
try:
conn.gssapi_bind()
certs = certstore.get_ca_certs(conn, base_dn, realm, ca_enabled)
except errors.NotFound:
raise errors.NoCertificateError(entry=server)
except errors.NetworkError as e:
raise errors.NetworkError(uri=conn.ldap_uri, error=str(e))
except Exception as e:
raise errors.LDAPError(str(e))
finally:
conn.unbind()
return certs
def get_ca_certs_from_file(url):
"""
Get the CA cert from a user supplied file and write it into the
paths.IPA_CA_CRT file.
Raises errors.NoCertificateError if unable to read cert.
Raises errors.FileError if unable to write cert.
"""
try:
parsed = urlparse(url, 'file')
except Exception:
raise errors.FileError(reason="unable to parse file url '%s'" % url)
if parsed.scheme != 'file':
raise errors.FileError(reason="url is not a file scheme '%s'" % url)
filename = parsed.path
if not os.path.exists(filename):
raise errors.FileError(reason="file '%s' does not exist" % filename)
if not os.path.isfile(filename):
raise errors.FileError(reason="file '%s' is not a file" % filename)
logger.debug("trying to retrieve CA cert from file %s", filename)
try:
certs = x509.load_certificate_list_from_file(filename)
except Exception:
raise errors.NoCertificateError(entry=filename)
return certs
def get_ca_certs_from_http(url, warn=True):
"""
Use HTTP to retrieve the CA cert and write it into the paths.IPA_CA_CRT
file. This is insecure and should be avoided.
Raises errors.NoCertificateError if unable to retrieve and write cert.
"""
if warn:
logger.warning("Downloading the CA certificate via HTTP, "
"this is INSECURE")
logger.debug("trying to retrieve CA cert via HTTP from %s", url)
try:
result = run([paths.BIN_CURL, "-o", "-", url], capture_output=True)
except CalledProcessError:
raise errors.NoCertificateError(entry=url)
stdout = result.raw_output
try:
certs = x509.load_certificate_list(stdout)
except Exception:
raise errors.NoCertificateError(entry=url)
return certs
def get_ca_certs_from_ldap(server, basedn, realm):
"""
Retrieve th CA cert from the LDAP server by binding to the
server with GSSAPI using the current Kerberos credentials.
Write the retrieved cert into the paths.IPA_CA_CRT file.
Raises errors.NoCertificateError if cert is not found.
Raises errors.NetworkError if LDAP connection can't be established.
Raises errors.LDAPError for any other generic LDAP error.
Raises errors.OnlyOneValueAllowed if more than one cert is found.
Raises errors.FileError if unable to write cert.
"""
logger.debug("trying to retrieve CA cert via LDAP from %s", server)
try:
certs = get_certs_from_ldap(server, basedn, realm, False)
except Exception as e:
logger.debug("get_ca_certs_from_ldap() error: %s", e)
raise
certs = [c[0] for c in certs if c[2] is not False]
return certs
def validate_new_ca_certs(existing_ca_certs, new_ca_certs, ask,
override=False):
if existing_ca_certs is None:
logger.info(
"%s",
cert_summary("Successfully retrieved CA cert", new_ca_certs))
return
existing_ca_certs = set(existing_ca_certs)
new_ca_certs = set(new_ca_certs)
if existing_ca_certs > new_ca_certs:
logger.warning(
"The CA cert available from the IPA server does not match the\n"
"local certificate available at %s", paths.IPA_CA_CRT)
logger.warning(
"%s",
cert_summary("Existing CA cert:", existing_ca_certs))
logger.warning(
"%s",
cert_summary("Retrieved CA cert:", new_ca_certs))
if override:
logger.warning("Overriding existing CA cert\n")
elif not ask or not user_input(
"Do you want to replace the local certificate with the CA\n"
"certificate retrieved from the IPA server?", True):
raise errors.CertificateInvalidError(name='Retrieved CA')
else:
logger.debug(
"Existing CA cert and Retrieved CA cert are identical")
def get_ca_certs(fstore, options, server, basedn, realm):
"""
Examine the different options and determine a method for obtaining
the CA cert.
If successful the CA cert will have been written into paths.IPA_CA_CRT.
Raises errors.NoCertificateError if not successful.
The logic for determining how to load the CA cert is as follow:
In the OTP case (not -p and -w):
1. load from user supplied cert file
2. else load from HTTP
In the 'user_auth' case ((-p and -w) or interactive):
1. load from user supplied cert file
2. load from LDAP using SASL/GSS/Krb5 auth
(provides mutual authentication, integrity and security)
3. if LDAP failed and interactive ask for permission to
use insecure HTTP (default: No)
In the unattended case:
1. load from user supplied cert file
2. load from HTTP if --force specified else fail
In all cases if HTTP is used emit warning message
"""
ca_file = paths.IPA_CA_CRT + ".new"
def ldap_url():
return urlunparse(('ldap', ipautil.format_netloc(server),
'', '', '', ''))
def file_url():
return urlunparse(('file', '', options.ca_cert_file,
'', '', ''))
def http_url():
return urlunparse(('http', ipautil.format_netloc(server),
'/ipa/config/ca.crt', '', '', ''))
interactive = not options.unattended
otp_auth = options.principal is None and options.password is not None
existing_ca_certs = None
ca_certs = None
if options.ca_cert_file:
url = file_url()
try:
ca_certs = get_ca_certs_from_file(url)
except errors.FileError as e:
logger.debug("%s", e)
raise
except Exception as e:
logger.debug("%s", e)
raise errors.NoCertificateError(entry=url)
logger.debug("CA cert provided by user, use it!")
else:
if os.path.exists(paths.IPA_CA_CRT):
if os.path.isfile(paths.IPA_CA_CRT):
try:
existing_ca_certs = x509.load_certificate_list_from_file(
paths.IPA_CA_CRT)
except Exception as e:
raise errors.FileError(
reason=u"Unable to load existing CA cert '%s': %s" %
(paths.IPA_CA_CRT, e))
else:
raise errors.FileError(
reason=(
f"Existing ca cert '{paths.IPA_CA_CRT}' is not a plain "
"file"
),
)
if otp_auth:
if existing_ca_certs:
logger.info("OTP case, CA cert preexisted, use it")
else:
url = http_url()
override = not interactive
if interactive and not user_input(
"Do you want to download the CA cert from " + url + " ?\n"
"(this is INSECURE)", False
):
raise errors.NoCertificateError(
message=u"HTTP certificate download declined by user")
try:
ca_certs = get_ca_certs_from_http(url, override)
except Exception as e:
logger.debug("%s", e)
raise errors.NoCertificateError(entry=url)
validate_new_ca_certs(existing_ca_certs, ca_certs, False,
override)
else:
# Auth with user credentials
url = ldap_url()
try:
ca_certs = get_ca_certs_from_ldap(server, basedn, realm)
validate_new_ca_certs(existing_ca_certs, ca_certs, interactive)
except errors.FileError as e:
logger.debug("%s", e)
raise
except (errors.NoCertificateError, errors.LDAPError) as e:
logger.debug("%s", str(e))
url = http_url()
if existing_ca_certs:
logger.warning(
"Unable to download CA cert from LDAP\n"
"but found preexisting cert, using it.\n")
elif interactive and not user_input(
"Unable to download CA cert from LDAP.\n"
"Do you want to download the CA cert from " + url + "?\n"
"(this is INSECURE)", False
):
raise errors.NoCertificateError(
message=u"HTTP "
"certificate download declined by user")
elif not interactive and not options.force:
logger.error(
"In unattended mode without a One Time Password "
"(OTP) or without --ca-cert-file\nYou must specify"
" --force to retrieve the CA cert using HTTP")
raise errors.NoCertificateError(
message=u"HTTP "
"certificate download requires --force")
else:
try:
ca_certs = get_ca_certs_from_http(url)
except Exception as e:
logger.debug("%s", e)
raise errors.NoCertificateError(entry=url)
validate_new_ca_certs(existing_ca_certs, ca_certs,
interactive)
except Exception as e:
logger.debug("%s", str(e))
raise errors.NoCertificateError(entry=url)
if ca_certs is None and existing_ca_certs is None:
raise errors.InternalError(u"expected CA cert file '%s' to "
u"exist, but it's absent" % ca_file)
if ca_certs is not None:
try:
x509.write_certificate_list(ca_certs, ca_file, mode=0o644)
except Exception as e:
if os.path.exists(ca_file):
try:
os.unlink(ca_file)
except OSError as e2:
logger.error(
"Failed to remove '%s': %s", ca_file, e2)
raise errors.FileError(
reason=u"cannot write certificate file '%s': %s" % (
ca_file, e)
)
os.rename(ca_file, paths.IPA_CA_CRT)
# Make sure the file permissions are correct
try:
os.chmod(paths.IPA_CA_CRT, 0o644)
except Exception as e:
raise errors.FileError(reason=u"Unable set permissions on ca "
u"cert '%s': %s" % (paths.IPA_CA_CRT, e))
# IMPORTANT: First line of FF config file is ignored
FIREFOX_CONFIG_TEMPLATE = """
/* Kerberos SSO configuration */
pref("network.negotiate-auth.trusted-uris", ".$DOMAIN");
/* These are the defaults */
pref("network.negotiate-auth.gsslib", "");
pref("network.negotiate-auth.using-native-gsslib", true);
pref("network.negotiate-auth.allow-proxies", true);
"""
FIREFOX_PREFERENCES_FILENAME = "all-ipa.js"
FIREFOX_PREFERENCES_REL_PATH = "browser/defaults/preferences"
def configure_firefox(options, statestore, domain):
try:
logger.debug("Setting up Firefox configuration.")
preferences_dir = None
# Check user specified location of firefox install directory
if options.firefox_dir is not None:
pref_path = os.path.join(options.firefox_dir,
FIREFOX_PREFERENCES_REL_PATH)
if os.path.isdir(pref_path):
preferences_dir = pref_path
else:
logger.error("Directory '%s' does not exists.", pref_path)
else:
# test if firefox is installed
if os.path.isfile(paths.FIREFOX):
# find valid preferences path
for path in [paths.LIB_FIREFOX, paths.LIB64_FIREFOX]:
pref_path = os.path.join(path,
FIREFOX_PREFERENCES_REL_PATH)
if os.path.isdir(pref_path):
preferences_dir = pref_path
break
else:
logger.error(
"Firefox configuration skipped (Firefox not found).")
return
# setting up firefox
if preferences_dir is not None:
# user could specify relative path, we need to store absolute
preferences_dir = os.path.abspath(preferences_dir)
logger.debug(
"Firefox preferences directory found '%s'.", preferences_dir)
preferences_fname = os.path.join(
preferences_dir, FIREFOX_PREFERENCES_FILENAME)
update_txt = ipautil.template_str(
FIREFOX_CONFIG_TEMPLATE, dict(DOMAIN=domain))
logger.debug(
"Firefox trusted uris will be set as '.%s' domain.", domain)
logger.debug(
"Firefox configuration will be stored in '%s' file.",
preferences_fname)
try:
with open(preferences_fname, 'w') as f:
f.write(update_txt)
logger.info("Firefox sucessfully configured.")
statestore.backup_state(
'firefox', 'preferences_fname', preferences_fname)
except Exception as e:
logger.debug(
"An error occured during creating preferences file: %s.",
e)
logger.error("Firefox configuration failed.")
else:
logger.debug("Firefox preferences directory not found.")
logger.error("Firefox configuration failed.")
except Exception as e:
logger.debug("%s", str(e))
logger.error("Firefox configuration failed.")
def purge_host_keytab(realm):
try:
ipautil.run([
paths.IPA_RMKEYTAB,
'-k', paths.KRB5_KEYTAB, '-r', realm
])
except CalledProcessError as e:
if e.returncode not in (3, 5, 7):
# 3 - Unable to open keytab
# 5 - Principal name or realm not found in keytab
# 7 - Failed to set cursor, typically when errcode
# would be issued in past
logger.error(
"Error trying to clean keytab: "
"/usr/sbin/ipa-rmkeytab returned %s", e.returncode)
else:
logger.info(
"Removed old keys for realm %s from %s",
realm, paths.KRB5_KEYTAB)
def install_check(options):
global hostname
global hostname_source
global nosssd_files
global dnsok
global cli_domain
global cli_server
global subject_base
global cli_realm
global cli_kdc
global client_domain
global cli_basedn
global selinux_works
print("This program will set up IPA client.")
print("Version {}".format(version.VERSION))
print("")
cli_domain_source = 'Unknown source'
cli_server_source = 'Unknown source'
if not os.getegid() == 0:
raise ScriptError(
"You must be root to run ipa-client-install.",
rval=CLIENT_INSTALL_ERROR)
selinux_works = tasks.check_selinux_status()
if is_ipa_client_configured(on_master=options.on_master):
logger.error("IPA client is already configured on this system.")
logger.info(
"If you want to reinstall the IPA client, uninstall it first "
"using 'ipa-client-install --uninstall'.")
raise ScriptError(rval=CLIENT_ALREADY_CONFIGURED)
check_ldap_conf()
if options.conf_ntp:
try:
timeconf.check_timedate_services()
except timeconf.NTPConflictingService as e:
print(
"WARNING: conflicting time&date synchronization service "
"'{}' will be disabled in favor of chronyd\n".format(
e.conflicting_service
)
)
except timeconf.NTPConfigurationError:
pass
if options.unattended and (
options.password is None
and options.principal is None
and options.keytab is None
and options.pkinit_identity is None
and options.prompt_password is False
and not options.on_master
):
raise ScriptError(
"One of password / principal / keytab is required.",
rval=CLIENT_INSTALL_ERROR)
if options.pkinit_identity is not None and (
options.password is not None
or options.keytab is not None
):
raise ScriptError(
"pkinit_identity is mutually exclusive with password / keytab.",
rval=CLIENT_INSTALL_ERROR
)
if options.hostname:
hostname = options.hostname
hostname_source = 'Provided as option'
else:
hostname = FQDN
hostname_source = "Machine's FQDN"
if hostname != hostname.lower():
raise ScriptError(
"Invalid hostname '{}', must be lower-case.".format(hostname),
rval=CLIENT_INSTALL_ERROR
)
if hostname in ('localhost', 'localhost.localdomain'):
raise ScriptError(
"Invalid hostname, '{}' must not be used.".format(hostname),
rval=CLIENT_INSTALL_ERROR)
try:
validate_hostname(hostname, maxlen=MAXHOSTNAMELEN)
except ValueError as e:
raise ScriptError(
'invalid hostname: {}'.format(e),
rval=CLIENT_INSTALL_ERROR)
# --no-sssd is not supported any more for rhel-based distros
if not tasks.is_nosssd_supported() and not options.sssd:
raise ScriptError(
"Option '--no-sssd' is incompatible with the 'authselect' tool "
"provided by this distribution for configuring system "
"authentication resources",
rval=CLIENT_INSTALL_ERROR)
# --noac is not supported any more for rhel-based distros
if not tasks.is_nosssd_supported() and options.no_ac:
raise ScriptError(
"Option '--noac' is incompatible with the 'authselect' tool "
"provided by this distribution for configuring system "
"authentication resources",
rval=CLIENT_INSTALL_ERROR)
# --mkhomedir is not supported by fedora_container and rhel_container
if not tasks.is_mkhomedir_supported() and options.mkhomedir:
raise ScriptError(
"Option '--mkhomedir' is incompatible with the 'authselect' tool "
"provided by this distribution for configuring system "
"authentication resources",
rval=CLIENT_INSTALL_ERROR)
# When installing without the "--no-sudo" option, check whether sudo is
# available.
if options.conf_sudo:
try:
ipautil.run(['sudo', '-V'])
except FileNotFoundError:
logger.info(
"The sudo binary does not seem to be present on this "
"system. Please consider installing sudo if required."
)
# when installing with the '--no-sssd' option, check whether nss-ldap is
# installed
if not options.sssd:
if not os.path.exists(paths.PAM_KRB5_SO):
raise ScriptError(
"The pam_krb5 package must be installed",
rval=CLIENT_INSTALL_ERROR)
(nssldap_installed, nosssd_files) = nssldap_exists()
if not nssldap_installed:
raise ScriptError(
"One of these packages must be installed: nss_ldap or "
"nss-pam-ldapd",
rval=CLIENT_INSTALL_ERROR)
if options.keytab and options.principal:
raise ScriptError(
"Options 'principal' and 'keytab' cannot be used together.",
rval=CLIENT_INSTALL_ERROR)
if options.keytab and options.force_join:
logger.warning("Option 'force-join' has no additional effect "
"when used with together with option 'keytab'.")
# Remove invalid keytab file
try:
gssapi.Credentials(
store={'keytab': paths.KRB5_KEYTAB},
usage='accept',
)
except gssapi.exceptions.GSSError:
logger.debug("Deleting invalid keytab: '%s'.", paths.KRB5_KEYTAB)
remove_file(paths.KRB5_KEYTAB)
# Check if old certificate exist and show warning
if (
not options.ca_cert_file and
get_cert_path(options.ca_cert_file) == paths.IPA_CA_CRT
):
logger.warning("Using existing certificate '%s'.", paths.IPA_CA_CRT)
if not check_ip_addresses(options):
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
# Create the discovery instance
ds = discovery.IPADiscovery()
ret = ds.search(
domain=options.domain,
servers=options.server,
realm=options.realm_name,
hostname=hostname,
ca_cert_path=get_cert_path(options.ca_cert_file)
)
if options.server and ret != 0:
# There is no point to continue with installation as server list was
# passed as a fixed list of server and thus we cannot discover any
# better result
logger.error(
"Failed to verify that %s is an IPA Server.",
', '.join(options.server))
logger.error(
"This may mean that the remote server is not up "
"or is not reachable due to network or firewall settings.")
print_port_conf_info()
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
if ret == discovery.BAD_HOST_CONFIG:
logger.error("Can't get the fully qualified name of this host")
logger.info("Check that the client is properly configured")
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
if ret == discovery.NOT_FQDN:
raise ScriptError(
"{} is not a fully-qualified hostname".format(hostname),
rval=CLIENT_INSTALL_ERROR)
if ret in (discovery.NO_LDAP_SERVER, discovery.NOT_IPA_SERVER) \
or not ds.domain:
if ret == discovery.NO_LDAP_SERVER:
if ds.server:
logger.debug("%s is not an LDAP server", ds.server)
else:
logger.debug("No LDAP server found")
elif ret == discovery.NOT_IPA_SERVER:
if ds.server:
logger.debug("%s is not an IPA server", ds.server)
else:
logger.debug("No IPA server found")
else:
logger.debug("Domain not found")
if options.domain:
cli_domain = options.domain
cli_domain_source = 'Provided as option'
elif options.unattended:
raise ScriptError(
"Unable to discover domain, not provided on command line",
rval=CLIENT_INSTALL_ERROR)
else:
logger.info(
"DNS discovery failed to determine your DNS domain")
cli_domain = user_input(
"Provide the domain name of your IPA server (ex: example.com)",
allow_empty=False)
cli_domain_source = 'Provided interactively'
logger.debug(
"will use interactively provided domain: %s", cli_domain)
ret = ds.search(
domain=cli_domain,
servers=options.server,
hostname=hostname,
ca_cert_path=get_cert_path(options.ca_cert_file))
if not cli_domain:
if ds.domain:
cli_domain = ds.domain
cli_domain_source = ds.domain_source
logger.debug("will use discovered domain: %s", cli_domain)
client_domain = hostname[hostname.find(".")+1:]
if ret in (discovery.NO_LDAP_SERVER, discovery.NOT_IPA_SERVER) \
or not ds.server:
logger.debug("IPA Server not found")
if options.server:
cli_server = options.server
cli_server_source = 'Provided as option'
elif options.unattended:
raise ScriptError(
"Unable to find IPA Server to join",
rval=CLIENT_INSTALL_ERROR)
else:
logger.debug("DNS discovery failed to find the IPA Server")
cli_server = [
user_input(
"Provide your IPA server name (ex: ipa.example.com)",
allow_empty=False)
]
cli_server_source = 'Provided interactively'
logger.debug(
"will use interactively provided server: %s", cli_server[0])
ret = ds.search(
domain=cli_domain,
servers=cli_server,
hostname=hostname,
ca_cert_path=get_cert_path(options.ca_cert_file))
else:
# Only set dnsok to True if we were not passed in one or more servers
# and if DNS discovery actually worked.
if not options.server:
(server, domain) = ds.check_domain(
ds.domain, set(), "Validating DNS Discovery")
if server and domain:
logger.debug("DNS validated, enabling discovery")
dnsok = True
else:
logger.debug("DNS discovery failed, disabling discovery")
else:
logger.debug(
"Using servers from command line, disabling DNS discovery")
if not cli_server:
if options.server:
cli_server = ds.servers
cli_server_source = 'Provided as option'
logger.debug(
"will use provided server: %s", ', '.join(options.server))
elif ds.server:
cli_server = ds.servers
cli_server_source = ds.server_source
logger.debug("will use discovered server: %s", cli_server[0])
if ret == discovery.NOT_IPA_SERVER:
logger.error("%s is not an IPA v2 Server.", cli_server[0])
print_port_conf_info()
logger.debug("(%s: %s)", cli_server[0], cli_server_source)
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
if ret == discovery.NO_ACCESS_TO_LDAP:
logger.warning("Anonymous access to the LDAP server is disabled.")
logger.info("Proceeding without strict verification.")
logger.info(
"Note: This is not an error if anonymous access "
"has been explicitly restricted.")
ret = 0
if ret == discovery.NO_TLS_LDAP:
logger.warning(
"The LDAP server requires TLS is but we do not have the CA.")
logger.info("Proceeding without strict verification.")
ret = 0
if ret != 0:
logger.error(
"Failed to verify that %s is an IPA Server.",
cli_server[0])
logger.error(
"This may mean that the remote server is not up "
"or is not reachable due to network or firewall settings.")
print_port_conf_info()
logger.debug("(%s: %s)", cli_server[0], cli_server_source)
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
cli_kdc = ds.kdc
if dnsok and not cli_kdc:
logger.error(
"DNS domain '%s' is not configured for automatic "
"KDC address lookup.", ds.realm.lower())
logger.debug("(%s: %s)", ds.realm, ds.realm_source)
logger.error("KDC address will be set to fixed value.")
if dnsok:
logger.info("Discovery was successful!")
elif not options.unattended:
if not options.server:
logger.warning(
"The failure to use DNS to find your IPA "
"server indicates that your resolv.conf file is not properly "
"configured.")
logger.info(
"Autodiscovery of servers for failover cannot work "
"with this configuration.")
logger.info(
"If you proceed with the installation, services "
"will be configured to always access the discovered server for "
"all operations and will not fail over to other servers in case "
"of failure.")
if not user_input(
"Proceed with fixed values and no DNS discovery?", False):
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
if options.conf_ntp:
if not options.on_master and not options.unattended and not (
options.ntp_servers or options.ntp_pool):
options.ntp_servers, options.ntp_pool = timeconf.get_time_source()
cli_realm = ds.realm
cli_realm_source = ds.realm_source
logger.debug("will use discovered realm: %s", cli_realm)
if options.realm_name and options.realm_name != cli_realm:
logger.error(
"The provided realm name [%s] does not match discovered one [%s]",
options.realm_name, cli_realm)
logger.debug("(%s: %s)", cli_realm, cli_realm_source)
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
cli_basedn = ds.basedn
cli_basedn_source = ds.basedn_source
logger.debug("will use discovered basedn: %s", cli_basedn)
subject_base = DN(('O', cli_realm))
logger.info("Client hostname: %s", hostname)
logger.debug("Hostname source: %s", hostname_source)
logger.info("Realm: %s", cli_realm)
logger.debug("Realm source: %s", cli_realm_source)
logger.info("DNS Domain: %s", cli_domain)
logger.debug("DNS Domain source: %s", cli_domain_source)
logger.info("IPA Server: %s", ', '.join(cli_server))
logger.debug("IPA Server source: %s", cli_server_source)
logger.info("BaseDN: %s", cli_basedn)
logger.debug("BaseDN source: %s", cli_basedn_source)
if not options.on_master:
if options.ntp_servers:
for server in options.ntp_servers:
logger.info("NTP server: %s", server)
if options.ntp_pool:
logger.info("NTP pool: %s", options.ntp_pool)
# ipa-join would fail with IP address instead of a FQDN
for srv in cli_server:
try:
socket.inet_pton(socket.AF_INET, srv)
is_ipaddr = True
except socket.error:
try:
socket.inet_pton(socket.AF_INET6, srv)
is_ipaddr = True
except socket.error:
is_ipaddr = False
if is_ipaddr:
print()
logger.warning(
"It seems that you are using an IP address "
"instead of FQDN as an argument to --server. The "
"installation may fail.")
break
print()
if not options.unattended and not user_input(
"Continue to configure the system with these values?", False):
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
def create_ipa_nssdb(db=None):
if db is None:
db = certdb.NSSDatabase(paths.IPA_NSSDB_DIR)
db.create_db(mode=0o755, backup=True)
os.chmod(db.pwd_file, 0o600)
def update_ipa_nssdb():
ipa_db = certdb.NSSDatabase(paths.IPA_NSSDB_DIR)
sys_db = certdb.NSSDatabase(paths.NSS_DB_DIR)
if not ipa_db.exists():
create_ipa_nssdb(ipa_db)
if ipa_db.dbtype == 'dbm':
ipa_db.convert_db(rename_old=False)
for nickname, trust_flags in (
('IPA CA', certdb.IPA_CA_TRUST_FLAGS),
('External CA cert', certdb.EXTERNAL_CA_TRUST_FLAGS)):
try:
cert = sys_db.get_cert(nickname)
except RuntimeError:
continue
try:
ipa_db.add_cert(cert, nickname, trust_flags)
except ipautil.CalledProcessError as e:
raise RuntimeError("Failed to add %s to %s: %s" %
(nickname, ipa_db.secdir, e))
# Remove IPA certs from /etc/pki/nssdb
for nickname, trust_flags in ipa_db.list_certs():
while sys_db.has_nickname(nickname):
try:
sys_db.delete_cert(nickname)
except ipautil.CalledProcessError as e:
raise RuntimeError("Failed to remove %s from %s: %s" %
(nickname, sys_db.secdir, e))
def sync_time(ntp_servers, ntp_pool, fstore, statestore):
"""
Will disable any other time synchronization service and configure chrony
with given ntp(chrony) server and/or pool using Augeas.
If there is no option --ntp-server set IPADiscovery will try to find ntp
server in DNS records.
"""
# We assume that NTP servers are discoverable through SRV records in DNS.
# disable other time&date services first
timeconf.force_chrony(statestore)
if not ntp_servers and not ntp_pool:
# autodiscovery happens in case that NTP configuration isn't explicitly
# disabled and user did not provide any NTP server addresses or
# NTP pool address to the installer interactively or as an cli argument
ds = discovery.IPADiscovery()
ntp_servers = ds.ipadns_search_srv(
cli_domain, '_ntp._udp', None, break_on_first=False
)
if ntp_servers:
for server in ntp_servers:
# when autodiscovery found server records
logger.debug("Found DNS record for NTP server: \t%s", server)
logger.info('Synchronizing time')
configured = False
if ntp_servers or ntp_pool:
configured = timeconf.configure_chrony(ntp_servers, ntp_pool,
fstore, statestore)
else:
logger.warning("No SRV records of NTP servers found and no NTP server "
"or pool address was provided.")
if not configured:
print("Using default chrony configuration.")
return timeconf.sync_chrony()
def restore_time_sync(statestore, fstore):
if statestore.has_state('chrony'):
chrony_enabled = statestore.restore_state('chrony', 'enabled')
restored = False
try:
# Restore might fail due to missing file(s) in backup.
# One example is if the client was updated from a previous version
# not configured with chrony. In such a cast it is OK to fail.
restored = fstore.restore_file(paths.CHRONY_CONF)
except ValueError: # this will not handle possivble IOError
logger.debug("Configuration file %s was not restored.",
paths.CHRONY_CONF)
if not chrony_enabled:
services.knownservices.chronyd.stop()
services.knownservices.chronyd.disable()
elif restored:
services.knownservices.chronyd.restart()
try:
timeconf.restore_forced_timeservices(statestore)
except CalledProcessError as e:
logger.error('Failed to restore time synchronization service: %s', e)
def configure_selinux_for_client(statestore):
def backup_state(key, value):
statestore.backup_state('selinux', key, value)
try:
tasks.set_selinux_booleans(constants.SELINUX_BOOLEAN_SSSD,
backup_state)
except SetseboolError as e:
for c in constants.SELINUX_BOOLEAN_SSSD:
if c in e.failed:
logger.warning(
"SELinux does not support SSSD boolean %s, ignoring", c)
def install(options):
try:
_install(options, dict())
except ScriptError as e:
if e.rval == CLIENT_INSTALL_ERROR:
if options.force:
logger.warning(
"Installation failed. Force set so not rolling back "
"changes.")
elif options.on_master:
logger.warning(
"Installation failed. As this is IPA server, changes will "
"not be rolled back.")
else:
logger.error("Installation failed. Rolling back changes.")
options.unattended = True
try:
uninstall(options)
except Exception as ex:
logger.debug("%s", traceback.format_exc())
logger.error("%s", ex)
raise
finally:
try:
os.remove(CCACHE_FILE)
except Exception:
pass
@cleanup
def _install(options, tdict):
env = {'PATH': SECURE_PATH}
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
statestore.backup_state('installation', 'complete', False)
krb_name = tdict['krb_name']
ccache_dir = tdict['ccache_dir']
if not options.on_master:
# Try removing old principals from the keytab
purge_host_keytab(cli_realm)
if options.hostname and not options.on_master:
# skip this step when run by ipa-server-install as it always configures
# hostname
tasks.backup_hostname(fstore, statestore)
tasks.set_hostname(options.hostname)
if options.conf_ntp:
# Attempt to configure and sync time with NTP server (chrony).
sync_time(options.ntp_servers, options.ntp_pool, fstore, statestore)
elif options.on_master:
# If we're on master skipping the time sync here because it was done
# in ipa-server-install
logger.debug("Skipping attempt to configure and synchronize time with"
" chrony server as it has been already done on master.")
else:
logger.info("Skipping chrony configuration")
if not options.unattended:
if (options.principal is None and options.password is None and
options.prompt_password is False and options.keytab is None
and options.pkinit_identity is None):
options.principal = user_input("User authorized to enroll "
"computers", allow_empty=False)
logger.debug(
"will use principal provided as option: %s", options.principal)
host_principal = 'host/%s@%s' % (hostname, cli_realm)
if not options.on_master:
nolog = tuple()
configure_krb5_conf(
cli_realm=cli_realm,
cli_domain=cli_domain,
cli_server=cli_server,
cli_kdc=cli_kdc,
dnsok=False,
filename=krb_name,
client_domain=client_domain,
client_hostname=hostname,
configure_sssd=options.sssd,
force=options.force)
env['KRB5_CONFIG'] = krb_name
ccache_name = os.path.join(ccache_dir, 'ccache')
join_args = [
paths.SBIN_IPA_JOIN,
"-s", cli_server[0],
"-b", str(realm_to_suffix(cli_realm)),
"-h", hostname,
"-k", paths.KRB5_KEYTAB
]
if options.debug:
join_args.append("-d")
env['XMLRPC_TRACE_CURL'] = 'yes'
if options.force_join:
join_args.append("-f")
if options.principal is not None:
stdin = None
principal = options.principal
if principal.find('@') == -1:
principal = '%s@%s' % (principal, cli_realm)
if options.password is not None:
stdin = options.password
else:
if not options.unattended:
try:
stdin = getpass.getpass(
"Password for %s: " % principal)
except EOFError:
stdin = None
if not stdin:
raise ScriptError(
"Password must be provided for {}.".format(
principal),
rval=CLIENT_INSTALL_ERROR)
else:
if sys.stdin.isatty():
logger.error(
"Password must be provided in "
"non-interactive mode.")
logger.info(
"This can be done via "
"echo password | ipa-client-install ... "
"or with the -w option.")
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
else:
stdin = sys.stdin.readline()
try:
kinit_password(principal, stdin, ccache_name,
config=krb_name)
except RuntimeError as e:
print_port_conf_info()
raise ScriptError(
"Kerberos authentication failed: {}".format(e),
rval=CLIENT_INSTALL_ERROR)
elif options.keytab:
join_args.append("-f")
if os.path.exists(options.keytab):
try:
kinit_keytab(host_principal,
options.keytab,
ccache_name,
config=krb_name,
attempts=options.kinit_attempts)
except gssapi.exceptions.GSSError as e:
print_port_conf_info()
raise ScriptError(
"Kerberos authentication failed: {}".format(e),
rval=CLIENT_INSTALL_ERROR)
else:
raise ScriptError(
"Keytab file could not be found: {}".format(
options.keytab),
rval=CLIENT_INSTALL_ERROR)
elif options.pkinit_identity:
join_args.append("-f")
with open(paths.CA_BUNDLE_PEM, "w"):
# HACK: kinit fails when "pkinit_pool" file is missing.
# Create an empty file and remove it after PKINIT.
pass
# if no principal is set, use host principal
if options.principal is None:
pkinit_principal = host_principal
else:
pkinit_principal = options.principal
try:
kinit_pkinit(
pkinit_principal,
options.pkinit_identity,
ccache_name=ccache_name,
config=krb_name,
pkinit_anchors=options.pkinit_anchors
)
except CalledProcessError as e:
print_port_conf_info()
raise ScriptError(
f"Kerberos PKINIT authentication failed: {e}",
rval=CLIENT_INSTALL_ERROR
)
finally:
remove_file(paths.CA_BUNDLE_PEM)
elif options.password:
nolog = (options.password,)
join_args.append("-w")
join_args.append(options.password)
elif options.prompt_password:
if options.unattended:
raise ScriptError(
"Password must be provided in non-interactive mode",
rval=CLIENT_INSTALL_ERROR)
try:
password = getpass.getpass("Password: ")
except EOFError:
password = None
if not password:
raise ScriptError(
"Password must be provided.",
rval=CLIENT_INSTALL_ERROR)
join_args.append("-w")
join_args.append(password)
nolog = (password,)
env['KRB5CCNAME'] = os.environ['KRB5CCNAME'] = ccache_name
# Get the CA certificate
try:
os.environ['KRB5_CONFIG'] = env['KRB5_CONFIG']
get_ca_certs(fstore, options, cli_server[0], cli_basedn,
cli_realm)
except errors.FileError as e:
logger.error('%s', e)
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
except Exception as e:
logger.error("Cannot obtain CA certificate\n%s", e)
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
# Now join the domain
result = run(
join_args, raiseonerr=False, env=env, nolog=nolog,
capture_error=True)
stderr = result.error_output
if result.returncode != 0:
logger.error("Joining realm failed: %s", stderr)
if not options.force:
if result.returncode == 13:
logger.info(
"Use --force-join option to override the host "
"entry on the server and force client enrollment.")
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
logger.info(
"Use ipa-getkeytab to obtain a host "
"principal for this server.")
else:
logger.info("Enrolled in IPA realm %s", cli_realm)
if options.principal is not None:
run([paths.KDESTROY], raiseonerr=False, env=env)
# Obtain the TGT. We do it with the temporary krb5.conf, so that
# only the KDC we're installing under is contacted.
# Other KDCs might not have replicated the principal yet.
# Once we have the TGT, it's usable on any server.
try:
kinit_keytab(host_principal, paths.KRB5_KEYTAB, CCACHE_FILE,
config=krb_name,
attempts=options.kinit_attempts)
env['KRB5CCNAME'] = os.environ['KRB5CCNAME'] = CCACHE_FILE
except gssapi.exceptions.GSSError as e:
print_port_conf_info()
logger.error("Failed to obtain host TGT: %s", e)
# failure to get ticket makes it impossible to login and bind
# from sssd to LDAP, abort installation and rollback changes
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
# Configure ipa.conf
if not options.on_master:
configure_ipa_conf(fstore, cli_basedn, cli_realm, cli_domain,
cli_server, hostname)
logger.info("Created /etc/ipa/default.conf")
with certdb.NSSDatabase() as tmp_db:
api.bootstrap(context='cli_installer',
confdir=paths.ETC_IPA,
debug=options.debug,
delegate=False,
nss_dir=tmp_db.secdir)
if 'config_loaded' not in api.env:
raise ScriptError(
"Failed to initialize IPA API.",
rval=CLIENT_INSTALL_ERROR)
# Always back up sssd.conf. It gets updated by authconfig --enablekrb5.
fstore.backup_file(paths.SSSD_CONF)
if options.sssd:
if configure_sssd_conf(fstore, cli_realm, cli_domain, cli_server,
options, client_domain, hostname):
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
logger.info("Configured /etc/sssd/sssd.conf")
if options.on_master:
# If on master assume kerberos is already configured properly.
# Get the host TGT.
try:
kinit_keytab(host_principal, paths.KRB5_KEYTAB, CCACHE_FILE,
attempts=options.kinit_attempts)
os.environ['KRB5CCNAME'] = CCACHE_FILE
except gssapi.exceptions.GSSError as e:
logger.error("Failed to obtain host TGT: %s", e)
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
# Clear out any current session keyring information
try:
delete_persistent_client_session_data(host_principal)
except ValueError:
pass
# Add CA certs to a temporary NSS database
ca_certs = x509.load_certificate_list_from_file(paths.IPA_CA_CRT)
try:
tmp_db.create_db()
for i, cert in enumerate(ca_certs):
tmp_db.add_cert(cert,
'CA certificate %d' % (i + 1),
certdb.EXTERNAL_CA_TRUST_FLAGS)
except CalledProcessError:
raise ScriptError(
"Failed to add CA to temporary NSS database.",
rval=CLIENT_INSTALL_ERROR)
api.finalize()
# Now, let's try to connect to the server's RPC interface
connected = False
try:
api.Backend.rpcclient.connect()
connected = True
logger.debug("Try RPC connection")
api.Backend.rpcclient.forward('ping')
except errors.KerberosError as e:
if connected:
api.Backend.rpcclient.disconnect()
logger.info(
"Cannot connect to the server due to Kerberos error: %s. "
"Trying with delegate=True", e)
try:
api.Backend.rpcclient.connect(delegate=True)
logger.debug("Try RPC connection")
api.Backend.rpcclient.forward('ping')
logger.info("Connection with delegate=True successful")
# The remote server is not capable of Kerberos S4U2Proxy
# delegation. This features is implemented in IPA server
# version 2.2 and higher
logger.warning(
"Target IPA server has a lower version than the enrolled "
"client")
logger.warning(
"Some capabilities including the ipa command capability "
"may not be available")
except errors.PublicError as e2:
logger.warning(
"Second connect with delegate=True also failed: %s", e2)
raise ScriptError(
"Cannot connect to the IPA server RPC interface: %s" % e2,
rval=CLIENT_INSTALL_ERROR)
except errors.PublicError as e:
raise ScriptError(
"Cannot connect to the server due to generic error: %s" % e,
rval=CLIENT_INSTALL_ERROR)
# Use the RPC directly so older servers are supported
try:
result = api.Backend.rpcclient.forward(
'ca_is_enabled',
version=u'2.107',
)
ca_enabled = result['result']
except (errors.CommandError, errors.NetworkError):
result = api.Backend.rpcclient.forward(
'env',
server=True,
version=u'2.0',
)
ca_enabled = result['result']['enable_ra']
if not ca_enabled:
disable_ra()
try:
result = api.Backend.rpcclient.forward(
'config_show',
raw=True, # so that servroles are not queried
version=u'2.0'
)
except Exception as e:
logger.debug("config_show failed %s", e, exc_info=True)
raise ScriptError(
"Failed to retrieve CA certificate subject base: {}".format(e),
rval=CLIENT_INSTALL_ERROR)
else:
subject_base = DN(result['result']['ipacertificatesubjectbase'][0])
# Create IPA NSS database
try:
create_ipa_nssdb()
except ipautil.CalledProcessError as e:
raise ScriptError(
"Failed to create IPA NSS database: %s" % e,
rval=CLIENT_INSTALL_ERROR)
# Get CA certificates from the certificate store
try:
ca_certs = get_certs_from_ldap(cli_server[0], cli_basedn, cli_realm,
ca_enabled)
except errors.NoCertificateError:
if ca_enabled:
ca_subject = DN(('CN', 'Certificate Authority'), subject_base)
else:
ca_subject = None
ca_certs = certstore.make_compat_ca_certs(ca_certs, cli_realm,
ca_subject)
ca_certs_trust = [(c, n, certstore.key_policy_to_trust_flags(t, True, u))
for (c, n, t, u) in ca_certs]
x509.write_certificate_list(
[c for c, n, t, u in ca_certs if t is not False],
paths.KDC_CA_BUNDLE_PEM,
mode=0o644
)
x509.write_certificate_list(
[c for c, n, t, u in ca_certs if t is not False],
paths.CA_BUNDLE_PEM,
mode=0o644
)
# Add the CA certificates to the IPA NSS database
logger.debug("Adding CA certificates to the IPA NSS database.")
ipa_db = certdb.NSSDatabase(paths.IPA_NSSDB_DIR)
for cert, nickname, trust_flags in ca_certs_trust:
try:
ipa_db.add_cert(cert, nickname, trust_flags)
except CalledProcessError as e:
raise ScriptError(
"Failed to add %s to the IPA NSS database." % nickname,
rval=CLIENT_INSTALL_ERROR)
# Add the CA certificates to the platform-dependant systemwide CA store
tasks.insert_ca_certs_into_systemwide_ca_store(ca_certs)
if not options.on_master:
client_dns(cli_server[0], hostname, options)
update_ssh_keys(hostname, paths.SSH_CONFIG_DIR, options.create_sshfp)
try:
os.remove(CCACHE_FILE)
except Exception:
pass
# Name Server Caching Daemon. Disable for SSSD, use otherwise
# (if installed)
nscd = services.knownservices.nscd
if nscd.is_installed():
save_state(nscd, statestore)
nscd_service_action = None
try:
if options.sssd:
nscd_service_action = 'stop'
nscd.stop()
else:
nscd_service_action = 'restart'
nscd.restart()
except Exception:
logger.warning(
"Failed to %s the %s daemon",
nscd_service_action, nscd.service_name)
if not options.sssd:
logger.warning(
"Caching of users/groups will not be available")
try:
if options.sssd:
nscd.disable()
else:
nscd.enable()
except Exception:
if not options.sssd:
logger.warning(
"Failed to configure automatic startup of the %s daemon",
nscd.service_name)
logger.info(
"Caching of users/groups will not be "
"available after reboot")
else:
logger.warning(
"Failed to disable %s daemon. Disable it manually.",
nscd.service_name)
else:
# this is optional service, just log
if not options.sssd:
logger.info(
"%s daemon is not installed, skip configuration",
nscd.service_name)
nslcd = services.knownservices.nslcd
if nslcd.is_installed():
save_state(nslcd, statestore)
retcode, conf = (0, None)
if not options.no_ac:
# Modify nsswitch/pam stack
tasks.modify_nsswitch_pam_stack(
sssd=options.sssd,
mkhomedir=options.mkhomedir,
statestore=statestore,
sudo=options.conf_sudo,
subid=options.subid
)
# if mkhomedir, make sure oddjobd is enabled and started
if options.mkhomedir:
oddjobd = services.service('oddjobd', api)
running = oddjobd.is_running()
enabled = oddjobd.is_enabled()
statestore.backup_state('oddjobd', 'running', running)
statestore.backup_state('oddjobd', 'enabled', enabled)
try:
if not enabled:
oddjobd.enable()
if not running:
oddjobd.start()
except Exception as e:
logger.critical("Unable to start oddjobd: %s", str(e))
logger.info("%s enabled", "SSSD" if options.sssd else "LDAP")
if options.sssd:
if selinux_works:
configure_selinux_for_client(statestore)
sssd = services.service('sssd', api)
try:
sssd.restart()
except CalledProcessError:
logger.warning("SSSD service restart was unsuccessful.")
try:
sssd.enable()
except CalledProcessError as e:
logger.warning(
"Failed to enable automatic startup of the SSSD daemon: "
"%s", e)
if not options.sssd:
tasks.modify_pam_to_use_krb5(statestore)
logger.info("Kerberos 5 enabled")
# Update non-SSSD LDAP configuration after authconfig calls as it would
# change its configuration otherways
if not options.sssd:
for configurer in [configure_ldap_conf, configure_nslcd_conf]:
(retcode, conf, filenames) = configurer(
fstore, cli_basedn, cli_realm,
cli_domain, cli_server, dnsok,
options, nosssd_files[configurer.__name__])
if retcode:
raise ScriptError(rval=CLIENT_INSTALL_ERROR)
if conf:
logger.info(
"%s configured using configuration file(s) %s",
conf, filenames)
if configure_openldap_conf(fstore, cli_basedn, cli_server):
logger.info("Configured /etc/openldap/ldap.conf")
else:
logger.info("Failed to configure /etc/openldap/ldap.conf")
# Check that nss is working properly
if not options.on_master:
user = options.principal
if user is None:
user = "admin@%s" % cli_domain
logger.info(
"Principal is not set when enrolling with OTP "
"or PKINIT; using principal '%s' for 'getent passwd'.",
user
)
elif '@' not in user:
user = "%s@%s" % (user, cli_domain)
n = 0
found = False
# Loop for up to 10 seconds to see if nss is working properly.
# It can sometimes take a few seconds to connect to the remote
# provider.
# Particulary, SSSD might take longer than 6-8 seconds.
while n < 10 and not found:
try:
ipautil.run([paths.GETENT, "passwd", user])
found = True
except Exception as e:
time.sleep(1)
n = n + 1
if not found:
logger.error("Unable to find '%s' user with 'getent "
"passwd %s'!", user.split("@")[0], user)
if conf:
logger.info("Recognized configuration: %s", conf)
else:
logger.error(
"Unable to reliably detect "
"configuration. Check NSS setup manually.")
try:
hardcode_ldap_server(cli_server)
except Exception as e:
logger.error(
"Adding hardcoded server name to "
"/etc/ldap.conf failed: %s", str(e))
if options.conf_ssh:
configure_ssh_config(fstore, options)
if options.conf_sshd:
configure_sshd_config(fstore, options)
if options.location:
configure_automount(options, statestore)
# Reload the state as automount install may have modified it
fstore._load()
statestore._load()
if options.configure_firefox:
configure_firefox(options, statestore, cli_domain)
if not options.no_nisdomain:
configure_nisdomain(
options=options, domain=cli_domain, statestore=statestore)
# Configure the final krb5.conf
if not options.on_master:
fstore.backup_file(paths.KRB5_CONF)
configure_krb5_conf(
cli_realm=cli_realm,
cli_domain=cli_domain,
cli_server=cli_server,
cli_kdc=cli_kdc,
dnsok=dnsok,
filename=paths.KRB5_CONF,
client_domain=client_domain,
client_hostname=hostname,
configure_sssd=options.sssd,
force=options.force)
logger.info("Configured /etc/krb5.conf for IPA realm %s", cli_realm)
# Configure certmonger after krb5.conf is created and last
# to give higher chance that the new client is replicated.
configure_certmonger(fstore, subject_base, cli_realm, hostname,
options, ca_enabled)
statestore.delete_state('installation', 'complete')
statestore.backup_state('installation', 'complete', True)
logger.info('Client configuration complete.')
def uninstall_check(options):
global selinux_works
if not is_ipa_client_configured():
if options.on_master:
rval = SUCCESS
else:
rval = CLIENT_NOT_CONFIGURED
raise ScriptError(
"IPA client is not configured on this system.",
rval=rval)
if is_ipa_configured() and not options.on_master:
logger.error(
"IPA client is configured as a part of IPA server on this system.")
logger.info("Refer to ipa-server-install for uninstallation.")
raise ScriptError(rval=CLIENT_NOT_CONFIGURED)
selinux_works = tasks.check_selinux_status()
def uninstall(options):
env = {'PATH': SECURE_PATH}
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
statestore.backup_state('installation', 'automount', True)
try:
run([paths.IPA_CLIENT_AUTOMOUNT, "--uninstall", "--debug"])
except CalledProcessError as e:
if e.returncode != CLIENT_NOT_CONFIGURED:
logger.error(
"Unconfigured automount client failed: %s", str(e))
finally:
statestore.delete_state('installation', 'automount')
# Reload the state as automount unconfigure may have modified it
fstore._load()
statestore._load()
hostname = None
ipa_domain = None
was_sssd_configured = False
try:
sssdconfig = SSSDConfig.SSSDConfig()
sssdconfig.import_config()
domains = sssdconfig.list_active_domains()
all_domains = sssdconfig.list_domains()
# we consider all the domains, because handling sssd.conf
# during uninstall is dependant on was_sssd_configured flag
# so the user does not lose info about inactive domains
if len(all_domains) > 1:
# There was more than IPA domain configured
was_sssd_configured = True
for name in domains:
domain = sssdconfig.get_domain(name)
try:
provider = domain.get_option('id_provider')
except SSSDConfig.NoOptionError:
continue
if provider == "ipa":
try:
hostname = domain.get_option('ipa_hostname')
except SSSDConfig.NoOptionError:
continue
try:
ipa_domain = domain.get_option('ipa_domain')
except SSSDConfig.NoOptionError:
pass
except Exception:
# We were unable to read existing SSSD config. This might mean few
# things:
# - sssd wasn't installed
# - sssd was removed after install and before uninstall
# - there are no active domains
# in both cases we cannot continue with SSSD
all_domains = []
if hostname is None:
hostname = FQDN
ipa_db = certdb.NSSDatabase(paths.IPA_NSSDB_DIR)
sys_db = certdb.NSSDatabase(paths.NSS_DB_DIR)
cmonger = services.knownservices.certmonger
if ipa_db.has_nickname('Local IPA host'):
try:
certmonger.stop_tracking(paths.IPA_NSSDB_DIR,
nickname='Local IPA host')
except RuntimeError as e:
logger.error("%s failed to stop tracking certificate: %s",
cmonger.service_name, e)
client_nss_nickname = 'IPA Machine Certificate - %s' % hostname
if sys_db.has_nickname(client_nss_nickname):
try:
certmonger.stop_tracking(paths.NSS_DB_DIR,
nickname=client_nss_nickname)
except RuntimeError as e:
logger.error("%s failed to stop tracking certificate: %s",
cmonger.service_name, e)
for filename in certdb.NSS_FILES:
remove_file(os.path.join(ipa_db.secdir, filename))
# Remove any special principal names we added to the IPA CA helper
certmonger.remove_principal_from_cas()
try:
cmonger.stop()
except Exception as e:
log_service_error(cmonger.service_name, 'stop', e)
try:
cmonger.disable()
except Exception as e:
logger.error(
"Failed to disable automatic startup of the %s service: %s",
cmonger.service_name, str(e))
if not options.on_master and os.path.exists(paths.IPA_DEFAULT_CONF):
logger.info("Unenrolling client from IPA server")
join_args = [
paths.SBIN_IPA_JOIN,
"--unenroll",
"-h", hostname,
"-k", paths.KRB5_KEYTAB
]
if options.debug:
join_args.append("-d")
env['XMLRPC_TRACE_CURL'] = 'yes'
result = run(join_args, raiseonerr=False, env=env)
if result.returncode != 0:
logger.error("Unenrolling host failed: %s", result.error_log)
if os.path.exists(paths.IPA_DEFAULT_CONF) and os.path.exists(
paths.KRB5_KEYTAB
):
logger.info(
"Removing Kerberos service principals from /etc/krb5.keytab")
try:
parser = RawConfigParser()
parser.read(paths.IPA_DEFAULT_CONF)
realm = parser.get('global', 'realm')
run([paths.IPA_RMKEYTAB, "-k", paths.KRB5_KEYTAB, "-r", realm])
except CalledProcessError as err:
if err.returncode != 5:
# 5 means Principal name or realm not found in keytab
# and can be ignored
logger.error(
"Failed to remove Kerberos service principals: %s",
str(err))
except Exception as e:
logger.error(
"Failed to remove Kerberos service principals: %s", str(e))
# Restore oddjobd to its original state
oddjobd = services.service('oddjobd', api)
if not statestore.restore_state('oddjobd', 'running'):
try:
oddjobd.stop()
except Exception:
pass
if not statestore.restore_state('oddjobd', 'enabled'):
try:
oddjobd.disable()
except Exception:
pass
logger.info("Disabling client Kerberos and LDAP configurations")
was_sssd_installed = False
was_sshd_configured = False
if fstore.has_files():
was_sssd_installed = fstore.has_file(paths.SSSD_CONF)
was_sshd_configured = fstore.has_file(paths.SSHD_CONFIG)
try:
tasks.restore_pre_ipa_client_configuration(fstore,
statestore,
was_sssd_installed,
was_sssd_configured)
except Exception as e:
raise ScriptError(
"Failed to remove krb5/LDAP configuration: {}".format(e),
rval=CLIENT_INSTALL_ERROR)
# Clean up the SSSD cache before SSSD service is stopped or restarted
remove_file(paths.SSSD_MC_GROUP)
remove_file(paths.SSSD_MC_PASSWD)
remove_file(paths.SSSD_MC_INITGROUPS)
remove_file(paths.SSSD_MC_SID)
for root, _dirs, files in os.walk(paths.SSSD_PIPES):
for file in files:
remove_file(os.path.join(root, file))
for domain in all_domains:
name = f"domain_realm_{domain.replace('.', '_')}"
filename = os.path.join(paths.SSSD_PUBCONF_KRB5_INCLUDE_D_DIR, name)
if os.path.exists(filename):
remove_file(filename)
if was_sssd_installed:
try:
run([paths.SSSCTL, "cache-remove", "-o", "--stop", "--start"])
except Exception:
logger.info(
"An error occurred while removing SSSD's cache."
"Please remove the cache manually by executing "
"sssctl cache-remove -o.")
if ipa_domain:
sssd_domain_ldb = "cache_" + ipa_domain + ".ldb"
sssd_ldb_file = os.path.join(paths.SSSD_DB, sssd_domain_ldb)
remove_file(sssd_ldb_file)
sssd_domain_ccache = "ccache_" + ipa_domain.upper()
sssd_ccache_file = os.path.join(paths.SSSD_DB, sssd_domain_ccache)
remove_file(sssd_ccache_file)
remove_file(paths.SSSD_LDB)
remove_file(paths.SSSD_CONFIG_LDB)
# Stop sssd-kcm.service before removing the KCM ccaches database
# it is socket-activated and will be restarted whenever needed
try:
services.service('sssd-kcm', api).stop()
except Exception as e:
logger.warning("Failed to stop sssd-kcm: %s", e)
remove_file(paths.SSSD_SECRETS)
sssd_timestamps = "timestamps_" + ipa_domain + ".ldb"
sssd_timestamps_file = os.path.join(paths.SSSD_DB, sssd_timestamps)
remove_file(sssd_timestamps_file)
# Next if-elif-elif construction deals with sssd.conf file.
# Old pre-IPA domains are preserved due merging the old sssd.conf
# during the installation of ipa-client but any new domains are
# only present in sssd.conf now, so we don't want to delete them
# by rewriting sssd.conf file. IPA domain is removed gracefully.
# SSSD was installed before our installation and other non-IPA domains
# found, restore backed up sssd.conf to sssd.conf.bkp and remove IPA
# domain from the current sssd.conf
if was_sssd_installed and was_sssd_configured:
logger.info(
"The original configuration of SSSD included other domains than "
"the IPA-based one.")
delete_ipa_domain()
restored = False
try:
restored = fstore.restore_file(
paths.SSSD_CONF, paths.SSSD_CONF_BKP)
except OSError:
logger.debug(
"Error while restoring pre-IPA /etc/sssd/sssd.conf.")
if restored:
logger.info(
"Original pre-IPA SSSD configuration file was "
"restored to /etc/sssd/sssd.conf.bkp.")
logger.info(
"IPA domain removed from current one, restarting SSSD service")
sssd = services.service('sssd', api)
try:
sssd.restart()
except CalledProcessError:
logger.warning("SSSD service restart was unsuccessful.")
# SSSD was not installed before our installation, but other domains found,
# delete IPA domain, but leave other domains intact
elif not was_sssd_installed and was_sssd_configured:
delete_ipa_domain()
logger.info(
"Other domains than IPA domain found, IPA domain was removed "
"from /etc/sssd/sssd.conf.")
sssd = services.service('sssd', api)
try:
sssd.restart()
except CalledProcessError:
logger.warning("SSSD service restart was unsuccessful.")
# SSSD was not installed before our installation, and no other domains
# than IPA are configured in sssd.conf - make sure config file is removed
elif not was_sssd_installed and not was_sssd_configured \
and os.path.exists(paths.SSSD_CONF):
try:
os.rename(paths.SSSD_CONF, paths.SSSD_CONF_DELETED)
except OSError:
logger.debug("Error while moving /etc/sssd/sssd.conf to %s",
paths.SSSD_CONF_DELETED)
logger.info(
"Redundant SSSD configuration file "
"/etc/sssd/sssd.conf was moved to /etc/sssd/sssd.conf.deleted")
sssd = services.service('sssd', api)
try:
sssd.stop()
except CalledProcessError:
logger.warning("SSSD service could not be stopped")
try:
sssd.disable()
except CalledProcessError as e:
logger.warning(
"Failed to disable automatic startup of the SSSD daemon: %s",
e)
if statestore.has_state('selinux'):
# Restore SELinux boolean states
boolean_states = {name: statestore.restore_state('selinux', name)
for name in constants.SELINUX_BOOLEAN_SSSD}
try:
tasks.set_selinux_booleans(boolean_states)
except SetseboolError as e:
logger.warning("Unable to reset SELinux variable: %s", str(e))
tasks.restore_hostname(fstore, statestore)
if fstore.has_files():
logger.info("Restoring client configuration files")
fstore.restore_all_files()
unconfigure_nisdomain(statestore)
nscd = services.knownservices.nscd
nslcd = services.knownservices.nslcd
for service in (nscd, nslcd):
if service.is_installed():
restore_state(service, statestore)
else:
# this is an optional service, just log
logger.info(
"%s daemon is not installed, skip configuration",
service.service_name
)
restore_time_sync(statestore, fstore)
if was_sshd_configured and services.knownservices.sshd.is_running():
remove_file(paths.SSHD_IPA_CONFIG)
remove_file(paths.SSH_IPA_CONFIG)
services.knownservices.sshd.restart()
# Remove the Firefox configuration
if statestore.has_state('firefox'):
logger.info("Removing Firefox configuration.")
preferences_fname = statestore.restore_state(
'firefox', 'preferences_fname')
if preferences_fname is not None:
if os.path.isfile(preferences_fname):
try:
os.remove(preferences_fname)
except Exception as e:
logger.warning(
"'%s' could not be removed: %s.",
preferences_fname, str(e))
logger.warning(
"Please remove file '%s' manually.", preferences_fname)
rv = SUCCESS
if fstore.has_files():
logger.error('Some files have not been restored, see %s',
paths.SYSRESTORE_INDEX)
statestore.delete_state('installation', 'complete')
has_state = False
for module in statestore.modules:
logger.error(
'Some installation state for %s has not been '
'restored, see /var/lib/ipa/sysrestore/sysrestore.state',
module)
has_state = True
rv = CLIENT_UNINSTALL_ERROR
if has_state:
logger.warning(
'Some installation state has not been restored.\n'
'This may cause re-installation to fail.\n'
'It should be safe to remove %s '
'but it may\n mean your system hasn\'t been restored '
'to its pre-installation state.',
os.path.join(paths.IPA_CLIENT_SYSRESTORE,
sysrestore.SYSRESTORE_STATEFILE)
)
# Remove the IPA configuration file
remove_file(paths.IPA_DEFAULT_CONF)
remove_file(paths.IPA_DEFAULT_CONF + '.ipabkp')
# Remove misc backups
remove_file(paths.OPENLDAP_LDAP_CONF + '.ipabkp')
remove_file(paths.NSSWITCH_CONF + '.ipabkp')
# Remove the CA cert from the systemwide certificate store
tasks.remove_ca_certs_from_systemwide_ca_store()
# Remove the CA cert
remove_file(paths.IPA_CA_CRT)
remove_file(paths.KDC_CA_BUNDLE_PEM)
remove_file(paths.CA_BUNDLE_PEM)
logger.info("Client uninstall complete.")
# The next block of code prompts for reboot, therefore all uninstall
# logic has to be done before
if not options.unattended:
logger.info(
"The original nsswitch.conf configuration has been restored.")
logger.info(
"You may need to restart services or reboot the machine.")
if not options.on_master:
if user_input("Do you want to reboot the machine?", False):
try:
run([paths.SBIN_REBOOT])
except Exception as e:
raise ScriptError(
"Reboot command failed to execute: {}".format(e),
rval=CLIENT_UNINSTALL_ERROR)
# IMPORTANT: Do not put any client uninstall logic after the block above
if rv:
raise ScriptError(rval=rv)
def init(installer):
root_logger = logging.getLogger()
for handler in root_logger.handlers:
if (isinstance(handler, logging.StreamHandler) and
handler.stream is sys.stderr):
installer.debug = handler.level == logging.DEBUG
break
else:
installer.debug = True
installer.unattended = not installer.interactive
if installer.domain_name:
installer.domain = normalize_hostname(installer.domain_name)
else:
installer.domain = None
installer.server = installer.servers
installer.realm = installer.realm_name
installer.primary = installer.fixed_primary
if installer.principal:
installer.password = installer.admin_password
else:
installer.password = installer.host_password
installer.hostname = installer.host_name
installer.conf_ntp = not installer.no_ntp
installer.trust_sshfp = installer.ssh_trust_dns
installer.conf_ssh = not installer.no_ssh
installer.conf_sshd = not installer.no_sshd
installer.conf_sudo = not installer.no_sudo
installer.create_sshfp = not installer.no_dns_sshfp
if installer.ca_cert_files:
installer.ca_cert_file = installer.ca_cert_files[-1]
else:
installer.ca_cert_file = None
installer.location = installer.automount_location
installer.dns_updates = installer.enable_dns_updates
installer.krb5_offline_passwords = not installer.no_krb5_offline_passwords
installer.sssd = not installer.no_sssd
@group
class ClientInstallInterface(hostname_.HostNameInstallInterface,
service.ServiceAdminInstallInterface,
sssd.SSSDInstallInterface):
"""
Interface of the client installer
Knobs defined here will be available in:
* ipa-client-install
* ipa-server-install
* ipa-replica-prepare
* ipa-replica-install
"""
description = "Client"
principal = extend_knob(
service.ServiceAdminInstallInterface.principal,
description="principal to use to join the IPA realm",
)
principal = enroll_only(principal)
host_password = knob(
str, None,
sensitive=True,
)
host_password = enroll_only(host_password)
keytab = knob(
str, None,
description="path to backed up keytab from previous enrollment",
cli_names=[None, '-k'],
)
keytab = enroll_only(keytab)
mkhomedir = knob(
None,
description="create home directories for users on their first login",
)
mkhomedir = enroll_only(mkhomedir)
force_join = knob(
None,
description="Force client enrollment even if already enrolled",
)
force_join = enroll_only(force_join)
ntp_servers = knob(
typing.List[str], None,
description="ntp server to use. This option can be used multiple "
"times",
cli_names='--ntp-server',
cli_metavar='NTP_SERVER',
)
ntp_servers = enroll_only(ntp_servers)
ntp_pool = knob(
str, None,
description="ntp server pool to use",
)
ntp_pool = enroll_only(ntp_pool)
no_ntp = knob(
None,
description="do not configure ntp",
cli_names=[None, '-N'],
)
no_ntp = enroll_only(no_ntp)
force_ntpd = knob(
None, False,
deprecated=True,
description="Stop and disable any time&date synchronization services "
"besides ntpd. This option has been deprecated",
)
force_ntpd = enroll_only(force_ntpd)
nisdomain = knob(
str, None,
description="NIS domain name",
)
nisdomain = enroll_only(nisdomain)
no_nisdomain = knob(
None,
description="do not configure NIS domain name",
)
no_nisdomain = enroll_only(no_nisdomain)
ssh_trust_dns = knob(
None,
description="configure OpenSSH client to trust DNS SSHFP records",
)
ssh_trust_dns = enroll_only(ssh_trust_dns)
no_ssh = knob(
None,
description="do not configure OpenSSH client",
)
no_ssh = enroll_only(no_ssh)
no_sshd = knob(
None,
description="do not configure OpenSSH server",
)
no_sshd = enroll_only(no_sshd)
no_sudo = knob(
None,
description="do not configure SSSD as data source for sudo",
)
no_sudo = enroll_only(no_sudo)
subid = knob(
None,
description="configure SSSD as data source for subid",
)
subid = enroll_only(subid)
no_dns_sshfp = knob(
None,
description="do not automatically create DNS SSHFP records",
)
no_dns_sshfp = enroll_only(no_dns_sshfp)
kinit_attempts = knob(
int, 5,
description="number of attempts to obtain host TGT (defaults to 5).",
)
kinit_attempts = enroll_only(kinit_attempts)
@kinit_attempts.validator
def kinit_attempts(self, value):
if value < 1:
raise ValueError("expects an integer greater than 0.")
request_cert = knob(
None,
deprecated=True,
description="request certificate for the machine",
)
request_cert = prepare_only(request_cert)
def __init__(self, **kwargs):
super(ClientInstallInterface, self).__init__(**kwargs)
if self.servers and not self.domain_name:
raise RuntimeError(
"--server cannot be used without providing --domain")
if self.force_ntpd:
logger.warning(
"Option --force-ntpd has been deprecated and will be "
"removed in a future release."
)
if self.ntp_servers and self.no_ntp:
raise RuntimeError(
"--ntp-server cannot be used together with --no-ntp")
if self.ntp_pool and self.no_ntp:
raise RuntimeError(
"--ntp-pool cannot be used together with --no-ntp")
if self.request_cert:
logger.warning(
"Option --request-cert has been deprecated and will be "
"removed in a future release."
)
if self.no_nisdomain and self.nisdomain:
raise RuntimeError(
"--no-nisdomain cannot be used together with --nisdomain")
if self.ip_addresses:
if self.enable_dns_updates:
raise RuntimeError(
"--ip-address cannot be used together with"
" --enable-dns-updates")
if self.all_ip_addresses:
raise RuntimeError(
"--ip-address cannot be used together with"
"--all-ip-addresses")
@group
class PKINITInstallInterface(service.ServiceInstallInterface):
description = "PKINIT"
pkinit_identity = knob(
type=str,
default=None,
description=(
"PKINIT identity information (for example "
"FILE:/path/to/cert.pem,/path/to/key.pem)"
),
cli_metavar="IDENTITY",
)
@pkinit_identity.validator
def pkinit_identity(self, value):
# see pkinit_crypto_openssl.c:crypto_load_certs()
# ignore "ENV:" prefix
if not value.startswith(
("FILE:", "PKCS11:", "PKCS12:", "DIR:", "ENV:")
):
raise ValueError(
"identity must start with FILE:, PKCS11:, PKCS12:, DIR:, "
"or ENV:"
)
pkinit_anchors = knob(
type=typing.List[str],
default=None,
description=(
"PKINIT trust anchors, prefixed with FILE: for CA PEM bundle "
"file or DIR: for an OpenSSL hash dir. The option can be used "
"used multiple times."
),
cli_names="--pkinit-anchor",
cli_metavar="FILEDIR",
)
@pkinit_anchors.validator
def pkinit_anchors(self, value):
# see pkinit_crypto_openssl.c:crypto_load_cas_and_crls()
for part in value:
prefix, sep, path = part.partition(":")
if not sep or prefix not in {"FILE", "DIR", "ENV:"}:
raise ValueError(
"Invalid pkinit_anchor '{part}' is not prefixed with "
"FILE: or DIR:."
)
if prefix == "FILE" and not os.path.isfile(path):
raise ValueError(
f"pkinit anchor path '{path}' does not exist or is not "
"a file."
)
if prefix == "DIR" and not os.path.isdir(path):
raise ValueError(
f"pkinit anchor path '{path}' does not exist or is not "
"a file."
)
class ClientInstall(ClientInstallInterface,
PKINITInstallInterface,
automount.AutomountInstallInterface):
"""
Client installer
"""
dm_password = None
ca_cert_files = extend_knob(
ClientInstallInterface.ca_cert_files,
)
@ca_cert_files.validator
def ca_cert_files(self, value):
if not isinstance(value, list):
raise ValueError("Expected list, got {!r}".format(value))
# this is what init() does
value = value[-1]
if not os.path.exists(value):
raise ValueError("'%s' does not exist" % value)
if not os.path.isfile(value):
raise ValueError("'%s' is not a file" % value)
if not os.path.isabs(value):
raise ValueError("'%s' is not an absolute file path" % value)
try:
x509.load_certificate_from_file(value)
except Exception:
raise ValueError("'%s' is not a valid certificate file" % value)
@property
def prompt_password(self):
return self.interactive
no_ac = False
force = knob(
None,
description="force setting of LDAP/Kerberos conf",
cli_names=[None, '-f'],
)
on_master = False
configure_firefox = knob(
None,
description="configure Firefox to use IPA domain credentials",
)
firefox_dir = knob(
str, None,
description="specify directory where Firefox is installed (for "
"example: '/usr/lib/firefox')",
)
def __init__(self, **kwargs):
super(ClientInstall, self).__init__(**kwargs)
if self.firefox_dir and not self.configure_firefox:
raise RuntimeError(
"--firefox-dir cannot be used without --configure-firefox "
"option")
@step()
def main(self):
init(self)
install_check(self)
yield
install(self)
@main.uninstaller
def main(self):
init(self)
uninstall_check(self)
yield
uninstall(self)
| 144,598
|
Python
|
.py
| 3,568
| 29.922365
| 80
| 0.593219
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,093
|
ipachangeconf.py
|
freeipa_freeipa/ipaclient/install/ipachangeconf.py
|
#
# ipachangeconf - configuration file manipulation classes and functions
# partially based on authconfig code
# Copyright (c) 1999-2007 Red Hat, Inc.
# Author: Simo Sorce <ssorce@redhat.com>
#
# 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/>.
#
import warnings
from ipapython.ipachangeconf import IPAChangeConf as realIPAChangeConf
class IPAChangeConf(realIPAChangeConf):
"""Advertise the old name"""
def __init__(self, name):
"""something"""
warnings.warn(
"Use 'ipapython.ipachangeconf.IPAChangeConfg'",
DeprecationWarning,
stacklevel=2
)
super(IPAChangeConf, self).__init__(name)
| 1,248
|
Python
|
.py
| 31
| 36.677419
| 71
| 0.741962
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,094
|
automount.py
|
freeipa_freeipa/ipaclient/install/automount.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
"""
Automount installer module
"""
from ipalib.install import service
from ipalib.install.service import enroll_only
from ipapython.install.core import group, knob
@group
class AutomountInstallInterface(service.ServiceInstallInterface):
"""
Interface of the automount installer
Knobs defined here will be available in:
* ipa-client-install
* ipa-client-automount
"""
description = "Automount"
automount_location = knob(
str, None,
description="Automount location",
)
automount_location = enroll_only(automount_location)
| 653
|
Python
|
.py
| 23
| 24.695652
| 66
| 0.753205
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,095
|
ipa_epn.py
|
freeipa_freeipa/ipaclient/install/ipa_epn.py
|
#
# Copyright (C) 2020 FreeIPA Contributors see COPYING for license
#
# 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/>.
"""This tool prepares then sends email notifications to users
whose passwords are expiring in the near future.
"""
from __future__ import absolute_import, print_function
import ast
import grp
import json
import os
import pwd
import logging
import smtplib
import ssl
import time
from collections import deque
from datetime import datetime, timedelta, timezone
UTC = timezone.utc
from email.utils import formataddr, formatdate
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email.utils import make_msgid
from socket import error as socketerror
from ipaplatform.paths import paths
from ipalib import api, errors
from ipalib.facts import is_ipa_client_configured
from ipapython import admintool, ipaldap
from ipapython.dn import DN
from jinja2 import Environment, FileSystemLoader, TemplateSyntaxError
EPN_CONF = "/etc/ipa/epn.conf"
EPN_CONFIG = {
"smtp_server": "localhost",
"smtp_port": 25,
"smtp_user": None,
"smtp_password": None,
"smtp_client_cert": None,
"smtp_client_key": None,
"smtp_client_key_pass": None,
"smtp_timeout": 60,
"smtp_security": "none",
"smtp_admin": "root@localhost",
"smtp_delay": None,
"mail_from": None,
"mail_from_name": "IPA-EPN",
"notify_ttls": "28,14,7,3,1",
"msg_charset": "utf8",
"msg_subtype": "plain",
"msg_subject": "Your password will expire soon.",
}
logger = logging.getLogger(__name__)
def drop_privileges(new_username="daemon", new_groupname="daemon"):
"""Drop privileges, defaults to daemon:daemon.
"""
try:
if os.getuid() != 0:
return
os.setgroups([])
os.setgid(pwd.getpwnam(new_username).pw_uid)
os.setuid(grp.getgrnam(new_groupname).gr_gid)
if os.getuid() == 0:
raise errors.RequiresRoot("Cannot drop privileges!")
logger.debug(
"Dropped privileges to user=%s, group=%s",
new_username,
new_groupname,
)
except Exception as e:
logger.error(
"Failed to drop privileges to %s, %s: %s",
new_username,
new_groupname,
e,
)
class EPNUserList:
"""Maintains a list of users whose passwords are expiring.
Provides add(), check(), pop(), and json_print().
From the outside, the list is considered always sorted:
* displaying the list results in a sorted JSON representation thereof
* pop() returns the "most urgent" item from the list.
Internal implementation notes:
* Uses a deque instead of a list for efficiency reasons
* all add()-style methods MUST set _sorted to False.
* all print() and pop-like methods MUST call _sort() first.
"""
def __init__(self):
self._sorted = False
self._expiring_password_user_dq = deque()
def __bool__(self):
"""If it quacks like a container...
"""
return bool(self._expiring_password_user_dq)
def __len__(self):
"""Return len(self)."""
return len(self._expiring_password_user_dq)
def get_ldap_attr(self, entry, attr):
"""Get a single value from a multi-valued attr in a safe way"""
return str(entry.get(attr, [""]).pop(0))
def add(self, entry):
"""Parses and appends an LDAP user entry with the uid, cn,
givenname, sn, krbpasswordexpiration and mail attributes.
"""
try:
self._sorted = False
if entry.get("mail") is None:
logger.error("IPA-EPN: No mail address defined for: %s",
entry.dn)
return
self._expiring_password_user_dq.append(
dict(
uid=self.get_ldap_attr(entry, "uid"),
cn=self.get_ldap_attr(entry, "cn"),
givenname=self.get_ldap_attr(entry, "givenname"),
sn=self.get_ldap_attr(entry, "sn"),
krbpasswordexpiration=(
self.get_ldap_attr(entry,"krbpasswordexpiration")
),
mail=str(entry.get("mail")),
)
)
except IndexError as e:
logger.info("IPA-EPN: Could not parse entry: %s", e)
def pop(self):
"""Returns the "most urgent" user to notify.
In fact: popleft()
"""
self._sort()
try:
return self._expiring_password_user_dq.popleft()
except IndexError:
return False
def check(self):
self.json_print(really_print=False)
def json_print(self, really_print=True):
"""Dump self._expiring_password_user_dq to JSON.
Check that the result can be re-rencoded to UTF-8.
If really_print, print the result.
"""
try:
self._sort()
temp_str = json.dumps(
list(self._expiring_password_user_dq),
indent=4,
ensure_ascii=False,
)
temp_str.encode("utf8")
if really_print:
print(temp_str)
except Exception as e:
logger.error("IPA-EPN: unexpected error: %s", e)
def _sort(self):
if not self._sorted:
if isinstance(self._expiring_password_user_dq, deque):
self._expiring_password_user_dq = deque(
sorted(
self._expiring_password_user_dq,
key=lambda item: item["krbpasswordexpiration"],
)
)
self._sorted = True
class EPN(admintool.AdminTool):
command_name = "IPA-EPN"
log_file_name = paths.IPAEPN_LOG
usage = "%prog [options]"
description = "Expiring Password Notifications (EPN)"
def __init__(self, options, args):
super(EPN, self).__init__(options, args)
self._conn = None
self._ssl_context = None
self._expiring_password_user_list = EPNUserList()
self._ldap_data = []
self._date_ranges = []
self._mailer = None
self.env = None
self.default_email_domain = None
@classmethod
def add_options(cls, parser):
super(EPN, cls).add_options(parser, debug_option=True)
parser.add_option(
"--from-nbdays",
dest="from_nbdays",
action="store",
default=None,
help="minimal number of days",
)
parser.add_option(
"--to-nbdays",
dest="to_nbdays",
action="store",
default=None,
help="maximal number of days",
)
parser.add_option(
"--dry-run",
dest="dry_run",
action="store_true",
default=False,
help="Dry run mode. JSON ouput only.",
)
parser.add_option(
"--mail-test",
dest="mailtest",
action="store_true",
default=False,
help="Send a test e-mail",
)
def validate_options(self):
super(EPN, self).validate_options(needs_root=True)
if self.options.to_nbdays is not None:
try:
if int(self.options.to_nbdays) < 0:
raise RuntimeError('Input is negative.')
except Exception as e:
self.option_parser.error(
"--to-nbdays must be a positive integer. "
"{error}".format(error=e)
)
self.options.dry_run = True
if self.options.from_nbdays is not None:
try:
if int(self.options.from_nbdays) < 0:
raise RuntimeError('Input is negative.')
except Exception as e:
self.option_parser.error(
"--from-nbdays must be a positive integer. "
"{error}".format(error=e)
)
if self.options.from_nbdays is not None and \
self.options.to_nbdays is not None:
if int(self.options.from_nbdays) >= int(self.options.to_nbdays):
self.option_parser.error(
"--from-nbdays must be smaller than --to-nbdays."
)
if self.options.from_nbdays is not None and \
self.options.to_nbdays is None:
self.option_parser.error(
"You cannot specify --from-nbdays without --to-nbdays"
)
if self.options.mailtest and self.options.dry_run:
self.option_parser.error(
"You cannot specify --mail-test and --dry-run together"
)
def setup_logging(self, log_file_mode="a"):
super(EPN, self).setup_logging(log_file_mode="a")
def run(self):
super(EPN, self).run()
if not is_ipa_client_configured():
logger.error("IPA client is not configured on this system.")
raise admintool.ScriptError()
# tasks required privileges
self._get_krb5_ticket()
self._read_configuration()
self._validate_configuration()
self._parse_configuration()
self._get_connection()
self._read_ipa_configuration()
self._create_ssl_context()
drop_privileges()
if self.options.mailtest:
self._gentestdata()
else:
if self.options.to_nbdays:
self._build_cli_date_ranges()
for date_range in self._date_ranges:
self._fetch_data_from_ldap(date_range)
self._parse_ldap_data()
if self.options.dry_run:
self._pretty_print_data()
else:
self._mailer = MailUserAgent(
security_protocol=api.env.smtp_security,
smtp_hostname=api.env.smtp_server,
smtp_port=api.env.smtp_port,
smtp_timeout=api.env.smtp_timeout,
smtp_username=api.env.smtp_user,
smtp_password=api.env.smtp_password,
ssl_context=self._ssl_context,
x_mailer=self.command_name,
msg_subtype=api.env.msg_subtype,
msg_charset=api.env.msg_charset,
)
self._send_emails()
def _get_date_range_from_nbdays(self, nbdays_end, nbdays_start=None):
"""Detects current time and returns a date range, given a number
of days in the future.
If only nbdays_end is specified, the range is 1d long.
"""
now = datetime.now(tz=UTC)
today_at_midnight = datetime.combine(now, datetime.min.time())
range_end = today_at_midnight + timedelta(days=nbdays_end)
if nbdays_start is not None:
range_start = today_at_midnight + timedelta(days=nbdays_start)
else:
range_start = range_end - timedelta(days=1)
logger.debug(
"IPA-EPN: Current date: %s \n"
"IPA-EPN: Date & time, today at midnight: %s \n"
"IPA-EPN: Date range start: %s \n"
"IPA-EPN: Date range end: %s \n",
now,
today_at_midnight,
range_start,
range_end,
)
return (range_start, range_end)
def _datetime_to_generalized_time(self, dt):
"""Convert datetime to LDAP_GENERALIZED_TIME_FORMAT
Note: Consider moving into ipalib.
"""
dt = dt.timetuple()
generalized_time_str = str(dt.tm_year) + "".join(
"0" * (2 - len(str(item))) + str(item)
for item in (
dt.tm_mon,
dt.tm_mday,
dt.tm_hour,
dt.tm_min,
dt.tm_sec,
)
)
return generalized_time_str + "Z"
def _get_krb5_ticket(self):
"""Setup the environment to obtain a krb5 ticket for us using the
system keytab.
Uses CCACHE = MEMORY (limited to the current process).
"""
os.environ.setdefault("KRB5_CLIENT_KTNAME", "/etc/krb5.keytab")
os.environ["KRB5CCNAME"] = "MEMORY:"
def _read_configuration(self):
"""Merge in the EPN configuration from /etc/ipa/epn.conf"""
base_config = dict(
context="epn", confdir=paths.ETC_IPA, in_server=False,
)
api.bootstrap(**base_config)
api.env._merge(**EPN_CONFIG)
if not api.isdone("finalize"):
api.finalize()
def _validate_configuration(self):
"""Examine the user-provided configuration.
"""
if api.env.smtp_security.lower() not in ("none", "starttls", "ssl"):
raise RuntimeError(
"smtp_security must be one of: none, starttls or ssl"
)
if api.env.smtp_user is not None and api.env.smtp_password is None:
raise RuntimeError("smtp_user set and smtp_password is not")
if api.env.notify_ttls is None:
raise RuntimeError("notify_ttls must be set in %s" % EPN_CONF)
try:
[int(k) for k in str(api.env.notify_ttls).split(',')]
except ValueError as e:
raise RuntimeError('Failed to parse notify_ttls: \'%s\': %s' %
(api.env.notify_ttls, e))
if api.env.smtp_delay:
try:
float(api.env.smtp_delay)
except ValueError as e:
raise RuntimeError('smtp_delay is misformatted: %s' % e)
if float(api.env.smtp_delay) < 0:
raise RuntimeError('smtp_delay cannot be less than zero')
def _parse_configuration(self):
"""
"""
daylist = [int(k) for k in str(api.env.notify_ttls).split(',')]
daylist.sort()
for day in daylist:
self._date_ranges.append(
self._get_date_range_from_nbdays(
nbdays_start=None, nbdays_end=day + 1
)
)
loader = FileSystemLoader(os.path.join(api.env.confdir, 'epn'))
self.env = Environment(loader=loader)
def _read_ipa_configuration(self):
"""Get the IPA configuration"""
api.Backend.rpcclient.connect()
result = api.Command.config_show()['result']
self.default_email_domain = result.get('ipadefaultemaildomain',
[None])[0]
api.Backend.rpcclient.disconnect()
def _get_connection(self):
"""Create a connection to LDAP and bind to it.
"""
if self._conn is not None:
return self._conn
try:
# LDAPI
self._conn = ipaldap.LDAPClient.from_realm(api.env.realm)
self._conn.external_bind()
except Exception:
try:
# LDAP + GSSAPI
self._conn = ipaldap.LDAPClient.from_hostname_secure(
api.env.server
)
self._conn.gssapi_bind()
except Exception as e:
logger.error(
"Unable to bind to LDAP server %s: %s",
self._conn.ldap_uri,
e,
)
return self._conn
def _create_ssl_context(self):
"""Create SSL context.
This must be done before the dropping priviliges to allow
read in the smtp client's certificate and private key if specified.
"""
if api.env.smtp_security.lower() in ("starttls", "ssl"):
self._ssl_context = ssl.create_default_context()
if api.env.smtp_client_cert:
self._ssl_context.load_cert_chain(
certfile=api.env.smtp_client_cert,
keyfile=api.env.smtp_client_key,
password=str(api.env.smtp_client_key_pass),
)
def _fetch_data_from_ldap(self, date_range):
"""Run a LDAP query to fetch a list of user entries whose passwords
would expire in the near future. Store in self._ldap_data.
"""
if self._conn is None:
logger.error(
"IPA-EPN: Connection to LDAP not established. Exiting."
)
search_base = DN(api.env.container_user, api.env.basedn)
attrs_list = ["uid", "krbpasswordexpiration", "mail", "cn",
"givenname", "surname"]
search_filter = (
"(&(!(nsaccountlock=TRUE)) \
(krbpasswordexpiration<=%s) \
(krbpasswordexpiration>=%s))"
% (
self._datetime_to_generalized_time(date_range[1]),
self._datetime_to_generalized_time(date_range[0]),
)
)
try:
self._ldap_data = self._conn.get_entries(
search_base,
filter=search_filter,
attrs_list=attrs_list,
scope=self._conn.SCOPE_SUBTREE,
)
except errors.EmptyResult:
logger.debug("Empty Result.")
finally:
logger.debug("%d entries found", len(self._ldap_data))
def _parse_ldap_data(self):
"""Fill out self._expiring_password_user_list from data from ldap.
"""
if self._ldap_data:
for entry in self._ldap_data:
self._expiring_password_user_list.add(entry)
# Validate json.
try:
self._pretty_print_data(really_print=False)
except Exception as e:
logger.error("IPA-EPN: Could not create JSON: %s", e)
finally:
self._ldap_data = []
def _pretty_print_data(self, really_print=True):
"""Dump self._expiring_password_user_list to JSON.
"""
self._expiring_password_user_list.json_print(
really_print=really_print
)
def _send_emails(self):
if self._mailer is None:
logger.error("IPA-EPN: mailer was not configured.")
return
else:
try:
template = self.env.get_template("expire_msg.template")
except TemplateSyntaxError as e:
raise RuntimeError("Parsing template %s failed: %s" %
(e.filename, e))
if api.env.mail_from:
mail_from = api.env.mail_from
else:
mail_from = "noreply@%s" % self.default_email_domain
while self._expiring_password_user_list:
entry = self._expiring_password_user_list.pop()
body = template.render(
uid=entry["uid"],
first=entry["givenname"],
last=entry["sn"],
fullname=entry["cn"],
expiration=entry["krbpasswordexpiration"],
)
self._mailer.send_message(
mail_subject=api.env.msg_subject,
mail_body=body,
subscribers=ast.literal_eval(entry["mail"]),
mail_from=mail_from,
mail_from_name=api.env.mail_from_name,
)
now = datetime.now(tz=UTC)
expdate = datetime.strptime(
entry["krbpasswordexpiration"],
'%Y-%m-%d %H:%M:%S').replace(tzinfo=UTC)
logger.debug(
"Notified %s (%s). Password expiring in %d days at %s.",
entry["mail"], entry["uid"], (expdate - now).days,
expdate)
if api.env.smtp_delay:
time.sleep(float(api.env.smtp_delay) / 1000)
self._mailer.cleanup()
def _gentestdata(self):
"""Generate a sample user to process through the template.
"""
expdate = datetime.now(tz=UTC).strftime('%Y-%m-%d %H:%M:%S')
entry = dict(
uid=["SAUSER"],
cn=["SAMPLE USER"],
givenname=["SAMPLE"],
sn=["USER"],
krbpasswordexpiration=[expdate],
mail=[api.env.smtp_admin],
)
self._expiring_password_user_list.add(entry)
def _build_cli_date_ranges(self):
"""When self.options.to_nbdays is set, override the date ranges read
from the configuration file and build the date ranges from the CLI
options.
"""
self._date_ranges = []
logger.debug("IPA-EPN: Ignoring configuration file ranges.")
if self.options.from_nbdays is not None:
self._date_ranges.append(
self._get_date_range_from_nbdays(
nbdays_start=int(self.options.from_nbdays),
nbdays_end=int(self.options.to_nbdays),
)
)
elif self.options.to_nbdays is not None:
self._date_ranges.append(
self._get_date_range_from_nbdays(
nbdays_start=None, nbdays_end=int(self.options.to_nbdays)
)
)
class MTAClient:
"""MTA Client class. Originally done for EPN.
"""
def __init__(
self,
security_protocol="none",
smtp_hostname="localhost",
smtp_port=25,
smtp_timeout=60,
smtp_username=None,
smtp_password=None,
ssl_context=None,
):
self._security_protocol = security_protocol
self._smtp_hostname = smtp_hostname
self._smtp_port = smtp_port
self._smtp_timeout = smtp_timeout
self._username = smtp_username
self._password = smtp_password
self._ssl_context = ssl_context
# This should not be touched
self._conn = None
if (
self._security_protocol == "none"
and "localhost" not in self._smtp_hostname
):
logger.error(
"IPA-EPN: using cleartext for non-localhost SMTPd "
"is not supported."
)
self._connect()
def cleanup(self):
self._disconnect()
def send_message(self, message_str=None, subscribers=None):
result = None
try:
result = self._conn.sendmail(
api.env.smtp_admin, subscribers, message_str,
)
except Exception as e:
logger.info("IPA-EPN: Failed to send mail: %s", e)
finally:
if result:
for key in result:
logger.info(
"IPA-EPN: Failed to send mail to '%s': %s %s",
key,
result[key][0],
result[key][1],
)
logger.info(
"IPA-EPN: Failed to send mail to at least one recipient"
)
def _connect(self):
try:
if self._security_protocol.lower() in ["none", "starttls"]:
self._conn = smtplib.SMTP(
host=self._smtp_hostname,
port=self._smtp_port,
timeout=self._smtp_timeout,
)
else:
self._conn = smtplib.SMTP_SSL(
host=self._smtp_hostname,
port=self._smtp_port,
timeout=self._smtp_timeout,
context=self._ssl_context,
)
except (socketerror, smtplib.SMTPException) as e:
msg = \
"IPA-EPN: Could not connect to the configured SMTP server: " \
"{host}:{port}: {error}".format(
host=self._smtp_hostname,
port=self._smtp_port,
error=e
)
raise admintool.ScriptError(msg)
try:
self._conn.ehlo()
except smtplib.SMTPException as e:
logger.error(
"IPA-EPN: EHLO failed for host %s:%s: %s",
self._smtp_hostname,
self._smtp_port,
e,
)
if self._security_protocol.lower() == "starttls":
try:
self._conn.starttls(context=self._ssl_context)
self._conn.ehlo()
except smtplib.SMTPException as e:
raise RuntimeError(
"IPA-EPN: Unable to create an encrypted session to "
"%s:%s: %s" % (self._smtp_hostname, self._smtp_port, e)
)
if self._username and self._password:
if self._conn.has_extn("AUTH"):
try:
self._conn.login(self._username, self._password)
if self._security_protocol == "none":
logger.warning(
"IPA-EPN: Username and Password "
"were sent in the clear."
)
except smtplib.SMTPAuthenticationError:
raise RuntimeError(
"IPA-EPN: Authentication to %s:%s failed, "
"please check your username and/or password:" %
(self._smtp_hostname,
self._smtp_port,)
)
except smtplib.SMTPException as e:
raise RuntimeError(
"IPA-EPN: SMTP Error at %s:%s:%s" %
(self._smtp_hostname,
self._smtp_port,
e,)
)
else:
err_str = (
"IPA-EPN: Server at %s:%s "
"does not support authentication." %
(self._smtp_hostname,
self._smtp_port,)
)
logger.error(err_str)
def _disconnect(self):
self._conn.quit()
class MailUserAgent:
"""The MUA class for EPN.
"""
def __init__(
self,
security_protocol="none",
smtp_hostname="localhost",
smtp_port=25,
smtp_timeout=60,
smtp_username=None,
smtp_password=None,
ssl_context=None,
x_mailer=None,
msg_subtype="plain",
msg_charset="utf8",
):
self._x_mailer = x_mailer
self._subject = None
self._body = None
self._subscribers = None
self._subtype = msg_subtype
self._charset = msg_charset
self._msg = None
self._message_str = None
self._mta_client = MTAClient(
security_protocol=security_protocol,
smtp_hostname=smtp_hostname,
smtp_port=smtp_port,
smtp_timeout=smtp_timeout,
smtp_username=smtp_username,
smtp_password=smtp_password,
ssl_context=ssl_context,
)
def cleanup(self):
self._mta_client.cleanup()
def send_message(
self, mail_subject=None, mail_body=None, subscribers=None,
mail_from=None, mail_from_name=None
):
"""Given mail_subject, mail_body, and subscribers, composes
the message and sends it.
"""
if None in [mail_subject, mail_body, subscribers,
mail_from, mail_from_name]:
logger.error("IPA-EPN: Tried to send an empty message.")
return False
self._compose_message(
mail_subject=mail_subject,
mail_body=mail_body,
subscribers=subscribers,
mail_from=mail_from,
mail_from_name=mail_from_name,
)
self._mta_client.send_message(
message_str=self._message_str, subscribers=subscribers
)
return True
def _compose_message(
self, mail_subject, mail_body, subscribers,
mail_from, mail_from_name
):
"""The composer creates a MIME multipart message.
"""
self._subject = mail_subject
self._body = mail_body
self._subscribers = subscribers
self._msg = MIMEMultipart(_charset=self._charset)
self._msg["From"] = formataddr((mail_from_name, mail_from))
self._msg["To"] = ", ".join(self._subscribers)
self._msg["Date"] = formatdate(localtime=True)
self._msg["Subject"] = Header(self._subject, self._charset)
self._msg["Message-Id"] = make_msgid()
self._msg.preamble = "Multipart message"
if "X-Mailer" not in self._msg and self._x_mailer:
self._msg.add_header("X-Mailer", self._x_mailer)
self._msg.attach(
MIMEText(
self._body + "\n\n",
_subtype=self._subtype,
_charset=self._charset,
)
)
self._message_str = self._msg.as_string()
| 29,521
|
Python
|
.py
| 764
| 26.680628
| 78
| 0.540917
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,096
|
ipadiscovery.py
|
freeipa_freeipa/ipaclient/install/ipadiscovery.py
|
#
# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
#
import warnings
from ipaclient.discovery import (
NOT_FQDN, NO_LDAP_SERVER, REALM_NOT_FOUND, NOT_IPA_SERVER,
NO_ACCESS_TO_LDAP, NO_TLS_LDAP, BAD_HOST_CONFIG,
UNKNOWN_ERROR, IPA_BASEDN_INFO, error_names, get_ipa_basedn,
IPADiscovery
)
__all__ = (
'NOT_FQDN', 'NO_LDAP_SERVER', 'REALM_NOT_FOUND',
'NOT_IPA_SERVER', 'NO_ACCESS_TO_LDAP', 'NO_TLS_LDAP',
'BAD_HOST_CONFIG', 'UNKNOWN_ERROR', 'IPA_BASEDN_INFO',
'error_names', 'get_ipa_basedn', 'IPADiscovery')
warnings.warn(
"ipaclient.install.ipadiscovery is deprecated, use ipaclient.discovery",
DeprecationWarning
)
| 677
|
Python
|
.py
| 19
| 32.315789
| 76
| 0.714067
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,097
|
sssd.py
|
freeipa_freeipa/ipaclient/install/sssd.py
|
#
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
#
from ipalib.install import service
from ipalib.install.service import enroll_only
from ipapython.install.core import group, knob
@group
class SSSDInstallInterface(service.ServiceInstallInterface):
description = "SSSD"
fixed_primary = knob(
None,
description="Configure sssd to use fixed server as primary IPA server",
)
fixed_primary = enroll_only(fixed_primary)
permit = knob(
None,
description="disable access rules by default, permit all access.",
)
permit = enroll_only(permit)
enable_dns_updates = knob(
None,
description="Configures the machine to attempt dns updates when the "
"ip address changes.",
)
enable_dns_updates = enroll_only(enable_dns_updates)
no_krb5_offline_passwords = knob(
None,
description="Configure SSSD not to store user password when the "
"server is offline",
)
no_krb5_offline_passwords = enroll_only(no_krb5_offline_passwords)
preserve_sssd = knob(
None,
description="Preserve old SSSD configuration if possible",
)
preserve_sssd = enroll_only(preserve_sssd)
no_sssd = False
| 1,275
|
Python
|
.py
| 37
| 28.135135
| 79
| 0.685924
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,098
|
ipa_certupdate.py
|
freeipa_freeipa/ipaclient/install/ipa_certupdate.py
|
# Authors: Jan Cholasta <jcholast@redhat.com>
#
# Copyright (C) 2014 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/>.
#
from __future__ import absolute_import
import logging
import os
from urllib.parse import urlsplit
from ipalib.install import certmonger, certstore
from ipalib.facts import is_ipa_configured
from ipapython import admintool, certdb, ipaldap, ipautil
from ipaplatform import services
from ipaplatform.paths import paths
from ipaplatform.tasks import tasks
from ipalib import api, errors, x509
from ipalib.constants import FQDN, IPA_CA_NICKNAME, RENEWAL_CA_NAME
from ipalib.util import check_client_configuration
logger = logging.getLogger(__name__)
class CertUpdate(admintool.AdminTool):
command_name = 'ipa-certupdate'
usage = "%prog [options]"
description = ("Update local IPA certificate databases with certificates "
"from the server.")
def validate_options(self):
super(CertUpdate, self).validate_options(needs_root=True)
def run(self):
check_client_configuration()
old_krb5ccname = os.environ.get('KRB5CCNAME')
os.environ['KRB5_CLIENT_KTNAME'] = '/etc/krb5.keytab'
os.environ['KRB5CCNAME'] = "MEMORY:"
try:
api.bootstrap(context='cli_installer', confdir=paths.ETC_IPA)
api.finalize()
api.Backend.rpcclient.connect()
run_with_args(api)
api.Backend.rpcclient.disconnect()
except errors.CCacheError:
logger.error(
"Unable to obtain credentials for %s from /etc/krb5.keytab",
FQDN
)
raise
finally:
if old_krb5ccname is None:
os.environ.pop('KRB5CCNAME', None)
else:
os.environ['KRB5CCNAME'] = old_krb5ccname
def run_with_args(api):
"""
Run the certupdate procedure with the given API object.
:param api: API object with ldap2/rpcclient backend connected
(such that Commands can be invoked)
"""
server = urlsplit(api.env.jsonrpc_uri).hostname
ldap = ipaldap.LDAPClient.from_hostname_secure(server)
try:
result = api.Command.ca_is_enabled(version=u'2.107')
ca_enabled = result['result']
except (errors.CommandError, errors.NetworkError):
result = api.Command.env(server=True, version=u'2.0')
ca_enabled = result['result']['enable_ra']
ldap.gssapi_bind()
certs = certstore.get_ca_certs(
ldap, api.env.basedn, api.env.realm, ca_enabled)
if ca_enabled:
lwcas = api.Command.ca_find()['result']
else:
lwcas = []
# update client certs before KDC and HTTPd are restarted.
update_client(certs)
if is_ipa_configured():
# look up CA servers before service restarts
resp = api.Command.server_role_find(
role_servrole=u'CA server',
status='enabled',
)
ca_servers = [server['server_server'] for server in resp['result']]
update_server(certs)
# pylint: disable=ipa-forbidden-import
from ipaserver.install import cainstance, custodiainstance
# pylint: enable=ipa-forbidden-import
# Add LWCA tracking requests. Only execute if *this server*
# has CA installed (ca_enabled indicates CA-ful topology).
if cainstance.CAInstance().is_configured():
try:
cainstance.add_lightweight_ca_tracking_requests(lwcas)
except Exception:
logger.exception(
"Failed to add lightweight CA tracking requests")
try:
update_server_ra_config(
cainstance, custodiainstance,
api.env.enable_ra, api.env.ca_host, ca_servers,
)
except Exception:
logger.exception("Failed to update RA config")
# update_server_ra_config possibly updated default.conf;
# restart httpd to pick up changes.
if services.knownservices.httpd.is_running():
services.knownservices.httpd.restart()
# update_client() may have updated KDC cert bundle; restart KDC to pick
# up changes.
if services.knownservices.krb5kdc.is_running():
services.knownservices.krb5kdc.restart()
def update_client(certs):
update_file(paths.IPA_CA_CRT, certs)
update_file(paths.KDC_CA_BUNDLE_PEM, certs)
update_file(paths.CA_BUNDLE_PEM, certs)
ipa_db = certdb.NSSDatabase(api.env.nss_dir)
# Remove old IPA certs from /etc/ipa/nssdb
for nickname in ('IPA CA', 'External CA cert'):
while ipa_db.has_nickname(nickname):
try:
ipa_db.delete_cert(nickname)
except ipautil.CalledProcessError as e:
logger.error(
"Failed to remove %s from %s: %s",
nickname, ipa_db.secdir, e)
break
update_db(ipa_db.secdir, certs)
tasks.remove_ca_certs_from_systemwide_ca_store()
tasks.insert_ca_certs_into_systemwide_ca_store(certs)
def update_server(certs):
instance = '-'.join(api.env.realm.split('.'))
update_db(paths.ETC_DIRSRV_SLAPD_INSTANCE_TEMPLATE % instance, certs)
if services.knownservices.dirsrv.is_running():
services.knownservices.dirsrv.restart(instance)
criteria = {
'cert-database': paths.PKI_TOMCAT_ALIAS_DIR,
'cert-nickname': IPA_CA_NICKNAME,
'ca-name': RENEWAL_CA_NAME,
}
request_id = certmonger.get_request_id(criteria)
if request_id is not None:
timeout = api.env.startup_timeout + 60
# The dogtag-ipa-ca-renew-agent-reuse Certmonger CA never
# actually renews the certificate; it only pulls it from the
# ca_renewal LDAP cert store.
#
# Why is this needed? If the CA cert gets renewed long
# before its notAfter (expiry) date (e.g. to switch from
# self-signed to external, or to switch to new external CA),
# then the other (i.e. not caRenewalMaster) CA replicas will
# not promptly pick up the new CA cert. So we make
# ipa-certupdate always check for an updated CA cert.
#
logger.debug("resubmitting certmonger request '%s'", request_id)
certmonger.resubmit_request(
request_id, ca='dogtag-ipa-ca-renew-agent-reuse')
try:
state = certmonger.wait_for_request(request_id, timeout)
except RuntimeError:
raise admintool.ScriptError(
"Resubmitting certmonger request '%s' timed out, "
"please check the request manually" % request_id)
ca_error = certmonger.get_request_value(request_id, 'ca-error')
if state != 'MONITORING' or ca_error:
raise admintool.ScriptError(
"Error resubmitting certmonger request '%s', "
"please check the request manually" % request_id)
logger.debug("modifying certmonger request '%s'", request_id)
certmonger.modify(request_id, ca='dogtag-ipa-ca-renew-agent')
update_file(paths.CA_CRT, certs)
update_file(paths.CACERT_PEM, certs)
def update_server_ra_config(
cainstance, custodiainstance,
enable_ra, ca_host, ca_servers,
):
"""
After promoting a CA-less deployment to CA-ful, or after removal
of a CA server from the topology, it may be necessary to update
the default.conf ca_host setting on non-CA replicas.
"""
if len(ca_servers) == 0:
return # nothing to do
# In case ca_host setting is not valid, select a new ca_host.
# Just choose the first server. (Choosing a server in the same
# location might be better, but we should only incur that
# complexity if a need is proven).
new_ca_host = ca_servers[0]
if not enable_ra:
# RA is not enabled, but deployment is CA-ful.
# Retrieve IPA RA credential and update ipa.conf.
cainstance.CAInstance.configure_certmonger_renewal_helpers()
custodia = custodiainstance.CustodiaInstance(
host_name=api.env.host,
realm=api.env.realm,
custodia_peer=new_ca_host,
)
cainstance.import_ra_key(custodia)
cainstance.update_ipa_conf(new_ca_host)
elif ca_host not in ca_servers:
# RA is enabled but ca_host is not among the deployment's
# CA servers. Set a valid ca_host.
cainstance.update_ipa_conf(new_ca_host)
def update_file(filename, certs, mode=0o644):
certs = (c[0] for c in certs if c[2] is not False)
try:
x509.write_certificate_list(certs, filename, mode=mode)
except Exception as e:
logger.error("failed to update %s: %s", filename, e)
def update_db(path, certs):
"""Drop all CA certs from db then add certs from list provided
This may result in some churn as existing certs are dropped
and re-added but this also provides the ability to change
the trust flags.
"""
db = certdb.NSSDatabase(path)
for name, flags in db.list_certs():
if flags.ca:
db.delete_cert(name)
for cert, nickname, trusted, eku in certs:
trust_flags = certstore.key_policy_to_trust_flags(trusted, True, eku)
try:
db.add_cert(cert, nickname, trust_flags)
except ipautil.CalledProcessError as e:
logger.error("failed to update %s in %s: %s", nickname, path, e)
| 10,107
|
Python
|
.py
| 231
| 35.683983
| 79
| 0.660185
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|
17,099
|
timeconf.py
|
freeipa_freeipa/ipaclient/install/timeconf.py
|
# Authors: Karl MacMillan <kmacmillan@redhat.com>
#
# Copyright (C) 2007 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/>.
#
from __future__ import absolute_import
import logging
import os
import shutil
from augeas import Augeas
from ipalib import api
from ipapython import ipautil
from ipaplatform.tasks import tasks
from ipaplatform import services
from ipaplatform.paths import paths
from ipapython.ipautil import user_input
logger = logging.getLogger(__name__)
def __backup_config(path, fstore=None):
if fstore:
fstore.backup_file(path)
else:
shutil.copy(path, "%s.ipasave" % (path))
def get_time_source():
"""
While in interactive installation user has to specify NTP server or pool
to be used in chrony configuration. This method asks user input on these
values in case that they were not specified before installation start.
"""
ntp_servers = []
ntp_pool = ""
if ipautil.user_input("Do you want to configure chrony "
"with NTP server or pool address?", False):
servers = user_input("Enter NTP source server addresses separated by "
"comma, or press Enter to skip", allow_empty=True)
if servers: # if user input is not '' (empty)
logger.debug("User provided NTP server(s):")
# cut possible multiple servers separated by comma into list
for server in servers.split(","):
# users tend to separate servers by ", " so strip() whitespaces
server = server.strip()
ntp_servers.append(server)
logger.debug("\t%s", server)
ntp_pool = user_input("Enter a NTP source pool address, "
"or press Enter to skip", allow_empty=True)
if ntp_pool: # if user input is not '' (empty)
logger.debug("User provided NTP pool:\t%s", ntp_pool)
return ntp_servers, ntp_pool
def sync_chrony():
"""
This method enables chronyd service on boot and restarts it to reload
chrony configuration file /etc/chrony.conf
Then it tries to synchronize time with chrony's new or defaut configuration
"""
# Set the chronyd to start on boot
services.knownservices.chronyd.enable()
# Restart chronyd
services.knownservices.chronyd.restart()
# chrony attempt count to sync with configured servers. Each attempt is
# retried after $interval seconds.
# 4 attempts with 3s interval result in a maximum delay of 9 seconds.
sync_attempt_count = 4
sync_attempt_interval = 3
args = [
paths.CHRONYC, '-d', 'waitsync',
# max-tries, max-correction, max-skew, interval
str(sync_attempt_count), '0', '0', str(sync_attempt_interval)
]
try:
logger.info('Attempting to sync time with chronyc.')
ipautil.run(args)
logger.info('Time synchronization was successful.')
return True
except ipautil.CalledProcessError:
logger.warning('Process chronyc waitsync failed to sync time!')
logger.warning(
"Unable to sync time with chrony server, assuming the time "
"is in sync. Please check that 123 UDP port is opened, "
"and any time server is on network.")
return False
def configure_chrony(ntp_servers, ntp_pool=None,
fstore=None, sysstore=None, debug=False):
"""
This method only configures chrony client with ntp_servers or ntp_pool
"""
module = "chrony"
if sysstore:
sysstore.backup_state(module, "enabled",
services.knownservices.chronyd.is_enabled())
aug = Augeas(flags=Augeas.NO_LOAD | Augeas.NO_MODL_AUTOLOAD,
loadpath=paths.USR_SHARE_IPA_DIR)
try:
logger.debug("Configuring chrony")
chrony_conf = os.path.abspath(paths.CHRONY_CONF)
aug.transform(module, chrony_conf) # loads chrony lens file
aug.load() # loads augeas tree
# augeas needs to prepend path with '/files'
path = '/files{path}'.format(path=chrony_conf)
# remove possible conflicting configuration of servers
aug.remove('{}/server'.format(path))
aug.remove('{}/pool'.format(path))
aug.remove('{}/peer'.format(path))
if ntp_pool:
logger.debug("Setting server pool:")
logger.debug("'%s'", ntp_pool)
aug.set('{}/pool[last()+1]'.format(path), ntp_pool)
aug.set('{}/pool[last()]/iburst'.format(path), None)
if ntp_servers:
logger.debug("Setting time servers:")
for server in ntp_servers:
aug.set('{}/server[last()+1]'.format(path), server)
aug.set('{}/server[last()]/iburst'.format(path), None)
logger.debug("'%s'", server)
# backup oginal conf file
logger.debug("Backing up '%s'", chrony_conf)
__backup_config(chrony_conf, fstore)
logger.debug("Writing configuration to '%s'", chrony_conf)
aug.save()
logger.info('Configuration of chrony was changed by installer.')
configured = True
except IOError:
logger.error("Augeas failed to configure file %s", chrony_conf)
configured = False
except RuntimeError as e:
logger.error("Configuration failed with: %s", e)
configured = False
finally:
aug.close()
tasks.restore_context(chrony_conf)
return configured
class NTPConfigurationError(Exception):
pass
class NTPConflictingService(NTPConfigurationError):
def __init__(self, message='', conflicting_service=None):
super(NTPConflictingService, self).__init__(self, message)
self.conflicting_service = conflicting_service
def check_timedate_services():
"""
System may contain conflicting services used for time&date synchronization.
As IPA server/client supports only chronyd, make sure that other services
are not enabled to prevent conflicts.
"""
for service in services.timedate_services:
if service == 'chronyd':
continue
# Make sure that the service is not enabled
instance = services.service(service, api)
if instance.is_enabled() or instance.is_running():
raise NTPConflictingService(
conflicting_service=instance.service_name)
def force_chrony(statestore):
"""
Force chronyd configuration and disable and stop any other conflicting
time&date service
"""
for service in services.timedate_services:
if service == 'chronyd':
continue
instance = services.service(service, api)
enabled = instance.is_enabled()
running = instance.is_running()
if enabled or running:
statestore.backup_state(instance.service_name, 'enabled', enabled)
statestore.backup_state(instance.service_name, 'running', running)
if running:
instance.stop()
if enabled:
instance.disable()
def restore_forced_timeservices(statestore, skip_service='chronyd'):
"""
Restore from installation and enable/start service that
were disabled/stopped during installation
"""
for service in services.timedate_services:
if service == skip_service:
continue
if statestore.has_state(service):
instance = services.service(service, api)
enabled = statestore.restore_state(instance.service_name,
'enabled')
running = statestore.restore_state(instance.service_name,
'running')
if enabled:
instance.enable()
if running:
instance.start()
| 8,497
|
Python
|
.py
| 198
| 34.525253
| 79
| 0.650926
|
freeipa/freeipa
| 975
| 339
| 31
|
GPL-3.0
|
9/5/2024, 5:12:14 PM (Europe/Amsterdam)
|