[Compose] New dockerapi-mailcow image

[Docker API] Fix for rspamd-mailcow rspamadm pw command
master
André 2018-04-19 12:56:49 +02:00
parent bfcfeeb1e8
commit 7031af4cc8
2 changed files with 15 additions and 2 deletions

View File

@ -97,7 +97,10 @@ class container_post(Resource):
for container in docker_client.containers.list(filters={"id": container_id}):
hash = container.exec_run(["/bin/bash", "-c", "/usr/bin/rspamadm pw -e -p '" + request.json['raw'].replace("'", "'\\''") + "' 2> /dev/null"], user='_rspamd')
if hash.exit_code == 0:
hash = str(hash.output)
hash_stdout = str(hash.output)
for line in hash_stdout.split("\n"):
if '$2$' in line:
hash = line.strip()
f = open("/access.inc", "w")
f.write('enable_password = "' + re.sub('[^0-9a-zA-Z\$]+', '', hash.rstrip()) + '";\n')
f.close()
@ -107,6 +110,16 @@ class container_post(Resource):
return jsonify(type='danger', msg='command did not complete, exit code was ' + int(hash.exit_code))
except Exception as e:
return jsonify(type='danger', msg=str(e))
elif request.json['cmd'] == 'mailman_password' and request.json['email'] and request.json['passwd']:
try:
for container in docker_client.containers.list(filters={"id": container_id}):
add_su = container.exec_run(["/bin/bash", "-c", "/opt/mm_web/add_su.py '" + request.json['passwd'].replace("'", "'\\''") + "' '" + request.json['email'].replace("'", "'\\''") + "'"], user='mailman')
if add_su.exit_code == 0:
return jsonify(type='success', msg='command completed successfully')
else:
return jsonify(type='danger', msg='command did not complete, exit code was ' + int(add_su.exit_code))
except Exception as e:
return jsonify(type='danger', msg=str(e))
else:
return jsonify(type='danger', msg='Unknown command')

View File

@ -368,7 +368,7 @@ services:
- watchdog
dockerapi-mailcow:
image: mailcow/dockerapi:1.9
image: mailcow/dockerapi:1.11
restart: always
build: ./data/Dockerfiles/dockerapi
sysctls: