Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If a user passes a socket file that does not exist then the is_unix_socket will raise an exception : ➜ haproxytool acl -F /var/lib/haproxy/statss -s /etc/haproxy/block_traffic_header_names.list Traceback (most recent call last): File "/home/pavlos/.virtualenvs/haproxy/bin/haproxytool", line 8, in <module> sys.exit(main()) File "/home/pavlos/.virtualenvs/haproxy/lib/python3.9/site-packages/haproxytool/cli.py", line 41, in main call_main(sub_cmd) File "/home/pavlos/.virtualenvs/haproxy/lib/python3.9/site-packages/haproxytool/acl.py", line 107, in main hap = haproxy_object(arguments) File "/home/pavlos/.virtualenvs/haproxy/lib/python3.9/site-packages/haproxytool/utils.py", line 57, in haproxy_object hap = haproxy.HAProxy(socket_file=arguments['--file'], File "/home/pavlos/.virtualenvs/haproxy/lib/python3.9/site-packages/haproxyadmin/haproxy.py", line 117, in __init__ elif (socket_file and is_unix_socket(socket_file) and File "/home/pavlos/.virtualenvs/haproxy/lib/python3.9/site-packages/haproxyadmin/utils.py", line 157, in is_unix_socket mode = os.stat(path).st_mode FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/haproxy/statss' Let's avoid this situation by catching OSError class exceptions.
- Loading branch information