Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python3 and smbpasswd package

I have a python utility with which I have been successfully managing our /etc/smbpasswd and /etc/samba/smbpasswd files for over 12 years. Time to update it to Python 3 !

I found that the latest smbpasswd installs in Python3, but doesn't load.

What is the best way to solve this using smbpasswd compatibility? I am not looking at replacing the working system with tdbsam!

like image 694
Omega Avatar asked Sep 19 '26 08:09

Omega


1 Answers

Even with the update of the package in 2011 python 3 had been out for a few years, so I assumed it is dead code.

There is an easy solution, install passlib with pip and create a file smbpasswd.py file with the following content:

import passlib.hash

def lmhash(s):
    return passlib.hash.lmhash.encrypt(s).upper()

def nthash(s):
    return passlib.hash.nthash.encrypt(s).upper()
like image 130
Anthon Avatar answered Sep 21 '26 01:09

Anthon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!