Ejemplo n.º 1
0
 def _get_password_from_keyring(self, service_name, user_name):
     """
     get password from system keyring (seahorse). The keyring is only
     available if User is logged in.
     """
     if self.keyring_supported:
         try:
             return tools.get_password(service_name, user_name)
         except Exception:
             logger.error('get password from Keyring failed', self)
     return None
Ejemplo n.º 2
0
    def _collect_passwords(self):
        """
        search all profiles in config and collect passwords from keyring.
        """
        run_daemon = False
        profiles = self.config.get_profiles()
        for profile_id in profiles:
            mode = self.config.get_snapshots_mode(profile_id)
            for pw_id in (1, 2):
                if self.config.mode_need_password(mode, pw_id):
                    if self.config.get_password_use_cache(profile_id):
                        run_daemon = True
                        if self.config.get_password_save(profile_id) and self.keyring_supported:
                            service_name = self.config.get_keyring_service_name(profile_id, mode, pw_id)
                            user_name = self.config.get_keyring_user_name(profile_id)

                            password = tools.get_password(service_name, user_name)
                            if password is None:
                                continue
                            self.db_keyring['%s/%s' %(service_name, user_name)] = password
        return run_daemon