s3-passdb: Fix the get/set routines for pw_history for samu
authorAmitay Isaacs <amitay@gmail.com>
Fri, 19 Aug 2011 05:50:49 +0000 (15:50 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 19 Aug 2011 06:35:11 +0000 (16:35 +1000)
Return pw_history with current string length (which is a multiple
of PW_HISTORY_ENTRY_LEN) and same thing for setting the pw_history.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
source3/passdb/py_passdb.c

index 878886d6d520ab3f49b33509730a568237969750..9192ab3ce78449b3d9720e7bc69cb411b2d24a1b 100644 (file)
@@ -658,7 +658,7 @@ static PyObject *py_samu_get_pw_history(PyObject *obj, void *closure)
                Py_RETURN_NONE;
        }
 
                Py_RETURN_NONE;
        }
 
-       py_nt_pw_his = PyString_FromStringAndSize(nt_pw_his, hist_len);
+       py_nt_pw_his = PyString_FromStringAndSize(nt_pw_his, hist_len*PW_HISTORY_ENTRY_LEN);
        return py_nt_pw_his;
 }
 
        return py_nt_pw_his;
 }
 
@@ -670,7 +670,7 @@ static int py_samu_set_pw_history(PyObject *obj, PyObject *value, void *closure)
        uint32_t hist_len;
 
        PyString_AsStringAndSize(value, &nt_pw_his, &len);
        uint32_t hist_len;
 
        PyString_AsStringAndSize(value, &nt_pw_his, &len);
-       hist_len = len;
+       hist_len = len / PW_HISTORY_ENTRY_LEN;
        if (!pdb_set_pw_history(sam_acct, (uint8_t *)nt_pw_his, hist_len, PDB_CHANGED)) {
                return -1;
        }
        if (!pdb_set_pw_history(sam_acct, (uint8_t *)nt_pw_his, hist_len, PDB_CHANGED)) {
                return -1;
        }