sys.stderr.write("Could not open the specified word file.\n")
sys.exit(1)
else:
- static_default = os.path.join(
- os.path.dirname(os.path.abspath(__file__)),
- 'static',
- 'default.txt')
- common_word_files = ["/usr/share/cracklib/cracklib-small",
- static_default,
- "/usr/dict/words",
- "/usr/share/dict/words"]
-
- for wfile in common_word_files:
- if os.path.exists(wfile):
- options.wordfile = wfile
- break
+ options.wordfile = locate_wordfile()
- if options.wordfile is None:
+ if not options.wordfile:
sys.stderr.write("Could not find a word file, or word file does "
"not exist.\n")
sys.exit(1)
+def locate_wordfile():
+ static_default = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ 'static',
+ 'default.txt')
+ common_word_files = ["/usr/share/cracklib/cracklib-small",
+ static_default,
+ "/usr/dict/words",
+ "/usr/share/dict/words"]
+
+ for wfile in common_word_files:
+ if os.path.exists(wfile):
+ return wfile
+
+
def generate_wordlist(wordfile=None,
min_length=5,
max_length=9,