absolute path of executable in multipartition Linux

121 Views Asked by At

I am using LSM hook to intercept exec system call to print the path of the executable being executed. On Debian with default partitioning options, the path of the executable is absolute path. But on Debian with multiple partions having separate mount points for tmp, home var etc, the first parent directory is truncated. For example a file in /tmp/abc.sh is appearing as abc.sh. Same is the case with other mount points. In this scenario, how can I get the absolute path?

1

There are 1 best solutions below

0
On

First, You cannot get absolute path in any LSM hook. Only necessary data (eg: structures, pointers, flags etc) are passed. Furthermore, everything sent is const, so you don't corrupt anything accidentally. Secondly, mapping of partition base paths vary with partitioning schemes. Last, It's absolutely not a good way to execute things from /tmp directory. Try to place your binaries in appropriate locations.