Page 1 of 1
[1.2.0] additional space at the beginning of password
Posted: January 20th, 2017, 9:36 am
by ZlatkO
When I feed an NZB to SABnzbd in the filename{{password}}.nzb format, the password suddenly contains an additional space in the beginning (ie. the password field in the web GUI reads " password"), automatic unpacking fails, and the download gets paused. So I have to klick into the password field for every encrypted RAR, deleted the space in the beginning, and continue the download, which then works fine as usual. Checked a couple of times, and the filename is in fact saved properly (ie. it does not contain the space afer the "{{" start-of-password marker), so I assume it's SABnzbd itself that adds it somewhere.
SABnzbd 1.2.0 on Slackware 14.2, Python 2.7.13. Additional info available on request if needed. Thanks in advance for any hints!
Thomas
Update: It does actually try with the proper password according to the logs (it gets .strip()ed before trying), but for some reason the call to zf.setpassword(password) in assembler.py throws an exception, so the following two lines (zf.testrar(), password_hit = password) never get executed, and so the assembler thinks the password is wrong. I'll try to figure out why this happens ...
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 4:26 am
by safihre
Found the space-bug
The password was re-parsed incorrectly when added via the {{}} method.
Will be fixed for 1.2.1.
zf.setpassword throws an exception when something is wrong with the encryption (possibly due to corrupted articles, breaking the header) or when the Cryptography library is missing.
Since you seem to know your Python, if you add this in those 2 except's in the Assembler below the zf.testrar() we can see why it is failing:
Code: Select all
logging.error('Error', exc_info=True)
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 6:27 am
by ZlatkO
Ah, thanks! :-) Okay, so here's the output:
Code: Select all
2017-01-21 11:35:51,845::ERROR::[assembler:361] Error
Traceback (most recent call last):
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/assembler.py", line 347, in check_encrypted_and_unwanted_files
zf.setpassword(password)
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 682, in setpassword
self._parse()
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 857, in _parse
self._file_parser.parse()
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 968, in parse
self._parse_real()
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 992, in _parse_real
h = self._parse_header(fd)
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 1071, in _parse_header
fd = self._decrypt_header(fd)
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 1235, in _decrypt_header
return HeaderDecrypt(fd, key, iv)
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 2351, in __init__
self.ciph = AES_CBC_Decrypt(key, iv)
File "/usr/local/stow/SABnzbd-1.2.0/lib/python2.7/site-packages/SABnzbd/sabnzbd/utils/rarfile.py", line 117, in __init__
ciph = Cipher(algorithms.AES(key), modes.CBC(iv), default_backend())
File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 71, in default_backend
_default_backend = MultiBackend(_available_backends())
File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/multibackend.py", line 36, in __init__
"Multibackend cannot be initialized with no backends. If you "
ValueError: Multibackend cannot be initialized with no backends. If you are seeing this error when trying to use default_backend() please try uninstalling and reinstalling cryptography.
Hm. I'm using the latest and greatest cryptography-1.7.1, and yes, obviously this does happen when trying to use default_backend(). I just don't see how un- & reinstalling cryptography would fix that ... oh well.
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 6:55 am
by safihre
Did the reinstalling help?
But odd, this error we normally see when we make for example the Windows or OSX executable and the cryptography package isn't loaded properly.
Is the python you use for Sab the same as system python that has access to the package?
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 10:42 am
by ZlatkO
No, the reinstall did not help, unfortunately, just as I thought. Yes, the Python version is the same for everything. Main stuff directly from Slackware, the rest (SAB, cryptography, Cheetah, NumPy, ...) installed in /usr/local. Strange.
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 11:31 am
by safihre
What happens if you delete the file sabnzbd/utils/__init__.py (and the compiled .pyc, while Sab is shutdown)
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 12:34 pm
by ZlatkO
Aaaaaaaaaaaaaaah - ha! I think I got it!
"If everything else fails, read the docs" ... only by very lucky chance I stumbled across a tiny file called /usr/local/lib/python2.7/site-packages/cryptography-1.7.1-py2.7.egg-info/requires.txt, which says:
Code: Select all
idna>=2.0
pyasn1>=0.1.8
six>=1.4.1
setuptools>=11.3
enum34
ipaddress
cffi>=1.4.1
[docstest]
doc8
pyenchant
readme_renderer >= 16.0
sphinx
sphinx_rtd_theme
sphinxcontrib-spelling
[pep8test]
flake8
flake8-import-order
pep8-naming
[test]
pytest>=2.9.0
pretend
iso8601
pyasn1_modules
pytz
hypothesis>=1.11.4
cryptography_vectors==1.7.1
And sure enough, I happened to miss idna, pyasn1, enum34 & ipaddress on my system ... these seem to be cryptography
runtime requirements only, as everything builds & installs just fine, and doesn't give the slightest warning ... and it's also mentioned nowhere else than in this tiny text file. SIGH.
Oh well ... with all of these modules installed, the exception is gone now, and everything works fine as usual. Yay! Sorry for the noise, and thanks for your help!
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 12:51 pm
by safihre
Interesting! Usually a "pip install cryptography" does this for you, but maybe you installed in a different way?
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 2:55 pm
by ZlatkO
Yup - download tarball, unpack, 'python setup.py build', 'python setup.py install'. I guess I'll have (to have) a look at installing via pip sooner or later.
Re: [1.2.0] additional space at the beginning of password
Posted: January 21st, 2017, 3:01 pm
by safihre
It simplifies things