Skip to content

stdbuf cannot use libstdbuf on the same directory if /proc is masked #11134

Open

Description

@oech3
$ run0 mv /usr/lib/uutils-coreutils/libstdbuf.so -t /tmp
$ cp /usr/bin/stdbuf -t /tmp
$ unshare -rm bash -c "mount -t tmpfs tmpfs /proc && /tmp/stdbuf -oL true"
stdbuf: External libstdbuf not found at configured path: /usr/lib/uutils-coreutils/libstdbuf.so

$ unshare -rm bash -c "mount -t tmpfs tmpfs /proc && /tmp/gnu-stdbuf -oL true"
# success

I believe it is because std::env::current_exe() requires /proc/self/exe:

if let Ok(exe_path) = std::env::current_exe() {

Activity

  1. oech3 commented on Feb 26, 2026

    @oech3
    ContributorAuthor
  2. oech3 commented on Feb 27, 2026

    @oech3
    ContributorAuthor

    It seems GNU use argv[0]. But if we need to care about secutiry, we could use AT_EXECFN at least on Linux. I don't know what can we use for other platforms.

  3. Ecordonnier commented on Feb 27, 2026

    @Ecordonnier
    Collaborator

    This is not security critical as far as I know, since stdbuf is not seteuid. I think the path discovery should be implemented the same way than in GNU coreutils.

  4. Ecordonnier commented on Feb 27, 2026

    @Ecordonnier
    Collaborator

    What happens if those test steps are executed with GNU coreutils?

  5. oech3 commented on Feb 27, 2026

    @oech3
    ContributorAuthor

    GNU tries to search libstdbuf based on argv[0] i.e. stdbuf success if libstdbuf.so is present at same dir with argv[0].

  6. oech3 commented on Mar 10, 2026

    @oech3
    ContributorAuthor

    GNU found libstdbuf from PATH:

    $ env PATH=/home/a/bin/gnu9.10 stdbuf -oL true # ok
    $ mv '/home/a/bin/gnu9.10/libstdbuf.so' '/home/a/bin/gnu9.10/libstdbuf.so-'
    $ env PATH=/home/a/bin/gnu9.10 stdbuf -oL true
    stdbuf: failed to find `libstdbuf.so'
    
  7. oech3 commented on Apr 1, 2026

    @oech3
    ContributorAuthor

    Since std rejected improving current_exe, I'll wait #10773 's uucore function.

  8. oech3 commented on Apr 20, 2026

    @oech3
    ContributorAuthor

    I still have no idea how to do #11134 (comment) on non-Llinux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions