Bug 2180914

Summary: Sequence processing failures for group_add using server context
Product: Red Hat Enterprise Linux 9 Reporter: Antonio Torres <antorres>
Component: ipaAssignee: Antonio Torres <antorres>
Status: CLOSED ERRATA QA Contact: anuja <amore>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.3CC: frenaud, gkaihoro, mpolovka, myusuf, rcritten, sumenon, tscherf
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ipa-4.10.2-1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of:
: 2180918 2180919 (view as bug list) Environment:
Last Closed: 2023-11-07 08:34:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2180918, 2180919    

Description Antonio Torres 2023-03-22 15:58:39 UTC
Cloned from upstream: https://pagure.io/freeipa/issue/9349

### Issue
Issues have been found for group_add sequence processing with server context with the work on https://github.com/freeipa/ansible-freeipa/pull/1001

1) Using group_add in sequence processing to create several groups where one is external, all groups have objectclass ipaexternalgroup, even if external is set to False for the group_add command.
2) After creating a nonposix group, all following group_add calls to add posix groups calls are failing with `missing attribute "gidNumber" required by object class "posixGroup"`

#### Reproducer 1 (external)

    from ipalib import api, errors

    api.bootstrap_with_global_options(context='server')
    api.finalize()
    if api.env.in_server:
        api.Backend.ldap2.connect()
    else:
        api.Backend.rpcclient.connect()

    print("Remove 'testgroup1'")
    try:
        api.Command["group_del"]("testgroup1")
    except errors.NotFound:
        pass

    print("Remove 'testgroup2'")
    try:
        api.Command["group_del"]("testgroup2")
    except errors.NotFound:
        pass

    print("Create 'testgroup1' with external=True")
    api.Command["group_add"]("testgroup1", external=True)

    print("Create 'testgroup2' with external=False")
    api.Command["group_add"]("testgroup2", external=False)

    result1 = api.Command["group_show"]("testgroup1", all=True)["result"]
    print("'testgroup1' userclass: %s" % repr(result1["objectclass"]))

    result2 = api.Command["group_show"]("testgroup2", all=True)["result"]
    print("'testgroup2' userclass: %s" % repr(result2["objectclass"]))


#### Reproducer 2 (nonposix)

    from ipalib import api, errors

    api.bootstrap_with_global_options(context='server')
    api.finalize()
    if api.env.in_server:
        api.Backend.ldap2.connect()
    else:
        api.Backend.rpcclient.connect()

    print("Remove 'testgroup1'")
    try:
        api.Command["group_del"]("testgroup1")
    except errors.NotFound:
        pass

    print("Remove 'testgroup2'")
    try:
        api.Command["group_del"]("testgroup2")
    except errors.NotFound:
        pass

    print("Remove 'testgroup3'")
    try:
        api.Command["group_del"]("testgroup3")
    except errors.NotFound:
        pass

    print("Create 'testgroup1' with nonposix=False")
    api.Command["group_add"]("testgroup1", nonposix=False)

    try:
        print("Create 'testgroup2' with nonposix=True")
        api.Command["group_add"]("testgroup2", nonposix=True)
    except Exception as e:
        print(str(e))

    try:
        print("Create 'testgroup3' with external=True")
        api.Command["group_add"]("testgroup3", external=True)
    except Exception as e:
        print(str(e))

#### Actual behavior
1) With reproducer 1 all groups are external.

    $ python3 external_test.py 
    Remove 'testgroup1'
    Remove 'testgroup2'
    Create 'testgroup1' with external=True
    Create 'testgroup2' with external=False
    'testgroup1' userclass: ['top', 'groupofnames', 'nestedgroup', 'ipausergroup', 'ipaobject', 'ipaexternalgroup']
    'testgroup2' userclass: ['top', 'groupofnames', 'nestedgroup', 'ipausergroup', 'ipaobject', 'ipaexternalgroup', 'posixgroup', 'ipantgroupattrs']


2) Reproducer 2 fails to create posix groups after nonposix group has been created.

    $ python3 nonposix_test.py 
    Remove 'testgroup1'
    Remove 'testgroup2'
    Remove 'testgroup3'
    Create 'testgroup1' with nonposix=False
    Create 'testgroup2' with nonposix=True
    missing attribute "gidNumber" required by object class "posixGroup"
    Create 'testgroup3' with external=True
    missing attribute "gidNumber" required by object class "posixGroup"

2) Reproducer 2 fails to create posix groups after nonposix group has been created.

#### Expected behavior
No issues.

#### Version/Release/Distribution

    $ rpm -q freeipa-server freeipa-client ipa-server ipa-client 389-ds-base pki-ca krb5-server
    freeipa-server-4.9.9-1.fc36.x86_64
    freeipa-client-4.9.9-1.fc36.x86_64
    package ipa-server is not installed
    package ipa-client is not installed
    389-ds-base-2.1.1-2.fc36.x86_64
    package pki-ca is not installed
    krb5-server-1.19.2-6.fc36.x86_64

### Addititional Information
The reproducers are passing using client context.

Comment 1 Antonio Torres 2023-03-22 16:01:22 UTC
*** Bug 2180915 has been marked as a duplicate of this bug. ***

Comment 2 Antonio Torres 2023-03-22 16:07:09 UTC
Upstream PR: https://github.com/freeipa/freeipa/pull/6741

Comment 3 Florence Blanc-Renaud 2023-03-23 09:14:09 UTC
Fixed upstream
master:
https://pagure.io/freeipa/c/05279ef447fbd3b59d47db51824e410728913064

Comment 4 Florence Blanc-Renaud 2023-03-23 13:36:10 UTC
Fixed upstream
ipa-4-6:
https://pagure.io/freeipa/c/6c9edcf2b1a830b06100f988503388b5022c16cf

Comment 5 Florence Blanc-Renaud 2023-03-23 16:13:11 UTC
Fixed upstream
ipa-4-10:
https://pagure.io/freeipa/c/b1b7cbc08d96e125ce21113ba1793a592d0ba35a

Comment 6 Florence Blanc-Renaud 2023-03-23 16:51:33 UTC
Fixed upstream
ipa-4-9:
https://pagure.io/freeipa/c/62fe608390c41115edf4e356a6cff2ab1a6d0daf

Comment 13 errata-xmlrpc 2023-11-07 08:34:04 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (ipa bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:6477