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

attic check with ATTIC_PASSPHRASE -- getpass.py/terminal issue #374

Open
bopolissimus opened this issue Jan 27, 2016 · 2 comments
Open

attic check with ATTIC_PASSPHRASE -- getpass.py/terminal issue #374

bopolissimus opened this issue Jan 27, 2016 · 2 comments

Comments

@bopolissimus
Copy link

I run attic check from cron (daily while testing, once a week in future). Attic uses a $ATTIC_PASSPHRASE set in the environment. This is running from cron.

attic check does the repository check OK but when it does the archive consistency check it fails with:

Starting repository check...
Repository check complete, no problems found.
Starting archive consistency check...
/usr/lib/python3.4/getpass.py:92: GetPassWarning: Can not control echo on the terminal.
  passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Enter passphrase for /backup/attic/work-backup.attic: Traceback (most recent call last):
  File "/usr/lib/python3.4/getpass.py", line 70, in unix_getpass
    old = termios.tcgetattr(fd)     # a copy to save
termios.error: (25, 'Inappropriate ioctl for device')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/attic", line 3, in <module>
    main()
  File "/usr/local/lib/python3.4/dist-packages/attic/archiver.py", line 730, in main
    exit_code = archiver.run(sys.argv[1:])
  File "/usr/local/lib/python3.4/dist-packages/attic/archiver.py", line 720, in run
    return args.func(args)
  File "/usr/local/lib/python3.4/dist-packages/attic/archiver.py", line 85, in do_check
    if not args.repo_only and not ArchiveChecker().check(repository, repair=args.repair):
  File "/usr/local/lib/python3.4/dist-packages/attic/archive.py", line 542, in check
    self.key = self.identify_key(repository)
  File "/usr/local/lib/python3.4/dist-packages/attic/archive.py", line 576, in identify_key
    return key_factory(repository, cdata)
  File "/usr/local/lib/python3.4/dist-packages/attic/key.py", line 45, in key_factory
    return PassphraseKey.detect(repository, manifest_data)
  File "/usr/local/lib/python3.4/dist-packages/attic/key.py", line 187, in detect
    passphrase = getpass(prompt)
  File "/usr/lib/python3.4/getpass.py", line 92, in unix_getpass
    passwd = fallback_getpass(prompt, stream)
  File "/usr/lib/python3.4/getpass.py", line 127, in fallback_getpass
    return _raw_input(prompt, stream)
  File "/usr/lib/python3.4/getpass.py", line 149, in _raw_input
    raise EOFError
EOFError

Is this a known issue and is there a command line parameter or environment variable or similar that I can set to make getpass.py not break when it thinks it's not talking to a terminal?

I think I could possibly get this working if I set up ssh key auth and have the cron job ssh to localhost to run attic-check. I'll test that (haven't yet) if there is no more standard way to fix.

Gerald Quimpo

@ThomasWaldmann
Copy link
Contributor

        passphrase = os.environ.get('ATTIC_PASSPHRASE')
        if passphrase is None:
            passphrase = getpass(prompt)  # this is line 187

That means you did not set ATTIC_PASSPHRASE.
If you did, it would not execute that line.

@bopolissimus
Copy link
Author

Thank you Thomas. After further investigation, I had a misunderstanding about how exporting a variable in a sourced script. The variable would be available to subshells, but not to the calling shell :-). I've changed how the attic passphrase env variable is initialized and it's now available to attic check.

I was confused since there was this:

Starting repository check...
Repository check complete, no problems found.

I'd assumed that repository check would also require the passphrase. but it looks like it doesn't since that succeeded and only the archive checks failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants