move etpConst['dbconfigprotect'] and etpConst['dbconfigprotectmask']
to SystemSettings
This commit is contained in:
@@ -93,6 +93,44 @@ class ClientSystemSettingsPlugin(SystemSettingsPlugin):
|
||||
except RepositoryError:
|
||||
pass
|
||||
|
||||
def client_repo_parser(self, system_settings_instance):
|
||||
|
||||
data = {
|
||||
'config_protect': [],
|
||||
'config_protect_mask': [],
|
||||
}
|
||||
if self._helper.clientDbconn != None:
|
||||
|
||||
config_protect = []
|
||||
config_protect_mask = []
|
||||
conn = self._helper.clientDbconn
|
||||
try:
|
||||
config_protect = conn.listConfigProtectDirectories()
|
||||
except (dbapi2.Error,):
|
||||
pass
|
||||
try:
|
||||
config_protect_mask = \
|
||||
conn.listConfigProtectDirectories(mask = True)
|
||||
except (dbapi2.Error,):
|
||||
pass
|
||||
|
||||
config_protect = [etpConst['systemroot']+x for x in config_protect]
|
||||
config_protect_mask = [etpConst['systemroot']+x for x in \
|
||||
config_protect_mask]
|
||||
|
||||
sys_conf_protect = system_settings_instance['client']['configprotect']
|
||||
sys_conf_protect_mask = system_settings_instance['client']['configprotectmask']
|
||||
|
||||
data['config_protect'] = config_protect + [
|
||||
etpConst['systemroot']+x for x in sys_conf_protect if \
|
||||
etpConst['systemroot']+x not in config_protect]
|
||||
|
||||
data['config_protect_mask'] = config_protect_mask + [
|
||||
etpConst['systemroot']+x for x in sys_conf_protect_mask if \
|
||||
etpConst['systemroot']+x not in config_protect_mask]
|
||||
|
||||
return data
|
||||
|
||||
class Client(Singleton, TextInterface, LoadersMixin, CacheMixin, CalculatorsMixin, \
|
||||
RepositoryMixin, MiscMixin, MatchMixin, FetchersMixin, ExtractorsMixin):
|
||||
|
||||
|
||||
@@ -437,25 +437,6 @@ class RepositoryMixin:
|
||||
# make sure settings are in sync
|
||||
self.SystemSettings.clear()
|
||||
|
||||
def __client_repo_setup_const(self, conn):
|
||||
if conn.doesTableExist('configprotect') and conn.doesTableExist('configprotectreference'):
|
||||
etpConst['dbconfigprotect'] = conn.listConfigProtectDirectories()
|
||||
if conn.doesTableExist('configprotectmask') and conn.doesTableExist('configprotectreference'):
|
||||
etpConst['dbconfigprotectmask'] = conn.listConfigProtectDirectories(mask = True)
|
||||
|
||||
etpConst['dbconfigprotect'] = [etpConst['systemroot']+x for x in etpConst['dbconfigprotect']]
|
||||
etpConst['dbconfigprotectmask'] = [etpConst['systemroot']+x for x in etpConst['dbconfigprotect']]
|
||||
|
||||
conf_protect = self.SystemSettings['client']['configprotect']
|
||||
conf_protect_mask = self.SystemSettings['client']['configprotectmask']
|
||||
|
||||
etpConst['dbconfigprotect'] += [etpConst['systemroot']+x for \
|
||||
x in conf_protect if etpConst['systemroot']+x not \
|
||||
in etpConst['dbconfigprotect']]
|
||||
etpConst['dbconfigprotectmask'] += [etpConst['systemroot']+x for \
|
||||
x in conf_protect_mask if etpConst['systemroot']+x not \
|
||||
in etpConst['dbconfigprotectmask']]
|
||||
|
||||
def open_client_repository(self):
|
||||
|
||||
def load_db_from_ram():
|
||||
@@ -496,9 +477,6 @@ class RepositoryMixin:
|
||||
self.entropyTools.print_traceback(f = self.clientLog)
|
||||
conn = load_db_from_ram()
|
||||
|
||||
if not etpConst['dbconfigprotect']:
|
||||
self.__client_repo_setup_const(conn)
|
||||
|
||||
self.clientDbconn = conn
|
||||
return self.clientDbconn
|
||||
|
||||
|
||||
@@ -366,13 +366,13 @@ class Package:
|
||||
|
||||
def __remove_content_from_system(self, protected_removable_config_files):
|
||||
|
||||
# load CONFIG_PROTECT and its mask
|
||||
# client database at this point has been surely opened,
|
||||
# so our dicts are already filled
|
||||
protect = etpConst['dbconfigprotect']
|
||||
mask = etpConst['dbconfigprotectmask']
|
||||
sys_root = etpConst['systemroot']
|
||||
col_protect = self.Entropy.SystemSettings['client']['collisionprotect']
|
||||
# load CONFIG_PROTECT and CONFIG_PROTECT_MASK
|
||||
sys_settings = self.Entropy.SystemSettings
|
||||
client_plugin_id = etpConst['system_settings_plugins_ids']['client_plugin']
|
||||
protect = sys_settings[client_plugin_id]['client_repo']['config_protect']
|
||||
mask = sys_settings[client_plugin_id]['client_repo']['config_protect_mask']
|
||||
col_protect = sys_settings['client']['collisionprotect']
|
||||
|
||||
# remove files from system
|
||||
directories = set()
|
||||
|
||||
@@ -38,7 +38,9 @@ class FileUpdates:
|
||||
raise IncorrectParameter("IncorrectParameter: %s" % (mytxt,))
|
||||
self.Entropy = EquoInstance
|
||||
from entropy.cache import EntropyCacher
|
||||
from entropy.core import SystemSettings
|
||||
self.Cacher = EntropyCacher()
|
||||
self.SystemSettings = SystemSettings()
|
||||
self.scandata = None
|
||||
|
||||
def merge_file(self, key):
|
||||
@@ -94,11 +96,12 @@ class FileUpdates:
|
||||
except:
|
||||
pass
|
||||
|
||||
# open client database to fill etpConst['dbconfigprotect']
|
||||
scandata = {}
|
||||
counter = 0
|
||||
name_cache = set()
|
||||
for path in etpConst['dbconfigprotect']:
|
||||
client_plugin_id = etpConst['system_settings_plugins_ids']['client_plugin']
|
||||
client_conf_protect = self.SystemSettings[client_plugin_id]['client_repo']['config_protect']
|
||||
for path in client_conf_protect:
|
||||
# it's a file?
|
||||
scanfile = False
|
||||
if os.path.isfile(path):
|
||||
|
||||
Reference in New Issue
Block a user