Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
927 stars 209 forks source link

linux-setup uses deprecated arguments to install_api #4287

Closed sherman5-str closed 1 year ago

sherman5-str commented 1 year ago

Version and Platform (required):

Bug Description: Our headless installation scripts for Binary Ninja have started failing (not sure when this issue began). The root cause I believe is at line 244 in linux-setup.sh. Seems like the fix is changing this line since install_api.py doesn't take any positional arguments.

(old) python3 -V >/dev/null 2>&1 && ${SUDO}python3 "${BNPATH}/scripts/install_api.py" ${ROOT} ${SILENT} (new) python3 -V >/dev/null 2>&1 && ${SUDO}python3 "${BNPATH}/scripts/install_api.py" ${SILENT}

Steps To Reproduce:

$ export BINJA_DL_SCRIPT="https://raw.githubusercontent.com/Vector35/binaryninja-api/master/scripts/download_headless.py"
$ export BINJA_SERIAL=`echo "import json; print(json.load(open('${HOME}/.binaryninja/license.dat'))[0]['serial'])" | python3`
$ curl -sSL ${BINJA_DL_SCRIPT} | python3 - --serial ${BINJA_SERIAL} -ic -d .
$ cd binaryninja/scripts/
$ ./linux-setup.sh -s
Configuring python path
usage: install_api.py [-h] [-s] [-u] [--install-on-root] [--install-on-pyenv]
install_api.py: error: unrecognized arguments: user

Expected Behavior: Expected headless installation to succeed

Screenshots:

Additional Information:

psifertex commented 1 year ago

./linux-setup.sh actually isn't intended for headless at all.

I would recommend instead running install_api.py directly as that's the only thing that you want from linux-setup anyway. The only things that linux-setup does that isn't install_api is intended for desktop usage anyway. We should probably document this in some new documentation on headless.

That said, the script is likely broken for regular uses too so I'm adjusting the issue appropriately.

psifertex commented 1 year ago

The fix here is really to just remove the root mode of linux-setup anyway. The UI isn't intended to ever be run as root and while the API install script can be run to install globally as root via sudo, that option still exists but I don't think plumbing it through to linux-setup makes sense as the shell script is really for users in the UI.

Next dev build will have an updated linux-setup that should work though again, for the above specific issue I'd recommend just using install_api.py directly.