Exemple #1
0
 def __enter__(self):
     LockFile.__enter__(self)
     utils.ScopedEnv.__enter__(self)
     if not self.__unlock():
         raise Exception("Failed to setup keychain")
         return None
     return self
Exemple #2
0
    def test_LockFile(self):
        if OsDetection.isUnix():
            lock = LockFile("foo")
            print("start")
            lock.lock()

            def _delayedUnlock():
                print("unlock1")
                lock.unlock()
            threading.Timer(5, _delayedUnlock).start()
            with LockFile("foo") as lock2:
               print("locked lock2")
            print("end")
Exemple #3
0
    def __init__(self):
        LockFile.__init__(self, "keychainLock")
        # ci setups tend to mess with the env and we need the users real home
        if not _MacSignScope.__REAL_HOME:
            user =  subprocess.getoutput("id -un")
            _MacSignScope.__REAL_HOME = Path("/Users") / user
        utils.ScopedEnv.__init__(self, {"HOME": str(_MacSignScope.__REAL_HOME)})
        self.certFileApplication = CraftCore.settings.get("CodeSigning", "MacCertificateApplication", "")
        self.certFilesInstaller = CraftCore.settings.get("CodeSigning", "MacCertificateInstaller", "")

        # FIXME: loginKeychain is misleading - it doesn't need to be login.keychain
        if self._useCertFile:
            self.loginKeychain = f"craft-{secrets.token_urlsafe(16)}.keychain"
        else:
            self.loginKeychain = CraftCore.settings.get("CodeSigning", "MacKeychainPath", os.path.expanduser("~/Library/Keychains/login.keychain"))
Exemple #4
0
 def __exit__(self, exc_type, exc_value, trback):
     if self._useCertFile:
         utils.system(["security", "delete-keychain", self.loginKeychain])
     utils.ScopedEnv.__exit__(self, exc_type, exc_value, trback)
     LockFile.__exit__(self, exc_type, exc_value, trback)