diff options
author | Rob Austein <sra@hactrn.net> | 2010-10-05 19:43:07 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2010-10-05 19:43:07 +0000 |
commit | 86acc6e5546a78abb5cdf4514e5e8e0d52785c72 (patch) | |
tree | 27de68349fd0f1bf72bcee70da0192869f75e5f2 /scripts/convert-https-to-http.py | |
parent | 0fe4f839564470234ab70805bf81567dd86b30d5 (diff) |
Hack to remove obsolete elements from entitydb files.
svn path=/scripts/convert-https-to-http.py; revision=3460
Diffstat (limited to 'scripts/convert-https-to-http.py')
-rw-r--r-- | scripts/convert-https-to-http.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/convert-https-to-http.py b/scripts/convert-https-to-http.py index ac5e7adf..9cfcd991 100644 --- a/scripts/convert-https-to-http.py +++ b/scripts/convert-https-to-http.py @@ -25,8 +25,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import getopt, sys, os -from xml.etree.ElementTree import (Element, SubElement, ElementTree) +import getopt, sys, os, lxml.etree cfg_file = "myrpki.conf" entitydb_dir = "entitydb" @@ -56,13 +55,28 @@ for root, dirs, files in os.walk(entitydb_dir): for filename in files: if filename.endswith(".xml"): filename = os.path.join(root, filename) - tree = ElementTree(file = filename).getroot() + tree = lxml.etree.ElementTree(file = filename) changed = False for e in tree.getiterator(): + p = e.getparent() + if (e.tag in ("{http://www.hactrn.net/uris/rpki/myrpki/}bpki_https_cert", + "{http://www.hactrn.net/uris/rpki/myrpki/}bpki_https_glue", + "{http://www.hactrn.net/uris/rpki/myrpki/}bpki_https_certificate") or + (e.tag == "{http://www.hactrn.net/uris/rpki/myrpki/}bpki_server_ta" and + p.tag == "{http://www.hactrn.net/uris/rpki/myrpki/}parent")): + p.remove(e) + changed = True + continue for k, v in e.items(): if v.startswith("https://"): e.set(k, v.replace("https://", "http://")) changed = True if changed: - ElementTree(tree).write(filename + ".new") + tree.write(filename + ".new") os.rename(filename + ".new", filename) + +# Also need to do something about changes to SQL schemas? svn diff +# old and new to calculate full set of changes (including replay +# protection stuff) and include static set of ALTER COLUMN (etc) +# instructions here? Use config file to figure out SQL passwords and +# make changes automatically? Ask for permission first? |