Re: [Freeipa-devel] [PATCH] 300-301 Fix DNS SOA serial parameters boundaries

2012-09-06 Thread Petr Viktorin

On 09/05/2012 01:31 PM, Martin Kosek wrote:

On 09/05/2012 12:26 PM, Petr Viktorin wrote:

On 09/05/2012 12:14 PM, Petr Viktorin wrote:

This works well, but please see some comments below.

On 09/04/2012 04:22 PM, Martin Kosek wrote:

To test, simply run the following command:

   ipa dnszone-mod example.com --serial=4294967295

This should work well on patched serverclient. Web UI should work too
as it
reads the max limit dynamically.


Please put this in the test suite.


Done.




---
[PATCH 2/2] Fix DNS SOA serial parameters boundaries:

Set correct boundaries for DNS SOA serial parameters (see RFC 1035,
2181).


[PATCH 1/2] Transfer long numbers over XMLRPC

Numeric parameters in ipalib were limited by XMLRPC boundaries for
integer (2^31-1) which is too low for some LDAP attributes like DNS
SOA serial field.

Transfer numbers which are not in XMLRPC boundary as a string and not
as a number to workaround this limitation. Int parameter had to be
updated to also accept Python's long type as valid int type.


freeipa-mkosek-300-transfer-long-numbers-over-xmlrpc.patch



 From 8782015a17b130c5ebae8b014a7241810b10dedd Mon Sep 17 00:00:00 2001

From: Martin Kosekmko...@redhat.com
Date: Tue, 4 Sep 2012 15:49:26 +0200
Subject: [PATCH 1/2] Transfer long numbers over XMLRPC

Numeric parameters in ipalib were limited by XMLRPC boundaries for
integer (2^31-1) which is too low for some LDAP attributes like DNS
SOA serial field.

Transfer numbers which are not in XMLRPC boundary as a string and not
as a number to workaround this limitation. Int parameter had to be
updated to also accept Python's long type as valid int type.

https://fedorahosted.org/freeipa/ticket/2568
---
   ipalib/parameters.py | 12 ++--
   ipalib/rpc.py|  5 -
   2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index
de0d14faf08d1ab79c99e65dab9cc08f406e3a1d..21e30356b2a351bf7a3be7d47d7fabf0130cf6d4

100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -1077,7 +1077,7 @@ class Number(Param):
   
   if type(value) is self.type:
   return value
-if type(value) in (unicode, int, float):
+if type(value) in (unicode, int, long, float):



PEP8 says that Object type comparisons should always use isinstance()
instead of comparing types directly.
It would be nice to change the old code whenever it is touched. It's
also in a few more places in the patch.



I considered doing this when I was developing the patch, but I did not want to
mix type/isinstance in the same code. Now, when I experimented and tried to
replace it in a larger scope, there were unexpected issues. Like bool type
suddenly passing an isinstance(value, (int, long)) test and causing issues 
later.

So I skipped this part (as we discussed off-list).


diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index
d1764e3e30492d5855450398e86689bfcad7aa39..85239ac65903acf447a4d971cce70f819979ce8d

100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -94,6 +95,8 @@ def xml_wrap(value):
   if type(value) is Decimal:
   # transfer Decimal as a string
   return unicode(value)
+if isinstance(value, (int, long)) and (value  MININT or value 
MAXINT):
+return unicode(value)
   if isinstance(value, DN):
   return str(value)
   assert type(value) in (unicode, int, float, bool, NoneType)


`long` should also be included here.

   api.Command.user_find(uidnumber=151100)
{'count': 1, 'truncated': False, 'result': ({...},), 'summary': u'1 user
matched'}
   api.Command.user_find(uidnumber=151100 + 0L)
Traceback (most recent call last):
File console, line 1, in module
...
File /usr/lib/python2.7/site-packages/ipalib/rpc.py, line 102, in
xml_wrap
  assert type(value) in (unicode, int, float, bool, NoneType)
AssertionError






One more thing: please update the VERSION file.



I did not want to do this because I just messed with validation, but yeah, I
can do that.

Fixed patches attached.



Both are good, ACK.


--
PetrĀ³

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 300-301 Fix DNS SOA serial parameters boundaries

2012-09-06 Thread Martin Kosek
On 09/06/2012 02:51 PM, Petr Viktorin wrote:
 On 09/05/2012 01:31 PM, Martin Kosek wrote:
 On 09/05/2012 12:26 PM, Petr Viktorin wrote:
 On 09/05/2012 12:14 PM, Petr Viktorin wrote:
 This works well, but please see some comments below.

 On 09/04/2012 04:22 PM, Martin Kosek wrote:
 To test, simply run the following command:

ipa dnszone-mod example.com --serial=4294967295

 This should work well on patched serverclient. Web UI should work too
 as it
 reads the max limit dynamically.

 Please put this in the test suite.

 Done.


 ---
 [PATCH 2/2] Fix DNS SOA serial parameters boundaries:

 Set correct boundaries for DNS SOA serial parameters (see RFC 1035,
 2181).


 [PATCH 1/2] Transfer long numbers over XMLRPC

 Numeric parameters in ipalib were limited by XMLRPC boundaries for
 integer (2^31-1) which is too low for some LDAP attributes like DNS
 SOA serial field.

 Transfer numbers which are not in XMLRPC boundary as a string and not
 as a number to workaround this limitation. Int parameter had to be
 updated to also accept Python's long type as valid int type.


 freeipa-mkosek-300-transfer-long-numbers-over-xmlrpc.patch


  From 8782015a17b130c5ebae8b014a7241810b10dedd Mon Sep 17 00:00:00 2001
 From: Martin Kosekmko...@redhat.com
 Date: Tue, 4 Sep 2012 15:49:26 +0200
 Subject: [PATCH 1/2] Transfer long numbers over XMLRPC

 Numeric parameters in ipalib were limited by XMLRPC boundaries for
 integer (2^31-1) which is too low for some LDAP attributes like DNS
 SOA serial field.

 Transfer numbers which are not in XMLRPC boundary as a string and not
 as a number to workaround this limitation. Int parameter had to be
 updated to also accept Python's long type as valid int type.

 https://fedorahosted.org/freeipa/ticket/2568
 ---
ipalib/parameters.py | 12 ++--
ipalib/rpc.py|  5 -
2 files changed, 10 insertions(+), 7 deletions(-)

 diff --git a/ipalib/parameters.py b/ipalib/parameters.py
 index
 de0d14faf08d1ab79c99e65dab9cc08f406e3a1d..21e30356b2a351bf7a3be7d47d7fabf0130cf6d4


 100644
 --- a/ipalib/parameters.py
 +++ b/ipalib/parameters.py
 @@ -1077,7 +1077,7 @@ class Number(Param):

if type(value) is self.type:
return value
 -if type(value) in (unicode, int, float):
 +if type(value) in (unicode, int, long, float):


 PEP8 says that Object type comparisons should always use isinstance()
 instead of comparing types directly.
 It would be nice to change the old code whenever it is touched. It's
 also in a few more places in the patch.


 I considered doing this when I was developing the patch, but I did not want 
 to
 mix type/isinstance in the same code. Now, when I experimented and tried to
 replace it in a larger scope, there were unexpected issues. Like bool type
 suddenly passing an isinstance(value, (int, long)) test and causing issues
 later.

 So I skipped this part (as we discussed off-list).

 diff --git a/ipalib/rpc.py b/ipalib/rpc.py
 index
 d1764e3e30492d5855450398e86689bfcad7aa39..85239ac65903acf447a4d971cce70f819979ce8d


 100644
 --- a/ipalib/rpc.py
 +++ b/ipalib/rpc.py
 @@ -94,6 +95,8 @@ def xml_wrap(value):
if type(value) is Decimal:
# transfer Decimal as a string
return unicode(value)
 +if isinstance(value, (int, long)) and (value  MININT or value 
 MAXINT):
 +return unicode(value)
if isinstance(value, DN):
return str(value)
assert type(value) in (unicode, int, float, bool, NoneType)

 `long` should also be included here.

api.Command.user_find(uidnumber=151100)
 {'count': 1, 'truncated': False, 'result': ({...},), 'summary': u'1 user
 matched'}
api.Command.user_find(uidnumber=151100 + 0L)
 Traceback (most recent call last):
 File console, line 1, in module
 ...
 File /usr/lib/python2.7/site-packages/ipalib/rpc.py, line 102, in
 xml_wrap
   assert type(value) in (unicode, int, float, bool, NoneType)
 AssertionError





 One more thing: please update the VERSION file.


 I did not want to do this because I just messed with validation, but yeah, I
 can do that.

 Fixed patches attached.

 
 Both are good, ACK.
 

Pushed to master, ipa-3-0.

Martin

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 300-301 Fix DNS SOA serial parameters boundaries

2012-09-05 Thread Martin Kosek
On 09/05/2012 12:26 PM, Petr Viktorin wrote:
 On 09/05/2012 12:14 PM, Petr Viktorin wrote:
 This works well, but please see some comments below.

 On 09/04/2012 04:22 PM, Martin Kosek wrote:
 To test, simply run the following command:

   ipa dnszone-mod example.com --serial=4294967295

 This should work well on patched serverclient. Web UI should work too
 as it
 reads the max limit dynamically.

 Please put this in the test suite.

Done.


 ---
 [PATCH 2/2] Fix DNS SOA serial parameters boundaries:

 Set correct boundaries for DNS SOA serial parameters (see RFC 1035,
 2181).


 [PATCH 1/2] Transfer long numbers over XMLRPC

 Numeric parameters in ipalib were limited by XMLRPC boundaries for
 integer (2^31-1) which is too low for some LDAP attributes like DNS
 SOA serial field.

 Transfer numbers which are not in XMLRPC boundary as a string and not
 as a number to workaround this limitation. Int parameter had to be
 updated to also accept Python's long type as valid int type.


 freeipa-mkosek-300-transfer-long-numbers-over-xmlrpc.patch


 From 8782015a17b130c5ebae8b014a7241810b10dedd Mon Sep 17 00:00:00 2001
 From: Martin Kosekmko...@redhat.com
 Date: Tue, 4 Sep 2012 15:49:26 +0200
 Subject: [PATCH 1/2] Transfer long numbers over XMLRPC

 Numeric parameters in ipalib were limited by XMLRPC boundaries for
 integer (2^31-1) which is too low for some LDAP attributes like DNS
 SOA serial field.

 Transfer numbers which are not in XMLRPC boundary as a string and not
 as a number to workaround this limitation. Int parameter had to be
 updated to also accept Python's long type as valid int type.

 https://fedorahosted.org/freeipa/ticket/2568
 ---
   ipalib/parameters.py | 12 ++--
   ipalib/rpc.py|  5 -
   2 files changed, 10 insertions(+), 7 deletions(-)

 diff --git a/ipalib/parameters.py b/ipalib/parameters.py
 index
 de0d14faf08d1ab79c99e65dab9cc08f406e3a1d..21e30356b2a351bf7a3be7d47d7fabf0130cf6d4

 100644
 --- a/ipalib/parameters.py
 +++ b/ipalib/parameters.py
 @@ -1077,7 +1077,7 @@ class Number(Param):
   
   if type(value) is self.type:
   return value
 -if type(value) in (unicode, int, float):
 +if type(value) in (unicode, int, long, float):


 PEP8 says that Object type comparisons should always use isinstance()
 instead of comparing types directly.
 It would be nice to change the old code whenever it is touched. It's
 also in a few more places in the patch.


I considered doing this when I was developing the patch, but I did not want to
mix type/isinstance in the same code. Now, when I experimented and tried to
replace it in a larger scope, there were unexpected issues. Like bool type
suddenly passing an isinstance(value, (int, long)) test and causing issues 
later.

So I skipped this part (as we discussed off-list).

 diff --git a/ipalib/rpc.py b/ipalib/rpc.py
 index
 d1764e3e30492d5855450398e86689bfcad7aa39..85239ac65903acf447a4d971cce70f819979ce8d

 100644
 --- a/ipalib/rpc.py
 +++ b/ipalib/rpc.py
 @@ -94,6 +95,8 @@ def xml_wrap(value):
   if type(value) is Decimal:
   # transfer Decimal as a string
   return unicode(value)
 +if isinstance(value, (int, long)) and (value  MININT or value 
 MAXINT):
 +return unicode(value)
   if isinstance(value, DN):
   return str(value)
   assert type(value) in (unicode, int, float, bool, NoneType)

 `long` should also be included here.

   api.Command.user_find(uidnumber=151100)
 {'count': 1, 'truncated': False, 'result': ({...},), 'summary': u'1 user
 matched'}
   api.Command.user_find(uidnumber=151100 + 0L)
 Traceback (most recent call last):
File console, line 1, in module
 ...
File /usr/lib/python2.7/site-packages/ipalib/rpc.py, line 102, in
 xml_wrap
  assert type(value) in (unicode, int, float, bool, NoneType)
 AssertionError




 
 One more thing: please update the VERSION file.
 

I did not want to do this because I just messed with validation, but yeah, I
can do that.

Fixed patches attached.

Martin
From 965fa27cf32dcb209a291945e9eb342c88fd18dd Mon Sep 17 00:00:00 2001
From: Martin Kosek mko...@redhat.com
Date: Tue, 4 Sep 2012 15:49:26 +0200
Subject: [PATCH 1/2] Transfer long numbers over XMLRPC

Numeric parameters in ipalib were limited by XMLRPC boundaries for
integer (2^31-1) which is too low for some LDAP attributes like DNS
SOA serial field.

Transfer numbers which are not in XMLRPC boundary as a string and not
as a number to workaround this limitation. Int parameter had to be
updated to also accept Python's long type as valid int type.

https://fedorahosted.org/freeipa/ticket/2568
---
 ipalib/parameters.py | 12 ++--
 ipalib/rpc.py|  7 +--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index de0d14faf08d1ab79c99e65dab9cc08f406e3a1d..21e30356b2a351bf7a3be7d47d7fabf0130cf6d4 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ 

[Freeipa-devel] [PATCH] 300-301 Fix DNS SOA serial parameters boundaries

2012-09-04 Thread Martin Kosek
To test, simply run the following command:

 ipa dnszone-mod example.com --serial=4294967295

This should work well on patched serverclient. Web UI should work too as it
reads the max limit dynamically.

---
[PATCH 2/2] Fix DNS SOA serial parameters boundaries:

Set correct boundaries for DNS SOA serial parameters (see RFC 1035,
2181).


[PATCH 1/2] Transfer long numbers over XMLRPC

Numeric parameters in ipalib were limited by XMLRPC boundaries for
integer (2^31-1) which is too low for some LDAP attributes like DNS
SOA serial field.

Transfer numbers which are not in XMLRPC boundary as a string and not
as a number to workaround this limitation. Int parameter had to be
updated to also accept Python's long type as valid int type.

From 8782015a17b130c5ebae8b014a7241810b10dedd Mon Sep 17 00:00:00 2001
From: Martin Kosek mko...@redhat.com
Date: Tue, 4 Sep 2012 15:49:26 +0200
Subject: [PATCH 1/2] Transfer long numbers over XMLRPC

Numeric parameters in ipalib were limited by XMLRPC boundaries for
integer (2^31-1) which is too low for some LDAP attributes like DNS
SOA serial field.

Transfer numbers which are not in XMLRPC boundary as a string and not
as a number to workaround this limitation. Int parameter had to be
updated to also accept Python's long type as valid int type.

https://fedorahosted.org/freeipa/ticket/2568
---
 ipalib/parameters.py | 12 ++--
 ipalib/rpc.py|  5 -
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index de0d14faf08d1ab79c99e65dab9cc08f406e3a1d..21e30356b2a351bf7a3be7d47d7fabf0130cf6d4 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -1077,7 +1077,7 @@ class Number(Param):
 
 if type(value) is self.type:
 return value
-if type(value) in (unicode, int, float):
+if type(value) in (unicode, int, long, float):
 try:
 return self.type(value)
 except ValueError:
@@ -1099,8 +1099,8 @@ class Int(Number):
 type_error = _('must be an integer')
 
 kwargs = Param.kwargs + (
-('minvalue', int, int(MININT)),
-('maxvalue', int, int(MAXINT)),
+('minvalue', (int, long), int(MININT)),
+('maxvalue', (int, long), int(MAXINT)),
 )
 
 def __init__(self, name, *rules, **kw):
@@ -1147,7 +1147,7 @@ class Int(Number):
 Check min constraint.
 
 assert type(value) in (int, long)
-if value  self.minvalue or value  MININT:
+if value  self.minvalue:
 return _('must be at least %(minvalue)d') % dict(
 minvalue=self.minvalue,
 )
@@ -1157,7 +1157,7 @@ class Int(Number):
 Check max constraint.
 
 assert type(value) in (int, long)
-if value  self.maxvalue or value  MAXINT:
+if value  self.maxvalue:
 return _('can be at most %(maxvalue)d') % dict(
 maxvalue=self.maxvalue,
 )
@@ -1490,7 +1490,7 @@ class Str(Data):
 
 if type(value) is self.type:
 return value
-if type(value) in (int, float, decimal.Decimal):
+if type(value) in (int, long, float, decimal.Decimal):
 return self.type(value)
 if type(value) in (tuple, list):
 raise ConversionError(name=self.name, index=index,
diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index d1764e3e30492d5855450398e86689bfcad7aa39..85239ac65903acf447a4d971cce70f819979ce8d 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -37,7 +37,8 @@ import sys
 import os
 import errno
 import locale
-from xmlrpclib import Binary, Fault, dumps, loads, ServerProxy, Transport, ProtocolError
+from xmlrpclib import (Binary, Fault, dumps, loads, ServerProxy, Transport,
+ProtocolError, MININT, MAXINT)
 import kerberos
 from dns import resolver, rdatatype
 from dns.exception import DNSException
@@ -94,6 +95,8 @@ def xml_wrap(value):
 if type(value) is Decimal:
 # transfer Decimal as a string
 return unicode(value)
+if isinstance(value, (int, long)) and (value  MININT or value  MAXINT):
+return unicode(value)
 if isinstance(value, DN):
 return str(value)
 assert type(value) in (unicode, int, float, bool, NoneType)
-- 
1.7.11.4

From bbfbd9ee11b38e29dee018e72f39fd5bfab39b2d Mon Sep 17 00:00:00 2001
From: Martin Kosek mko...@redhat.com
Date: Tue, 4 Sep 2012 16:05:34 +0200
Subject: [PATCH 2/2] Fix DNS SOA serial parameters boundaries

Set correct boundaries for DNS SOA serial parameters (see RFC 1035,
2181).

https://fedorahosted.org/freeipa/ticket/2568
---
 API.txt   | 36 ++--
 ipalib/plugins/dns.py |  8 +++-
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/API.txt b/API.txt
index aef12b7eb6e458d614c84ba20d782ef3154c09f0..cfdfaae708b0ef93c9d4cad603de68d69875d1a7 100644
--- a/API.txt
+++ b/API.txt
@@ -1014,12 +1014,12 @@ arg: Str('idnsname',