I am migrating one of our servers from centos 7 to ubutnu 22.4 lts

Found an interesting issue:

set /etc/security/limits.conf is set set with:
Code:
* soft core unlimited
* hard core unlimited
created new user named AAA,

code i am trying to run inside python3 shell:
Code:
import resource
resource.getrlimit(resource.RLIMIT_CORE)
resource.setrlimit(
    resource.RLIMIT_CORE,
        (resource.RLIM_INFINITY, resource.RLIM_INFINITY)
    )
when login to the user using the command:
sudo su AAA
the code works and i can set core dump to unlimited


when login to the user with:
sudo -i -u AAA /bin/bash

the python code fails, user dont have permission