nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

Missing `libnss_sss.so.2` where needed.

Open joergdw opened this issue 3 years ago • 8 comments

Describe the bug

libnss_sss.so.2 not contained in nix-environment for packages that need them. Among them:

Environment

The following environment probably does not matter (apart from not using NixOS) but I include it for completeness:

  • OS: Ubuntu 20.04
  • Nix: 2.13.2 (single-user-installation)
  • direnv: 2.32.1 (used to load shells defined in nix-flakes)

What may matter however: I use a company-linux making use of https://ubuntu.com/server/docs/service-sssd-ad to manage users.

Steps To Reproduce

Steps to reproduce the behavior with whoami:

  1. Open a terminal where whoami is provided by Nix.
  2. Execute whoami.

Addition: I found the reason using strace whoami:

[…]
openat(AT_FDCWD, "/nix/store/1nyg1fvhpz8bx3vn3r9f18zhra2rpbx9-glibc-2.37-8/lib/libnss_sss.so.2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (file or directory not found)
[…]

Expected behavior

I expect to see my username.

Actual behaviour

% whoami
whoami: cannot find name for user ID <my-user-id>

Additional context

There is a related issue which helped me to find the quick-fix: #31700

Quick fix

Using the library from my host-system: LD_PRELOAD='/lib/x86_64-linux-gnu/libnss_sss.so.2' whoami works!

The package that provides libnss_sss.so.2 under the mentioned path is libnss-sss.

Notify maintainers

For gnu-coreutils (whoami): @dasJ For bosh-cli: @risicle

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
these 2 paths will be fetched (1.10 MiB download, 6.93 MiB unpacked):
  /nix/store/f01r6lmbi7mg0xg80mvzdwqhlmrzvy4v-bash-interactive-5.2-p15
  /nix/store/skjaxjyjqf933mw7pcnhxzms9hk593q9-nix-info
copying path '/nix/store/f01r6lmbi7mg0xg80mvzdwqhlmrzvy4v-bash-interactive-5.2-p15' from 'https://cache.nixos.org'...
copying path '/nix/store/skjaxjyjqf933mw7pcnhxzms9hk593q9-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.0-69-generic, Ubuntu, 20.04.6 LTS (Focal Fossa), nobuild`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.3`
 - channels(i539286): `"nixpkgs"`
 - nixpkgs: `/sapmnt/home/<redacted>/.nix-defexpr/channels/nixpkgs`

joergdw avatar May 05 '23 12:05 joergdw

maybe similar to https://github.com/NixOS/nixpkgs/issues/12335 (read through it and the linked issues) solution should be to install nscd

Artturin avatar May 05 '23 16:05 Artturin

@Artturin Thank you for looking into the issue. However closing this ticket was too fast: nscd has been already available:

% whoami
whoami: cannot find name for user ID <my-user-id>
1 % which nscd
/nix/store/qvaj0419bgnldvnqy4dylfrq34khhfxr-glibc-2.37-8-bin/bin/nscd

Please re-open the ticket.

joergdw avatar May 08 '23 14:05 joergdw

Looks like this ticket may be related to #1868. (However as they try to fix builds there, the wrapper-solution does not look applicable to me for this problem.)

joergdw avatar May 08 '23 14:05 joergdw

Relevant: https://github.com/NixOS/nixpkgs/pull/111194

bjornfor avatar May 21 '23 18:05 bjornfor

Hi. I am using AlmaLinux9.2 with nix single-user installation. The system is connected to active directory via LDAP using sssd configuration. The problem is that glibc is not able to find libnss_sss.so, so it is not able to resolve users correctly. This affects a big number of any utilities that try to do it, starting from id, ps, through htop, glances, and finally: ssh is unusable and just exits with No user exists for uid 11021.

$ id -nu
id: cannot find name for user ID 11021
11021

Pre-loading host libnss_sss.so works:

$ LD_PRELOAD=/usr/lib64/libnss_sss.so.2 id -nu
kcukrowski

Pre-loading nix libnsss_sss.so works:

$ LD_PRELOAD=~/.nix-profile/lib/libnss_sss.so.2 id -nu
kcukrowski

Just adding the path to libnsss_sss for the linker to find it works:

$ LD_LIBRARY_PATH=~/.nix-profile/lib id -nu
kcukrowski

It would be great if utilities that depend on glibc would be able to find the library. How to solve such problem? Thanks.

Kamilcuk avatar Feb 16 '24 11:02 Kamilcuk

I added sssd to my shell.nix and set LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${pkgs.sssd}/lib which solved the problem on my system: Ubuntu 22.04, authentication via LDAP, nix 24.05.

I do not like this solution because shell.nix should not contain bits that are related to a specific host, but that is better than nothing.

frafra avatar Nov 28 '24 17:11 frafra

FYI. In flake's devShells you can fix this via this shellHook:

shellHook = ''
  export LD_LIBRARY_PATH=${pkgs.sssd}/lib
'';

https://discourse.nixos.org/t/whoami-cannot-find-name-for-user-id-in-nix-develop/64460/3

nikableh avatar May 19 '25 16:05 nikableh

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/whoami-cannot-find-name-for-user-id-in-nix-develop/64460/2

nixos-discourse avatar May 21 '25 06:05 nixos-discourse