Univention Bugzilla – Attachment 7501 Details for
Bug 40765
broken ldap filters in printer.py and printergroup.py causes no validation when changing quota settings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
40765.patch (text/plain), 5.63 KB, created by
Florian Best
on 2016-02-24 15:29:56 CET
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Florian Best
Created:
2016-02-24 15:29:56 CET
Size:
5.63 KB
patch
obsolete
>diff --git a/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printer.py b/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printer.py >index 254c926..68ad5ff 100644 >--- a/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printer.py >+++ b/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printer.py >@@ -31,6 +31,7 @@ > # <http://www.gnu.org/licenses/>. > > import re >+import ldap.filter > > from univention.admin.layout import Tab, Group > import univention.admin.uldap >@@ -324,9 +325,8 @@ def _ldap_pre_modify(self):# check for membership in a quota-printerclass > # cut off '/' at the beginning of the destination if it exists and protocol is file:/ > if self[ 'uri' ] and self[ 'uri' ][ 0 ] == 'file:/' and self[ 'uri' ][ 1 ][ 0 ] == '/': > self[ 'uri' ][ 1 ] = re.sub( r'^/+', '', self[ 'uri' ][ 1 ] ) >- if self.hasChanged('setQuota') and self.info['setQuota'] == '0': >- printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterQuotaSupport=1)(univentionPrinterSpoolHost=%s))' >- % self.info['spoolHost']) >+ if self.hasChanged('setQuota') and self.info['setQuota'] == '0' and self.info['spoolHost']: >+ printergroups = self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterQuotaSupport=1)(|%s))' % (''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost']))) > group_cn=[] > for pg_dn in printergroups: > member_list = self.lo.get(pg_dn, attr=['univentionPrinterGroupMember','cn']) >@@ -338,7 +338,7 @@ def _ldap_pre_modify(self):# check for membership in a quota-printerclass > > > def _ldap_pre_remove(self): # check for last member in printerclass >- printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterSpoolHost=%s))'%self.info['spoolHost']) >+ printergroups = self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(|%s))' % (''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost']))) > rm_attrib=[] > for pg_dn in printergroups: > member_list=self.lo.search( base=pg_dn, attr=['univentionPrinterGroupMember','cn']) >diff --git a/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printergroup.py b/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printergroup.py >index 1cc9b1d..2c0a728 100644 >--- a/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printergroup.py >+++ b/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printergroup.py >@@ -30,6 +30,8 @@ > # /usr/share/common-licenses/AGPL-3; if not, see > # <http://www.gnu.org/licenses/>. > >+import ldap.filter >+ > from univention.admin.layout import Tab, Group > import univention.admin.uldap > import univention.admin.syntax >@@ -192,7 +194,7 @@ def _ldap_modlist(self):# check for membership in a quota-printerclass > raise univention.admin.uexceptions.leavePrinterGroup(_('%(name)s is member of the following quota printer groups %(groups)s') % {'name': self.info['name'], 'groups': ', '.join(group_cn)}) > elif self.info.get( 'setQuota', None ) == '1': > for member_cn in self.info['groupMember']: >- member_dn=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(univentionPrinterSpoolHost=%s)(cn=%s)(univentionPrinterQuotaSupport=1))' % (self.info['spoolHost'][0], member_cn)) >+ member_dn=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(|%s)(cn=%s)(univentionPrinterSpoolHost=%s)(cn=%s)(univentionPrinterQuotaSupport=1))' % (''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost']), ldap.filter.escape_filter_chars(member_cn))) > if len(member_dn) < 1: > raise univention.admin.uexceptions.leavePrinterGroup, _('%s is disabled for quota support. ') % member_cn > if self.hasChanged('groupMember'): >@@ -200,7 +202,7 @@ def _ldap_modlist(self):# check for membership in a quota-printerclass > return univention.admin.handlers.simpleLdap._ldap_modlist(self) > > def _ldap_pre_remove(self): # check for last member in printerclass on same spoolhost >- printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterSpoolHost=%s))' % self.info['spoolHost']) >+ printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(|%s))' % ''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost'])) > rm_attrib=[] > for pg_dn in printergroups: > member_list=self.lo.search( base=pg_dn, attr=['univentionPrinterGroupMember','cn']) >@@ -218,12 +220,10 @@ def _ldap_pre_remove(self): # check for last member in printerclass on same spoo > > def isValidPrinterObject(self): # check printer on current spoolhost > for member in self.info['groupMember']: >- spoolhosts = '(|' >- for host in self.info[ 'spoolHost' ]: >- spoolhosts += "(univentionPrinterSpoolHost=%s)" % host >- spoolhosts += ')' > >- test=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(cn=%s)%s)' % ( member, spoolhosts ) ) >+ spoolhosts = '(|%s)' % ''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost']) >+ >+ test=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(cn=%s)%s)' % (ldap.filter.escape_filter_chars(member), spoolhosts ) ) > if len(test) < 1: > raise univention.admin.uexceptions.notValidPrinter(_('%(name)s is not a valid printer on Spoolhost %(host)s.') % {'name': member, 'host': self.info['spoolHost']}) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 40765
: 7501