mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
User provided certs.
This commit is contained in:
@@ -21,6 +21,10 @@ import logging
|
||||
import socket
|
||||
import errno
|
||||
import getpass
|
||||
import os
|
||||
import re
|
||||
import fileinput
|
||||
import sys
|
||||
|
||||
def get_fqdn():
|
||||
fqdn = ""
|
||||
@@ -105,4 +109,19 @@ def read_password(user):
|
||||
print ""
|
||||
return pwd
|
||||
|
||||
def update_file(filename, orig, subst):
|
||||
if os.path.exists(filename):
|
||||
pattern = "%s" % re.escape(orig)
|
||||
p = re.compile(pattern)
|
||||
for line in fileinput.input(filename, inplace=1):
|
||||
if not p.search(line):
|
||||
sys.stdout.write(line)
|
||||
else:
|
||||
sys.stdout.write(p.sub(subst, line))
|
||||
fileinput.close()
|
||||
return 0
|
||||
else:
|
||||
print "File %s doesn't exist." % filename
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user