commit 4b6e189
Emilia Smólska
·
2026-08-02 00:53:53 +0000 UTC
parent 766204d
print generated password immediately, add test "suite"
M
Makefile
+3,
-0
1@@ -23,3 +23,6 @@ install:
2 sed '1s:.*:#!${PERLSHEBANG}:' ${PROG} > ${BINDIR}/${PROG}
3 chmod +x ${BINDIR}/${PROG}
4 cp ${MAN} ${MAN1}/${MAN}
5+
6+check:
7+ perl test.pl
M
haslo
+6,
-2
1@@ -50,8 +50,9 @@ sub dogen
2 read URANDOM, my $buf, 128
3 or die "couldn't read from /dev/urandom: $!\n";
4 close URANDOM;
5- $buf = encode_base64 $buf;
6+ ($buf) = split /\n/, encode_base64 $buf;
7 writernppassword $target, $buf;
8+ print "$buf\n";
9 }
10
11 sub doget
12@@ -62,7 +63,10 @@ sub doget
13 or die "couldn't open pipe to rnp: $!\n";
14 my $password = <RNP>;
15 close RNP or die "rnp failed with exit code $?\n";
16- print $password;
17+ # this dance is needed because Perl prints some garbage at the end
18+ # otherwise??
19+ chomp $password;
20+ print "$password\n";
21 }
22
23 sub dolist
M
haslo.1
+2,
-1
1@@ -24,7 +24,8 @@ Delete the generated or created password for
2 Generate a random password for
3 .Ar name ,
4 using 128 bytes of entropy from
5-.Pa /dev/urandom .
6+.Pa /dev/urandom ,
7+then print it to standard output.
8 .It Cm get Ar name
9 Retrieve and print to the standard output the generated or created password for
10 .Ar name .
A
test.pl
+16,
-0
1@@ -0,0 +1,16 @@
2+use strict;
3+use warnings;
4+
5+# Verify that gen outputs the same thing as get
6+$ENV{'HASLODIR'} = '.';
7+do {
8+ local $SIG{__DIE__} = sub {
9+ die if system qw(haslo del tmp);
10+ };
11+ my $gen = qx(./haslo gen tmp);
12+ die if $?;
13+ my $get = qx(./haslo get tmp);
14+ die if $?;
15+ die "$gen ne $get" if $gen ne $get;
16+};
17+die if system qw(haslo del tmp);