Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed editing cache volume in Yandex browser #192

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions gpoa/frontend/appliers/file_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, file_obj, file_cache, exe_check, username=None):
self.archive = str2bool(file_obj.archive)
self.hidden = str2bool(file_obj.hidden)
self.suppress = str2bool(file_obj.suppress)
self.executable = str2bool(file_obj.executable)
self.username = username
self.fromPathFiles = list()
if self.fromPath:
Expand Down Expand Up @@ -98,6 +99,8 @@ def copy_target_file(self, targetFile:Path, fromFile:str):
logdata['fromFile'] = fromFile
logdata['exc'] = exc
log('W15', logdata)
targetFile.unlink()
return None

def set_exe_file(self, targetFile, fromFile):
if not targetFile.is_file():
Expand All @@ -109,7 +112,14 @@ def set_exe_file(self, targetFile, fromFile):
shutil.os.chmod(targetFile, 0o555)
else:
shutil.os.chmod(targetFile, 0o775)
elif self.executable:
if self.readOnly:
shutil.os.chmod(targetFile, 0o555)
else:
shutil.os.chmod(targetFile, 0o775)

else:

if self.readOnly:
shutil.os.chmod(targetFile, 0o444)
else:
Expand All @@ -123,7 +133,8 @@ def _create_action(self):
try:
targetFile = self.get_target_file(self.targetPath, fromFile)
if targetFile and not targetFile.exists():
self.copy_target_file(targetFile, fromFile)
if not self.copy_target_file(targetFile, fromFile):
raise
if self.username:
shutil.chown(targetFile, self.username)
self.set_exe_file(targetFile, fromFile)
Expand Down Expand Up @@ -160,7 +171,8 @@ def _update_action(self):
for fromFile in self.fromPathFiles:
targetFile = self.get_target_file(self.targetPath, fromFile)
try:
self.copy_target_file(targetFile, fromFile)
if not self.copy_target_file(targetFile, fromFile):
raise
if self.username:
shutil.chown(self.targetPath, self.username)
self.set_exe_file(targetFile, fromFile)
Expand Down
2 changes: 2 additions & 0 deletions gpoa/frontend/appliers/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def _create_action(self):

def _delete_action(self):
if self.folder_path.exists():
if self.action == FileAction.REPLACE:
self.delete_folder = True
remove_dir_tree(self.folder_path,
self.delete_files,
self.delete_folder,
Expand Down
1 change: 1 addition & 0 deletions gpoa/frontend/yandex_browser_applier.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def get_valuename_typeint(self):
'DefaultGeolocationSetting',
'DefaultPopupsSetting',
'DeveloperToolsAvailability',
'DiskCacheSize',
'IncognitoModeAvailability',
'PasswordProtectionWarningTrigger',
'SafeBrowsingProtectionLevel',
Expand Down
3 changes: 3 additions & 0 deletions gpoa/gpt/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def read_files(filesxml):
fil_obj.set_archive(props.get('archive', default=None))
fil_obj.set_hidden(props.get('hidden', default=None))
fil_obj.set_suppress(props.get('suppress', default=None))
fil_obj.set_executable(props.get('executable', default=None))
files.append(fil_obj)

return files
Expand All @@ -54,3 +55,5 @@ def set_hidden(self, hidden):
self.hidden = hidden
def set_suppress(self, suppress):
self.suppress = suppress
def set_executable(self, executable):
self.executable = executable
19 changes: 10 additions & 9 deletions gpoa/storage/record_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,17 +216,17 @@ class file_entry(object):
'''
Object mapping representing FILES.XML
'''
def __init__(self, sid, scrobj, policy_name):
def __init__(self, sid, fileobj, policy_name):
self.sid = sid
self.policy_name = policy_name
self.action = scrobj.action
self.fromPath = scrobj.fromPath
self.targetPath = scrobj.targetPath
self.readOnly = scrobj.readOnly
self.archive = scrobj.archive
self.hidden = scrobj.hidden
self.suppress = scrobj.suppress

self.action = fileobj.action
self.fromPath = fileobj.fromPath
self.targetPath = fileobj.targetPath
self.readOnly = fileobj.readOnly
self.archive = fileobj.archive
self.hidden = fileobj.hidden
self.suppress = fileobj.suppress
self.executable = fileobj.executable

def update_fields(self):
'''
Expand All @@ -241,6 +241,7 @@ def update_fields(self):
fields['archive'] = self.archive
fields['hidden'] = self.hidden
fields['suppress'] = self.suppress
fields['executable'] = self.executable

return fields

Expand Down
1 change: 1 addition & 0 deletions gpoa/storage/sqlite_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def __init__(self, db_name, registry_cache_dir=None):
, Column('archive', String)
, Column('hidden', String)
, Column('suppress', String)
, Column('executable', String)
, UniqueConstraint('sid', 'policy_name', 'targetPath', 'fromPath')
)
self.__ini = Table(
Expand Down
2 changes: 1 addition & 1 deletion gpupdate.spec
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fi
# Remove storage in case we've lost compatibility between versions.
# The storage will be regenerated on GPOA start.
%define active_policy %_sysconfdir/local-policy/active
%triggerpostun -- %name < 0.9.12
%triggerpostun -- %name < 0.9.12.3
rm -f %_cachedir/%name/registry.sqlite
if test -L %active_policy; then
sed -i "s|^\s*local-policy\s*=.*|local-policy = $(readlink -f %active_policy)|" \
Expand Down