conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
958 stars 1.76k forks source link

[package] jemalloc/5.2.1: failed to build from source if docker configured with user namespaces #20858

Open PodnimatelPingvinov opened 1 year ago

PodnimatelPingvinov commented 1 year ago

Description

Package fails to build if conan install is running inside docker with enabled remapping.

The problem seems to be with AutoToolsBuildEnvironment in conan itself. There are wrong permissions on generated configure script, executable bit isn't set for some reason. Although if you disable remapping everything works fine.

Because this helper is deprecated, I think it's better to rewrite package recipe using different autotools helper. Looks like it will solve the problem because I was able to build libev/4.33 (which is also using autotools) in the same environment.

Package and Environment Details

Conan profile

[settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=gcc compiler.libcxx=libstdc++ compiler.version=11 os=Linux os_build=Linux [options] [build_requires] [env]

Steps to reproduce

Enable remapping

echo "$(id -un):$(id -u):65536" | sudo sed -n "w /etc/subuid"
echo "$(id -gn):$(id -g):65536" | sudo sed -n "w /etc/subgid"
echo "{ \"userns-remap\": \"$(id -un):$(id -gn)\" }" | sudo sed -n "w /etc/docker/daemon.json"
sudo systemctl restart docker

Enter into image:

docker run -it --rm gcc:11.4.0-bullseye

Try to build package inside container:

apt update
apt install python3-pip
pip install conan==1.61.0
printf "[requires]\njemalloc/5.3.0\n" >conanfile.txt
conan install --build -- .

Logs

Click to expand log ``` jemalloc/5.3.0: Configuring sources in /root/.conan/data/jemalloc/5.3.0/_/_/source/src Downloading jemalloc-5.3.0.tar.bz2 completed [718.77k] jemalloc/5.3.0: 3.0: jemalloc/5.3.0: jemalloc/5.3.0: Copying sources to build folder jemalloc/5.3.0: Building your package in /root/.conan/data/jemalloc/5.3.0/_/_/build/c02edc20d60fabc691722829afe8093f125660f9 jemalloc/5.3.0: Generator txt created conanbuildinfo.txt jemalloc/5.3.0: Aggregating env generators jemalloc/5.3.0: Calling build() jemalloc/5.3.0: apply_conandata_patches(): No patches defined in conandata jemalloc/5.3.0: WARN: **** The 'AutoToolsBuildEnvironment' helper is deprecated. Please update your code and remove it. **** jemalloc/5.3.0: WARN: Error running `configure --help`: Error 126 while executing /root/.conan/data/jemalloc/5.3.0/_/_/build/c02edc20d60fabc691722829afe8093f125660f9/src/configure --help jemalloc/5.3.0: Calling: > /root/.conan/data/jemalloc/5.3.0/_/_/build/c02edc20d60fabc691722829afe8093f125660f9/src/configure '--with-jemalloc-prefix=' '--disable-debug' '--enable-cxx' '--enable-fill' '--enable-xmalloc' '--disable-readlinkat' '--enable-syscall' '--disable-lazy-lock' '--disable-log' '--enable-initial-exec-tls' '--enable-libdl' '--disable-shared' '--enable-static' '--prefix=/root/.conan/data/jemalloc/5.3.0/_/_/package/c02edc20d60fabc691722829afe8093f125660f9' /bin/sh: 1: /root/.conan/data/jemalloc/5.3.0/_/_/build/c02edc20d60fabc691722829afe8093f125660f9/src/configure: Permission denied jemalloc/5.3.0: jemalloc/5.3.0: ERROR: Package 'c02edc20d60fabc691722829afe8093f125660f9' build failed jemalloc/5.3.0: WARN: Build folder /root/.conan/data/jemalloc/5.3.0/_/_/build/c02edc20d60fabc691722829afe8093f125660f9/build-release ERROR: jemalloc/5.3.0: Error in build() method, line 170 autotools = self._configure_autotools() while calling '_configure_autotools', line 130 self._autotools.configure(args=self._autotools_args, configure_dir=self.source_folder) ConanException: Error 126 while executing /root/.conan/data/jemalloc/5.3.0/_/_/build/c02edc20d60fabc691722829afe8093f125660f9/src/configure '--with-jemalloc-prefix=' '--disable-debug' '--enable-cxx' '--enable-fill' '--enable-xmalloc' '--disable-readlinkat' '--enable-syscall' '--disable-lazy-lock' '--disable-log' '--enable-initial-exec-tls' '--enable-libdl' '--disable-shared' '--enable-static' '--prefix=/root/.conan/data/jemalloc/5.3.0/_/_/package/c02edc20d60fabc691722829afe8093f125660f9' ```
uilianries commented 1 year ago

That's weird for sure and probably is only related to jemalloc project.

All packages generated by Linux in ConanCenterIndex, they used Docker images available in https://github.com/conan-io/conan-docker-tools/. It's used a non-root user named as conan to build anything, exactly to avoid security flaws, but also permission errors.