privileged_daemon: Fix showing errors for freedombox-cmd command

Tests:

- When arguments are not provided to freedombox-cmd it shows errors on the
console.

- When a command is successfully executed, the output is printed on the console.

- The output of the privileged daemon goes to the journald.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2025-09-16 14:10:08 -07:00 committed by Veiko Aasa
parent c8f89e3ca5
commit c2d5d1d3c8
No known key found for this signature in database
GPG Key ID: 478539CAE680674E
2 changed files with 7 additions and 4 deletions

View File

@ -90,13 +90,16 @@ def _capture_warnings():
warnings.filterwarnings('default', '', ImportWarning)
def action_init():
def action_init(console: bool = False):
"""Initialize logging for action scripts."""
_capture_warnings()
configuration = get_configuration()
# Don't log to console
configuration['root']['handlers'] = ['journal']
if console:
configuration['root']['handlers'] = ['console']
else:
configuration['root']['handlers'] = ['journal']
logging.config.dictConfig(configuration)

View File

@ -207,7 +207,7 @@ class Server(socketserver.ThreadingUnixStreamServer):
def client_main() -> None:
"""Parse arguments for the client for privileged daemon."""
log.action_init()
log.action_init(console=True)
parser = argparse.ArgumentParser()
parser.add_argument('module', help='Module to trigger action in')