Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error when $TERM is not set #1658

Closed
meithecatte opened this issue Aug 16, 2020 · 0 comments · Fixed by #1659
Closed

Fatal error when $TERM is not set #1658

meithecatte opened this issue Aug 16, 2020 · 0 comments · Fixed by #1659
Labels
backport-required bug term This is connected to pwnlib.term module

Comments

@meithecatte
Copy link
Contributor

I am trying to use pwntools in a SageMath script. This works great interactively, but when I run my script with sage foo.sage, it fails somewhere in terminal code. I have traced this back to sage unsetting $TERM in non-interactive calls due to https://trac.sagemath.org/ticket/12263. Thus, issue can be easily reproduced without SageMath:

~$ docker run -it pwntools/pwntools:stable
pwntools@bce19e99e965:~$ TERM= python -c 'import pwn'
Warning: error: setupterm: could not find terminfo database

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pwn/__init__.py", line 4, in <module>
    from pwn.toplevel import *
  File "/usr/local/lib/python2.7/dist-packages/pwn/toplevel.py", line 20, in <module>
    import pwnlib
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/__init__.py", line 43, in <module>
    importlib.import_module('.%s' % module, 'pwnlib')
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/args.py", line 62, in <module>
    from pwnlib import term
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/__init__.py", line 6, in <module>
    from pwnlib.term import completer
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/completer.py", line 7, in <module>
    from pwnlib.term import readline
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/readline.py", line 13, in <module>
    from pwnlib.term import text
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py", line 126, in <module>
    sys.modules[__name__] = Module()
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/text.py", line 49, in __init__
    s = termcap.get(y)
  File "/usr/local/lib/python2.7/dist-packages/pwnlib/term/unix_termcap.py", line 28, in get
    s = curses.tigetstr(cap)
_curses.error: must call (at least) setupterm() first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-required bug term This is connected to pwnlib.term module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants