diff options
author | Martin Kosek <mkosek@redhat.com> | 2013-10-25 09:00:58 +0200 |
---|---|---|
committer | Petr Viktorin <pviktori@redhat.com> | 2013-10-25 15:35:49 +0200 |
commit | 63de9b80ffcfd7aa2c58dc16a2dd1970ca0800f0 (patch) | |
tree | 01fc2681d9daa8e79b1ea0ea616b21e3018daa8e | |
parent | b7335967b33fd55f767983351e146979f849fa3d (diff) | |
download | freeipa-63de9b80ffcfd7aa2c58dc16a2dd1970ca0800f0.tar.gz freeipa-63de9b80ffcfd7aa2c58dc16a2dd1970ca0800f0.tar.xz freeipa-63de9b80ffcfd7aa2c58dc16a2dd1970ca0800f0.zip |
Make set_directive and get_directive more strict
When set_directive was used for directive "foo" and the word "foo"
was detected anywhere on the line (e.g. in a comment, or in an example),
it was overwritten which may potentially lead to wrong line being
overwritten.
Only match the directives on the beginning of the lines, it is safer.
https://fedorahosted.org/freeipa/ticket/3974
-rw-r--r-- | ipaserver/install/installutils.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py index 8fcb43e9e..c26f072f2 100644 --- a/ipaserver/install/installutils.py +++ b/ipaserver/install/installutils.py @@ -331,7 +331,7 @@ def set_directive(filename, directive, value, quotes=True, separator=' '): fd = open(filename) newfile = [] for line in fd: - if directive in line: + if line.lstrip().startswith(directive): valueset = True if value is not None: if quotes: @@ -359,7 +359,7 @@ def get_directive(filename, directive, separator=' '): """ fd = open(filename, "r") for line in fd: - if directive in line: + if line.lstrip().startswith(directive): line = line.strip() result = line.split(separator, 1)[1] result = result.strip('"') |