Created
June 2, 2012 04:29
-
-
Save romabysen/2856589 to your computer and use it in GitHub Desktop.
Support for Apache md5 passwords in shinken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- passwd_ui.py.orig 2012-06-02 11:40:38.267756001 +0800 | |
+++ passwd_ui.py 2012-06-02 12:07:42.995755998 +0800 | |
@@ -36,6 +36,7 @@ | |
import fcrypt as crypt | |
from shinken.basemodule import BaseModule | |
+from shinken.md5crypt import apache_md5_crypt | |
print "Loaded Apache/Passwd module" | |
@@ -82,11 +83,20 @@ | |
elts = line.split(':') | |
name = elts[0] | |
hash = elts[1] | |
- salt = hash[:2] | |
+ if hash[:5] == '$apr1': | |
+ h = hash.split('$') | |
+ magic = h[1] | |
+ salt = h[2] | |
+ else: | |
+ magic = None | |
+ salt = hash[:2] | |
print "PASSWD:", name, hash, salt | |
# If we match the user, look at the crypt | |
if name == user: | |
- compute_hash = crypt.crypt(password, salt) | |
+ if magic == 'apr1': | |
+ compute_hash = apache_md5_crypt(password, salt) | |
+ else: | |
+ compute_hash = crypt.crypt(password, salt) | |
print "Computed hash", compute_hash | |
if compute_hash == hash: | |
print "PASSWD : it's good!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment