コード例 #1
0
ファイル: sigtest.py プロジェクト: tensor5/conary
    def testUpdateMissingKey(self):
        fingerprint = '95B457D16843B21EA3FC73BBC7C32FC1F94E405E'
        # supply the pass phrase for our private key
        keyCache = openpgpkey.getKeyCache()
        keyCache.getPrivateKey(fingerprint, '111111')

        self.cfg.signatureKey = fingerprint
        self.addQuickTestComponent("test:doc", "1.0-1-1")

        signtrove.signTroves(self.cfg, ["test:doc"])

        repos = self.openRepository()

        # utterly prevent the keycache from knowing about the key,
        # but give it a place to store a keyserver retrieved key.
        newKeyCache = openpgpkey.OpenPGPKeyFileCache()
        tmpPath = mkdtemp()
        pubRing = self.cfg.pubRing
        self.cfg.pubRing = [tmpPath + '/pubring.gpg']
        newKeyCache.publicPaths = self.cfg.pubRing
        keyCacheCallback = openpgpkey.KeyCacheCallback(repos, self.cfg)
        newKeyCache.setCallback(keyCacheCallback)

        openpgpkey.setKeyCache(newKeyCache)

        try:
            self.updatePkg(self.rootDir, "test:doc")
            newKeyCache.getPublicKey(fingerprint)
        finally:
            self.cfg.pubRing = pubRing
            openpgpkey.setKeyCache(keyCache)
        util.rmtree(tmpPath)
コード例 #2
0
ファイル: cvccmd.py プロジェクト: pombreda/conary-1
    def runCommand(self, thisCommand, cfg, argSet, args, debugAll=False):
        client = conaryclient.ConaryClient(cfg)
        repos = client.getRepos()
        callback = commit.CheckinCallback(cfg)

        if not cfg.buildLabel and cfg.installLabelPath:
            cfg.buildLabel = cfg.installLabelPath[0]

        sys.excepthook = util.genExcepthook(debug=cfg.debugExceptions,
                                            debugCtrlC=debugAll)

        if cfg.installLabelPath:
            cfg.installLabel = cfg.installLabelPath[0]
        else:
            cfg.installLabel = None

        cfg.initializeFlavors()
        log.setMinVerbosity(log.INFO)
        log.resetErrorOccurred()

        # set the build flavor here, just to set architecture information
        # which is used when initializing a recipe class
        use.setBuildFlagsFromFlavor(None, cfg.buildFlavor, error=False)

        profile = False
        if argSet.has_key('lsprof'):
            import cProfile
            prof = cProfile.Profile()
            prof.enable()
            profile = 'lsprof'
            del argSet['lsprof']

        keyCache = openpgpkey.getKeyCache()
        keyCache.setPublicPath(cfg.pubRing)
        repos = conaryclient.ConaryClient(cfg).getRepos()
        keyCacheCallback = openpgpkey.KeyCacheCallback(repos, cfg)
        keyCache.setCallback(keyCacheCallback)

        try:
            rv = options.MainHandler.runCommand(self,
                                                thisCommand,
                                                cfg,
                                                argSet,
                                                args,
                                                callback=callback,
                                                repos=client.getRepos(),
                                                profile=profile)
        finally:
            if profile == 'lsprof':
                prof.disable()
                prof.dump_stats('cvc.lsprof')
                prof.print_stats()
            elif profile:
                prof.stop()

        if log.errorOccurred():
            sys.exit(2)
        return rv
