mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
users: yapf cosmetic changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
696ce3b6a5
commit
7499b687c8
@ -20,13 +20,14 @@ Configuration helper for the LDAP user directory
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import augeas
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import augeas
|
||||
|
||||
from plinth import action_utils
|
||||
|
||||
ACCESS_CONF = '/etc/security/access.conf'
|
||||
@ -122,12 +123,13 @@ def subcommand_setup(_):
|
||||
|
||||
def configure_ldap_authentication():
|
||||
"""Configure LDAP authentication."""
|
||||
action_utils.dpkg_reconfigure('nslcd', {
|
||||
'ldap-uris': 'ldapi:///',
|
||||
'ldap-base': 'dc=thisbox',
|
||||
'ldap-auth-type': 'SASL',
|
||||
'ldap-sasl-mech': 'EXTERNAL'
|
||||
})
|
||||
action_utils.dpkg_reconfigure(
|
||||
'nslcd', {
|
||||
'ldap-uris': 'ldapi:///',
|
||||
'ldap-base': 'dc=thisbox',
|
||||
'ldap-auth-type': 'SASL',
|
||||
'ldap-sasl-mech': 'EXTERNAL'
|
||||
})
|
||||
action_utils.dpkg_reconfigure('libnss-ldapd',
|
||||
{'nsswitch': 'group, passwd, shadow'})
|
||||
action_utils.service_restart('nscd')
|
||||
@ -165,9 +167,9 @@ dn: ou={unit},dc=thisbox
|
||||
objectClass: top
|
||||
objectClass: organizationalUnit
|
||||
ou: {unit}'''.format(unit=unit)
|
||||
subprocess.run(['ldapadd', '-Q', '-Y', 'EXTERNAL', '-H',
|
||||
'ldapi:///'], input=input.encode(),
|
||||
stdout=subprocess.DEVNULL, check=True)
|
||||
subprocess.run(['ldapadd', '-Q', '-Y', 'EXTERNAL', '-H', 'ldapi:///'],
|
||||
input=input.encode(), stdout=subprocess.DEVNULL,
|
||||
check=True)
|
||||
|
||||
|
||||
def setup_admin():
|
||||
@ -185,8 +187,8 @@ def setup_admin():
|
||||
|
||||
if 'olcRootPW' in ldap_object:
|
||||
subprocess.run(
|
||||
['ldapmodify', '-Q', '-Y', 'EXTERNAL', '-H',
|
||||
'ldapi:///'], check=True, stdout=subprocess.DEVNULL, input=b'''
|
||||
['ldapmodify', '-Q', '-Y', 'EXTERNAL', '-H', 'ldapi:///'],
|
||||
check=True, stdout=subprocess.DEVNULL, input=b'''
|
||||
dn: olcDatabase={1}mdb,cn=config
|
||||
changetype: modify
|
||||
delete: olcRootPW''')
|
||||
@ -194,8 +196,8 @@ delete: olcRootPW''')
|
||||
root_dn = 'gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth'
|
||||
if ldap_object['olcRootDN'] != root_dn:
|
||||
subprocess.run(
|
||||
['ldapmodify', '-Q', '-Y', 'EXTERNAL', '-H',
|
||||
'ldapi:///'], check=True, stdout=subprocess.DEVNULL, input=b'''
|
||||
['ldapmodify', '-Q', '-Y', 'EXTERNAL', '-H', 'ldapi:///'],
|
||||
check=True, stdout=subprocess.DEVNULL, input=b'''
|
||||
dn: olcDatabase={1}mdb,cn=config
|
||||
changetype: modify
|
||||
replace: olcRootDN
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user