1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-10 04:58:46 +03:00

Add exception handling for not UNC path case in picture_fetch()

This commit is contained in:
Evgeny Sinelnikov 2021-09-06 05:29:24 +04:00
parent c83568cc70
commit 721ba96559
5 changed files with 19 additions and 3 deletions

View File

@ -51,12 +51,12 @@ def picture_fetch(schema, path, value):
logdata['src'] = value
try:
retval = cache.get(value)
logdata['dst'] = retval
logging.debug(slogm('Getting cached file for URI: {}'.format(logdata)))
except Exception as exc:
pass
logdata['dst'] = retval
logging.debug(slogm('Getting cached file for URI: {}'.format(logdata)))
return 'file://{}'.format(retval)
return retval
class gsettings_applier(applier_frontend):
__module_name = 'GSettingsApplier'

View File

@ -132,6 +132,7 @@ def debug_code(code):
debug_ids[59] = 'Running GPOA without GPT update directly for user'
debug_ids[60] = 'Running GPOA by root for user'
debug_ids[61] = 'The GPOA process was started for computer'
debug_ids[62] = 'Path not resolved as UNC URI'
return debug_ids.get(code, 'Unknown debug code')

View File

@ -25,6 +25,7 @@ import smbc
from util.logging import log
from util.paths import file_cache_dir, UNCPath
from util.exceptions import NotUNCPathError
class fs_file_cache:
@ -84,6 +85,9 @@ class fs_file_cache:
destfile = Path('{}/{}/{}'.format(self.storage_uri,
uri_path.get_domain(),
uri_path.get_path()))
except NotUNCPathError as exc:
logdata = dict({'path': str(exc)})
log('D62', logdata)
except Exception as exc:
logdata = dict({'exception': str(exc)})
log('E36', logdata)

View File

@ -39,3 +39,10 @@ def geterr():
return traceinfo
class NotUNCPathError(Exception):
def __init__(self, path):
self.path = path
def __str__(self):
return self.path

View File

@ -24,6 +24,7 @@ from urllib.parse import urlparse
from .config import GPConfig
from .util import get_default_policy_name
from .util.exceptions import NotUNCPathError
def default_policy_path():
@ -78,10 +79,13 @@ def local_policy_cache():
class UNCPath:
def __init__(self, path):
self.path = path
self.type = None
if self.path.startswith(r'smb://'):
self.type = 'uri'
if self.path.startswith(r'\\'):
self.type = 'unc'
if not self.type:
raise NotUNCPathError(path)
def get_uri(self):
path = self.path