diff --git a/data/Dockerfiles/dockerapi/server.py b/data/Dockerfiles/dockerapi/server.py index 57ed3570e..3ae67b70e 100644 --- a/data/Dockerfiles/dockerapi/server.py +++ b/data/Dockerfiles/dockerapi/server.py @@ -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') diff --git a/docker-compose.yml b/docker-compose.yml index 028c95d90..dbbd6e5d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: