From 8416c0831d0d6cea9a172ddf720180fdefdbda2c Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Mon, 9 Apr 2018 16:13:23 +0530 Subject: [PATCH] snapshots: Fix for permissions issue when updating configuration - Change `configure` command to `set-config` for consistency with `get-config` - Run `set-config` as superuser Fixes freedombox-team/plinth#1290 Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- actions/snapshot | 4 ++-- plinth/modules/snapshot/views.py | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/actions/snapshot b/actions/snapshot index 39e6aaf2c..818fde542 100755 --- a/actions/snapshot +++ b/actions/snapshot @@ -47,7 +47,7 @@ def parse_arguments(): subparser = subparsers.add_parser('delete-all', help='Delete all the snapshots') - subparser = subparsers.add_parser('configure', + subparser = subparsers.add_parser('set-config', help='Configure automatic snapshots') subparser.add_argument('config') @@ -196,7 +196,7 @@ def _get_delete_arg(range_list): return range_list[0] + '-' + range_list[-1] -def subcommand_configure(arguments): +def subcommand_set_config(arguments): command = ['snapper', 'set-config', arguments.config] subprocess.run(command, check=True) diff --git a/plinth/modules/snapshot/views.py b/plinth/modules/snapshot/views.py index 4be7f4b45..3860fc861 100644 --- a/plinth/modules/snapshot/views.py +++ b/plinth/modules/snapshot/views.py @@ -19,7 +19,6 @@ Views for snapshot module. """ import json -import subprocess from django.contrib import messages from django.shortcuts import redirect @@ -109,10 +108,8 @@ def update_configuration(request, old_status, new_status): ('number_min_age', 'NUMBER_MIN_AGE={}'), ])) - command = ['snapper', 'set-config'] + list(config) - try: - subprocess.run(command, check=True) + actions.superuser_run('snapshot', ['set-config', " ".join(config)]) messages.success(request, _('Storage snapshots configuration updated')) except ActionError as exception: