From 4cf8fe6eb9d645f390c2527a9efaeb0e444dc63c Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Fri, 20 Jul 2012 13:40:43 +0200 Subject: [PATCH] fixed rt.cpan.org#75145. rt.cpan.org#75146. --- CHANGELOG | 12 +++++++++++ README | 4 ++-- lib/Crypt/PWSafe3.pm | 11 +++++----- lib/Crypt/PWSafe3/Record.pm | 41 ++++++++++++++++++++++++------------- 4 files changed, 47 insertions(+), 21 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f3cd7ea..7e42a04 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,14 @@ +1.04 + + fixed rt.cpan.org#75145. uninitialized fields lead to + program abort. solved by pre-initializing them in the + new records method. types notes and groups affected. + + fixed rt.cpan.org#75146. mtime will only modified if + the passwd field changed. POD adjusted. Fix suggested + by Luca Filipozzi - thx. + + 1.03 after saving we do not mv the tmp file but copying it, because mv sometimes doesn't work with files the @@ -5,6 +16,7 @@ while cp works on such files. so now we cp and unlink the tmpfile after saving. + 1.02 doc fix in ::Record (group separator is . not /) added Shell.pm to Makefile.PL dependencies diff --git a/README b/README index 6ab2f84..7173efa 100644 --- a/README +++ b/README @@ -32,7 +32,7 @@ INSTALLATION COPYRIGHT Crypt::PWSafe3 - Copyright (c) 2011 by T. Linden + Copyright (c) 2011-2012 by T. Linden This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -49,4 +49,4 @@ AUTHOR VERSION - 1.03 + 1.04 diff --git a/lib/Crypt/PWSafe3.pm b/lib/Crypt/PWSafe3.pm index e8bdc93..570a821 100644 --- a/lib/Crypt/PWSafe3.pm +++ b/lib/Crypt/PWSafe3.pm @@ -22,7 +22,7 @@ use Data::Dumper; use Exporter (); use vars qw(@ISA @EXPORT); -$Crypt::PWSafe3::VERSION = '1.03'; +$Crypt::PWSafe3::VERSION = '1.04'; use Crypt::PWSafe3::Field; use Crypt::PWSafe3::HeaderField; @@ -869,9 +869,6 @@ T. Linden Report bugs to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-PWSafe3. -=head1 VERSION - -Crypt::PWSafe3 Version 1.03. =head1 SEE ALSO @@ -895,7 +892,7 @@ in this module are his ideas ported to perl. =head1 COPYRIGHT -Copyright (c) 2011 by T.Linden . +Copyright (c) 2011-2012 by T.Linden . All rights reserved. =head1 LICENSE @@ -903,6 +900,10 @@ All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. +=head1 VERSION + +Crypt::PWSafe3 Version 1.04. + =cut diff --git a/lib/Crypt/PWSafe3/Record.pm b/lib/Crypt/PWSafe3/Record.pm index 8d9426a..1492707 100644 --- a/lib/Crypt/PWSafe3/Record.pm +++ b/lib/Crypt/PWSafe3/Record.pm @@ -9,7 +9,7 @@ my %map2type = %Crypt::PWSafe3::Field::map2type; my %map2name = %Crypt::PWSafe3::Field::map2name; -$Crypt::PWSafe3::Record::VERSION = '1.02'; +$Crypt::PWSafe3::Record::VERSION = '1.03'; foreach my $field (keys %map2type ) { eval qq( @@ -37,6 +37,9 @@ sub new { # just in case this is a record to be filled by the user, # initialize it properly my $newuuid = $self->genuuid(); + + my $time = time; + $self->addfield(new Crypt::PWSafe3::Field( name => 'uuid', raw => $newuuid, @@ -44,17 +47,17 @@ sub new { $self->addfield(new Crypt::PWSafe3::Field( name => 'ctime', - value => time, + value => $time, )); $self->addfield(new Crypt::PWSafe3::Field( name => 'mtime', - value => time + value => $time )); $self->addfield(new Crypt::PWSafe3::Field( name => 'lastmod', - value => time + value => $time )); $self->addfield(new Crypt::PWSafe3::Field( @@ -72,6 +75,16 @@ sub new { value => '' )); + $self->addfield(new Crypt::PWSafe3::Field( + name => 'notes', + value => '' + )); + + $self->addfield(new Crypt::PWSafe3::Field( + name => 'group', + value => '' + )); + return $self; } @@ -85,21 +98,24 @@ sub modifyfield { type => $type, value => $value ); + + my $time = time; + # we are in fact just overwriting an eventually # existing field with a new one, instead of modifying # it, so we are using the conversion automatism in # Field::new() $this->addfield($field); - # mark the record as modified + # mark the field as modified if it's passwd field $this->addfield(new Crypt::PWSafe3::Field( name => 'mtime', - value => time - )); + value => $time + )) if $name eq 'passwd'; $this->addfield(new Crypt::PWSafe3::Field( name => "lastmod", - value => time + value => $time )); return $field; } @@ -207,11 +223,11 @@ you mind, do it yourself. =head2 B -Returns the modification time without argument. Sets the modification time +Returns the modification time of the passwd field without argument. Sets the modification time if an argument is given. Argument must be an integer timestamp as returned by L. -This will be generated automatically for modified records, so you +This will be generated automatically for modified records if the passwd field changed, so you normally don't have to cope with. =head2 B @@ -223,9 +239,6 @@ as returned by L. This will be generated automatically for modified records, so you normally don't have to cope with. -I - =head2 B Returns the url without argument. Sets the url @@ -283,7 +296,7 @@ T. Linden =head1 COPYRIGHT -Copyright (c) 2011 by T.Linden . +Copyright (c) 2011-2012 by T.Linden . All rights reserved. =head1 LICENSE