From fc03d941658b7641aca1404eb5f9b74dd5bc015e Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Fri, 26 Jan 2007 16:57:42 +0000 Subject: [PATCH] apply functionality patch for python binding from Nalin Dahyabhai git-svn-id: file:///tmp/cracklib-svn/trunk@93 4175fe1e-86d5-4fdc-8e6a-506fab9d8533 --- cracklib/NEWS | 1 + cracklib/python/cracklibmodule.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cracklib/NEWS b/cracklib/NEWS index ea3cddd..ca30fec 100644 --- a/cracklib/NEWS +++ b/cracklib/NEWS @@ -1,3 +1,4 @@ +v2.8.10 Patch for better hanlding of cracklist dictionary paths in python binding. (Nalin Dahyabhai) v2.8.8 Some shell quoting fixups for build scripts (Mike Frysinger) v2.8.7 Add support for NLS builds on FreeBSD v2.8.6 Add some sanity checkng to auto* script calls. (Mike Frysinger) diff --git a/cracklib/python/cracklibmodule.c b/cracklib/python/cracklibmodule.c index 8c2869d..1e4910f 100644 --- a/cracklib/python/cracklibmodule.c +++ b/cracklib/python/cracklibmodule.c @@ -19,6 +19,8 @@ static pthread_mutex_t cracklib_mutex = PTHREAD_MUTEX_INITIALIZER; #define UNLOCK() #endif +#define DICT_SUFFIX ".pwd" + static PyObject * cracklib_FascistCheck(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -27,6 +29,7 @@ cracklib_FascistCheck(PyObject *self, PyObject *args, PyObject *kwargs) const char *result; struct stat st; char *keywords[] = {"pw", "dictpath", NULL}; + char *dictfile; self = NULL; candidate = NULL; @@ -52,14 +55,23 @@ cracklib_FascistCheck(PyObject *self, PyObject *args, PyObject *kwargs) "second argument was not an absolute path!"); return NULL; } - if (lstat(dict, &st) == -1) + dictfile = malloc(strlen(dict) + sizeof(DICT_SUFFIX)); + if (dictfile == NULL) + { + PyErr_SetFromErrnoWithFilename(PyExc_OSError, dict); + return NULL; + } + sprintf(dictfile, "%s" DICT_SUFFIX, dict); + if (lstat(dictfile, &st) == -1) { PyErr_SetFromErrnoWithFilename(PyExc_OSError, dict); + free(dictfile); return NULL; } + free(dictfile); } else { - if (lstat(DEFAULT_CRACKLIB_DICT ".pwd", &st) == -1) + if (lstat(DEFAULT_CRACKLIB_DICT DICT_SUFFIX, &st) == -1) { PyErr_SetFromErrnoWithFilename(PyExc_OSError, DEFAULT_CRACKLIB_DICT); -- 2.40.0