jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
7.83k stars 187 forks source link

devbox shell cannot find the userid and groups and group names on a Linux VDI that uses LDAP for IAM #2129

Open peterzandbergen opened 3 weeks ago

peterzandbergen commented 3 weeks ago

What happened?

When I run devbox shell in an initialized directory, the output shows a list of groups for which it cannot find the names of the group. The shell starts successfully.

I looked at the code and it seems to me that the error is somewhere in config.go.

I can sort of simulate the same error with the program that I included.

NOTE: I will add the required info later.

Steps to reproduce

You need a Linux machine, mine is Ubuntu, that uses LDAP for authentication and authorization, and be logged in as a user from the LDAP. This results in not having the user in the /etc/passwd file and not having the group memberships in /etc/groups

  1. devbox-group-bug.tar.gz output.zip

Command

No response

devbox.json

# only ran devbox init

Devbox version

0.11.0

Nix version

2.22.1

What system does this bug occur on?

Linux (x86-64)

Debug logs

No response

gcurtis commented 3 weeks ago

@peterzandbergen thanks for adding this to an issue. As you mentioned in Discord, this is most likely due to Devbox being compiled with cgo disabled. From the os/user docs:

For most Unix systems, this package has two internal implementations of resolving user and group ids to names, and listing supplementary group IDs. One is written in pure Go and parses /etc/passwd and /etc/group. The other is cgo-based and relies on the standard C library (libc) routines such as getpwuid_r, getgrnam_r, and getgrouplist.

When cgo is available, and the required routines are implemented in libc for a particular platform, cgo-based (libc-backed) code is used. This can be overridden by using osusergo build tag, which enforces the pure Go implementation.

I'd rather not enable cgo, so we should track down why we need the current user and see if there's a way to degrade gracefully.

gcurtis commented 3 weeks ago

I double checked, and I can't find anywhere that devbox or its dependencies prints this error. All of our calls to the os/user package have annotated errors. I also don't see "cannot find name for group ID" in the Go stdlib source.

This might be from some other program that's running as part of an init hook, plugin, or shell rcfile.

@peterzandbergen I saw your comment about adding more info. I'll wait until we have the devbox.json and DEVBOX_DEBUG=1 logs before digging further.

peterzandbergen commented 3 weeks ago

Here are devbox.json and the output of devbox shell with DEVBOX_DEBUG=1

report.tar.gz

peterzandbergen commented 3 weeks ago

Taken from the terminal

devbox.debug.terminal.log

peterzandbergen commented 3 weeks ago

Looking at the last log I thought that this file might be useful. It is the file that is mentioned at line 36 in the previous log file I sent.

bashrc.zip

peterzandbergen commented 3 weeks ago

I ran the bash with -x and the rc file and this is the begin of the output where the error messages are written

bash-x.log.tar.gz

peterzandbergen commented 3 weeks ago

It looks like groups is the culprit

See the difference between the nix and non nix version.

groups-innix.log groups.log