}
deps_linux_debian_mingw() {
- apt-get install -y \
+ apt install -y \
mingw-w64 mingw-w64-tools \
wine wine-binfmt \
libgcrypt-mingw-w64-dev \
dpkg --add-architecture "$HOST"
fi
- apt-get update
+ apt update
- apt-get install -y \
+ apt install -y \
binfmt-support binutils gcc make pkgconf \
zlib1g-dev:"$HOST" \
libssl-dev:"$HOST" \
liblz4-dev:"$HOST" \
libncurses-dev:"$HOST" \
libreadline-dev:"$HOST" \
- libgcrypt-dev:"$HOST" \
+ libgcrypt20-dev:"$HOST" \
libminiupnpc-dev:"$HOST" \
libvdeplug-dev:"$HOST" \
libcmocka-dev:"$HOST" \
"$@"
if [ -n "$HOST" ]; then
- apt-get install -y crossbuild-essential-"$HOST" qemu-user
+ apt install -y crossbuild-essential-"$HOST" qemu-user
fi
}
deps_linux_debian() {
export DEBIAN_FRONTEND=noninteractive
- apt-get update
- apt-get upgrade -y
- apt-get install -y git pkgconf sudo texinfo meson
+ apt update
+ apt upgrade -y
+ apt install -y git pkgconf sudo texinfo meson
HOST=${HOST:-}
if [ "$HOST" = mingw ]; then
export DEBIAN_FRONTEND=noninteractive
-apt-get install -y devscripts git-buildpackage dh-make
+apt install -y devscripts git-buildpackage dh-make
export USER=${USER:-$(whoami)}
export EMAIL=ci@tinc-vpn.org
- name: Install tools
run: |
- sudo apt-get install -y astyle clang-tidy-$CLANG shellcheck shfmt black pylint mypy
+ sudo apt install -y astyle clang-tidy-$CLANG shellcheck shfmt black pylint mypy
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-$CLANG 100
sudo update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-$CLANG 100
python3 -m venv /tmp/venv
run: sh .ci/deps.sh
- name: Run tests with default settings
- run: CFLAGS=/opt/homebrew/include sh .ci/test/run.sh default
+ run: CFLAGS=-I/opt/homebrew/include sh .ci/test/run.sh default
- name: Run tests without legacy protocol
- run: CFLAGS=/opt/homebrew/include sh .ci/test/run.sh nolegacy
+ run: CFLAGS=-I/opt/homebrew/include sh .ci/test/run.sh nolegacy
if: always()
- name: Run tests with libgcrypt
- run: CFLAGS=/opt/homebrew/include sh .ci/test/run.sh gcrypt
+ run: CFLAGS=-I/opt/homebrew/include sh .ci/test/run.sh gcrypt
if: always()
- name: Upload test results
#endif
#endif
-#if defined(HAVE_ATTR_MALLOC_WITH_ARG)
+#if defined(HAVE_ATTR_MALLOC_WITH_ARG) && !defined(__clang__)
#define ATTR_DEALLOCATOR(dealloc) __attribute__((__malloc__(dealloc)))
#else
#define ATTR_DEALLOCATOR(dealloc)
hello there\n\
""".encode("utf-8")
-RAW_DATA = tempfile.mktemp()
+raw_fd, raw_path = tempfile.mkstemp()
-with open(RAW_DATA, "wb") as raw_file:
+with os.fdopen(raw_fd, "wb") as raw_file:
raw_file.write(util.random_string(64).encode("utf-8"))
check.is_in("Could not open", err)
os.truncate(foo.sub("ed25519_key.priv"), 0)
- _, err = foo.cmd("sign", RAW_DATA, code=1)
+ _, err = foo.cmd("sign", raw_path, code=1)
check.is_in("Could not read private key from", err)
os.remove(foo.sub("ed25519_key.priv"))
- _, err = foo.cmd("sign", RAW_DATA, code=1)
+ _, err = foo.cmd("sign", raw_path, code=1)
check.is_in("Could not open", err)
def test_verify(foo: Tinc) -> None:
"""Test `verify` of data known to work."""
- signed_file = tempfile.mktemp()
- with open(signed_file, "wb") as f:
+ fd, path = tempfile.mkstemp()
+ with os.fdopen(fd, "wb") as f:
f.write(SIGNED_BYTES)
foo.name = "foo"
for name in ".", foo.name:
foo.cmd("verify", name, stdin=SIGNED_BYTES)
- foo.cmd("verify", name, signed_file)
+ foo.cmd("verify", name, path)
if os.name != "nt":
foo.cmd("verify", "*", stdin=SIGNED_BYTES)
- foo.cmd("verify", "*", signed_file)
+ foo.cmd("verify", "*", path)
- os.remove(signed_file)
+ os.remove(path)
def test_verify_errors(foo: Tinc) -> None:
def test_sign_verify(foo: Tinc, bar: Tinc) -> None:
"""Test `sign` and pass its result to `verify`."""
- signed, _ = foo.cmd("sign", RAW_DATA, stdin=b"")
+ signed, _ = foo.cmd("sign", raw_path, stdin=b"")
assert isinstance(signed, bytes)
- signed_file = tempfile.mktemp()
- with open(signed_file, "wb") as f:
+ fd, path = tempfile.mkstemp()
+ with os.fdopen(fd, "wb") as f:
f.write(signed)
for name in ".", foo.name:
- foo.cmd("verify", name, signed_file)
+ foo.cmd("verify", name, path)
foo.cmd("verify", name, stdin=signed)
if os.name != "nt":
- foo.cmd("verify", "*", signed_file)
+ foo.cmd("verify", "*", path)
foo.cmd("verify", "*", stdin=signed)
- os.remove(signed_file)
+ os.remove(path)
cmd.exchange(foo, bar)
if os.name != "nt":
- signed, _ = foo.cmd("sign", RAW_DATA)
+ signed, _ = foo.cmd("sign", raw_path)
bar.cmd("verify", "*", stdin=signed)
- signed, _ = bar.cmd("sign", RAW_DATA)
+ signed, _ = bar.cmd("sign", raw_path)
foo.cmd("verify", bar.name, stdin=signed)
log.info("create a UNIX socket to transfer FD")
unix = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- unix_path = tempfile.mktemp()
+ unix_path = tempfile.mkstemp()[1] + ".socket"
unix.bind(unix_path)
unix.listen(1)
def test_watchdog(foo: Tinc) -> None:
"""Test systemd watchdog."""
- address = tempfile.mktemp()
+ address = tempfile.mkstemp()[1] + ".socket"
foo_log = foo.sub("log")
log.info("watchdog is disabled if no env vars are passed")
# Exit code to skip current test
EXIT_SKIP = 77
-# Family name for multiprocessing Listener/Connection
-MPC_FAMILY = "AF_PIPE" if os.name == "nt" else "AF_UNIX"
-
# Do access checks on files. Disabled when not available or not applicable.
RUN_ACCESS_CHECKS = os.name != "nt" and os.geteuid() != 0
from .log import log
from .event import Notification
-from .const import MPC_FAMILY
def _get_key(name, script) -> str:
os.kill(0, signal.SIGTERM)
def _listen(self) -> None:
- with mp.Listener(family=MPC_FAMILY, authkey=self.authkey) as listener:
+ with mp.Listener(authkey=self.authkey) as listener:
assert not isinstance(listener.address, tuple)
self.address = listener.address
self._ready.set()
from testlib.proc import Tinc
from testlib.event import Notification
from testlib.log import new_logger
-from testlib.const import MPC_FAMILY
this = Tinc('$NODE_NAME')
log = new_logger(this.name)
for retry in range(1, 10):
try:
- with mpc.Client($NOTIFICATIONS_ADDR, family=MPC_FAMILY, authkey=$AUTH_KEY) as conn:
+ with mpc.Client($NOTIFICATIONS_ADDR, authkey=$AUTH_KEY) as conn:
conn.send(evt)
log.debug(f'sent notification')
break
def temp_file(content: str) -> str:
"""Create a temporary file and write text content into it."""
- file = tempfile.mktemp()
- with open(file, "w", encoding="utf-8") as f:
+ fd, path = tempfile.mkstemp()
+ with os.fdopen(fd, "w", encoding="utf-8") as f:
f.write(content)
- return file
+ return path
def remove_file(path: T.Union[str, Path]) -> bool:
struct stat st;
strcpy(tmp, tmp_template);
- // mktemp() nags about safety and using better alternatives
int fd = mkstemp(tmp);
assert_int_not_equal(-1, fd);
close(fd);
static environment_t *device_env = NULL;
// NOLINTBEGIN(misc-use-internal-linkage)
+void __wrap_environment_init(environment_t *env);
+void __wrap_environment_exit(environment_t *env);
+bool __wrap_execute_script(const char *name, environment_t *env);
+
void __wrap_environment_init(environment_t *env) {
assert_non_null(env);
assert_null(device_env);