aboutsummaryrefslogtreecommitdiff
path: root/ca/rpkic
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-02-15 07:51:40 +0000
committerRob Austein <sra@hactrn.net>2016-02-15 07:51:40 +0000
commitdef95e42fda9a9e45bdf4f40a6ecb93b644dbf0b (patch)
tree1505c5859484053e8a120acaef60869389d3d901 /ca/rpkic
parent21527a93bf51875473bc29698189e9e9540aee1b (diff)
Checkpoint while shuffling stuff around for new installation scheme.
Installation of everything but Debian packages is probably broken, and Debian packages are too at the moment due to (probably) minor errors in buildtools/debian-skeleton, but enough has changed that this really needs a snapshot checked in for backup. svn path=/branches/tk705/; revision=6257
Diffstat (limited to 'ca/rpkic')
-rwxr-xr-xca/rpkic36
1 files changed, 20 insertions, 16 deletions
diff --git a/ca/rpkic b/ca/rpkic
index 3c3c7d99..5858014c 100755
--- a/ca/rpkic
+++ b/ca/rpkic
@@ -1,21 +1,25 @@
#!/usr/bin/env python
-# $Id$
+# Using a Python script to run sudo to run a Python script is a bit
+# silly, but it lets us use rpki.autoconf to locate sudo, lets us
+# avoid needing a custom setuid wrapper, lets us avoid another pass
+# through the adventures of shell quoting and tokenization, and
+# generally is just a lot simpler to implement correctly.
#
-# 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.
+# OK, it's probably a few milliseconds slower. Big deal.
if __name__ == "__main__":
- import rpki.rpkic
- rpki.rpkic.main()
+
+ try:
+ import os
+ import sys
+ import rpki.autoconf
+
+ argv = [rpki.autoconf.SUDO, "-u", rpki.autoconf.RPKI_USER,
+ sys.executable, "-c", "import rpki.rpkic; rpki.rpkic.main()"]
+
+ os.execv(rpki.autoconf.SUDO, argv + sys.argv[1:])
+ sys.exit("rpkic startup failure, no exception so don't know why, sorry")
+
+ except Exception as e:
+ sys.exit("Couldn't exec sudo python rpkic: {!s}".format(e))