mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-11-24 08:32:50 +02:00
[Compose] New dockerapi-mailcow image
[Docker API] Fix for rspamd-mailcow rspamadm pw command
This commit is contained in:
parent
bfcfeeb1e8
commit
7031af4cc8
@ -97,7 +97,10 @@ class container_post(Resource):
|
|||||||
for container in docker_client.containers.list(filters={"id": container_id}):
|
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')
|
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:
|
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 = open("/access.inc", "w")
|
||||||
f.write('enable_password = "' + re.sub('[^0-9a-zA-Z\$]+', '', hash.rstrip()) + '";\n')
|
f.write('enable_password = "' + re.sub('[^0-9a-zA-Z\$]+', '', hash.rstrip()) + '";\n')
|
||||||
f.close()
|
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))
|
return jsonify(type='danger', msg='command did not complete, exit code was ' + int(hash.exit_code))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify(type='danger', msg=str(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:
|
else:
|
||||||
return jsonify(type='danger', msg='Unknown command')
|
return jsonify(type='danger', msg='Unknown command')
|
||||||
|
@ -368,7 +368,7 @@ services:
|
|||||||
- watchdog
|
- watchdog
|
||||||
|
|
||||||
dockerapi-mailcow:
|
dockerapi-mailcow:
|
||||||
image: mailcow/dockerapi:1.9
|
image: mailcow/dockerapi:1.11
|
||||||
restart: always
|
restart: always
|
||||||
build: ./data/Dockerfiles/dockerapi
|
build: ./data/Dockerfiles/dockerapi
|
||||||
sysctls:
|
sysctls:
|
||||||
|
Loading…
Reference in New Issue
Block a user