mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-18 08:33:41 +00:00
- Rewrote action script to eliminate stdin communication - Changed return type of audit.*.get() - An audit can return multiple lines of diagnostics - Move recommended endpoint URLs into function docstrings
47 lines
870 B
Python
Executable File
47 lines
870 B
Python
Executable File
#!/usr/bin/python3
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import logging
|
|
import os
|
|
import sys
|
|
|
|
import plinth.modules.email_server.audit as audit
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
EXIT_SYNTAX = 10
|
|
EXIT_PERM = 20
|
|
|
|
|
|
def reserved_for_root(fun):
|
|
def wrapped(*args, **kwargs):
|
|
if os.getuid() != 0:
|
|
logger.critical('This action is reserved for root')
|
|
sys.exit(EXIT_PERM)
|
|
return fun(*args, **kwargs)
|
|
return wrapped
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) != 3:
|
|
sys.exit(EXIT_SYNTAX)
|
|
if sys.argv[1] != 'ipc':
|
|
sys.exit(EXIT_SYNTAX)
|
|
|
|
function_name = 'ipc_' + sys.argv[2]
|
|
globals()[function_name]()
|
|
|
|
|
|
@reserved_for_root
|
|
def ipc_set_sasl():
|
|
audit.ldap.action_set_sasl()
|
|
|
|
|
|
@reserved_for_root
|
|
def ipc_set_submission():
|
|
audit.ldap.action_set_submission()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|