infinet / xt_wgobfs

Iptables WireGuard obfuscation extension
GNU General Public License v2.0
223 stars 24 forks source link

Make failed - ./tools/objtool/objtool: not found #5

Closed Soberia closed 1 year ago

Soberia commented 1 year ago

I have struggled with make a Docker container. I've mounted /lib/modules:/lib/modules and /usr/src:/usr/src for accessing the host kernel when running the container, but compile process failed with objtool: not found which is actually exist on said directory on the Docker host.

Dockerfile ```dockerfile FROM alpine:latest RUN apk update && \ apk add curl unzip iptables-dev alpine-sdk linux-lts-dev autoconf automake libtool; \ # mkdir /tmp && cd /tmp; \ curl -sSL -o archive.zip https://github.com/infinet/xt_wgobfs/archive/refs/heads/main.zip; \ unzip archive.zip; \ cd xt_wgobfs-main; \ # ./autogen.sh; \ ./configure; WORKDIR /tmp/xt_wgobfs-main CMD make ```
make -C /lib/modules/5.19.0-26-generic/build M=/tmp/xt_wgobfs-main/src modules
make[1]: Entering directory '/usr/src/linux-headers-5.19.0-26-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.2.0-3ubuntu1) 12.2.0
  You are using:           gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924
  CC [M]  /tmp/xt_wgobfs-main/src/xt_WGOBFS_main.o
/bin/sh: ./tools/objtool/objtool: not found
make[2]: *** [scripts/Makefile.build:257: /tmp/xt_wgobfs-main/src/xt_WGOBFS_main.o] Error 127
make[2]: *** Deleting file '/tmp/xt_wgobfs-main/src/xt_WGOBFS_main.o'
make[1]: *** [Makefile:1851: /tmp/xt_wgobfs-main/src] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.19.0-26-generic'
make: *** [Makefile:736: modules] Error 2
infinet commented 1 year ago

Are you trying to build this module for host OS? That dockerfile uses alpine, while the host OS looks like ubuntu.

Soberia commented 1 year ago

No, I want to run it inside the container. I used Alpine because I faced this error when executing ./configure on Ubuntu/Debian base image:

checking for linux/netfilter/x_tables.h... yes
./configure: line 12787: syntax error near unexpected token `libxtables,'
./configure: line 12787: `PKG_CHECK_MODULES(libxtables, xtables >= 1.4.21)'

I've installed libxtables-dev because there is no iptables-dev in package repository.

infinet commented 1 year ago

I am not sure you can do that. Docker on linux still uses host kernel. It may be possible to build with Ubuntu/Debian base image, but I haven't tried. Can you use a Debian 10 base image? That is the version I tested.

Soberia commented 1 year ago

iptables-dev was present in Debian 10 (unlike Debian bullseye) and installed successfully. But still got same error as before when ruuning ./configure. I also tried to compile the source on the host and move the binaries to the container but still get this syntax error ... libxtables.

Host is Ubuntu 22.10 with 5.19.0-26 kernel

infinet commented 1 year ago

Have installed pkg-config?

Soberia commented 1 year ago

No, but installing that package also didn't help me.

Full log ``` root@xxx:/tmp/xt_wgobfs-main# ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a race-free mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... no checking whether make supports nested variables... no checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether gcc accepts -g... yes checking for gcc option to enable C11 features... none needed checking whether gcc understands -c and -o together... yes checking whether make supports the include directive... no checking dependency style of gcc... none checking for ar... ar checking the archiver (ar) interface... ar checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking how to print strings... printf checking for a sed that does not truncate output... /usr/bin/sed checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for fgrep... /usr/bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for file... file checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for a working dd... /usr/bin/dd checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1 checking for mt... mt checking if mt is a manifest tool... no checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking for linux/netfilter/x_tables.h... yes ./configure: line 12787: syntax error near unexpected token `libxtables,' ./configure: line 12787: `PKG_CHECK_MODULES(libxtables, xtables >= 1.4.21)' ```

These are the two lines that cause the error in generated configure file at line 12787 and 12788:

PKG_CHECK_MODULES(libxtables, xtables >= 1.4.21)
xtlibdir="$($PKG_CONFIG --variable=xtlibdir xtables)"
infinet commented 1 year ago

I tested under ubuntu 22.10. Apparently /usr/bin is not in root's PATH therefore configure cannot find pkg-config.

Soberia commented 1 year ago

Thanks for your help.

It was due to absence of pkg-config package. ./autogen.sh must run again after installing the package. build-essential, autoconf, libtool, pkg-config and libxtables-dev are packages needed for Ubuntu.

After completing the installation of the module for server (Ubuntu) and client (OpenWRT), I started WireGuard instances and noticed packets won't reach the server at all or reached with high delay (more than 30 second). For that reason, the handshake process will never finish.

I tried resending the captured packets manually with netcat and result was the same. I think it's result of nationwide blocking of UDP packets in Iran and nothing can be done about it.

Thanks again, I close this issue now.