Fix terminfo (#2532)

* Fix proper check symlink path

* Fix #2531 terminfo issues in portable build

* Remove useless line this should be remove in #2459 PR

* Fix terminfo for portable on darwin

* test ci TERM=xterm-256color

* portable: Disable user site packages `-s` (same as PYTHONNOUSERSITE=1)

* portable: fix bundling on darwin

* portable: Disable user site packages  (same as PYTHONNOUSERSITE=1)

* portable: Disable user site packages
pull/2554/head
patryk4815 1 year ago committed by GitHub
parent 1ab71ff7a0
commit 0caf175699
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -37,7 +37,7 @@ jobs:
run: nix build '.#pwndbg' --accept-flake-config -o result
- name: simple run pwndbg
run: ./result/bin/pwndbg <<< 'exit'
run: TERM=xterm-256color ./result/bin/pwndbg <<< 'exit'
- name: configure cache
if: github.ref == 'refs/heads/dev'
@ -75,7 +75,7 @@ jobs:
run: nix build '.#pwndbg-lldb' --accept-flake-config -o result
- name: simple run pwndbg
run: ./result/bin/pwndbg-lldb <<< 'exit'
run: TERM=xterm-256color ./result/bin/pwndbg-lldb <<< 'exit'
- name: configure cache
if: github.ref == 'refs/heads/dev'

@ -142,8 +142,6 @@ def main(debugger: lldb.SBDebugger, major: int, minor: int, debug: bool = False)
update_deps(src_root, venv_path)
fixup_paths(src_root, venv_path)
os.environ["PWNLIB_NOTERM"] = "1"
import pwndbg # noqa: F811
import pwndbg.dbg.lldb

@ -274,14 +274,14 @@ def copy_with_symlink_normal(src_file_path: Path, root_dir_src: Path, root_dst_d
file_resolved = src_file_path.resolve()
is_allowed_symlink = file_resolved.is_relative_to(root_dir_src)
if is_so and is_allowed_symlink:
# For .so / .dylib files, symlinks are only allowed within the same directory.
if is_so and is_allowed_symlink and sys.platform != 'darwin':
# For .so files, symlinks are only allowed within the same directory.
# This is because $ORIGIN in the runpath cannot resolve symlinks.
# This issue was specifically encountered with the file:
# lib/python3.12/site-packages/lldb/_lldb.cpython-312-aarch64-linux-gnu.so -> ../../../liblldb.so.19.1.1
# To avoid such issues, we check if the resolved file's parent directory
# matches the parent directory of the source file.
if file_resolved.relative_to(root_dir_src).parent != src_file_path.parent:
if file_resolved.parent != src_file_path.parent:
is_allowed_symlink = False
if is_allowed_symlink:

@ -16,32 +16,45 @@ let
echo -n $(basename $(patchelf --print-interpreter "${gdb}/bin/gdb")) > $out
''
);
ldLoader = if pkgs.stdenv.isDarwin then "" else "\"$dir/lib/${ldName}\"";
ldLoader = if pkgs.stdenv.isLinux then "\"$dir/lib/${ldName}\"" else "";
linuxLldbEnvs = pkgs.lib.optionalString (pkgs.stdenv.isLinux && isLLDB) ''
commonEnvs = pkgs.lib.optionalString (pkgs.stdenv.isLinux && isLLDB) ''
export LLDB_DEBUGSERVER_PATH="$dir/bin/lldb-server"
'' + pkgs.lib.optionalString pkgs.stdenv.isLinux ''
export TERMINFO_DIRS=${pkgs.lib.concatStringsSep ":" [
# Fix issue Linux https://github.com/pwndbg/pwndbg/issues/2531
"/etc/terminfo" # Debian, Fedora, Gentoo
"/lib/terminfo" # Debian
"/usr/share/terminfo" # upstream default, probably all FHS-based distros
"/run/current-system/sw/share/terminfo" # NixOS
]}
'' + pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
export TERMINFO_DIRS=${pkgs.lib.concatStringsSep ":" [
# Fix issue Darwin https://github.com/pwndbg/pwndbg/issues/2531
"/usr/share/terminfo" # upstream default, probably all FHS-based distros
]}
'' + ''
export PYTHONNOUSERSITE=1
export PYTHONHOME="$dir"
export PATH="$dir/bin/:$PATH"
'';
wrapperBinPwndbgGdbinit = pkgs.writeScript "pwndbg-wrapper-bin-gdbinit" ''
#!/bin/sh
dir="$(cd -- "$(dirname "$(dirname "$(realpath "$0")")")" >/dev/null 2>&1 ; pwd -P)"
export PYTHONHOME="$dir"
export PATH="$dir/bin/:$PATH"
${commonEnvs}
exec ${ldLoader} "$dir/exe/gdb" --quiet --early-init-eval-command="set auto-load safe-path /" --command=$dir/exe/gdbinit.py "$@"
'';
wrapperBinPy = file: pkgs.writeScript "pwndbg-wrapper-bin-py" ''
#!/bin/sh
dir="$(cd -- "$(dirname "$(dirname "$(realpath "$0")")")" >/dev/null 2>&1 ; pwd -P)"
export PYTHONHOME="$dir"
export PATH="$dir/bin/:$PATH"
${linuxLldbEnvs}
${commonEnvs}
exec ${ldLoader} "$dir/exe/python3" "$dir/${file}" "$@"
'';
wrapperBin = file: pkgs.writeScript "pwndbg-wrapper-bin" ''
#!/bin/sh
dir="$(cd -- "$(dirname "$(dirname "$(realpath "$0")")")" >/dev/null 2>&1 ; pwd -P)"
export PATH="$dir/bin/:$PATH"
export PYTHONHOME="$dir"
${linuxLldbEnvs}
${commonEnvs}
exec ${ldLoader} "$dir/${file}" "$@"
'';
skipVenv = pkgs.writeScript "pwndbg-skip-venv" "";

Loading…
Cancel
Save