diff --git a/iputils/.gitignore b/iputils/.gitignore new file mode 100644 index 0000000..50151ad --- /dev/null +++ b/iputils/.gitignore @@ -0,0 +1,2 @@ +/iputils-* +/*.tar.gz diff --git a/iputils/README.md b/iputils/README.md new file mode 100644 index 0000000..451689b --- /dev/null +++ b/iputils/README.md @@ -0,0 +1,65 @@ +# iputils + +Build the [iputils](https://github.com/iputils/iputils/) set of tools as static PIE ELF binaries running on Linux. + +## Requirements + +Make sure the following packages are installed: +* gcc >= 8 (required for the `-static-pie` linking option) +* autotools +* meson +* GNU Make + +For Debian, run the command below to install all requirements: + +```bash +$ sudo apt install build-essential +export DEBIAN_FRONTEND="noninteractive" + +apt update + +apt install -y --no-install-recommends \ + clang \ + docbook-xsl-ns \ + file \ + gcc \ + gettext \ + iproute2 \ + libcap-dev \ + libidn2-0-dev \ + libssl-dev \ + make \ + meson \ + pkg-config \ + xsltproc + +``` + +## Building + +The static PIE ELF file are located in the current directory. +If you want to rebuild them, run: + +```bash +$ ./build.sh +``` + +This script downloads, unpacks, patches, configures and builds the tools. + +## Running + +The resulting binaries can be used as is. +For example, you can ping an address by issuing the command: + +```bash +$ ./ping 1.1.1.1 +``` + +## Issues + +1. When running in KVM with LWIP you can't use RAW sockets because they're not + available by default. See this for more information: + https://github.com/unikraft/lib-lwip/pull/2 + +2. There is a bug in LWIP where normal sockets (not RAW) that use ICMP protocol + are sent using UDP protocol instead. See https://github.com/unikraft/lib-lwip/issues/32 diff --git a/iputils/arping b/iputils/arping new file mode 100755 index 0000000..7e4acb9 Binary files /dev/null and b/iputils/arping differ diff --git a/iputils/build.sh b/iputils/build.sh new file mode 100755 index 0000000..b20fc36 --- /dev/null +++ b/iputils/build.sh @@ -0,0 +1,33 @@ +#!/bin/bash + + +BUILD_VERSION=20221126 +# Clean up. +rm -fr iputils-* +rm -fr *.tar.gz + +echo -n "Downloading iputils ... " +wget -O "${BUILD_VERSION}.tar.gz" -q https://github.com/iputils/iputils/archive/refs/tags/${BUILD_VERSION}.tar.gz +echo "" + +echo -n "Unpacking iputils ... " +tar xzf "${BUILD_VERSION}.tar.gz" +echo "" + +SOURCE_DIR="iputils-${BUILD_VERSION}" +pushd "${SOURCE_DIR}" > /dev/null 2>&1 + +echo "Patching iputils files ... " +patch < ../iputils.patch +echo "" + +echo "Building ... " +./configure --prefix=. +make + +popd > /dev/null 2>&1 + +ln -fn "${SOURCE_DIR}/builddir/ping/ping" . +ln -fn "${SOURCE_DIR}/builddir/arping" . +ln -fn "${SOURCE_DIR}/builddir/tracepath" . +ln -fn "${SOURCE_DIR}/builddir/clockdiff" . diff --git a/iputils/clockdiff b/iputils/clockdiff new file mode 100755 index 0000000..91f36cb Binary files /dev/null and b/iputils/clockdiff differ diff --git a/iputils/iputils.patch b/iputils/iputils.patch new file mode 100644 index 0000000..cef1646 --- /dev/null +++ b/iputils/iputils.patch @@ -0,0 +1,59 @@ +--- configure 2022-11-26 01:07:21.000000000 +0200 ++++ configure 2023-03-31 12:40:52.167300078 +0300 +@@ -1,14 +1,16 @@ + #!/bin/sh + + DIR=builddir + ++export LDFLAGS="-static-pie" ++ + echo "Using './$DIR' as the directory for build output" + echo + + if [ $# -ne 0 ]; then + meson configure $DIR + echo + echo 'Configuration can be changed like this:' + echo " meson configure $DIR -Dprefix=/usr" + echo ' More info: http://mesonbuild.com/Configuring-a-build-directory.html' + # See also: http://mesonbuild.com/howtox.html +--- meson.build 2022-11-26 01:07:21.000000000 +0200 ++++ meson.build 2023-03-31 12:41:28.679222461 +0300 +@@ -1,32 +1,37 @@ + # Copyright (c) Iputils Project, 2017-2021 + + project('iputils', 'c', + default_options : [ + 'c_std=c99', + 'warning_level=3', + 'localstatedir=var', ++ 'USE_IDN=false', + ], + meson_version : '>=0.40', + version : '20221126') # keep in sync with: git describe | awk -F- '{print $1}' + + cc = meson.get_compiler('c') + + add_project_arguments( ++ '-fPIC', + '-include', 'config.h', + '-include', 'git-version.h', + language : 'c' + ) + + conf = configuration_data() + conf.set_quoted('PACKAGE_NAME', meson.project_name()) + ++conf.set('prefer_static', true) ++conf.set('default_library', 'static') ++ + build_arping = get_option('BUILD_ARPING') + build_clockdiff = get_option('BUILD_CLOCKDIFF') + build_ping = get_option('BUILD_PING') + build_tracepath = get_option('BUILD_TRACEPATH') + + build_mans = get_option('BUILD_MANS') + build_html_mans = get_option('BUILD_HTML_MANS') + run_tests = not get_option('SKIP_TESTS') + + prefix = get_option('prefix') diff --git a/iputils/ping b/iputils/ping new file mode 100755 index 0000000..6a84167 Binary files /dev/null and b/iputils/ping differ diff --git a/iputils/tracepath b/iputils/tracepath new file mode 100755 index 0000000..d96e6cc Binary files /dev/null and b/iputils/tracepath differ