2
# Jr Aquino <jr.aquino@citrixonline.com>
4
# Copyright (C) 2010 Red Hat
5
# see file 'COPYING' for use and warranty information
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
from ipalib import api
21
from ipalib import Str
22
from ipalib.plugable import Registry
23
from ipalib.plugins.baseldap import *
24
from ipalib import _, ngettext
27
Groups of Sudo Commands
29
Manage groups of Sudo Commands.
33
Add a new Sudo Command Group:
34
ipa sudocmdgroup-add --desc='administrators commands' admincmds
36
Remove a Sudo Command Group:
37
ipa sudocmdgroup-del admincmds
39
Manage Sudo Command Group membership, commands:
40
ipa sudocmdgroup-add-member --sudocmds=/usr/bin/less --sudocmds=/usr/bin/vim admincmds
42
Manage Sudo Command Group membership, commands:
43
ipa group-remove-member --sudocmds=/usr/bin/less admincmds
45
Show a Sudo Command Group:
46
ipa group-show localadmins
51
topic = ('sudo', _('commands for controlling sudo configuration'))
54
class sudocmdgroup(LDAPObject):
56
Sudo Command Group object.
58
container_dn = api.env.container_sudocmdgroup
59
object_name = _('sudo command group')
60
object_name_plural = _('sudo command groups')
61
object_class = ['ipaobject', 'ipasudocmdgrp']
62
permission_filter_objectclasses = ['ipasudocmdgrp']
63
default_attributes = [
64
'cn', 'description', 'member',
66
uuid_attribute = 'ipauniqueid'
68
'member': ['sudocmd'],
70
managed_permissions = {
71
'System: Read Sudo Command Groups': {
72
'replaces_global_anonymous_aci': True,
73
'ipapermbindruletype': 'all',
74
'ipapermright': {'read', 'search', 'compare'},
75
'ipapermdefaultattr': {
76
'businesscategory', 'cn', 'description', 'ipauniqueid',
77
'member', 'o', 'objectclass', 'ou', 'owner', 'seealso',
78
'memberuser', 'memberhost',
81
'System: Add Sudo Command Group': {
82
'ipapermright': {'add'},
84
'(target = "ldap:///cn=*,cn=sudocmdgroups,cn=sudo,$SUFFIX")(version 3.0;acl "permission:Add Sudo command group";allow (add) groupdn = "ldap:///cn=Add Sudo command group,cn=permissions,cn=pbac,$SUFFIX";)',
86
'default_privileges': {'Sudo Administrator'},
88
'System: Delete Sudo Command Group': {
89
'ipapermright': {'delete'},
91
'(target = "ldap:///cn=*,cn=sudocmdgroups,cn=sudo,$SUFFIX")(version 3.0;acl "permission:Delete Sudo command group";allow (delete) groupdn = "ldap:///cn=Delete Sudo command group,cn=permissions,cn=pbac,$SUFFIX";)',
93
'default_privileges': {'Sudo Administrator'},
95
'System: Modify Sudo Command Group': {
96
'ipapermright': {'write'},
97
'ipapermdefaultattr': {'description'},
98
'default_privileges': {'Sudo Administrator'},
100
'System: Manage Sudo Command Group Membership': {
101
'ipapermright': {'write'},
102
'ipapermdefaultattr': {'member'},
104
'(targetattr = "member")(target = "ldap:///cn=*,cn=sudocmdgroups,cn=sudo,$SUFFIX")(version 3.0;acl "permission:Manage Sudo command group membership";allow (write) groupdn = "ldap:///cn=Manage Sudo command group membership,cn=permissions,cn=pbac,$SUFFIX";)',
106
'default_privileges': {'Sudo Administrator'},
110
label = _('Sudo Command Groups')
111
label_singular = _('Sudo Command Group')
115
cli_name='sudocmdgroup_name',
116
label=_('Sudo Command Group'),
118
normalizer=lambda value: value.lower(),
122
label=_('Description'),
123
doc=_('Group description'),
125
Str('membercmd_sudocmd?',
127
flags=['no_create', 'no_update', 'no_search'],
129
Str('membercmd_sudocmdgroup?',
130
label=_('Sudo Command Groups'),
131
flags=['no_create', 'no_update', 'no_search'],
138
class sudocmdgroup_add(LDAPCreate):
139
__doc__ = _('Create new Sudo Command Group.')
141
msg_summary = _('Added Sudo Command Group "%(value)s"')
146
class sudocmdgroup_del(LDAPDelete):
147
__doc__ = _('Delete Sudo Command Group.')
149
msg_summary = _('Deleted Sudo Command Group "%(value)s"')
154
class sudocmdgroup_mod(LDAPUpdate):
155
__doc__ = _('Modify Sudo Command Group.')
157
msg_summary = _('Modified Sudo Command Group "%(value)s"')
162
class sudocmdgroup_find(LDAPSearch):
163
__doc__ = _('Search for Sudo Command Groups.')
165
msg_summary = ngettext(
166
'%(count)d Sudo Command Group matched',
167
'%(count)d Sudo Command Groups matched', 0
173
class sudocmdgroup_show(LDAPRetrieve):
174
__doc__ = _('Display Sudo Command Group.')
179
class sudocmdgroup_add_member(LDAPAddMember):
180
__doc__ = _('Add members to Sudo Command Group.')
185
class sudocmdgroup_remove_member(LDAPRemoveMember):
186
__doc__ = _('Remove members from Sudo Command Group.')