I'm trying to use an exec
system call to start another executable, but that executable is using readlink()
on /proc/self/exe
to determine its file location. I would like it to think that it has the same location as the parent executable, but it instead determines its actual location. I think that I could potentially accomplish something like this by using LD_PRELOAD
to intercept the readlink()
call, but is there any easier or more direct way to accomplish this? I'm looking only for solutions that can be implemented in the parent executable, modifying the child is not an option.
Create a hard link to the executable:
$sudo ln /bin/ls ./ls
[sudo] password for plasser:
# check it:
$ls -l ls
-rwxr-xr-x 2 root root 110080 mrt 10 2016 ls
#call it:
$./ls -l /proc/self/exe
lrwxrwxrwx 1 plasser uri 0 mrt 3 18:36 /proc/self/exe -> /home/plasser/krant/ls
$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.