r11193 - in /branches/upstream/libterm-readpassword-perl/current: Changes META.yml ReadPassword.pm t/2_interactive.t
rmayorga-guest at users.alioth.debian.org
rmayorga-guest at users.alioth.debian.org
Fri Dec 14 07:39:42 UTC 2007
Author: rmayorga-guest
Date: Fri Dec 14 07:39:42 2007
New Revision: 11193
URL: http://svn.debian.org/wsvn/?sc=1&rev=11193
Log:
[svn-upgrade] Integrating new upstream version, libterm-readpassword-perl (0.09)
Modified:
branches/upstream/libterm-readpassword-perl/current/Changes
branches/upstream/libterm-readpassword-perl/current/META.yml
branches/upstream/libterm-readpassword-perl/current/ReadPassword.pm
branches/upstream/libterm-readpassword-perl/current/t/2_interactive.t
Modified: branches/upstream/libterm-readpassword-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libterm-readpassword-perl/current/Changes?rev=11193&op=diff
==============================================================================
--- branches/upstream/libterm-readpassword-perl/current/Changes (original)
+++ branches/upstream/libterm-readpassword-perl/current/Changes Fri Dec 14 07:39:42 2007
@@ -17,3 +17,10 @@
0.05 Tue Jun 14 11:50:00 2005
- a space in place of the password now skips the interactive test
- save and restore the cc array, which seems to fix a bug
+
+0.06 Sun Aug 28 13:07:00 2005
+ - Setting $Term::ReadPassword::USE_STARS to a true value now
+ echoes stars for password characters.
+
+0.09 Wed Dec 12 11:20:00 2007
+ - Bug fix wrt CC_FIELDS, improved documentation
Modified: branches/upstream/libterm-readpassword-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libterm-readpassword-perl/current/META.yml?rev=11193&op=diff
==============================================================================
--- branches/upstream/libterm-readpassword-perl/current/META.yml (original)
+++ branches/upstream/libterm-readpassword-perl/current/META.yml Fri Dec 14 07:39:42 2007
@@ -1,10 +1,10 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Term-ReadPassword
-version: 0.05
+version: 0.09
version_from: ReadPassword.pm
installdirs: site
requires:
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.25
+generated_by: ExtUtils::MakeMaker version 6.17
Modified: branches/upstream/libterm-readpassword-perl/current/ReadPassword.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libterm-readpassword-perl/current/ReadPassword.pm?rev=11193&op=diff
==============================================================================
--- branches/upstream/libterm-readpassword-perl/current/ReadPassword.pm (original)
+++ branches/upstream/libterm-readpassword-perl/current/ReadPassword.pm Fri Dec 14 07:39:42 2007
@@ -3,13 +3,24 @@
use strict;
use Term::ReadLine;
use POSIX qw(:termios_h);
- use constant CC_FIELDS =>
- (VEOF VEOL VERASE VINTR VKILL VQUIT
- VSUSP VSTART VSTOP VMIN VTIME NCCS);
+my %CC_FIELDS = (
+ VEOF => VEOF,
+ VEOL => VEOL,
+ VERASE => VERASE,
+ VINTR => VINTR,
+ VKILL => VKILL,
+ VQUIT => VQUIT,
+ VSUSP => VSUSP,
+ VSTART => VSTART,
+ VSTOP => VSTOP,
+ VMIN => VMIN,
+ VTIME => VTIME,
+ );
use vars qw(
$VERSION @ISA @EXPORT @EXPORT_OK
$ALLOW_STDIN %SPECIAL $SUPPRESS_NEWLINE $INPUT_LIMIT
+ $USE_STARS $STAR_STRING $UNSTAR_STRING
);
require Exporter;
@@ -18,7 +29,7 @@
@EXPORT = qw(
read_password
);
-$VERSION = '0.05';
+$VERSION = '0.09';
# The special characters in the input stream
%SPECIAL = (
@@ -73,7 +84,10 @@
my $term = POSIX::Termios->new();
$term->getattr($fd_tty);
my $original_flags = $term->getlflag();
- my %original_cc = map +($_, $term->getcc($_)), CC_FIELDS;
+ my %original_cc;
+ for my $field_name (keys %CC_FIELDS) {
+ $original_cc{$field_name} = $term->getcc($CC_FIELDS{$field_name});
+ }
# What makes this setup different from the ordinary?
# No keyboard-generated signals, no echoing, no canonical input
@@ -92,6 +106,11 @@
# Continue as soon as one character has been struck
$term->setcc(VMIN, 1);
}
+
+ # Optionally echo stars in place of password characters. The
+ # $unstar_string uses backspace characters.
+ my $star_string = $USE_STARS ? ($STAR_STRING || '*') : '';
+ my $unstar_string = $USE_STARS ? ($UNSTAR_STRING || "\b*\b \b") : '';
# If there's anything already buffered, we should throw it out. This
# is to discourage users from typing their password before they see
@@ -121,10 +140,16 @@
} elsif ($meaning eq 'DEL') {
# Delete/backspace key
# Take back one char, if possible
- chop $input;
+ if (length $input) {
+ $input = substr $input, 0, length($input)-1;
+ print TTYOUT $unstar_string;
+ }
} elsif ($meaning eq 'NAK') {
# Control-U (NAK)
# Clear what we have read so far
+ for (1..length $input) {
+ print TTYOUT $unstar_string;
+ }
$input = '';
} elsif ($interruptable and $meaning eq 'INT') {
# Breaking out of the program
@@ -133,10 +158,12 @@
} else {
# Just an ordinary keystroke
$input .= $new_key;
+ print TTYOUT $star_string;
}
} else {
# Not special
$input .= $new_key;
+ print TTYOUT $star_string;
}
}
# Just in case someone sends a lot of data
@@ -151,12 +178,12 @@
# Done with waiting for input. Let's not leave the cursor sitting
# there, after the prompt.
- print TTY "\n" unless $SUPPRESS_NEWLINE;
+ print TTYOUT "\n" unless $SUPPRESS_NEWLINE;
# Let's put everything back where we found it.
$term->setlflag($original_flags);
while (my($field, $value) = each %original_cc) {
- $term->setcc($field, $value);
+ $term->setcc($CC_FIELDS{$field}, $value);
}
$term->setattr($fd_tty, TCSAFLUSH);
close(TTY);
@@ -260,6 +287,16 @@
normally or not, a newline character will be printed, so that the cursor
will not remain on the line after the prompt.
+=head1 BUGS
+
+This module has a poorly-designed interface, and should be thoroughly
+rethought.
+
+Users who wish to see password characters echoed as stars may set
+$Term::ReadPassword::USE_STARS to a true value. The bugs are that some
+terminals may not erase stars when the user corrects an error, and that
+using stars leaks information to shoulder-surfers.
+
=head1 SECURITY
You would think that a module dealing with passwords would be full of
@@ -273,6 +310,11 @@
In short, if serious security is an issue, don't use this module.
+=head1 LICENSE
+
+This program is free software; you may redistribute it, modify it, or
+both, under the same terms as Perl itself.
+
=head1 AUTHOR
Tom Phoenix <rootbeer at redcat.com>
Modified: branches/upstream/libterm-readpassword-perl/current/t/2_interactive.t
URL: http://svn.debian.org/wsvn/branches/upstream/libterm-readpassword-perl/current/t/2_interactive.t?rev=11193&op=diff
==============================================================================
--- branches/upstream/libterm-readpassword-perl/current/t/2_interactive.t (original)
+++ branches/upstream/libterm-readpassword-perl/current/t/2_interactive.t Fri Dec 14 07:39:42 2007
@@ -6,6 +6,8 @@
print "1..0 # Skip: Automated testing detected (AUTOMATED_TESTING) \n";
exit;
}
+
+$Term::ReadPassword::USE_STARS = $ENV{USE_STARS};
print "1..1\n";
More information about the Pkg-perl-cvs-commits
mailing list