Merge branch 'master' into reversedns

This commit is contained in:
Michael Kroes 2016-02-28 21:17:22 +01:00
commit 4f14460453
4 changed files with 27 additions and 21 deletions

View File

@ -6,17 +6,11 @@ from functools import wraps
from flask import Flask, request, render_template, abort, Response, send_from_directory 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_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_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 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() env = utils.load_environment()
auth_service = auth.KeyAuthService() auth_service = auth.KeyAuthService()
@ -436,7 +430,10 @@ def system_status():
def print_line(self, message, monospace=False): def print_line(self, message, monospace=False):
self.items[-1]["extra"].append({ "text": message, "monospace": monospace }) self.items[-1]["extra"].append({ "text": message, "monospace": monospace })
output = WebOutput() output = WebOutput()
# Create a temporary pool of processes for the status checks
pool = multiprocessing.pool.Pool(processes=5)
run_checks(False, env, output, pool) run_checks(False, env, output, pool)
pool.terminate()
return json_response(output.items) return json_response(output.items)
@app.route('/system/updates') @app.route('/system/updates')

View File

@ -137,19 +137,20 @@ def get_mail_users_ex(env, with_archived=False, with_slow_info=False):
if with_archived: if with_archived:
root = os.path.join(env['STORAGE_ROOT'], 'mail/mailboxes') root = os.path.join(env['STORAGE_ROOT'], 'mail/mailboxes')
for domain in os.listdir(root): for domain in os.listdir(root):
for user in os.listdir(os.path.join(root, domain)): if os.path.isdir(os.path.join(root, domain)):
email = user + "@" + domain for user in os.listdir(os.path.join(root, domain)):
mbox = os.path.join(root, domain, user) email = user + "@" + domain
if email in active_accounts: continue mbox = os.path.join(root, domain, user)
user = { if email in active_accounts: continue
"email": email, user = {
"privileges": "", "email": email,
"status": "inactive", "privileges": "",
"mailbox": mbox, "status": "inactive",
} "mailbox": mbox,
users.append(user) }
if with_slow_info: users.append(user)
user["mailbox_size"] = utils.du(mbox) if with_slow_info:
user["mailbox_size"] = utils.du(mbox)
# Group by domain. # Group by domain.
domains = { } domains = { }

View File

@ -33,3 +33,10 @@ if [ ! -d /vagrant ]; then
exit exit
fi fi
fi fi
# 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

View File

@ -5,7 +5,8 @@
source setup/functions.sh # load our functions source setup/functions.sh # load our functions
# Check system setup: Are we running as root on Ubuntu 14.04 on a # 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 source setup/preflight.sh
# Ensure Python reads/writes files in UTF-8. If the machine # Ensure Python reads/writes files in UTF-8. If the machine