From b9ea94e261276a1da6ab9d4242d39b6f99894218 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 5 Apr 2013 22:36:23 +0000 Subject: Consolidate list of scripts for setup.py to install into setup.py, get rid of a lot of Makefile.in code that no longer serves any useful purpose. svn path=/trunk/; revision=5285 --- rpkid/Makefile.in | 117 +------ rpkid/irbe_cli | 385 ++++++++++++++++++++++ rpkid/irbe_cli.py | 385 ---------------------- rpkid/irdbd | 23 ++ rpkid/irdbd.py | 23 -- rpkid/portal-gui/rpki.wsgi | 31 ++ rpkid/portal-gui/rpki.wsgi.in | 31 -- rpkid/portal-gui/scripts/rpki-manage | 13 + rpkid/portal-gui/scripts/rpki-manage.py | 13 - rpkid/portal-gui/scripts/rpkigui-check-expired | 61 ++++ rpkid/portal-gui/scripts/rpkigui-check-expired.py | 61 ---- rpkid/portal-gui/scripts/rpkigui-import-routes | 67 ++++ rpkid/portal-gui/scripts/rpkigui-import-routes.py | 67 ---- rpkid/portal-gui/scripts/rpkigui-rcynic | 54 +++ rpkid/portal-gui/scripts/rpkigui-rcynic.py | 54 --- rpkid/pubd | 23 ++ rpkid/pubd.py | 23 -- rpkid/rootd | 23 ++ rpkid/rootd.py | 23 -- rpkid/rpki-confgen | 181 ++++++++++ rpkid/rpki-confgen.py | 181 ---------- rpkid/rpki-sql-backup | 57 ++++ rpkid/rpki-sql-backup.py | 57 ---- rpkid/rpki-sql-setup | 122 +++++++ rpkid/rpki-sql-setup.py | 122 ------- rpkid/rpki-start-servers | 87 +++++ rpkid/rpki-start-servers.py | 87 ----- rpkid/rpkic | 23 ++ rpkid/rpkic.py | 23 -- rpkid/rpkid | 23 ++ rpkid/rpkid.py | 23 -- rpkid/setup.py | 26 +- rpkid/tests/smoketest.py | 6 +- 33 files changed, 1205 insertions(+), 1290 deletions(-) create mode 100755 rpkid/irbe_cli delete mode 100644 rpkid/irbe_cli.py create mode 100755 rpkid/irdbd delete mode 100644 rpkid/irdbd.py create mode 100644 rpkid/portal-gui/rpki.wsgi delete mode 100644 rpkid/portal-gui/rpki.wsgi.in create mode 100755 rpkid/portal-gui/scripts/rpki-manage delete mode 100644 rpkid/portal-gui/scripts/rpki-manage.py create mode 100755 rpkid/portal-gui/scripts/rpkigui-check-expired delete mode 100644 rpkid/portal-gui/scripts/rpkigui-check-expired.py create mode 100755 rpkid/portal-gui/scripts/rpkigui-import-routes delete mode 100644 rpkid/portal-gui/scripts/rpkigui-import-routes.py create mode 100755 rpkid/portal-gui/scripts/rpkigui-rcynic delete mode 100644 rpkid/portal-gui/scripts/rpkigui-rcynic.py create mode 100755 rpkid/pubd delete mode 100644 rpkid/pubd.py create mode 100755 rpkid/rootd delete mode 100644 rpkid/rootd.py create mode 100755 rpkid/rpki-confgen delete mode 100644 rpkid/rpki-confgen.py create mode 100755 rpkid/rpki-sql-backup delete mode 100644 rpkid/rpki-sql-backup.py create mode 100755 rpkid/rpki-sql-setup delete mode 100644 rpkid/rpki-sql-setup.py create mode 100755 rpkid/rpki-start-servers delete mode 100644 rpkid/rpki-start-servers.py create mode 100755 rpkid/rpkic delete mode 100644 rpkid/rpkic.py create mode 100755 rpkid/rpkid delete mode 100644 rpkid/rpkid.py diff --git a/rpkid/Makefile.in b/rpkid/Makefile.in index 5c697f91..17635389 100644 --- a/rpkid/Makefile.in +++ b/rpkid/Makefile.in @@ -30,53 +30,14 @@ srcdir = @srcdir@ SETUP_PY_INSTALL_LAYOUT = @SETUP_PY_INSTALL_LAYOUT@ -# PID files seem to go into /var/run/ on every platform we support. -# We could make this an autoconf substitution if anything ever cares, -# but let's keep it simple for now. - -PID_DIR = ${DESTDIR}/var/run/rpkid - -SETUP_PY = \ - AC_CFLAGS='${CFLAGS}' \ - AC_LDFLAGS='${LDFLAGS}' \ - AC_LIBS='${LIBS}' \ - AC_SBINDIR='${sbindir}' \ - AC_SCRIPTS='${SCRIPTS}' \ - AC_DATA_FILES='${DATA_FILES}' \ - AC_CONF_FILES='${CONF_FILES}' \ - AC_ABS_BUILDDIR='${abs_builddir}' \ - AC_LIBEXECDIR='${libexecdir}' \ - AC_DATAROOTDIR='${datarootdir}/rpki' \ - AC_SYSCONFDIR='${sysconfdir}/rpki' \ - ${PYTHON} setup.py - SETUP_PY_ROOT = `${PYTHON} -c 'import sys; print "--root " + sys.argv[1] if sys.argv[1] else ""' '${DESTDIR}'` -POW_SO = rpki/POW/_POW.so - -SCRIPTS = \ - rpki-sql-backup rpki-sql-setup rpki-start-servers irbe_cli irdbd \ - pubd rootd rpkic rpkid rpki-confgen \ - portal-gui/scripts/rpkigui-import-routes \ - portal-gui/scripts/rpkigui-check-expired \ - portal-gui/scripts/rpkigui-rcynic \ - portal-gui/scripts/rpki-manage - -# scripts we build, but don't install -BUILD_SCRIPTS = \ - portal-gui/rpki.wsgi \ - rpki/autoconf.py +POW_SO = rpki/POW/_POW.so -# these files get put in ${datarootdir}/rpki -DATA_FILES = portal-gui/routeviews.sh - -# these files get put in ${sysconfdir}/rpki -CONF_FILES = portal-gui/apache.conf rpki-confgen.xml - -all:: ${POW_SO} rpki/relaxng.py myrpki.rng rpki/sql_schemas.py ${SCRIPTS} ${BUILD_SCRIPTS} +all:: rpki/autoconf.py ${POW_SO} rpki/relaxng.py myrpki.rng rpki/sql_schemas.py ${POW_SO}: ext/POW.c setup.py setup_autoconf.py - ${SETUP_PY} build_ext --inplace + ${PYTHON} setup.py build_ext --inplace clean:: rm -rf ${POW_SO} build dist @@ -106,19 +67,12 @@ rpki/sql_schemas.py: ${abs_top_srcdir}/buildtools/make-sql-schemas.py rpkid.sql clean:: find . -type f -name '*.py[co]' -delete cd tests; $(MAKE) $@ - rm -f ${SCRIPTS} ${SETTINGS} ${BUILD_SCRIPTS} install:: all - ${SETUP_PY} install ${SETUP_PY_ROOT} ${SETUP_PY_INSTALL_LAYOUT} --record installed + ${PYTHON} setup.py install ${SETUP_PY_ROOT} ${SETUP_PY_INSTALL_LAYOUT} --record installed @echo @echo "== Default configuration file location is ${sysconfdir}/rpki.conf ==" @echo -# -# We used to do this, but Debian/Ubuntu lintian complained that -# /var/run may be a temporary filesystem, thus directories like this -# should be created at boot. Fair point. -# -# if test -d ${PID_DIR}; then :; else ${INSTALL} -d ${PID_DIR}; fi uninstall deinstall:: xargs rm -fv $@ +clean:: + rm -f rpki/autoconf.py + setup_autoconf.py: rpki/autoconf.py @echo 'Generating $@'; \ (cat rpki/autoconf.py; \ diff --git a/rpkid/irbe_cli b/rpkid/irbe_cli new file mode 100755 index 00000000..f8f87990 --- /dev/null +++ b/rpkid/irbe_cli @@ -0,0 +1,385 @@ +#!/usr/bin/env python + +""" +Command line IR back-end control program for rpkid and pubd. + +$Id$ + +Copyright (C) 2009--2013 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +import sys +import getopt +import textwrap +import rpki.left_right +import rpki.http +import rpki.x509 +import rpki.config +import rpki.log +import rpki.publication +import rpki.async + +pem_out = None + +class UsageWrapper(textwrap.TextWrapper): + """ + Call interface around Python textwrap.Textwrapper class. + """ + + def __call__(self, *args): + """ + Format arguments, with TextWrapper indentation. + """ + return self.fill(textwrap.dedent(" ".join(args))) + +usage_fill = UsageWrapper(subsequent_indent = " " * 4) + +class reply_elt_mixin(object): + """ + Protocol mix-in for printout of reply PDUs. + """ + + is_cmd = False + + def client_reply_decode(self): + pass + + def client_reply_show(self): + print self.element_name + for i in self.attributes + self.elements: + if getattr(self, i) is not None: + print " %s: %s" % (i, getattr(self, i)) + +class cmd_elt_mixin(reply_elt_mixin): + """ + Protocol mix-in for command line client element PDUs. + """ + + is_cmd = True + + ## @var excludes + # XML attributes and elements that should not be allowed as command + # line arguments. + excludes = () + + @classmethod + def usage(cls): + """ + Generate usage message for this PDU. + """ + args = " ".join("--" + x + "=" for x in cls.attributes + cls.elements if x not in cls.excludes) + bools = " ".join("--" + x for x in cls.booleans) + if args and bools: + return args + " " + bools + else: + return args or bools + + def client_getopt(self, argv): + """ + Parse options for this class. + """ + # pylint: disable=W0621 + opts, argv = getopt.getopt(argv, "", [x + "=" for x in self.attributes + self.elements if x not in self.excludes] + list(self.booleans)) + for o, a in opts: + o = o[2:] + handler = getattr(self, "client_query_" + o, None) + if handler is not None: + handler(a) + elif o in self.booleans: + setattr(self, o, True) + else: + assert o in self.attributes + setattr(self, o, a) + return argv + + def client_query_bpki_cert(self, arg): + """ + Special handler for --bpki_cert option. + """ + self.bpki_cert = rpki.x509.X509(Auto_file = arg) + + def client_query_glue(self, arg): + """ + Special handler for --bpki_glue option. + """ + self.bpki_glue = rpki.x509.X509(Auto_file = arg) + + def client_query_bpki_cms_cert(self, arg): + """ + Special handler for --bpki_cms_cert option. + """ + self.bpki_cms_cert = rpki.x509.X509(Auto_file = arg) + + def client_query_cms_glue(self, arg): + """ + Special handler for --bpki_cms_glue option. + """ + self.bpki_cms_glue = rpki.x509.X509(Auto_file = arg) + +class cmd_msg_mixin(object): + """ + Protocol mix-in for command line client message PDUs. + """ + + @classmethod + def usage(cls): + """ + Generate usage message for this PDU. + """ + for k, v in cls.pdus.items(): + if v.is_cmd: + print usage_fill(k, v.usage()) + +# left-right protcol + +class left_right_msg(cmd_msg_mixin, rpki.left_right.msg): + + class self_elt(cmd_elt_mixin, rpki.left_right.self_elt): + pass + + class bsc_elt(cmd_elt_mixin, rpki.left_right.bsc_elt): + + excludes = ("pkcs10_request",) + + def client_query_signing_cert(self, arg): + """--signing_cert option.""" + self.signing_cert = rpki.x509.X509(Auto_file = arg) + + def client_query_signing_cert_crl(self, arg): + """--signing_cert_crl option.""" + self.signing_cert_crl = rpki.x509.CRL(Auto_file = arg) + + def client_reply_decode(self): + global pem_out + if pem_out is not None and self.pkcs10_request is not None: + if isinstance(pem_out, str): + pem_out = open(pem_out, "w") + pem_out.write(self.pkcs10_request.get_PEM()) + + class parent_elt(cmd_elt_mixin, rpki.left_right.parent_elt): + pass + + class child_elt(cmd_elt_mixin, rpki.left_right.child_elt): + pass + + class repository_elt(cmd_elt_mixin, rpki.left_right.repository_elt): + pass + + class list_published_objects_elt(cmd_elt_mixin, rpki.left_right.list_published_objects_elt): + excludes = ("uri",) + + class list_received_resources_elt(cmd_elt_mixin, rpki.left_right.list_received_resources_elt): + excludes = ("parent_handle", "notBefore", "notAfter", "uri", "sia_uri", "aia_uri", "asn", "ipv4", "ipv6") + + class report_error_elt(reply_elt_mixin, rpki.left_right.report_error_elt): + pass + + pdus = dict((x.element_name, x) + for x in (self_elt, bsc_elt, parent_elt, child_elt, repository_elt, + list_published_objects_elt, list_received_resources_elt, report_error_elt)) + +class left_right_sax_handler(rpki.left_right.sax_handler): + pdu = left_right_msg + +class left_right_cms_msg(rpki.left_right.cms_msg): + saxify = left_right_sax_handler.saxify + +# Publication protocol + +class publication_msg(cmd_msg_mixin, rpki.publication.msg): + + class config_elt(cmd_elt_mixin, rpki.publication.config_elt): + + def client_query_bpki_crl(self, arg): + """ + Special handler for --bpki_crl option. + """ + self.bpki_crl = rpki.x509.CRL(Auto_file = arg) + + class client_elt(cmd_elt_mixin, rpki.publication.client_elt): + pass + + class certificate_elt(cmd_elt_mixin, rpki.publication.certificate_elt): + pass + + class crl_elt(cmd_elt_mixin, rpki.publication.crl_elt): + pass + + class manifest_elt(cmd_elt_mixin, rpki.publication.manifest_elt): + pass + + class roa_elt(cmd_elt_mixin, rpki.publication.roa_elt): + pass + + class report_error_elt(reply_elt_mixin, rpki.publication.report_error_elt): + pass + + class ghostbuster_elt(cmd_elt_mixin, rpki.publication.ghostbuster_elt): + pass + + pdus = dict((x.element_name, x) + for x in (config_elt, client_elt, certificate_elt, crl_elt, + manifest_elt, roa_elt, report_error_elt, + ghostbuster_elt)) + +class publication_sax_handler(rpki.publication.sax_handler): + pdu = publication_msg + +class publication_cms_msg(rpki.publication.cms_msg): + saxify = publication_sax_handler.saxify + +# Usage + +top_opts = ["config=", "help", "pem_out=", "quiet", "verbose"] + +def usage(code = 1): + if __doc__ is not None: + print __doc__.strip() + print + print "Usage:" + print + print "# Top-level options:" + print usage_fill(*["--" + x for x in top_opts]) + print + print "# left-right protocol:" + left_right_msg.usage() + print + print "# publication protocol:" + publication_msg.usage() + sys.exit(code) + +# Main program + +rpki.log.init("irbe_cli") + +argv = sys.argv[1:] + +if not argv: + usage(0) + +cfg_file = None +verbose = True + +opts, argv = getopt.getopt(argv, "c:hpqv?", top_opts) +for o, a in opts: + if o in ("-?", "-h", "--help"): + usage(0) + elif o in ("-c", "--config"): + cfg_file = a + elif o in ("-p", "--pem_out"): + pem_out = a + elif o in ("-q", "--quiet"): + verbose = False + elif o in ("-v", "--verbose"): + verbose = True + +if not argv: + usage(1) + +cfg = rpki.config.parser(cfg_file, "irbe_cli") + +q_msg_left_right = [] +q_msg_publication = [] + +while argv: + if argv[0] in left_right_msg.pdus: + q_pdu = left_right_msg.pdus[argv[0]]() + q_msg = q_msg_left_right + elif argv[0] in publication_msg.pdus: + q_pdu = publication_msg.pdus[argv[0]]() + q_msg = q_msg_publication + else: + usage(1) + argv = q_pdu.client_getopt(argv[1:]) + q_msg.append(q_pdu) + +from django.conf import settings + +settings.configure( + DATABASES = { "default" : { + "ENGINE" : "django.db.backends.mysql", + "NAME" : cfg.get("sql-database", section = "irdbd"), + "USER" : cfg.get("sql-username", section = "irdbd"), + "PASSWORD" : cfg.get("sql-password", section = "irdbd"), + "HOST" : "", + "PORT" : "", + "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}}, + INSTALLED_APPS = ("rpki.irdb",), +) + +import rpki.irdb + +server_ca = rpki.irdb.ServerCA.objects.get() +irbe = server_ca.ee_certificates.get(purpose = "irbe") + +if q_msg_left_right: + + class left_right_proto(object): + cms_msg = left_right_cms_msg + msg = left_right_msg + + rpkid = server_ca.ee_certificates.get(purpose = "rpkid") + + rpkid_url = "http://%s:%s/left-right/" % ( + cfg.get("server-host", section = "rpkid"), + cfg.get("server-port", section = "rpkid")) + + call_rpkid = rpki.async.sync_wrapper(rpki.http.caller( + proto = left_right_proto, + client_key = irbe.private_key, + client_cert = irbe.certificate, + server_ta = server_ca.certificate, + server_cert = rpkid.certificate, + url = rpkid_url, + debug = verbose)) + + call_rpkid(*q_msg_left_right) + +if q_msg_publication: + + class publication_proto(object): + msg = publication_msg + cms_msg = publication_cms_msg + + pubd = server_ca.ee_certificates.get(purpose = "pubd") + + pubd_url = "http://%s:%s/control/" % ( + cfg.get("server-host", section = "pubd"), + cfg.get("server-port", section = "pubd")) + + call_pubd = rpki.async.sync_wrapper(rpki.http.caller( + proto = publication_proto, + client_key = irbe.private_key, + client_cert = irbe.certificate, + server_ta = server_ca.certificate, + server_cert = pubd.certificate, + url = pubd_url, + debug = verbose)) + + call_pubd(*q_msg_publication) diff --git a/rpkid/irbe_cli.py b/rpkid/irbe_cli.py deleted file mode 100644 index f8f87990..00000000 --- a/rpkid/irbe_cli.py +++ /dev/null @@ -1,385 +0,0 @@ -#!/usr/bin/env python - -""" -Command line IR back-end control program for rpkid and pubd. - -$Id$ - -Copyright (C) 2009--2013 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -import sys -import getopt -import textwrap -import rpki.left_right -import rpki.http -import rpki.x509 -import rpki.config -import rpki.log -import rpki.publication -import rpki.async - -pem_out = None - -class UsageWrapper(textwrap.TextWrapper): - """ - Call interface around Python textwrap.Textwrapper class. - """ - - def __call__(self, *args): - """ - Format arguments, with TextWrapper indentation. - """ - return self.fill(textwrap.dedent(" ".join(args))) - -usage_fill = UsageWrapper(subsequent_indent = " " * 4) - -class reply_elt_mixin(object): - """ - Protocol mix-in for printout of reply PDUs. - """ - - is_cmd = False - - def client_reply_decode(self): - pass - - def client_reply_show(self): - print self.element_name - for i in self.attributes + self.elements: - if getattr(self, i) is not None: - print " %s: %s" % (i, getattr(self, i)) - -class cmd_elt_mixin(reply_elt_mixin): - """ - Protocol mix-in for command line client element PDUs. - """ - - is_cmd = True - - ## @var excludes - # XML attributes and elements that should not be allowed as command - # line arguments. - excludes = () - - @classmethod - def usage(cls): - """ - Generate usage message for this PDU. - """ - args = " ".join("--" + x + "=" for x in cls.attributes + cls.elements if x not in cls.excludes) - bools = " ".join("--" + x for x in cls.booleans) - if args and bools: - return args + " " + bools - else: - return args or bools - - def client_getopt(self, argv): - """ - Parse options for this class. - """ - # pylint: disable=W0621 - opts, argv = getopt.getopt(argv, "", [x + "=" for x in self.attributes + self.elements if x not in self.excludes] + list(self.booleans)) - for o, a in opts: - o = o[2:] - handler = getattr(self, "client_query_" + o, None) - if handler is not None: - handler(a) - elif o in self.booleans: - setattr(self, o, True) - else: - assert o in self.attributes - setattr(self, o, a) - return argv - - def client_query_bpki_cert(self, arg): - """ - Special handler for --bpki_cert option. - """ - self.bpki_cert = rpki.x509.X509(Auto_file = arg) - - def client_query_glue(self, arg): - """ - Special handler for --bpki_glue option. - """ - self.bpki_glue = rpki.x509.X509(Auto_file = arg) - - def client_query_bpki_cms_cert(self, arg): - """ - Special handler for --bpki_cms_cert option. - """ - self.bpki_cms_cert = rpki.x509.X509(Auto_file = arg) - - def client_query_cms_glue(self, arg): - """ - Special handler for --bpki_cms_glue option. - """ - self.bpki_cms_glue = rpki.x509.X509(Auto_file = arg) - -class cmd_msg_mixin(object): - """ - Protocol mix-in for command line client message PDUs. - """ - - @classmethod - def usage(cls): - """ - Generate usage message for this PDU. - """ - for k, v in cls.pdus.items(): - if v.is_cmd: - print usage_fill(k, v.usage()) - -# left-right protcol - -class left_right_msg(cmd_msg_mixin, rpki.left_right.msg): - - class self_elt(cmd_elt_mixin, rpki.left_right.self_elt): - pass - - class bsc_elt(cmd_elt_mixin, rpki.left_right.bsc_elt): - - excludes = ("pkcs10_request",) - - def client_query_signing_cert(self, arg): - """--signing_cert option.""" - self.signing_cert = rpki.x509.X509(Auto_file = arg) - - def client_query_signing_cert_crl(self, arg): - """--signing_cert_crl option.""" - self.signing_cert_crl = rpki.x509.CRL(Auto_file = arg) - - def client_reply_decode(self): - global pem_out - if pem_out is not None and self.pkcs10_request is not None: - if isinstance(pem_out, str): - pem_out = open(pem_out, "w") - pem_out.write(self.pkcs10_request.get_PEM()) - - class parent_elt(cmd_elt_mixin, rpki.left_right.parent_elt): - pass - - class child_elt(cmd_elt_mixin, rpki.left_right.child_elt): - pass - - class repository_elt(cmd_elt_mixin, rpki.left_right.repository_elt): - pass - - class list_published_objects_elt(cmd_elt_mixin, rpki.left_right.list_published_objects_elt): - excludes = ("uri",) - - class list_received_resources_elt(cmd_elt_mixin, rpki.left_right.list_received_resources_elt): - excludes = ("parent_handle", "notBefore", "notAfter", "uri", "sia_uri", "aia_uri", "asn", "ipv4", "ipv6") - - class report_error_elt(reply_elt_mixin, rpki.left_right.report_error_elt): - pass - - pdus = dict((x.element_name, x) - for x in (self_elt, bsc_elt, parent_elt, child_elt, repository_elt, - list_published_objects_elt, list_received_resources_elt, report_error_elt)) - -class left_right_sax_handler(rpki.left_right.sax_handler): - pdu = left_right_msg - -class left_right_cms_msg(rpki.left_right.cms_msg): - saxify = left_right_sax_handler.saxify - -# Publication protocol - -class publication_msg(cmd_msg_mixin, rpki.publication.msg): - - class config_elt(cmd_elt_mixin, rpki.publication.config_elt): - - def client_query_bpki_crl(self, arg): - """ - Special handler for --bpki_crl option. - """ - self.bpki_crl = rpki.x509.CRL(Auto_file = arg) - - class client_elt(cmd_elt_mixin, rpki.publication.client_elt): - pass - - class certificate_elt(cmd_elt_mixin, rpki.publication.certificate_elt): - pass - - class crl_elt(cmd_elt_mixin, rpki.publication.crl_elt): - pass - - class manifest_elt(cmd_elt_mixin, rpki.publication.manifest_elt): - pass - - class roa_elt(cmd_elt_mixin, rpki.publication.roa_elt): - pass - - class report_error_elt(reply_elt_mixin, rpki.publication.report_error_elt): - pass - - class ghostbuster_elt(cmd_elt_mixin, rpki.publication.ghostbuster_elt): - pass - - pdus = dict((x.element_name, x) - for x in (config_elt, client_elt, certificate_elt, crl_elt, - manifest_elt, roa_elt, report_error_elt, - ghostbuster_elt)) - -class publication_sax_handler(rpki.publication.sax_handler): - pdu = publication_msg - -class publication_cms_msg(rpki.publication.cms_msg): - saxify = publication_sax_handler.saxify - -# Usage - -top_opts = ["config=", "help", "pem_out=", "quiet", "verbose"] - -def usage(code = 1): - if __doc__ is not None: - print __doc__.strip() - print - print "Usage:" - print - print "# Top-level options:" - print usage_fill(*["--" + x for x in top_opts]) - print - print "# left-right protocol:" - left_right_msg.usage() - print - print "# publication protocol:" - publication_msg.usage() - sys.exit(code) - -# Main program - -rpki.log.init("irbe_cli") - -argv = sys.argv[1:] - -if not argv: - usage(0) - -cfg_file = None -verbose = True - -opts, argv = getopt.getopt(argv, "c:hpqv?", top_opts) -for o, a in opts: - if o in ("-?", "-h", "--help"): - usage(0) - elif o in ("-c", "--config"): - cfg_file = a - elif o in ("-p", "--pem_out"): - pem_out = a - elif o in ("-q", "--quiet"): - verbose = False - elif o in ("-v", "--verbose"): - verbose = True - -if not argv: - usage(1) - -cfg = rpki.config.parser(cfg_file, "irbe_cli") - -q_msg_left_right = [] -q_msg_publication = [] - -while argv: - if argv[0] in left_right_msg.pdus: - q_pdu = left_right_msg.pdus[argv[0]]() - q_msg = q_msg_left_right - elif argv[0] in publication_msg.pdus: - q_pdu = publication_msg.pdus[argv[0]]() - q_msg = q_msg_publication - else: - usage(1) - argv = q_pdu.client_getopt(argv[1:]) - q_msg.append(q_pdu) - -from django.conf import settings - -settings.configure( - DATABASES = { "default" : { - "ENGINE" : "django.db.backends.mysql", - "NAME" : cfg.get("sql-database", section = "irdbd"), - "USER" : cfg.get("sql-username", section = "irdbd"), - "PASSWORD" : cfg.get("sql-password", section = "irdbd"), - "HOST" : "", - "PORT" : "", - "OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}}, - INSTALLED_APPS = ("rpki.irdb",), -) - -import rpki.irdb - -server_ca = rpki.irdb.ServerCA.objects.get() -irbe = server_ca.ee_certificates.get(purpose = "irbe") - -if q_msg_left_right: - - class left_right_proto(object): - cms_msg = left_right_cms_msg - msg = left_right_msg - - rpkid = server_ca.ee_certificates.get(purpose = "rpkid") - - rpkid_url = "http://%s:%s/left-right/" % ( - cfg.get("server-host", section = "rpkid"), - cfg.get("server-port", section = "rpkid")) - - call_rpkid = rpki.async.sync_wrapper(rpki.http.caller( - proto = left_right_proto, - client_key = irbe.private_key, - client_cert = irbe.certificate, - server_ta = server_ca.certificate, - server_cert = rpkid.certificate, - url = rpkid_url, - debug = verbose)) - - call_rpkid(*q_msg_left_right) - -if q_msg_publication: - - class publication_proto(object): - msg = publication_msg - cms_msg = publication_cms_msg - - pubd = server_ca.ee_certificates.get(purpose = "pubd") - - pubd_url = "http://%s:%s/control/" % ( - cfg.get("server-host", section = "pubd"), - cfg.get("server-port", section = "pubd")) - - call_pubd = rpki.async.sync_wrapper(rpki.http.caller( - proto = publication_proto, - client_key = irbe.private_key, - client_cert = irbe.certificate, - server_ta = server_ca.certificate, - server_cert = pubd.certificate, - url = pubd_url, - debug = verbose)) - - call_pubd(*q_msg_publication) diff --git a/rpkid/irdbd b/rpkid/irdbd new file mode 100755 index 00000000..63370ab5 --- /dev/null +++ b/rpkid/irdbd @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +""" +$Id$ + +Copyright (C) 2010 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +if __name__ == "__main__": + import rpki.irdbd + rpki.irdbd.main() diff --git a/rpkid/irdbd.py b/rpkid/irdbd.py deleted file mode 100644 index 63370ab5..00000000 --- a/rpkid/irdbd.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -""" -$Id$ - -Copyright (C) 2010 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -if __name__ == "__main__": - import rpki.irdbd - rpki.irdbd.main() diff --git a/rpkid/portal-gui/rpki.wsgi b/rpkid/portal-gui/rpki.wsgi new file mode 100644 index 00000000..37bed594 --- /dev/null +++ b/rpkid/portal-gui/rpki.wsgi @@ -0,0 +1,31 @@ +# Copyright (C) 2010, 2011 SPARTA, Inc. dba Cobham Analytic Solutions +# Copyright (C) 2012, 2013 SPARTA, Inc. a Parsons Company +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# This is an example wsgi application for use with mod_wsgi and apache. + +__version__ = '$Id$' + +import sys +import os +import rpki.autoconf + +os.environ['DJANGO_SETTINGS_MODULE'] = 'rpki.gui.default_settings' +# needed for local_settings.py +sys.path.insert(1, rpki.autoconf.sysconfdir + '/rpki') + +import django.core.handlers.wsgi +application = django.core.handlers.wsgi.WSGIHandler() + +# vim:ft=python diff --git a/rpkid/portal-gui/rpki.wsgi.in b/rpkid/portal-gui/rpki.wsgi.in deleted file mode 100644 index 37bed594..00000000 --- a/rpkid/portal-gui/rpki.wsgi.in +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2010, 2011 SPARTA, Inc. dba Cobham Analytic Solutions -# Copyright (C) 2012, 2013 SPARTA, Inc. a Parsons Company -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# This is an example wsgi application for use with mod_wsgi and apache. - -__version__ = '$Id$' - -import sys -import os -import rpki.autoconf - -os.environ['DJANGO_SETTINGS_MODULE'] = 'rpki.gui.default_settings' -# needed for local_settings.py -sys.path.insert(1, rpki.autoconf.sysconfdir + '/rpki') - -import django.core.handlers.wsgi -application = django.core.handlers.wsgi.WSGIHandler() - -# vim:ft=python diff --git a/rpkid/portal-gui/scripts/rpki-manage b/rpkid/portal-gui/scripts/rpki-manage new file mode 100755 index 00000000..0d581ce9 --- /dev/null +++ b/rpkid/portal-gui/scripts/rpki-manage @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +import os +from django.core.management import execute_from_command_line + +# django-admin seems to have problems creating the superuser account when +# $LANG is unset or is set to something totally incompatible with UTF-8. +if os.environ.get('LANG') in (None, "", "C"): + os.environ['LANG'] = 'en_US.UTF-8' + +os.environ['DJANGO_SETTINGS_MODULE'] = 'rpki.gui.default_settings' + +execute_from_command_line() diff --git a/rpkid/portal-gui/scripts/rpki-manage.py b/rpkid/portal-gui/scripts/rpki-manage.py deleted file mode 100644 index 0d581ce9..00000000 --- a/rpkid/portal-gui/scripts/rpki-manage.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python - -import os -from django.core.management import execute_from_command_line - -# django-admin seems to have problems creating the superuser account when -# $LANG is unset or is set to something totally incompatible with UTF-8. -if os.environ.get('LANG') in (None, "", "C"): - os.environ['LANG'] = 'en_US.UTF-8' - -os.environ['DJANGO_SETTINGS_MODULE'] = 'rpki.gui.default_settings' - -execute_from_command_line() diff --git a/rpkid/portal-gui/scripts/rpkigui-check-expired b/rpkid/portal-gui/scripts/rpkigui-check-expired new file mode 100755 index 00000000..eb0c7fbb --- /dev/null +++ b/rpkid/portal-gui/scripts/rpkigui-check-expired @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +# Copyright (C) 2012 SPARTA, Inc. a Parsons Company +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +__version__ = '$Id$' + +from optparse import OptionParser +import logging +import sys + +# configure django ORM +from rpki.gui.script_util import setup +setup() + +from rpki.gui.app.check_expired import notify_expired + +usage = '%prog [ -nV ] [ handle1 handle2... ]' + +description = """Generate a report detailing all RPKI/BPKI certificates which +are due for impending expiration. If no resource handles are specified, a +report about all resource handles hosted by the local rpkid instance will be +generated.""" + +parser = OptionParser(usage, description=description) +parser.add_option('-V', '--version', help='display script version', + action='store_true', dest='version', default=False) +parser.add_option('-f', '--from', metavar='ADDRESS', dest='from_email', + help='specify the return email address for notifications') +parser.add_option('-t', '--expire-time', dest='expire_days', metavar='DAYS', + help='specify the number of days in the future to check') +parser.add_option('-l', '--level', dest='log_level', default='WARNING', + help='Set logging level [Default: %default]') +(options, args) = parser.parse_args() +if options.version: + print __version__ + sys.exit(0) + +v = getattr(logging, options.log_level.upper()) +logging.basicConfig(level=v) +logging.info('logging level set to ' + logging.getLevelName(v)) + +kwargs = {} +if options.from_email: + kwargs['from_email'] = options.from_email +if options.expire_days: + kwargs['expire_days'] = int(options.expire_days) +notify_expired(**kwargs) + +sys.exit(0) diff --git a/rpkid/portal-gui/scripts/rpkigui-check-expired.py b/rpkid/portal-gui/scripts/rpkigui-check-expired.py deleted file mode 100644 index eb0c7fbb..00000000 --- a/rpkid/portal-gui/scripts/rpkigui-check-expired.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2012 SPARTA, Inc. a Parsons Company -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -__version__ = '$Id$' - -from optparse import OptionParser -import logging -import sys - -# configure django ORM -from rpki.gui.script_util import setup -setup() - -from rpki.gui.app.check_expired import notify_expired - -usage = '%prog [ -nV ] [ handle1 handle2... ]' - -description = """Generate a report detailing all RPKI/BPKI certificates which -are due for impending expiration. If no resource handles are specified, a -report about all resource handles hosted by the local rpkid instance will be -generated.""" - -parser = OptionParser(usage, description=description) -parser.add_option('-V', '--version', help='display script version', - action='store_true', dest='version', default=False) -parser.add_option('-f', '--from', metavar='ADDRESS', dest='from_email', - help='specify the return email address for notifications') -parser.add_option('-t', '--expire-time', dest='expire_days', metavar='DAYS', - help='specify the number of days in the future to check') -parser.add_option('-l', '--level', dest='log_level', default='WARNING', - help='Set logging level [Default: %default]') -(options, args) = parser.parse_args() -if options.version: - print __version__ - sys.exit(0) - -v = getattr(logging, options.log_level.upper()) -logging.basicConfig(level=v) -logging.info('logging level set to ' + logging.getLevelName(v)) - -kwargs = {} -if options.from_email: - kwargs['from_email'] = options.from_email -if options.expire_days: - kwargs['expire_days'] = int(options.expire_days) -notify_expired(**kwargs) - -sys.exit(0) diff --git a/rpkid/portal-gui/scripts/rpkigui-import-routes b/rpkid/portal-gui/scripts/rpkigui-import-routes new file mode 100755 index 00000000..fa3ff3e9 --- /dev/null +++ b/rpkid/portal-gui/scripts/rpkigui-import-routes @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +# Copyright (C) 2012, 2013 SPARTA, Inc. a Parsons Company +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +__version__ = '$Id$' + +import optparse +import logging + +# configure django ORM +from rpki.gui.script_util import setup +setup() + +from rpki.gui.routeview.util import import_routeviews_dump + + +class BadArgument(Exception): + pass + + +if __name__ == '__main__': + parser = optparse.OptionParser( + usage='%prog [options] [PATH]', + description="""This tool is used to import the IPv4/6 BGP table dumps +from routeviews.org into the RPKI Web Portal database. If the +input file is a bzip2 compressed file, it will be decompressed +automatically.""") + parser.add_option('-t', '--type', dest='filetype', metavar='TYPE', + help='Specify the input file type (auto, text, mrt) [Default: %default]') + parser.add_option('-l', '--level', dest='log_level', default='ERROR', + help='Set logging level [Default: %default]') + parser.add_option('-u', '--bunzip2', dest='bunzip', metavar='PROG', + help='Specify bunzip2 program to use') + parser.add_option('-b', '--bgpdump', dest='bgpdump', metavar='PROG', + help='Specify path to bgdump binary') + parser.set_defaults(debug=False, verbose=False, filetype='auto') + options, args = parser.parse_args() + + v = getattr(logging, options.log_level.upper()) + logging.basicConfig(level=v) + logging.info('logging level set to ' + logging.getLevelName(v)) + + if options.bgpdump: + BGPDUMP = os.path.expanduser(options.bgpdump) + + try: + if len(args) > 1: + raise BadArgument('more than one filename specified') + import_routeviews_dump(*args) + + except Exception as e: + logging.exception(e) + rc = 1 + + logging.shutdown() diff --git a/rpkid/portal-gui/scripts/rpkigui-import-routes.py b/rpkid/portal-gui/scripts/rpkigui-import-routes.py deleted file mode 100644 index fa3ff3e9..00000000 --- a/rpkid/portal-gui/scripts/rpkigui-import-routes.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2012, 2013 SPARTA, Inc. a Parsons Company -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -__version__ = '$Id$' - -import optparse -import logging - -# configure django ORM -from rpki.gui.script_util import setup -setup() - -from rpki.gui.routeview.util import import_routeviews_dump - - -class BadArgument(Exception): - pass - - -if __name__ == '__main__': - parser = optparse.OptionParser( - usage='%prog [options] [PATH]', - description="""This tool is used to import the IPv4/6 BGP table dumps -from routeviews.org into the RPKI Web Portal database. If the -input file is a bzip2 compressed file, it will be decompressed -automatically.""") - parser.add_option('-t', '--type', dest='filetype', metavar='TYPE', - help='Specify the input file type (auto, text, mrt) [Default: %default]') - parser.add_option('-l', '--level', dest='log_level', default='ERROR', - help='Set logging level [Default: %default]') - parser.add_option('-u', '--bunzip2', dest='bunzip', metavar='PROG', - help='Specify bunzip2 program to use') - parser.add_option('-b', '--bgpdump', dest='bgpdump', metavar='PROG', - help='Specify path to bgdump binary') - parser.set_defaults(debug=False, verbose=False, filetype='auto') - options, args = parser.parse_args() - - v = getattr(logging, options.log_level.upper()) - logging.basicConfig(level=v) - logging.info('logging level set to ' + logging.getLevelName(v)) - - if options.bgpdump: - BGPDUMP = os.path.expanduser(options.bgpdump) - - try: - if len(args) > 1: - raise BadArgument('more than one filename specified') - import_routeviews_dump(*args) - - except Exception as e: - logging.exception(e) - rc = 1 - - logging.shutdown() diff --git a/rpkid/portal-gui/scripts/rpkigui-rcynic b/rpkid/portal-gui/scripts/rpkigui-rcynic new file mode 100755 index 00000000..c8f1b994 --- /dev/null +++ b/rpkid/portal-gui/scripts/rpkigui-rcynic @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +# Copyright (C) 2011 SPARTA, Inc. dba Cobham +# Copyright (C) 2012, 2013 SPARTA, Inc. a Parsons Company +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +__version__ = '$Id$' + +# probably should be exported from rpki.gui.cacheview.util +default_logfile = '/var/rcynic/data/rcynic.xml' +default_root = '/var/rcynic/data' + +import logging +import sys + +from rpki.gui.script_util import setup +setup() + +from rpki.gui.cacheview.util import import_rcynic_xml + +if __name__ == '__main__': + import optparse + + parser = optparse.OptionParser() + parser.add_option("-l", "--level", dest="log_level", default='WARNING', + help="specify the logging level [default: %default]") + parser.add_option( + "-f", "--file", dest="logfile", + help="specify the rcynic XML file to parse [default: %default]", + default=default_logfile) + parser.add_option( + "-r", "--root", + help="specify the chroot directory for the rcynic jail [default: %default]", + metavar="DIR", default=default_root) + options, args = parser.parse_args(sys.argv) + + v = getattr(logging, options.log_level.upper()) + logging.basicConfig(level=v) + logging.info('log level set to %s' % logging.getLevelName(v)) + + import_rcynic_xml(options.root, options.logfile) + + logging.shutdown() diff --git a/rpkid/portal-gui/scripts/rpkigui-rcynic.py b/rpkid/portal-gui/scripts/rpkigui-rcynic.py deleted file mode 100644 index c8f1b994..00000000 --- a/rpkid/portal-gui/scripts/rpkigui-rcynic.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2011 SPARTA, Inc. dba Cobham -# Copyright (C) 2012, 2013 SPARTA, Inc. a Parsons Company -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -__version__ = '$Id$' - -# probably should be exported from rpki.gui.cacheview.util -default_logfile = '/var/rcynic/data/rcynic.xml' -default_root = '/var/rcynic/data' - -import logging -import sys - -from rpki.gui.script_util import setup -setup() - -from rpki.gui.cacheview.util import import_rcynic_xml - -if __name__ == '__main__': - import optparse - - parser = optparse.OptionParser() - parser.add_option("-l", "--level", dest="log_level", default='WARNING', - help="specify the logging level [default: %default]") - parser.add_option( - "-f", "--file", dest="logfile", - help="specify the rcynic XML file to parse [default: %default]", - default=default_logfile) - parser.add_option( - "-r", "--root", - help="specify the chroot directory for the rcynic jail [default: %default]", - metavar="DIR", default=default_root) - options, args = parser.parse_args(sys.argv) - - v = getattr(logging, options.log_level.upper()) - logging.basicConfig(level=v) - logging.info('log level set to %s' % logging.getLevelName(v)) - - import_rcynic_xml(options.root, options.logfile) - - logging.shutdown() diff --git a/rpkid/pubd b/rpkid/pubd new file mode 100755 index 00000000..8445b6e1 --- /dev/null +++ b/rpkid/pubd @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +""" +$Id$ + +Copyright (C) 2010 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +if __name__ == "__main__": + import rpki.pubd + rpki.pubd.main() diff --git a/rpkid/pubd.py b/rpkid/pubd.py deleted file mode 100644 index 8445b6e1..00000000 --- a/rpkid/pubd.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -""" -$Id$ - -Copyright (C) 2010 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -if __name__ == "__main__": - import rpki.pubd - rpki.pubd.main() diff --git a/rpkid/rootd b/rpkid/rootd new file mode 100755 index 00000000..8e98bd89 --- /dev/null +++ b/rpkid/rootd @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +""" +$Id$ + +Copyright (C) 2010 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +if __name__ == "__main__": + import rpki.rootd + rpki.rootd.main() diff --git a/rpkid/rootd.py b/rpkid/rootd.py deleted file mode 100644 index 8e98bd89..00000000 --- a/rpkid/rootd.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -""" -$Id$ - -Copyright (C) 2010 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -if __name__ == "__main__": - import rpki.rootd - rpki.rootd.main() diff --git a/rpkid/rpki-confgen b/rpkid/rpki-confgen new file mode 100755 index 00000000..9913a1e5 --- /dev/null +++ b/rpkid/rpki-confgen @@ -0,0 +1,181 @@ +#!/usr/bin/env python + +import sys +import getopt +import textwrap + +from lxml.etree import Element, SubElement, ElementTree + +space2 = " " * 2 +space4 = " " * 4 +space6 = " " * 6 +space8 = " " * 8 + +text_wrapper = textwrap.TextWrapper() +conf_wrapper = textwrap.TextWrapper(initial_indent = "# ", subsequent_indent = "# ") +item_wrapper = textwrap.TextWrapper(initial_indent = space2, subsequent_indent = space2) +xml6_wrapper = textwrap.TextWrapper(initial_indent = space6, subsequent_indent = space6) +xml8_wrapper = textwrap.TextWrapper(initial_indent = space8, subsequent_indent = space8) + +class Option(object): + + def __init__(self, name, value, doc): + self.name = name + self.value = value + self.doc = doc + + @property + def width(self): + return len(self.name) + + def to_xml(self): + x = Element("option", name = self.name, value = self.value) + for d in self.doc: + SubElement(x, "doc").text = "\n" + xml8_wrapper.fill(d) + "\n" + space6 + return x + + def to_wiki(self, f): + f.write("\n%s::" % self.name) + for d in self.doc: + f.write("\n%s\n" % item_wrapper.fill(d)) + + def to_conf(self, f, width): + for d in self.doc: + f.write("\n%s\n" % conf_wrapper.fill(d)) + f.write("\n%-*s = %s\n" % (width, self.name, self.value)) + +class Section(object): + + def __init__(self, name): + self.name = name + self.doc = [] + self.options = [] + + @property + def width(self): + return max(o.width for o in self.options) + + @classmethod + def from_xml(cls, elt): + self = cls(name = elt.get("name")) + for x in elt.iterchildren("doc"): + self.doc.append(" ".join(x.text.split())) + for x in elt.iterchildren("option"): + self.options.append(Option(name = x.get("name"), value = x.get("value"), + doc = [" ".join(d.text.split()) + for d in x.iterchildren("doc")])) + return self + + def to_xml(self): + x = Element("section", name = self.name) + for d in self.doc: + SubElement(x, "doc").text = "\n" + xml6_wrapper.fill(d) + "\n" + space4 + x.extend(o.to_xml() for o in self.options) + return x + + def to_wiki(self, f): + f.write('''\ +{{{ +#!comment +THIS PAGE WAS GENERATED AUTOMATICALLY, DO NOT EDIT. + +Generated from ''' + ident + ''' +by $Id$ +}}} + += ![''' + self.name + '''] section = +''') + for d in self.doc: + f.write("\n%s\n" % text_wrapper.fill(d)) + for o in self.options: + o.to_wiki(f) + + def to_conf(self, f, width): + f.write(''' +################################################################################ + +[''' + self.name + '''] +''') + for d in self.doc: + f.write("\n%s\n" % conf_wrapper.fill(d)) + for o in self.options: + o.to_conf(f, width) + +sections = [] +section_map = None +option_map = None +ident = None + +opts, argv = getopt.getopt(sys.argv[1:], "", + ["read-xml=", "write-xml=", + "write-wiki=", "write-conf=", + "set=", "autoconf"]) +for o, a in opts: + + if o == "--read-xml": + option_map = None + root = ElementTree(file = a).getroot() + ident = root.get("ident") + sections.extend(Section.from_xml(x) for x in root) + option_map = {} + section_map = {} + for section in sections: + if section.name in section_map: + sys.exit("Duplicate section %s" % section.name) + section_map[section.name] = section + for option in section.options: + name = (section.name, option.name) + if name in option_map: + sys.exit("Duplicate option %s::%s" % name) + option_map[name] = option + + elif o == "--set": + try: + name, value = a.split("=", 1) + section, option = name.split("::") + except ValueError: + sys.exit("Couldn't parse --set specification \"%s\"" % a) + name = (section, option) + if name not in option_map: + sys.exit("Couldn't find option %s::%s" % name) + option_map[name].value = value + + elif o == "--autoconf": + try: + import rpki.autoconf + for option in section_map["autoconf"].options: + try: + option.value = getattr(rpki.autoconf, option.name) + except AttributeError: + pass + except ImportError: + sys.exit("rpki.autoconf module is not available") + except KeyError: + sys.exit("Couldn't find autoconf section") + + elif o == "--write-xml": + x = Element("configuration", ident = ident) + x.extend(s.to_xml() for s in sections) + ElementTree(x).write(a, pretty_print = True, encoding = "us-ascii") + + elif o == "--write-wiki": + with open(a, "w") as f: + for i, section in enumerate(sections): + if i: + f.write("\f\n") + section.to_wiki(f) + + elif o == "--write-conf": + with open(a, "w") as f: + f.write('''\ +# Automatically generated. Edit as needed, but be careful of overwriting. +# +# Generated from ''' + ident + ''' +# by $Id$ +''') + width = max(s.width for s in sections) + for section in sections: + section.to_conf(f, width) + +if argv: + sys.exit("Unexpected arguments %s" % argv) diff --git a/rpkid/rpki-confgen.py b/rpkid/rpki-confgen.py deleted file mode 100644 index 9913a1e5..00000000 --- a/rpkid/rpki-confgen.py +++ /dev/null @@ -1,181 +0,0 @@ -#!/usr/bin/env python - -import sys -import getopt -import textwrap - -from lxml.etree import Element, SubElement, ElementTree - -space2 = " " * 2 -space4 = " " * 4 -space6 = " " * 6 -space8 = " " * 8 - -text_wrapper = textwrap.TextWrapper() -conf_wrapper = textwrap.TextWrapper(initial_indent = "# ", subsequent_indent = "# ") -item_wrapper = textwrap.TextWrapper(initial_indent = space2, subsequent_indent = space2) -xml6_wrapper = textwrap.TextWrapper(initial_indent = space6, subsequent_indent = space6) -xml8_wrapper = textwrap.TextWrapper(initial_indent = space8, subsequent_indent = space8) - -class Option(object): - - def __init__(self, name, value, doc): - self.name = name - self.value = value - self.doc = doc - - @property - def width(self): - return len(self.name) - - def to_xml(self): - x = Element("option", name = self.name, value = self.value) - for d in self.doc: - SubElement(x, "doc").text = "\n" + xml8_wrapper.fill(d) + "\n" + space6 - return x - - def to_wiki(self, f): - f.write("\n%s::" % self.name) - for d in self.doc: - f.write("\n%s\n" % item_wrapper.fill(d)) - - def to_conf(self, f, width): - for d in self.doc: - f.write("\n%s\n" % conf_wrapper.fill(d)) - f.write("\n%-*s = %s\n" % (width, self.name, self.value)) - -class Section(object): - - def __init__(self, name): - self.name = name - self.doc = [] - self.options = [] - - @property - def width(self): - return max(o.width for o in self.options) - - @classmethod - def from_xml(cls, elt): - self = cls(name = elt.get("name")) - for x in elt.iterchildren("doc"): - self.doc.append(" ".join(x.text.split())) - for x in elt.iterchildren("option"): - self.options.append(Option(name = x.get("name"), value = x.get("value"), - doc = [" ".join(d.text.split()) - for d in x.iterchildren("doc")])) - return self - - def to_xml(self): - x = Element("section", name = self.name) - for d in self.doc: - SubElement(x, "doc").text = "\n" + xml6_wrapper.fill(d) + "\n" + space4 - x.extend(o.to_xml() for o in self.options) - return x - - def to_wiki(self, f): - f.write('''\ -{{{ -#!comment -THIS PAGE WAS GENERATED AUTOMATICALLY, DO NOT EDIT. - -Generated from ''' + ident + ''' -by $Id$ -}}} - -= ![''' + self.name + '''] section = -''') - for d in self.doc: - f.write("\n%s\n" % text_wrapper.fill(d)) - for o in self.options: - o.to_wiki(f) - - def to_conf(self, f, width): - f.write(''' -################################################################################ - -[''' + self.name + '''] -''') - for d in self.doc: - f.write("\n%s\n" % conf_wrapper.fill(d)) - for o in self.options: - o.to_conf(f, width) - -sections = [] -section_map = None -option_map = None -ident = None - -opts, argv = getopt.getopt(sys.argv[1:], "", - ["read-xml=", "write-xml=", - "write-wiki=", "write-conf=", - "set=", "autoconf"]) -for o, a in opts: - - if o == "--read-xml": - option_map = None - root = ElementTree(file = a).getroot() - ident = root.get("ident") - sections.extend(Section.from_xml(x) for x in root) - option_map = {} - section_map = {} - for section in sections: - if section.name in section_map: - sys.exit("Duplicate section %s" % section.name) - section_map[section.name] = section - for option in section.options: - name = (section.name, option.name) - if name in option_map: - sys.exit("Duplicate option %s::%s" % name) - option_map[name] = option - - elif o == "--set": - try: - name, value = a.split("=", 1) - section, option = name.split("::") - except ValueError: - sys.exit("Couldn't parse --set specification \"%s\"" % a) - name = (section, option) - if name not in option_map: - sys.exit("Couldn't find option %s::%s" % name) - option_map[name].value = value - - elif o == "--autoconf": - try: - import rpki.autoconf - for option in section_map["autoconf"].options: - try: - option.value = getattr(rpki.autoconf, option.name) - except AttributeError: - pass - except ImportError: - sys.exit("rpki.autoconf module is not available") - except KeyError: - sys.exit("Couldn't find autoconf section") - - elif o == "--write-xml": - x = Element("configuration", ident = ident) - x.extend(s.to_xml() for s in sections) - ElementTree(x).write(a, pretty_print = True, encoding = "us-ascii") - - elif o == "--write-wiki": - with open(a, "w") as f: - for i, section in enumerate(sections): - if i: - f.write("\f\n") - section.to_wiki(f) - - elif o == "--write-conf": - with open(a, "w") as f: - f.write('''\ -# Automatically generated. Edit as needed, but be careful of overwriting. -# -# Generated from ''' + ident + ''' -# by $Id$ -''') - width = max(s.width for s in sections) - for section in sections: - section.to_conf(f, width) - -if argv: - sys.exit("Unexpected arguments %s" % argv) diff --git a/rpkid/rpki-sql-backup b/rpkid/rpki-sql-backup new file mode 100755 index 00000000..561aa4e5 --- /dev/null +++ b/rpkid/rpki-sql-backup @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +""" +Back up data from SQL databases, looking at config file to figure out +which databases and what credentials to use with them. + +For the moment, this just writes all the SQL to stdout. + +$Id$ + +Copyright (C) 2010-2012 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +import subprocess, os, getopt, sys, time, rpki.config + +os.environ["TZ"] = "UTC" +time.tzset() + +cfg_file = None + +opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) +for o, a in opts: + if o in ("-h", "--help", "-?"): + print __doc__ + sys.exit(0) + elif o in ("-c", "--config"): + cfg_file = a + +cfg = rpki.config.parser(cfg_file, "myrpki") + +def dump(section): + subprocess.check_call( + ("mysqldump", "--add-drop-database", + "-u", cfg.get("sql-username", section = section), + "-p" + cfg.get("sql-password", section = section), + "-B", cfg.get("sql-database", section = section))) + +if cfg.getboolean("start_rpkid", False): + dump("irdbd") + +if cfg.getboolean("start_irdbd", False): + dump("rpkid") + +if cfg.getboolean("start_pubd", False): + dump("pubd") diff --git a/rpkid/rpki-sql-backup.py b/rpkid/rpki-sql-backup.py deleted file mode 100644 index 561aa4e5..00000000 --- a/rpkid/rpki-sql-backup.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -""" -Back up data from SQL databases, looking at config file to figure out -which databases and what credentials to use with them. - -For the moment, this just writes all the SQL to stdout. - -$Id$ - -Copyright (C) 2010-2012 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -import subprocess, os, getopt, sys, time, rpki.config - -os.environ["TZ"] = "UTC" -time.tzset() - -cfg_file = None - -opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) -for o, a in opts: - if o in ("-h", "--help", "-?"): - print __doc__ - sys.exit(0) - elif o in ("-c", "--config"): - cfg_file = a - -cfg = rpki.config.parser(cfg_file, "myrpki") - -def dump(section): - subprocess.check_call( - ("mysqldump", "--add-drop-database", - "-u", cfg.get("sql-username", section = section), - "-p" + cfg.get("sql-password", section = section), - "-B", cfg.get("sql-database", section = section))) - -if cfg.getboolean("start_rpkid", False): - dump("irdbd") - -if cfg.getboolean("start_irdbd", False): - dump("rpkid") - -if cfg.getboolean("start_pubd", False): - dump("pubd") diff --git a/rpkid/rpki-sql-setup b/rpkid/rpki-sql-setup new file mode 100755 index 00000000..01de0822 --- /dev/null +++ b/rpkid/rpki-sql-setup @@ -0,0 +1,122 @@ +#!/usr/bin/env python + +""" +Automated setup of all the pesky SQL stuff we need. Prompts for MySQL +root password, pulls other information from rpki.conf. + +$Id$ + +Copyright (C) 2009--2013 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +import getopt +import sys +import getpass +import rpki.config +import rpki.sql_schemas + +from rpki.mysql_import import MySQLdb + +def read_schema(name): + """ + Convert an SQL file into a list of SQL statements. + """ + + lines = [] + for line in getattr(rpki.sql_schemas, name, "").splitlines(): + line = " ".join(line.split()) + if line and not line.startswith("--"): + lines.append(line) + + return [statement.strip() for statement in " ".join(lines).rstrip(";").split(";") if statement.strip()] + +def sql_setup(name): + """ + Create a new SQL database and construct all its tables. + """ + + database = cfg.get("sql-database", section = name) + username = cfg.get("sql-username", section = name) + password = cfg.get("sql-password", section = name) + schema = read_schema(name) + + if missing_only and database in databases: + print "Database already present and --missing-only set, skipping \"%s\"" % database + return + + print "Creating database", database + cur = rootdb.cursor() + try: + cur.execute("DROP DATABASE IF EXISTS %s" % database) + except Exception: + pass + cur.execute("CREATE DATABASE %s" % database) + cur.execute("GRANT ALL ON %s.* TO %s@localhost IDENTIFIED BY %%s" % (database, username), (password,)) + rootdb.commit() + + db = MySQLdb.connect(db = database, user = username, passwd = password) + cur = db.cursor() + for statement in schema: + if statement.upper().startswith("DROP TABLE"): + continue + if verbose: + print "+", statement + cur.execute(statement) + db.commit() + db.close() + +cfg_file = None + +verbose = False +mysql_defaults = None +missing_only = False + +opts, argv = getopt.getopt(sys.argv[1:], "c:hv?", ["config=", "help", "missing_only", "mysql_defaults=", "verbose"]) +for o, a in opts: + if o in ("-h", "--help", "-?"): + print __doc__ + sys.exit(0) + if o in ("-v", "--verbose"): + verbose = True + if o in ("-c", "--config"): + cfg_file = a + if o == "--missing_only": + missing_only = not missing_only + if o == "--mysql_defaults": + mysql_defaults = a + +cfg = rpki.config.parser(cfg_file, "myrpki") + +if mysql_defaults is None: + rootdb = MySQLdb.connect(db = "mysql", user = "root", passwd = getpass.getpass("Please enter your MySQL root password: ")) +else: + mysql_cfg = rpki.config.parser(mysql_defaults, "client") + rootdb = MySQLdb.connect(db = "mysql", user = mysql_cfg.get("user"), passwd = mysql_cfg.get("password")) + +cur = rootdb.cursor() +cur.execute("SHOW DATABASES") +databases = set(d[0] for d in cur.fetchall()) +del cur + +if cfg.getboolean("start_irdbd", False): + sql_setup("irdbd") + +if cfg.getboolean("start_rpkid", False): + sql_setup("rpkid") + +if cfg.getboolean("start_pubd", False): + sql_setup("pubd") + +rootdb.close() diff --git a/rpkid/rpki-sql-setup.py b/rpkid/rpki-sql-setup.py deleted file mode 100644 index 01de0822..00000000 --- a/rpkid/rpki-sql-setup.py +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env python - -""" -Automated setup of all the pesky SQL stuff we need. Prompts for MySQL -root password, pulls other information from rpki.conf. - -$Id$ - -Copyright (C) 2009--2013 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -import getopt -import sys -import getpass -import rpki.config -import rpki.sql_schemas - -from rpki.mysql_import import MySQLdb - -def read_schema(name): - """ - Convert an SQL file into a list of SQL statements. - """ - - lines = [] - for line in getattr(rpki.sql_schemas, name, "").splitlines(): - line = " ".join(line.split()) - if line and not line.startswith("--"): - lines.append(line) - - return [statement.strip() for statement in " ".join(lines).rstrip(";").split(";") if statement.strip()] - -def sql_setup(name): - """ - Create a new SQL database and construct all its tables. - """ - - database = cfg.get("sql-database", section = name) - username = cfg.get("sql-username", section = name) - password = cfg.get("sql-password", section = name) - schema = read_schema(name) - - if missing_only and database in databases: - print "Database already present and --missing-only set, skipping \"%s\"" % database - return - - print "Creating database", database - cur = rootdb.cursor() - try: - cur.execute("DROP DATABASE IF EXISTS %s" % database) - except Exception: - pass - cur.execute("CREATE DATABASE %s" % database) - cur.execute("GRANT ALL ON %s.* TO %s@localhost IDENTIFIED BY %%s" % (database, username), (password,)) - rootdb.commit() - - db = MySQLdb.connect(db = database, user = username, passwd = password) - cur = db.cursor() - for statement in schema: - if statement.upper().startswith("DROP TABLE"): - continue - if verbose: - print "+", statement - cur.execute(statement) - db.commit() - db.close() - -cfg_file = None - -verbose = False -mysql_defaults = None -missing_only = False - -opts, argv = getopt.getopt(sys.argv[1:], "c:hv?", ["config=", "help", "missing_only", "mysql_defaults=", "verbose"]) -for o, a in opts: - if o in ("-h", "--help", "-?"): - print __doc__ - sys.exit(0) - if o in ("-v", "--verbose"): - verbose = True - if o in ("-c", "--config"): - cfg_file = a - if o == "--missing_only": - missing_only = not missing_only - if o == "--mysql_defaults": - mysql_defaults = a - -cfg = rpki.config.parser(cfg_file, "myrpki") - -if mysql_defaults is None: - rootdb = MySQLdb.connect(db = "mysql", user = "root", passwd = getpass.getpass("Please enter your MySQL root password: ")) -else: - mysql_cfg = rpki.config.parser(mysql_defaults, "client") - rootdb = MySQLdb.connect(db = "mysql", user = mysql_cfg.get("user"), passwd = mysql_cfg.get("password")) - -cur = rootdb.cursor() -cur.execute("SHOW DATABASES") -databases = set(d[0] for d in cur.fetchall()) -del cur - -if cfg.getboolean("start_irdbd", False): - sql_setup("irdbd") - -if cfg.getboolean("start_rpkid", False): - sql_setup("rpkid") - -if cfg.getboolean("start_pubd", False): - sql_setup("pubd") - -rootdb.close() diff --git a/rpkid/rpki-start-servers b/rpkid/rpki-start-servers new file mode 100755 index 00000000..3babfd1c --- /dev/null +++ b/rpkid/rpki-start-servers @@ -0,0 +1,87 @@ +#!/usr/bin/env python + +""" +Start servers, logging to files, looking at config file to figure out +which servers the user wants started. + +$Id$ + +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +""" + +import subprocess, os, getopt, sys, time, rpki.config + +rpkid_dir = os.path.normpath(sys.path[0]) + +os.environ["TZ"] = "UTC" +time.tzset() + +cfg_file = None +debug = False + +opts, argv = getopt.getopt(sys.argv[1:], "c:dhp:?", ["config=", "debug" "help"]) +for o, a in opts: + if o in ("-h", "--help", "-?"): + print __doc__ + sys.exit(0) + elif o in ("-c", "--config"): + cfg_file = a + elif o in ("-d", "--debug"): + debug = True + +cfg = rpki.config.parser(cfg_file, "myrpki") + + +def run(name): + # pylint: disable=E1103 + cmd = (sys.executable, os.path.join(rpkid_dir, name), "-c", cfg.filename) + if debug: + proc = subprocess.Popen(cmd + ("-d",), stdout = open(name + ".log", "a"), stderr = subprocess.STDOUT) + else: + proc = subprocess.Popen(cmd) + if debug and proc.poll() is None: + print "Started %s, pid %s" % (name, proc.pid) + elif not debug and proc.wait() == 0: + print "Started %s" % name + else: + print "Problem starting %s, pid %s" % (name, proc.pid) + + +if cfg.getboolean("start_rpkid", cfg.getboolean("run_rpkid", False)): + run("irdbd") + +if cfg.getboolean("start_irdbd", cfg.getboolean("run_rpkid", False)): + run("rpkid") + +if cfg.getboolean("start_pubd", cfg.getboolean("run_pubd", False)): + run("pubd") + +if cfg.getboolean("start_rootd", cfg.getboolean("run_rootd", False)): + run("rootd") diff --git a/rpkid/rpki-start-servers.py b/rpkid/rpki-start-servers.py deleted file mode 100644 index 3babfd1c..00000000 --- a/rpkid/rpki-start-servers.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python - -""" -Start servers, logging to files, looking at config file to figure out -which servers the user wants started. - -$Id$ - -Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -""" - -import subprocess, os, getopt, sys, time, rpki.config - -rpkid_dir = os.path.normpath(sys.path[0]) - -os.environ["TZ"] = "UTC" -time.tzset() - -cfg_file = None -debug = False - -opts, argv = getopt.getopt(sys.argv[1:], "c:dhp:?", ["config=", "debug" "help"]) -for o, a in opts: - if o in ("-h", "--help", "-?"): - print __doc__ - sys.exit(0) - elif o in ("-c", "--config"): - cfg_file = a - elif o in ("-d", "--debug"): - debug = True - -cfg = rpki.config.parser(cfg_file, "myrpki") - - -def run(name): - # pylint: disable=E1103 - cmd = (sys.executable, os.path.join(rpkid_dir, name), "-c", cfg.filename) - if debug: - proc = subprocess.Popen(cmd + ("-d",), stdout = open(name + ".log", "a"), stderr = subprocess.STDOUT) - else: - proc = subprocess.Popen(cmd) - if debug and proc.poll() is None: - print "Started %s, pid %s" % (name, proc.pid) - elif not debug and proc.wait() == 0: - print "Started %s" % name - else: - print "Problem starting %s, pid %s" % (name, proc.pid) - - -if cfg.getboolean("start_rpkid", cfg.getboolean("run_rpkid", False)): - run("irdbd") - -if cfg.getboolean("start_irdbd", cfg.getboolean("run_rpkid", False)): - run("rpkid") - -if cfg.getboolean("start_pubd", cfg.getboolean("run_pubd", False)): - run("pubd") - -if cfg.getboolean("start_rootd", cfg.getboolean("run_rootd", False)): - run("rootd") diff --git a/rpkid/rpkic b/rpkid/rpkic new file mode 100755 index 00000000..0dd1c122 --- /dev/null +++ b/rpkid/rpkic @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +""" +$Id$ + +Copyright (C) 2010-2011 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +if __name__ == "__main__": + import rpki.rpkic + rpki.rpkic.main() diff --git a/rpkid/rpkic.py b/rpkid/rpkic.py deleted file mode 100644 index 0dd1c122..00000000 --- a/rpkid/rpkic.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -""" -$Id$ - -Copyright (C) 2010-2011 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -if __name__ == "__main__": - import rpki.rpkic - rpki.rpkic.main() diff --git a/rpkid/rpkid b/rpkid/rpkid new file mode 100755 index 00000000..4f52040e --- /dev/null +++ b/rpkid/rpkid @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +""" +$Id$ + +Copyright (C) 2010 Internet Systems Consortium ("ISC") + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + +if __name__ == "__main__": + import rpki.rpkid + rpki.rpkid.main() diff --git a/rpkid/rpkid.py b/rpkid/rpkid.py deleted file mode 100644 index 4f52040e..00000000 --- a/rpkid/rpkid.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -""" -$Id$ - -Copyright (C) 2010 Internet Systems Consortium ("ISC") - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -""" - -if __name__ == "__main__": - import rpki.rpkid - rpki.rpkid.main() diff --git a/rpkid/setup.py b/rpkid/setup.py index c4d0fb60..79847b37 100644 --- a/rpkid/setup.py +++ b/rpkid/setup.py @@ -1,6 +1,6 @@ # $Id$ # -# Copyright (C) 2011-2012 Internet Systems Consortium ("ISC") +# Copyright (C) 2011-2013 Internet Systems Consortium ("ISC") # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -20,11 +20,6 @@ import os # We can't build POW without these settings, but allow them to be null # so that things like "python setup.py --help" will work. -ac_scripts = os.getenv("AC_SCRIPTS", "").split() -ac_aux_scripts = os.getenv("AC_AUX_SCRIPTS", "").split() -ac_data_files = os.getenv("AC_DATA_FILES", "").split() -ac_conf_files = os.getenv("AC_CONF_FILES", "").split() - try: import setup_autoconf ac_cflags = setup_autoconf.CFLAGS.split() @@ -44,6 +39,25 @@ except ImportError: ac_datarootdir = None ac_sysconfdir = None +# Scripts and data files, moved here from Makefile.in. + +ac_scripts = [ + "rpki-sql-backup", "rpki-sql-setup", + "rpki-start-servers", "irbe_cli", "irdbd", + "pubd rootd rpkic rpkid rpki-confgen", + "portal-gui/scripts/rpkigui-import-routes", + "portal-gui/scripts/rpkigui-check-expired", + "portal-gui/scripts/rpkigui-rcynic", + "portal-gui/scripts/rpki-manage" ] + +ac_aux_scripts = [] + +ac_data_files = [] + +ac_conf_files = [ + "portal-gui/apache.conf", + "rpki-confgen.xml" ] + # Non-standard extension build specification: we need to force # whatever build options our top-level ./configure selected, and we # have to specify our libraries as extra_link_args because they may be diff --git a/rpkid/tests/smoketest.py b/rpkid/tests/smoketest.py index b3ad008a..b7918642 100644 --- a/rpkid/tests/smoketest.py +++ b/rpkid/tests/smoketest.py @@ -139,11 +139,11 @@ rcynic_name = cfg.get("rcynic_name", "rcynic") pubd_name = cfg.get("pubd_name", "pubd") prog_python = cfg.get("prog_python", sys.executable) -prog_rpkid = cfg.get("prog_rpkid", "../../rpkid.py") +prog_rpkid = cfg.get("prog_rpkid", "../../rpkid") prog_irdbd = cfg.get("prog_irdbd", "../old_irdbd.py") prog_poke = cfg.get("prog_poke", "../testpoke.py") -prog_rootd = cfg.get("prog_rootd", "../../rootd.py") -prog_pubd = cfg.get("prog_pubd", "../../pubd.py") +prog_rootd = cfg.get("prog_rootd", "../../rootd") +prog_pubd = cfg.get("prog_pubd", "../../pubd") prog_rsyncd = cfg.get("prog_rsyncd", "rsync") prog_rcynic = cfg.get("prog_rcynic", "../../../rcynic/rcynic") prog_openssl = cfg.get("prog_openssl", "../../../openssl/openssl/apps/openssl") -- cgit v1.2.3