summaryrefslogtreecommitdiffstats
path: root/ipaserver
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-02-10 22:13:42 -0500
committerRob Crittenden <rcritten@redhat.com>2011-02-11 09:51:44 -0500
commit95b0563817c20bd7d7d82719d8baf8eac2bc9098 (patch)
tree801e9437d000bdb36759d2a6cefcaafd4939e6f4 /ipaserver
parenta880396de94af284e82223913dbcf9598c2bdb4c (diff)
downloadfreeipa-95b0563817c20bd7d7d82719d8baf8eac2bc9098.tar.gz
freeipa-95b0563817c20bd7d7d82719d8baf8eac2bc9098.tar.xz
freeipa-95b0563817c20bd7d7d82719d8baf8eac2bc9098.zip
Ensure that file ownership doesn't change when config is updated.
Out of the blue update_file() and set_directive() changed file ownership to root:root when it updated some files. This was causing dogtag to break. So grab the owner before opening the file and reset it after closing. ticket 928
Diffstat (limited to 'ipaserver')
-rw-r--r--ipaserver/install/installutils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 314c26c7f..99d1582eb 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -282,6 +282,7 @@ def read_password(user, confirm=True, validate=True):
def update_file(filename, orig, subst):
if os.path.exists(filename):
+ st = os.stat(filename)
pattern = "%s" % re.escape(orig)
p = re.compile(pattern)
for line in fileinput.input(filename, inplace=1):
@@ -290,6 +291,7 @@ def update_file(filename, orig, subst):
else:
sys.stdout.write(p.sub(subst, line))
fileinput.close()
+ os.chown(filename, st.st_uid, st.st_gid) # reset perms
return 0
else:
print "File %s doesn't exist." % filename
@@ -301,6 +303,7 @@ def set_directive(filename, directive, value, quotes=True, separator=' '):
This has only been tested with nss.conf
"""
valueset = False
+ st = os.stat(filename)
fd = open(filename)
newfile = []
for line in fd:
@@ -322,6 +325,7 @@ def set_directive(filename, directive, value, quotes=True, separator=' '):
fd = open(filename, "w")
fd.write("".join(newfile))
fd.close()
+ os.chown(filename, st.st_uid, st.st_gid) # reset perms
def get_directive(filename, directive, separator=' '):
"""