mirror of
https://github.com/trailofbits/algo.git
synced 2026-08-21 15:12:31 +02:00
Algo focuses exclusively on Ubuntu LTS. Remove dead code for BSD support that was never fully implemented: - Remove roles/common/tasks/bsd_ipv6_facts.yml (unused file) - Remove BSD handlers (restart ipfw, restart loopback bsd) - Remove FreeBSD compatibility claim from privacy README - Remove BSD loopback mock from integration tests The FAQ entries about OpenBSD are kept as they explain why BSD is NOT supported (historical context about IPSEC). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
#!/usr/bin/python
|
|
# Mock shell module for Docker testing
|
|
|
|
import subprocess
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
def main():
|
|
module = AnsibleModule(
|
|
argument_spec={
|
|
"_raw_params": {"type": "str"},
|
|
"cmd": {"type": "str"},
|
|
"creates": {"type": "path"},
|
|
"removes": {"type": "path"},
|
|
"chdir": {"type": "path"},
|
|
"executable": {"type": "path", "default": "/bin/sh"},
|
|
"warn": {"type": "bool", "default": False},
|
|
"stdin": {"type": "str"},
|
|
"stdin_add_newline": {"type": "bool", "default": True},
|
|
},
|
|
supports_check_mode=True,
|
|
)
|
|
|
|
# Get the command
|
|
raw_params = module.params.get("_raw_params")
|
|
cmd = module.params.get("cmd") or raw_params
|
|
|
|
if not cmd:
|
|
module.fail_json(msg="no command given")
|
|
|
|
result = {"changed": False, "cmd": cmd, "rc": 0, "stdout": "", "stderr": "", "stdout_lines": [], "stderr_lines": []}
|
|
|
|
# Log the operation
|
|
with open("/var/log/mock-shell-module.log", "a") as f:
|
|
f.write(f"shell module called: cmd={cmd}\n")
|
|
|
|
# Handle specific commands
|
|
if "echo 1 > /proc/sys/net/ipv4/route/flush" in cmd:
|
|
# Routing cache flush - just pretend it worked
|
|
result["stdout"] = ""
|
|
result["changed"] = True
|
|
else:
|
|
# For other commands, try to run them
|
|
try:
|
|
proc = subprocess.run(
|
|
cmd,
|
|
shell=True,
|
|
capture_output=True,
|
|
text=True,
|
|
executable=module.params.get("executable"),
|
|
cwd=module.params.get("chdir"),
|
|
)
|
|
result["rc"] = proc.returncode
|
|
result["stdout"] = proc.stdout
|
|
result["stderr"] = proc.stderr
|
|
result["stdout_lines"] = proc.stdout.splitlines()
|
|
result["stderr_lines"] = proc.stderr.splitlines()
|
|
result["changed"] = True
|
|
except Exception as e:
|
|
result["rc"] = 1
|
|
result["stderr"] = str(e)
|
|
result["msg"] = str(e)
|
|
module.fail_json(msg=result["msg"], **result)
|
|
|
|
if result["rc"] == 0:
|
|
module.exit_json(**result)
|
|
else:
|
|
if "msg" not in result:
|
|
result["msg"] = f"Command failed with return code {result['rc']}"
|
|
module.fail_json(msg=result["msg"], **result)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|