scripts/moduser
Anthony Wang f66983313f
Pass LDAP password filename instead of password itself in *user scripts
This ensures the LDAP password doesn't show up in process table. I was an idiot when I wrote the original code.
2023-06-14 18:57:02 +00:00

25 lines
558 B
Python
Executable file

#!/usr/bin/python
# A wrapper script over ldapvi
# Requires http://www.lichteblau.com/ldapvi/
from os import environ
from subprocess import run
from sys import argv
def moduser(username):
"""Modify an existing user"""
if 'EDITOR' not in environ:
environ['EDITOR'] = 'micro'
if username == 'Manager':
run(['ldapvi', '-y', '/etc/ldappass', '--user', 'cn=Manager,dc=exozy,dc=me'])
else:
dn = 'uid=' + username + ',ou=People,dc=exozy,dc=me'
run(['ldapvi', '--user', dn, '--base', dn])
moduser(argv[1])