コード例 #3
0
ファイル: sigtest.py プロジェクト: tensor5/conary
    def testFileUpdateMissingKey(self):
        fingerprint = '95B457D16843B21EA3FC73BBC7C32FC1F94E405E'

        # make a changeset with useful stuff that could be installed
        cs = changeset.ChangeSet()
        flavor = deps.parseFlavor('')
        v = versions.VersionFromString('/%s/1.0-1-1' %
                                       self.cfg.buildLabel.asString()).copy()
        v.resetTimeStamps()
        t = trove.Trove('test:test', v, flavor, None)

        path = self.workDir + '/blah'
        f = open(path, 'w')
        f.write('hello, world!\n')
        f.close()
        pathId = sha1helper.md5String('/blah')
        f = files.FileFromFilesystem(path, pathId)

        fileId = f.fileId()
        t.addFile(pathId, '/blah', v, fileId)
        cs.addFile(None, fileId, f.freeze())
        cs.addFileContents(pathId, fileId, changeset.ChangedFileTypes.file,
                           filecontents.FromFilesystem(path),
                           f.flags.isConfig())
        diff = t.diff(None, absolute=1)[0]
        cs.newTrove(diff)
        cs.addPrimaryTrove('test:test', v, flavor)

        # sign the changeset
        csPath = os.path.join(self.workDir, 'test-1.0-1.ccs')
        cs = cook.signAbsoluteChangeset(cs, fingerprint)
        cs.writeToFile(csPath)

        tmpPath = mkdtemp()

        keyCache = openpgpkey.getKeyCache()
        newKeyCache = openpgpkey.OpenPGPKeyFileCache()

        pubRing = self.cfg.pubRing

        self.cfg.pubRing = [tmpPath + '/pubring.gpg']
        keyCacheCallback = openpgpkey.KeyCacheCallback(None, self.cfg)
        newKeyCache.setCallback(keyCacheCallback)

        openpgpkey.setKeyCache(newKeyCache)

        try:
            self.updatePkg(self.rootDir, csPath)
        finally:
            self.cfg.pubRing = pubRing
            openpgpkey.setKeyCache(keyCache)
コード例 #4
0
ファイル: sigtest.py プロジェクト: tensor5/conary
 def testUnaccessiblePubkey(self):
     fingerprint = '95B457D16843B21EA3FC73BBC7C32FC1F94E405E'
     pubRing = self.cfg.pubRing
     pubRing = '/not/a/valid/path/pubring.gpg'
     keyCache = openpgpkey.OpenPGPKeyFileCache()
     keyCache.setPublicPath(pubRing)
     # first seek with no callback
     self.assertRaises(openpgpfile.KeyNotFound, keyCache.getPublicKey,
                       fingerprint)
     repos = self.openRepository()
     keyCacheCallback = openpgpkey.KeyCacheCallback(repos, self.cfg)
     keyCache.setCallback(keyCacheCallback)
     # now seek with callback
     self.assertRaises(openpgpfile.KeyNotFound, keyCache.getPublicKey,
                       fingerprint)
コード例 #5
0
    def __init__(self, cfg = None, passwordPrompter = None,
                 resolverClass=resolve.DependencySolver, updateCallback=None,
                 repos=None, modelFile=None):
        """
        @param cfg: a custom L{conarycfg.ConaryConfiguration} object.
                    If None, the standard Conary configuration is loaded
                    from /etc/conaryrc, ~/.conaryrc, and ./conaryrc.
        @type cfg: L{conarycfg.ConaryConfiguration}
        """

        ClientUpdate.__init__(self, callback=updateCallback)

        if cfg == None:
            cfg = conarycfg.ConaryConfiguration()
            cfg.initializeFlavors()
        self.repos = None

        self.cfg = cfg
        self.db = database.Database(cfg.root, cfg.dbPath, cfg.modelPath,
                                    modelFile=modelFile)
        if repos:
            self.repos = repos
        else:
            self.repos = self.createRepos(self.db, cfg,
                                          passwordPrompter = passwordPrompter)

        log.openSysLog(self.cfg.root, self.cfg.logFile)

        if not resolverClass:
            resolverClass = resolve.DependencySolver

        self.resolver = resolverClass(self, cfg, self.db)

        # Set up the callbacks for the PGP key cache
        keyCache = openpgpkey.getKeyCache()
        keyCache.setPublicPath(cfg.pubRing)
        keyCacheCallback = openpgpkey.KeyCacheCallback(self.repos,
                                                       cfg)
        keyCache.setCallback(keyCacheCallback)