users: Use own copy of ldapscripts config

Avoid modifying the conffile shipped with ldapscripts.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2017-10-23 19:47:09 -04:00 committed by Sunil Mohan Adapa
parent 44b92f12eb
commit 4cbb60ccfe
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -21,15 +21,17 @@ Configuration helper for the LDAP user directory
""" """
import argparse import argparse
import augeas
import os
import re import re
import shutil
import subprocess import subprocess
import sys import sys
import augeas
from plinth import action_utils from plinth import action_utils
ACCESS_CONF = '/etc/security/access.conf' ACCESS_CONF = '/etc/security/access.conf'
LDAPSCRIPTS_CONF = '/etc/ldapscripts/ldapscripts.conf' LDAPSCRIPTS_CONF = '/etc/ldapscripts/freedombox-ldapscripts.conf'
def parse_arguments(): def parse_arguments():
@ -186,6 +188,9 @@ olcRootDN: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
def configure_ldapscripts(): def configure_ldapscripts():
"""Set the configuration used by ldapscripts for later user management.""" """Set the configuration used by ldapscripts for later user management."""
# modify a copy of the config file
shutil.copy('/etc/ldapscripts/ldapscripts.conf', LDAPSCRIPTS_CONF)
aug = augeas.Augeas( aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD) flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns') aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
@ -338,10 +343,11 @@ def flush_cache():
def _run(arguments, **kwargs): def _run(arguments, **kwargs):
"""Run a command. Check return code and suppress output by default.""" """Run a command. Check return code and suppress output by default."""
env = dict(os.environ, LDAPSCRIPTS_CONF=LDAPSCRIPTS_CONF)
kwargs['stdout'] = kwargs.get('stdout', subprocess.DEVNULL) kwargs['stdout'] = kwargs.get('stdout', subprocess.DEVNULL)
kwargs['stderr'] = kwargs.get('stderr', subprocess.DEVNULL) kwargs['stderr'] = kwargs.get('stderr', subprocess.DEVNULL)
kwargs['check'] = kwargs.get('check', True) kwargs['check'] = kwargs.get('check', True)
return subprocess.run(arguments, **kwargs) return subprocess.run(arguments, env=env, **kwargs)
def main(): def main():