mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
transmission: Read configuration as super user
Due to permission restrictions on the configuration file (due to stored password), it is not possible to read it as plinth user. Read it using sudo instead.
This commit is contained in:
parent
522db2ce4c
commit
afdea208ec
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- dynamicdns: Allowed Plinth to run as non-root.
|
- dynamicdns: Allowed Plinth to run as non-root.
|
||||||
|
- transmission: Read configuration as super user.
|
||||||
|
|
||||||
## [0.10.0] - 2016-08-12
|
## [0.10.0] - 2016-08-12
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -37,13 +37,10 @@ def parse_arguments():
|
|||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||||
|
|
||||||
# Enable service
|
|
||||||
subparsers.add_parser('enable', help='Enable Transmission service')
|
subparsers.add_parser('enable', help='Enable Transmission service')
|
||||||
|
|
||||||
# Disable service
|
|
||||||
subparsers.add_parser('disable', help='Disable Transmission service')
|
subparsers.add_parser('disable', help='Disable Transmission service')
|
||||||
|
subparsers.add_parser(
|
||||||
# Merge given JSON configration with existing
|
'get-configuration', help='Return the current configuration')
|
||||||
subparsers.add_parser(
|
subparsers.add_parser(
|
||||||
'merge-configuration',
|
'merge-configuration',
|
||||||
help='Merge JSON configuration from stdin with existing')
|
help='Merge JSON configuration from stdin with existing')
|
||||||
@ -63,6 +60,12 @@ def subcommand_disable(_):
|
|||||||
action_utils.service_disable('transmission-daemon')
|
action_utils.service_disable('transmission-daemon')
|
||||||
|
|
||||||
|
|
||||||
|
def subcommand_get_configuration(_):
|
||||||
|
"""Return the current configuration in JSON format."""
|
||||||
|
configuration = open(TRANSMISSION_CONFIG, 'r').read()
|
||||||
|
print(configuration)
|
||||||
|
|
||||||
|
|
||||||
def subcommand_merge_configuration(arguments):
|
def subcommand_merge_configuration(arguments):
|
||||||
"""Merge given JSON configuration with existing configuration."""
|
"""Merge given JSON configuration with existing configuration."""
|
||||||
configuration = sys.stdin.read()
|
configuration = sys.stdin.read()
|
||||||
|
|||||||
@ -47,8 +47,6 @@ description = [
|
|||||||
|
|
||||||
service = None
|
service = None
|
||||||
|
|
||||||
TRANSMISSION_CONFIG = '/etc/transmission-daemon/settings.json'
|
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""Intialize the Transmission module."""
|
"""Intialize the Transmission module."""
|
||||||
|
|||||||
@ -42,7 +42,8 @@ class TransmissionServiceView(views.ServiceView):
|
|||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
"""Get the current settings from Transmission server."""
|
"""Get the current settings from Transmission server."""
|
||||||
configuration = open(transmission.TRANSMISSION_CONFIG, 'r').read()
|
configuration = actions.superuser_run(
|
||||||
|
'transmission', ['get-configuration'])
|
||||||
status = json.loads(configuration)
|
status = json.loads(configuration)
|
||||||
status = {key.translate(str.maketrans({'-': '_'})): value
|
status = {key.translate(str.maketrans({'-': '_'})): value
|
||||||
for key, value in status.items()}
|
for key, value in status.items()}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user