radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.39k stars 2.98k forks source link

Support runtime configurable paths #21484

Open prodrigestivill opened 1 year ago

prodrigestivill commented 1 year ago

Description

In the radare2 snap version the installation paths changes on every build install because it is using the classic confinement and the actual installed path changes on runtime.

Currently the following environment variables are set to address this issue:

environment:
  R2_LIBR_PLUGINS: "$SNAP/usr/lib/radare2/$SNAP_VERSION"
  R2_MAGICPATH: "$SNAP/usr/share/radare2/$SNAP_VERSION/magic"
  SLEIGHHOME: "$SNAP/usr/lib/radare2/$SNAP_VERSION"

With this configuration plugins, sleigh and magic files are loaded correctly.

First issue: radare2 -H

The first issue would be that the paths changed on runtime currently are not reported back when running radare2 -H command, not sure the importance/effects of this.

Second issue: the rest of share files

The second issue are that radare2 in snap don't load any other file from /usr/share/radare2/VERSION/*, example of files not loaded are: charsets, cons, fcnsign, flag, format, hid, opcodes, syscall, www, ...

Inspired on what is observed the radare2 -H output a possible solution could be to implemented the use of R2_PREFIX env var for those paths, also allowing to remove the now unneeded R2_MAGICPATH from the snap environment.

Alternatively adding variables for each non working paths, like the one currently working for R2_MAGICPATH could also be a possible solution.

Whatever fits best for the project rest of environments where it is executed.

trufae commented 1 year ago

that may help towards this :) https://github.com/radareorg/radare2/pull/21486

prodrigestivill commented 1 year ago

I think it works, just as a comment, the variables R2_INCDIR and R2_LIBDIR are still reported wrong in the radare2 -H. But I don't think it will affect anything for now...

trufae commented 1 year ago

Yep. im aware, incdir/libdir are not tied to prefix, its a similar issue to the problem i faced when generating the pkg config files. But those vars are not used anywhere outside r2pm. So i think that for runtime we are good to go. i'll look into testing r2pm with the snap package installed (without any local installation) and come back to you. But i think we are good to update the snap package now!

Thanks!

prodrigestivill commented 2 weeks ago

As a note, this will affect the new iaito-snap implementation (linked issue above).

Current iaito snap implementation defines correctly R2_PREFIX environment varible, but this doesn't fix R2_INCDIR, R2_LIBDIR and R2_BINDIR.

So my understanding is that as of now, if somebody tries to use iaito.r2pm when only having iaito snap installed, it will try to access to the paths from radare2 snap.