changed socket path to secure temp file

This commit is contained in:
bigtedde 2023-07-09 17:46:50 -04:00
parent ed02164b68
commit 2c5f6645b4
1 changed files with 2 additions and 4 deletions

View File

@ -1,7 +1,6 @@
import errno
import json
import os
import tempfile
from random import randbytes
import shutil
import socket
@ -169,14 +168,13 @@ def test_create_duplicate_root(archivers, request):
@pytest.mark.skipif(is_win32, reason="unix sockets not available on windows")
def test_unix_socket(archivers, request):
def test_unix_socket(archivers, request, tmp_path):
archiver = request.getfixturevalue(archivers)
repo_location = archiver.repository_location
cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
try:
name = tempfile.mktemp(prefix="test_sock", suffix=".sock") # short path needed for socket.bind
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.bind(name)
sock.bind(os.path.join(archiver.input_path, "unix-socket"))
except PermissionError as err:
if err.errno == errno.EPERM:
pytest.skip("unix sockets disabled or not supported")