From 057903a303cd78263750d39ddd70a96ac66212c7 Mon Sep 17 00:00:00 2001 From: yodax Date: Sun, 21 Feb 2016 13:49:07 +0100 Subject: [PATCH 1/4] Allow files in /home/user-data/mail/mailboxes --- management/mailconfig.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/management/mailconfig.py b/management/mailconfig.py index d9ffdf65..d044c1ab 100755 --- a/management/mailconfig.py +++ b/management/mailconfig.py @@ -137,19 +137,20 @@ def get_mail_users_ex(env, with_archived=False, with_slow_info=False): if with_archived: root = os.path.join(env['STORAGE_ROOT'], 'mail/mailboxes') for domain in os.listdir(root): - for user in os.listdir(os.path.join(root, domain)): - email = user + "@" + domain - mbox = os.path.join(root, domain, user) - if email in active_accounts: continue - user = { - "email": email, - "privileges": "", - "status": "inactive", - "mailbox": mbox, - } - users.append(user) - if with_slow_info: - user["mailbox_size"] = utils.du(mbox) + if os.path.isdir(os.path.join(root, domain)): + for user in os.listdir(os.path.join(root, domain)): + email = user + "@" + domain + mbox = os.path.join(root, domain, user) + if email in active_accounts: continue + user = { + "email": email, + "privileges": "", + "status": "inactive", + "mailbox": mbox, + } + users.append(user) + if with_slow_info: + user["mailbox_size"] = utils.du(mbox) # Group by domain. domains = { } From 42f879687f5618dc08cc2a5151b0bf36db2ade4f Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Sun, 21 Feb 2016 12:43:04 -0500 Subject: [PATCH 2/4] Add check to preflight for exec on tmp --- setup/preflight.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup/preflight.sh b/setup/preflight.sh index 26df3ed1..a1899e81 100644 --- a/setup/preflight.sh +++ b/setup/preflight.sh @@ -33,3 +33,11 @@ if [ ! -d /vagrant ]; then exit fi fi + +# Check that tempfs is not mounted with noexec +MOUNTED_TMP_AS_NO_EXEC=$(grep "/tmp.*noexec" /proc/mounts) +if [ -n "$MOUNTED_TMP_AS_NO_EXEC" ]; then + echo "Mail-in-a-Box has to have exec rights on /tmp, please mount /tmp with exec" + + exit +fi From a7e60af93f1ddb2eaaa98f66e9a4f4aa4fd942bb Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Sun, 21 Feb 2016 12:47:09 -0500 Subject: [PATCH 3/4] Update comments --- setup/preflight.sh | 3 +-- setup/start.sh | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/preflight.sh b/setup/preflight.sh index a1899e81..e854249e 100644 --- a/setup/preflight.sh +++ b/setup/preflight.sh @@ -34,10 +34,9 @@ if [ ! -d /vagrant ]; then fi fi -# Check that tempfs is not mounted with noexec +# Check that tempfs is mounted with exec MOUNTED_TMP_AS_NO_EXEC=$(grep "/tmp.*noexec" /proc/mounts) if [ -n "$MOUNTED_TMP_AS_NO_EXEC" ]; then echo "Mail-in-a-Box has to have exec rights on /tmp, please mount /tmp with exec" - exit fi diff --git a/setup/start.sh b/setup/start.sh index ab6d3055..3a93ac22 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -5,7 +5,8 @@ source setup/functions.sh # load our functions # Check system setup: Are we running as root on Ubuntu 14.04 on a -# machine with enough memory? If not, this shows an error and exits. +# machine with enough memory? Is /tmp mounted with exec. +# If not, this shows an error and exits. source setup/preflight.sh # Ensure Python reads/writes files in UTF-8. If the machine From 721730f0e8cff0fbce8da308b1ecec7fa0f8bb4f Mon Sep 17 00:00:00 2001 From: yodax Date: Tue, 23 Feb 2016 06:32:01 +0100 Subject: [PATCH 4/4] Create a temporary multiprocessing pool --- management/daemon.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/management/daemon.py b/management/daemon.py index 6de0a59a..bf3c9134 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -6,17 +6,11 @@ from functools import wraps from flask import Flask, request, render_template, abort, Response, send_from_directory -import auth, utils +import auth, utils, multiprocessing.pool from mailconfig import get_mail_users, get_mail_users_ex, get_admins, add_mail_user, set_mail_password, remove_mail_user from mailconfig import get_mail_user_privileges, add_remove_mail_user_privilege from mailconfig import get_mail_aliases, get_mail_aliases_ex, get_mail_domains, add_mail_alias, remove_mail_alias -# Create a worker pool for the status checks. The pool should -# live across http requests so we don't baloon the system with -# processes. -import multiprocessing.pool -pool = multiprocessing.pool.Pool(processes=5) - env = utils.load_environment() auth_service = auth.KeyAuthService() @@ -436,7 +430,10 @@ def system_status(): def print_line(self, message, monospace=False): self.items[-1]["extra"].append({ "text": message, "monospace": monospace }) output = WebOutput() + # Create a temporary pool of processes for the status checks + pool = multiprocessing.pool.Pool(processes=5) run_checks(False, env, output, pool) + pool.terminate() return json_response(output.items) @app.route('/system/updates')