AppImage / AppImage/appimage.github.io

Do not use /proc/self/exe to allow running in chroot without /proc

Open
#1,004 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
374
Forks
769
Avg merge
4d 10h
Merged PRs (30d)
8

Description

Running in a chroot, `/proc` may not be mounted:

```
Cannot open /proc/self/exe: No such file or directory
execv error: No such file or directory
```

> An alternative on Linux to using either `/proc/self/exe` or `argv[0]` is using the information passed by the ELF interpreter, made available by glibc as such:
>
```
#include
#include

int main(int argc, char **argv)
{
printf("%s\n", (char *)getauxval(AT_EXECFN));
return(0);
}
```
>
>Note that getauxval is a glibc extension, and to be robust you should check so that it doesn't return NULL (indicating that the ELF interpreter hasn't provided the `AT_EXECFN` parameter), but I don't think this is ever actually a problem on Linux.

Source: https://code.i-harness.com/en/q/f9d4a

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.