0fcb1e
From 97fc368df2db3b559a9def236d3c3e0a12bcdd0a Mon Sep 17 00:00:00 2001
0fcb1e
From: Florence Blanc-Renaud <flo@redhat.com>
0fcb1e
Date: Mon, 23 Jan 2023 20:28:17 +0100
0fcb1e
Subject: [PATCH] trust-add: handle missing msSFU30MaxGidNumber
0fcb1e
0fcb1e
When ipa trust-add is executed with --range-type ad-trust-posix,
0fcb1e
the server tries to find the max uidnumber and max gidnumber
0fcb1e
from AD domain controller.
0fcb1e
The values are extracted from the entry
0fcb1e
CN=<domain>,CN=ypservers,CN=ypServ30,CN=RpcServices,CN=System,<AD suffix>
0fcb1e
in the msSFU30MaxUidNumber and msSFU30MaxGidNumber attributes.
0fcb1e
0fcb1e
msSFU30MaxUidNumber is required but not msSFU30MaxGidNumber.
0fcb1e
In case msSFU30MaxGidNumber is missing, the code is currently assigning
0fcb1e
a "None" value and later on evaluates the max between this value and
0fcb1e
msSFU30MaxUidNumber. The max function cannot compare None and a list
0fcb1e
of string and triggers an exception.
0fcb1e
0fcb1e
To avoid the exception, assign [b'0'] to max gid if msSFU30MaxGidNumber
0fcb1e
is missing. This way, the comparison succeeds and max returns the
0fcb1e
value from msSFU30MaxUidNumber.
0fcb1e
0fcb1e
Fixes: https://pagure.io/freeipa/issue/9310
0fcb1e
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
0fcb1e
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
0fcb1e
---
0fcb1e
 ipaserver/plugins/trust.py | 5 ++++-
0fcb1e
 1 file changed, 4 insertions(+), 1 deletion(-)
0fcb1e
0fcb1e
diff --git a/ipaserver/plugins/trust.py b/ipaserver/plugins/trust.py
0fcb1e
index c074f6d6e609476e416c95bcbe607654718ae9ce..79264b8d8a3b15dd4e5d0553e4ce42194b0ae044 100644
0fcb1e
--- a/ipaserver/plugins/trust.py
0fcb1e
+++ b/ipaserver/plugins/trust.py
0fcb1e
@@ -379,7 +379,10 @@ def add_range(myapi, trustinstance, range_name, dom_sid, *keys, **options):
0fcb1e
                 range_type = u'ipa-ad-trust-posix'
0fcb1e
 
0fcb1e
                 max_uid = info.get('msSFU30MaxUidNumber')
0fcb1e
-                max_gid = info.get('msSFU30MaxGidNumber', None)
0fcb1e
+                # if max_gid is missing, assume 0 and the max will
0fcb1e
+                # be obtained from max_uid. We just checked that
0fcb1e
+                # msSFU30MaxUidNumber is defined
0fcb1e
+                max_gid = info.get('msSFU30MaxGidNumber', [b'0'])
0fcb1e
                 max_id = int(max(max_uid, max_gid)[0])
0fcb1e
 
0fcb1e
                 base_id = int(info.get('msSFU30OrderNumber')[0])
0fcb1e
-- 
0fcb1e
2.39.1
0fcb1e