goodpasswd: First char not '-': looks like an option.

This commit is contained in:
Ole Tange 2014-09-18 14:15:00 +02:00
parent 583d6970f9
commit 54b1aa2308

View file

@ -5,32 +5,30 @@
# * are hard to guess # * are hard to guess
# * will be displayed unambigously in any (normal) font # * will be displayed unambigously in any (normal) font
# * will survive being passed through a bad fax machine # * will survive being passed through a bad fax machine
# * will survive being passed through handwriting
# * has UPPER lower number and sign # * has UPPER lower number and sign
# #
# Too close: B8 cC g9 kK lI l1 oO O0 pP sS uU vV xX zZ Z2 ,. :; `' S5 # Too close: B8 cC g9 6G kK lI l1 oO O0 pP sS uU vV xX zZ Z2 ,. :; `' S5
# Causes problems in URLs: @/: # Causes problems in URLs: @/:
# Causes problems in shell: ! " # $ & ( ) [ ] { } ? | < > \ * = # Causes problems in shell: ! " # $ & ( ) [ ] { } ? | < > \ * =
# SQL uses: % for wildcard # SQL uses: % for wildcard
# Hard to type: ^ ~ ¨ ¤ § ½ æ ø å Æ Ø Å # Hard to type: ^ ~ ¨ ¤ § ½ æ ø å Æ Ø Å
# Never 2 same chars next to eachother. (--) is bad # Never 2 same chars next to eachother. (--) is bad
# Do not start with '-' or '+' as that looks like an (long) option
# #
# US-kbd: ~!@#$%^&*()_+ [] {} ;'\ :"| < > ,./ <>? # US-kbd: ~!@#$%^&*()_+ [] {} ;'\ :"| < > ,./ <>?
# DK-kbd: §!"#¤%&/()=?` å" Å^ æø' ÆØ* < > ,.- ;:_ # DK-kbd: §!"#¤%&/()=?` å" Å^ æø' ÆØ* < > ,.- ;:_
# Common: ! # % < > ,. # Common: ! # % < > ,.
my $pw; my $pw;
my @chars=split //, 'abdefhijmnqrtyADEFGHJLMNQRTY3467+-'; my @chars=split //, 'abdefhijmnqrtyADEFHJLMNQRTY347+-';
do { do {
$pw = ""; $pw = "";
for (1..12) { for (1..12) {
do { $pw .= $chars[rand $#chars+1]
# avoid double chars (such as --)
$this = $chars[rand $#chars+1]
} while($last eq $this);
$last = $this;
$pw .= $this;
} }
} while (not($pw =~ /[A-Z]/ and } while (($pw =~ /^[+-]/ or $pw =~ /(.)\1/) or
not($pw =~ /[A-Z]/ and
$pw =~ /[a-z]/ and $pw =~ /[a-z]/ and
$pw =~ /[0-9]/ and $pw =~ /[0-9]/ and
$pw =~ /[^a-zA-Z0-9]/)); $pw =~ /[^a-zA-Z0-9]/));