forked from UNIVERSAL-IT-SYSTEMS/gentoo-keys
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gentoo#38 from gentoo/gkeys-gpg
Gkeys-gpg
- Loading branch information
Showing
16 changed files
with
708 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
'''Gentoo-keys is a gpg key manager for managing | ||
gentoo's gpg-signing keys. It is these keys that are | ||
used to verify and validate release media, etc.. | ||
This gkeys-gpg command is a wrapper to gnupg's gpg command | ||
which uses the gentoo-keys keyring system to control the | ||
keydirs and keyrings visible to gpg | ||
Distributed under the terms of the GNU General Public License v2 | ||
Copyright: | ||
(c) 2011 Brian Dolbec | ||
Distributed under the terms of the GNU General Public License v2 | ||
Author(s): | ||
Brian Dolbec <[email protected]> | ||
''' | ||
|
||
from __future__ import print_function | ||
|
||
from gkeysgpg.cli import Main | ||
|
||
import os | ||
import sys | ||
|
||
|
||
# This block ensures that ^C interrupts are handled quietly. | ||
try: | ||
import signal | ||
|
||
def exithandler(signum,frame): | ||
signal.signal(signal.SIGINT, signal.SIG_IGN) | ||
signal.signal(signal.SIGTERM, signal.SIG_IGN) | ||
print() | ||
sys.exit(1) | ||
|
||
signal.signal(signal.SIGINT, exithandler) | ||
signal.signal(signal.SIGTERM, exithandler) | ||
signal.signal(signal.SIGPIPE, signal.SIG_DFL) | ||
|
||
except KeyboardInterrupt: | ||
print() | ||
sys.exit(1) | ||
|
||
root = None | ||
if 'ROOT' in os.environ: | ||
root = os.environ['ROOT'] | ||
|
||
main = Main(root=root) | ||
returncode = main() | ||
|
||
sys.exit(returncode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# | ||
#-*- coding:utf-8 -*- | ||
|
||
""" | ||
Gentoo-keys - actionbase.py | ||
Base api interface module | ||
@copyright: 2012-2015 by Brian Dolbec <[email protected]> | ||
@license: GNU GPL2, see COPYING for details. | ||
""" | ||
|
||
from __future__ import print_function | ||
|
||
import os | ||
import sys | ||
|
||
if sys.version_info[0] >= 3: | ||
_unicode = str | ||
else: | ||
_unicode = unicode | ||
|
||
|
||
from snakeoil.demandload import demandload | ||
|
||
demandload( | ||
"json:load", | ||
"gkeys.lib:GkeysGPG", | ||
"gkeys.keyhandler:KeyHandler", | ||
) | ||
|
||
|
||
|
||
class ActionBase(object): | ||
'''Base actions class holding comon functions and init''' | ||
|
||
def __init__(self, config, output=None, logger=None): | ||
self.config = config | ||
self.output = output | ||
self.logger = logger | ||
self.seeds = None | ||
self._seedhandler = None | ||
self._keyhandler = None | ||
self._gpg = None | ||
self.category = None | ||
|
||
|
||
@property | ||
def gpg(self): | ||
'''Holds the classwide GkeysGPG instance''' | ||
if not self._gpg: | ||
self._gpg = GkeysGPG(self.config, | ||
self._set_category(self.category), self.logger) | ||
else: | ||
self._gpg.basedir = self._set_category(self.category) | ||
return self._gpg | ||
|
||
|
||
@property | ||
def keyhandler(self): | ||
'''Holds the classwide KeyHandler instance''' | ||
if not self._keyhandler: | ||
self._init_keyhandler() | ||
return self._keyhandler | ||
|
||
|
||
def _init_keyhandler(self): | ||
self._keyhandler = KeyHandler(self.config, self.logger) | ||
self._seedhandler = self._keyhandler.seedhandler | ||
|
||
|
||
@property | ||
def seedhandler(self): | ||
'''Holds the classwide SeedHandler instance | ||
which is a convienience variable for the keyhandler's instance of it''' | ||
if not self._seedhandler: | ||
self._init_keyhandler() | ||
return self._seedhandler | ||
|
||
|
||
def _set_category(self, cat): | ||
keyring = self.config.get_key('keyring') | ||
if "foo-bar'd" in keyring: | ||
raise | ||
self.category = cat | ||
catdir = os.path.join(keyring, cat) | ||
self.logger.debug(_unicode("ACTIONS: _set_category; catdir = %s") % catdir) | ||
return catdir | ||
|
||
|
Oops, something went wrong.