Python compile problem on Linux as Samba user

Last week I had a head banging problem that had me pulling my hair. Although I do not do it often, I needed to install a specific version of Python on my laptop. Usually I use asdf or py-env to accomplish this. Both utilities are package managers to install a specific version of a package for local use. They do that by compiling the Python version locally and install it in a directory in your home directory to avoid the versions installed system-wide. This makes switching between Python versions for different projects easier.
So I just typed in the following command:

 $ asdf install 3.13.2
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 0), reused 1 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (8/8), 26.01 KiB | 2.00 MiB/s, done.
From https://github.com/pyenv/pyenv
   bf193666..e13b5848  master     -> origin/master
python-build 3.13.2 /home/PALANTHIR/arjan/.asdf/installs/python/3.13.2
Downloading Python-3.13.2.tar.xz...
-> https://www.python.org/ftp/python/3.13.2/Python-3.13.2.tar.xz
Installing Python-3.13.2...

BUILD FAILED (openSUSE 20250611 using python-build 2.6.2-2-ge13b5848)

Inspect or clean up the working tree at /tmp/python-build.20250616083639.305007
Results logged to /tmp/python-build.20250616083639.305007.log

Last 10 log lines:
./configure: line 5294: 5: Bad file descriptor
./configure: line 5294: 5: Bad file descriptor
./configure: line 5294: 5: Bad file descriptor
./configure: line 5294: 5: Bad file descriptor
checking whether the C compiler works... ./configure: line 5341: 5: Bad file descriptor
no
./configure: line 5386: 5: Bad file descriptor
configure: error: in `/tmp/python-build.20250616083639.305007/Python-3.13.2':
configure: error: C compiler cannot create executables
See `config.log' for more details
error installing version: failed to run install callback: exit status 1

You can see the command downloads the specific Python version, tries to compile it, and fails. Usually when a compile fails on Linux there is something wrong with your local environment, so I spent hours checking what was wrong with my local environment until I noticed that the command just worked perfectly when run as a local user on my laptop.
Upon investigating what exactly went wrong I started to notice the command had issues during the configure process:

configure:5317: checking whether the C compiler works
configure:5339: gcc  -I/home/PALANTHIR/arjan/.asdf/installs/python/3.13.2/include -L/home/PALANTHIR/arjan/.asdf/installs/python/3.13.2/lib -Wl,-rpath,/home/PALANTHIR/arjan/.asdf/installs/python/3.13.2/lib conftest.c -L/home/PALANTHIR/arjan/.asdf/installs/python/3.13.2/lib -Wl,-rpath,/home/PALANTHIR/arjan/.asdf/installs/python/3.13.2/lib >&5
configure:5343: $? = 1
configure:5383: result: no
configure: failed program was:
configure:5388: error: in `/tmp/python-build.20250616083639.305007/Python-3.13.2':
configure:5390: error: C compiler cannot create executables
See `config.log' for more details

the line 5294 as mentioned above in the error description on the configure script does this:

cat conftest.er1 >&5

Since the error "Bad file descriptor" usually means a file does not exist, it HAD to be the part of the command ">&5" which basically means sending the output to a specific file stream used by configure. This has nothing to do with a local environment. So I started searching on the internet if someone already had this problem. After hours of searching I finally found a hint: the problem arises when the user is a Samba user and indeed my Linux installs are joined in an ActiveDirectory domain using winbind, which is part of the Samba package.
And then I found a bug in Samba version 4.18. But I am using Samba 4.22 so the bug apparently is back.

I tried to test it. I changed one line in the /etc/nsswitch.conf file from:

passwd:     compat systemd winbind

to

passwd:     compat systemd

and then tried again, and it worked!

By this time it was 3 AM in the night. Since I do not have an account on the Samba Bugzilla site I could not leave a comment on this bug to re-open it. I have sent the Samba team an email to notify them of my find. I will update this page if I hear back from them.

For me, this is really an edge case of what can happen with software. Because it was so late in the night I did not bother to investigate what is causing this bug. It could however do it if I had the time. This is what I like about open source software.

Update 2025-06-16 14:04

The Samba team decided to give me a user account on their Bugzilla, so I updated the bug report there also samba-4.18.0 and above causes pyenv to fail with Bad file descriptor

Links