[Pcsclite-git-commit] [pcsc-tools] 01/02: ATR_analysis: update the ATR list if non present
Ludovic Rousseau
rousseau at moszumanska.debian.org
Tue Aug 4 15:40:30 UTC 2015
This is an automated email from the git hooks/post-receive script.
rousseau pushed a commit to branch master
in repository pcsc-tools.
commit 5e37873ce4ad2998632e03d5c767cac68b2f9516
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date: Tue Aug 4 10:55:01 2015 +0200
ATR_analysis: update the ATR list if non present
If no ATR list cache is present then it was not be updated.
The ATR list automatic update did work only if a file
~/.cache/smartcard_list.txt was already present.
---
ATR_analysis | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/ATR_analysis b/ATR_analysis
index 990c916..7f2c4e5 100755
--- a/ATR_analysis
+++ b/ATR_analysis
@@ -45,6 +45,7 @@ use strict;
use warnings;
use Getopt::Std;
use Chipcard::PCSC::Card;
+use File::stat;
# default value for XDG_CACHE_HOME
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -223,7 +224,19 @@ sub update_smartcard_list($$)
my $url = shift;
# Has the $file file been modified in the last 10 hours?
- my $old = `find $file -cmin +600`;
+ my $old = 0;
+
+ my $stat_obj = stat $file;
+ if (! $stat_obj)
+ {
+ # no file, so force update
+ $old = 1;
+ }
+ elsif ($stat_obj->mtime < time() - 10*60*60)
+ {
+ # file is too old, update
+ $old = 1;
+ }
# old file
if ($old)
@@ -248,11 +261,22 @@ sub update_smartcard_list($$)
}
# find the corresponding card type
-if (find_card($atr, @SMARTCARD_LIST))
+my $found = find_card($atr, @SMARTCARD_LIST);
+if ($found == 2)
{
+ # not ATR file found
+ mkdir $Cache;
+
+ # continue with the ATR list update
+ $found = 1;
+}
+
+if ($found == 1)
+{
+ # ATR not found
my $file = $SMARTCARD_LIST[0];
my $url = "http://ludovic.rousseau.free.fr/softwares/pcsc-tools/smartcard_list.txt";
- my $found = 0;
+ $found = 0;
# update the ATR list
if (update_smartcard_list($file, $url))
@@ -514,7 +538,7 @@ sub find_card($@)
}
# no valid file found
- return if (!defined $file);
+ return 2 if (!defined $file);
$found = 0;
print "\nPossibly identified card (using $file):\n";
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/pcsc-tools.git
More information about the Pcsclite-cvs-commit
mailing list