Bug 50575 - Python3: we need python3-smbpasswd
Python3: we need python3-smbpasswd
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: Samba
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 5.0
Assigned To: Florian Best
Philipp Hahn
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-11-28 14:42 CET by Florian Best
Modified: 2021-05-25 16:03 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments
patch (10.17 KB, patch)
2019-11-29 15:08 CET, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2019-11-28 14:42:30 CET
There is no python3-smbpasswd package in debian yet.

https://packages.debian.org/de/source/sid/python-smbpasswd

The bug report for the deprecation of python 2 is:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=938176

python-smbpasswd is only used by python-univention-directory-manager:

management/univention-directory-manager-modules/modules/univention/admin/password.py:import smbpasswd
management/univention-directory-manager-modules/modules/univention/admin/password.py:   nt = smbpasswd.nthash(password)
management/univention-directory-manager-modules/modules/univention/admin/password.py:           lm = smbpasswd.lmhash(password)
Comment 1 Arvid Requate univentionstaff 2019-11-28 20:14:44 CET
Maybe we can replace this by python-samba methods?

>>> from samba import credentials
>>> creds = credentials.Credentials()
>>> creds.set_password("S3CreT")
True
>>> creds.get_nt_hash()
'\x84_z\xc5\x0b\xcc\xdb\xb4\x91\xa2WQGx%C'


No luck for LM hash though.
Comment 2 Florian Best univentionstaff 2019-11-29 15:08:14 CET
Created attachment 10241 [details]
patch
Comment 3 Florian Best univentionstaff 2020-06-04 14:54:45 CEST
The package is build in the python3-scope.
Patches are:
python-smbpasswd/4.4-0-0-ucs/1.0.1-1.3-python3/0001-remove-trailing-whitespace.patch
python-smbpasswd/4.4-0-0-ucs/1.0.1-1.3-python3/0002-Migrate-to-Python-3-compatibility.patch
python-smbpasswd/4.4-0-0-ucs/1.0.1-1.3-python3/0003-Add-python3-smbpasswd-package.patch
Comment 4 Florian Best univentionstaff 2020-06-04 15:07:18 CEST
Applied the patches for UCS 5.0:

r18965 | Bug #50575: Add patches

Package: python-smbpasswd
Version: 1.0.1-1.3A~5.0.0.202006041505
Comment 5 Philipp Hahn univentionstaff 2020-06-12 17:43:30 CEST
OK: diff -ur  python-smbpasswd/5.0-0-0-ucs/1.0.1-1.3 python-smbpasswd/4.4-0-0-ucs/1.0.1-1.3-python3
OK: # SELECT * FROM binpkg WHERE major=5 AND site='apt' AND srcpkg='python-smbpasswd';
          binpkg          |            binver             | arch  |      srcpkg      |            srcver             | major | minor | patch | scope | site | maintained |    id    
--------------------------+-------------------------------+-------+------------------+-------------------------------+-------+-------+-------+-------+------+------------+----------
 python-smbpasswd-dbgsym  | 1.0.1-1.3A~5.0.0.202006041505 | amd64 | python-smbpasswd | 1.0.1-1.3A~5.0.0.202006041505 |     5 |     0 |     0 |       | apt  |            | 17755223
 python-smbpasswd         | 1.0.1-1.3A~5.0.0.202006041505 | amd64 | python-smbpasswd | 1.0.1-1.3A~5.0.0.202006041505 |     5 |     0 |     0 |       | apt  |            | 17755224
 python3-smbpasswd-dbgsym | 1.0.1-1.3A~5.0.0.202006041505 | amd64 | python-smbpasswd | 1.0.1-1.3A~5.0.0.202006041505 |     5 |     0 |     0 |       | apt  |            | 17755225
 python3-smbpasswd        | 1.0.1-1.3A~5.0.0.202006041505 | amd64 | python-smbpasswd | 1.0.1-1.3A~5.0.0.202006041505 |     5 |     0 |     0 |       | apt  |            | 17755226
(4 Zeilen)
OK: python -m univention.repong.dchdiff -l 1 amd64/python3-smbpasswd_1.0.1-1.3A~5.0.0.202006041505_amd64.deb
OK:
 apt install -t apt python3-smbpasswd
 python3 -c 'import smbpasswd;print(smbpasswd.nthash("S3CreT"), smbpasswd.lmhash("S3CreT"))'
 python2 -c 'import smbpasswd;print(smbpasswd.nthash("S3CreT"), smbpasswd.lmhash("S3CreT"))'
Comment 6 Florian Best univentionstaff 2020-06-16 13:06:14 CEST
We could instead also migrate the code to python{,3}-passlib:

>>> import smbpasswd
>>> smbpasswd.nthash('foobar')
'BAAC3929FABC9E6DCD32421BA94A84D4'
>>> smbpasswd.lmhash('foobar')                                                                                                                                                                                                                
'D85774CF671A9947AAD3B435B51404EE'

>>> passlib.hash.nthash.hash('foobar').upper()
'BAAC3929FABC9E6DCD32421BA94A84D4'
>>> passlib.hash.lmhash.hash('foobar').upper()
'D85774CF671A9947AAD3B435B51404EE'
Comment 7 Florian Best univentionstaff 2021-05-25 16:03:22 CEST
UCS 5.0 has been released:
 https://docs.software-univention.de/release-notes-5.0-0-en.html
 https://docs.software-univention.de/release-notes-5.0-0-de.html

If this error occurs again, please use "Clone This Bug".