Some distros like openSUSE & Debian don't build netavark from git,
so the commit information won't be available.
Make this test conditional when NETAVARK_UPSTREAM is set.
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Rust String type has a pretty well documented difference to most string
types in many other languages. A rust string must be valid utf-8.
However linux itself does not care about the char encoding in paths, it
is simply a non zero byte array. This means that technically netavark
will not accept all valid paths. While it unlikely that anyone is using
non utf-8 paths in the real world it is still a non great to deny that.
Rust actually offers the OsString/OsStr types that do not enforce the
utf-8 requirement. And there is also PathBuf/Path types that futher
abstract file paths. So to fix this just use these types instead.
See the added test which checks for it, without this patch we would see
a `error: invalid UTF-8 was detected in one or more arguments` message.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
There is no need to open /dev/stdin, we should just read directly from
fd 0 without having to call open().
Also convert the error inside the function to prevent duplication.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Also, start fixing tests - there are a lot of error string
comparisons that no longer work due to the strings changing.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Add bats tests for netavark. The test run netavark in completely
separate network namespaces to not leak any information on the host. The
test runs with the iptables driver but also with the firewalld driver
see test/020-firewalld.bats. This is important to cover all firewall
driver code paths.
You can run the tests with `sudo bats test/` or `podman unshare
--rootless-netns bats test/`. Note that the `--rootless-netns` flag is
called `--rootless-cni` for podman < v4.0.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>