dyne / tomb

the Crypto Undertaker
https://dyne.org/software/tomb
GNU General Public License v3.0
1.32k stars 151 forks source link

list_processes: use lsof to list processes #504

Closed Narrat closed 7 months ago

Narrat commented 7 months ago

Parsing the output from lsof had possibilities for race conditions. Either due to short lived processes or issuing "tomb ps" from a terminal which cwd is from inside the tomb. This would for example list available users on the system. To avoid this use the lsof output directly.

In the future formatting could be reintroduced via commands like "lsof +D "$tombmount" -F Lc" or "lsof +D "$tombmount" -F Lc0".

This fixes #503


The lazy solution for #503. For me the output is enough :D

Example:

$  ./tomb ps
tomb (*) Listing processes running inside all open tombs...
COMMAND  PID   USER  FD   TYPE DEVICE SIZE/OFF NODE NAME
zsh     1221 omnius cwd    DIR  254,0    12288    2 /run/media/omnius/Z

This doesn't touch slam_tomb() which in general uses the same logic and should probably be updated.

jaromil commented 7 months ago

Nice approach, less code and parsing done