mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-20 16:03:59 +01:00
Soft Chroot for Headphones
This commit is contained in:
@@ -1095,7 +1095,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label>Plex Token</label><input type="text" name="plex_token" value="${config['plex_token']}" size="30">
|
<label>Plex Token</label><input type="text" name="plex_token" value="${config['plex_token']}" size="30">
|
||||||
<small>Plex Token (for use with Plex Home)</small>
|
<small>Plex Token (for use with Plex Home)</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="checkbox row">
|
<div class="checkbox row">
|
||||||
<input type="checkbox" name="plex_update" value="1" ${config['plex_update']} /><label>Update Plex Library</label>
|
<input type="checkbox" name="plex_update" value="1" ${config['plex_update']} /><label>Update Plex Library</label>
|
||||||
|
|||||||
@@ -138,13 +138,13 @@ def initialize(config_file):
|
|||||||
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR,
|
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR,
|
||||||
verbose=VERBOSE)
|
verbose=VERBOSE)
|
||||||
|
|
||||||
if CONFIG.SOFT_CHROOT:
|
try:
|
||||||
# soft chroot defined, lets try to initialize:
|
SOFT_CHROOT = SoftChroot(str(CONFIG.SOFT_CHROOT))
|
||||||
try:
|
if SOFT_CHROOT.isEnabled():
|
||||||
SOFT_CHROOT = SoftChroot(str(CONFIG.SOFT_CHROOT))
|
logger.info("Soft-chroot enabled for dir: %s", str(CONFIG.SOFT_CHROOT))
|
||||||
except exceptions.SoftChrootError as e:
|
except exceptions.SoftChrootError as e:
|
||||||
logger.error("SoftChroot error: %s", e)
|
logger.error("SoftChroot error: %s", e)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if not CONFIG.CACHE_DIR:
|
if not CONFIG.CACHE_DIR:
|
||||||
# Put the cache dir in the data dir for now
|
# Put the cache dir in the data dir for now
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ _CONFIG_DEFINITIONS = {
|
|||||||
'HEADPHONES_INDEXER': (bool_int, 'General', False),
|
'HEADPHONES_INDEXER': (bool_int, 'General', False),
|
||||||
'HPPASS': (str, 'General', ''),
|
'HPPASS': (str, 'General', ''),
|
||||||
'HPUSER': (str, 'General', ''),
|
'HPUSER': (str, 'General', ''),
|
||||||
'HTTPS_CERT': (str, 'General', ''),
|
'HTTPS_CERT': (path, 'General', ''),
|
||||||
'HTTPS_KEY': (str, 'General', ''),
|
'HTTPS_KEY': (path, 'General', ''),
|
||||||
'HTTP_HOST': (str, 'General', 'localhost'),
|
'HTTP_HOST': (str, 'General', 'localhost'),
|
||||||
'HTTP_PASSWORD': (str, 'General', ''),
|
'HTTP_PASSWORD': (str, 'General', ''),
|
||||||
'HTTP_PORT': (int, 'General', 8181),
|
'HTTP_PORT': (int, 'General', 8181),
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ import os
|
|||||||
from headphones.exceptions import SoftChrootError
|
from headphones.exceptions import SoftChrootError
|
||||||
|
|
||||||
class SoftChroot(object):
|
class SoftChroot(object):
|
||||||
|
""" SoftChroot provides SOFT chrooting for UI
|
||||||
|
|
||||||
|
IMPORTANT: call methods of this class just in modules, which generates data for client UI. Try to avoid unnecessary usage.
|
||||||
|
"""
|
||||||
|
|
||||||
enabled = False
|
enabled = False
|
||||||
chroot = None
|
chroot = None
|
||||||
|
|||||||
@@ -1367,6 +1367,13 @@ class WebInterface(object):
|
|||||||
"idtag": checked(headphones.CONFIG.IDTAG)
|
"idtag": checked(headphones.CONFIG.IDTAG)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for k, v in config.iteritems():
|
||||||
|
if isinstance(v, headphones.config.path):
|
||||||
|
# need to apply SoftChroot to paths:
|
||||||
|
nv = headphones.SOFT_CHROOT.apply(v)
|
||||||
|
if v != nv:
|
||||||
|
config[k] = headphones.config.path(nv)
|
||||||
|
|
||||||
# Need to convert EXTRAS to a dictionary we can pass to the config:
|
# Need to convert EXTRAS to a dictionary we can pass to the config:
|
||||||
# it'll come in as a string like 2,5,6,8
|
# it'll come in as a string like 2,5,6,8
|
||||||
|
|
||||||
@@ -1436,6 +1443,17 @@ class WebInterface(object):
|
|||||||
kwargs[plain_config] = kwargs[use_config]
|
kwargs[plain_config] = kwargs[use_config]
|
||||||
del kwargs[use_config]
|
del kwargs[use_config]
|
||||||
|
|
||||||
|
for k, v in kwargs.iteritems():
|
||||||
|
# TODO : HUGE crutch. It is all because there is no way to deal with options...
|
||||||
|
_conf = headphones.CONFIG._define(k)
|
||||||
|
conftype = _conf[1]
|
||||||
|
|
||||||
|
#print '===>', conftype
|
||||||
|
if conftype is headphones.config.path:
|
||||||
|
nv = headphones.SOFT_CHROOT.revoke(v)
|
||||||
|
if nv != v:
|
||||||
|
kwargs[k] = nv
|
||||||
|
|
||||||
# Check if encoderoutputformat is set multiple times
|
# Check if encoderoutputformat is set multiple times
|
||||||
if len(kwargs['encoderoutputformat'][-1]) > 1:
|
if len(kwargs['encoderoutputformat'][-1]) > 1:
|
||||||
kwargs['encoderoutputformat'] = kwargs['encoderoutputformat'][-1]
|
kwargs['encoderoutputformat'] = kwargs['encoderoutputformat'][-1]
|
||||||
|
|||||||
Reference in New Issue
Block a user