AppImage / appimage.github.io

Given an URL to an AppImage, the GitHub action in this project inspects the AppImage and puts it into a community-maintained catalog
https://appimage.github.io/
Other
306 stars 550 forks source link

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

Open probonopd opened 5 years ago

probonopd commented 5 years ago

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 <stdio.h>
#include <sys/auxv.h>

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
probonopd commented 4 years ago

This returns a relative path, we need the absolute one. Can we combine it with readlink to get an absolute one?

CherryDT commented 3 years ago

Just ran into this one on a shared hosting. Would be great if it could work...