mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-04 08:13:38 +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
|
||||
- dynamicdns: Allowed Plinth to run as non-root.
|
||||
- transmission: Read configuration as super user.
|
||||
|
||||
## [0.10.0] - 2016-08-12
|
||||
### Added
|
||||
|
||||
@ -37,13 +37,10 @@ def parse_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
|
||||
# Enable service
|
||||
subparsers.add_parser('enable', help='Enable Transmission service')
|
||||
|
||||
# Disable service
|
||||
subparsers.add_parser('disable', help='Disable Transmission service')
|
||||
|
||||
# Merge given JSON configration with existing
|
||||
subparsers.add_parser(
|
||||
'get-configuration', help='Return the current configuration')
|
||||
subparsers.add_parser(
|
||||
'merge-configuration',
|
||||
help='Merge JSON configuration from stdin with existing')
|
||||
@ -63,6 +60,12 @@ def subcommand_disable(_):
|
||||
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):
|
||||
"""Merge given JSON configuration with existing configuration."""
|
||||
configuration = sys.stdin.read()
|
||||
|
||||
@ -47,8 +47,6 @@ description = [
|
||||
|
||||
service = None
|
||||
|
||||
TRANSMISSION_CONFIG = '/etc/transmission-daemon/settings.json'
|
||||
|
||||
|
||||
def init():
|
||||
"""Intialize the Transmission module."""
|
||||
|
||||
@ -42,7 +42,8 @@ class TransmissionServiceView(views.ServiceView):
|
||||
|
||||
def get_initial(self):
|
||||
"""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 = {key.translate(str.maketrans({'-': '_'})): value
|
||||
for key, value in status.items()}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user