properly handle chowning DATA_DIR on init when using sudo

This commit is contained in:
Nick Sweeting 2024-10-09 04:39:09 -07:00
parent 2f68a1d476
commit ad675a8e7c
No known key found for this signature in database
7 changed files with 46 additions and 19 deletions

View file

@ -19,13 +19,16 @@ from .settings import LDAP_CONFIG, get_ldap_lib
###################### Config ##########################
def get_LDAP_LIB_path(paths):
def get_LDAP_LIB_path(paths=()):
LDAP_LIB = get_ldap_lib()[0]
if not LDAP_LIB:
return None
# check that LDAP_LIB path is in one of the specified site packages dirs
lib_path = Path(inspect.getfile(LDAP_LIB))
if not paths:
return lib_path
for site_packges_dir in paths:
if str(lib_path.parent.parent.resolve()) == str(Path(site_packges_dir).resolve()):
return lib_path
@ -57,7 +60,7 @@ class LdapBinary(BaseBinary):
"packages": lambda: ['python-ldap>=3.4.3', 'django-auth-ldap>=4.1.0'],
},
apt.name: {
"abspath": lambda: get_LDAP_LIB_path((*USER_SITE_PACKAGES, *SYS_SITE_PACKAGES)),
"abspath": lambda: get_LDAP_LIB_path(),
"version": lambda: get_LDAP_LIB_version(),
"packages": lambda: ['libssl-dev', 'libldap2-dev', 'libsasl2-dev', 'python3-ldap', 'python3-msgpack', 'python3-mutagen'],
},