Author: rrelyea
Update of /cvs/dirsec/coolkey/src/coolkey
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11789
Modified Files:
slot.cpp log.h
Log Message:
Add syslog support.
Add CAC support
Index: slot.cpp
===================================================================
RCS file: /cvs/dirsec/coolkey/src/coolkey/slot.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- slot.cpp 25 Jul 2006 23:37:11 -0000 1.2
+++ slot.cpp 10 Nov 2006 19:08:07 -0000 1.3
@@ -585,16 +585,41 @@
}
Transaction trans;
- trans.begin(conn);
+ status = trans.begin(conn);
+
+ /* CAC card are cranky after they are first inserted.
+ * don't continue until we can convince the tranaction to work */
+ for (int count = 0; count < 10 && status == CKYSCARDERR
+ && CKYCardConnection_GetLastError(conn) == SCARD_W_RESET_CARD; count++) {
+ log->log("CAC Card Reset detected retry %d: time %d ms\n", count,
+ OSTimeNow() - time);
+ CKYCardConnection_Disconnect(conn);
+ OSSleep(100000); /* 100 ms */
+ status = CKYCardConnection_Connect(conn, readerName);
+ if (status != CKYSUCCESS) {
+ continue;
+ }
+ status = trans.begin(conn);
+ }
+
+ /* Can't get a transaction, give up */
+ if (status != CKYSUCCESS) {
+ log->log("Transaction Failed 0x%x\n", status);
+ handleConnectionError();
+ }
// see if the applet is selectable
log->log("time connnect: Begin transaction %d ms\n", OSTimeNow() -
time);
status = CKYApplet_SelectCoolKeyManager(conn, NULL);
if (status != CKYSUCCESS) {
+ log->log("CoolKey Select failed 0x%x\n", status);
status = CACApplet_SelectPKI(conn, 0, NULL);
if (status != CKYSUCCESS) {
+ log->log("CAC Select failed 0x%x\n", status);
if (status == CKYSCARDERR) {
+ log->log("CAC Card Failure 0x%x\n",
+ CKYCardConnection_GetLastError(conn));
disconnect();
}
return;
@@ -1121,6 +1146,8 @@
{
long error = CKYCardConnection_GetLastError(conn);
+ log->log("Connection Error = 0x%x\n", error);
+
// Force a reconnect after a token operation fails. The most
// common reason for it to fail is that it has been removed, but
// it doesn't hurt to do it in other cases either (such as a reset).
@@ -1966,7 +1993,7 @@
Slot::loadCACCert(CKYByte instance)
{
CKYISOStatus apduRC;
- CKYStatus status;
+ CKYStatus status = CKYSUCCESS;
CKYBuffer cert;
CKYBuffer rawCert;
CKYBuffer shmCert;
Index: log.h
===================================================================
RCS file: /cvs/dirsec/coolkey/src/coolkey/log.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- log.h 9 Jun 2006 18:39:11 -0000 1.1
+++ log.h 10 Nov 2006 19:08:07 -0000 1.2
@@ -53,4 +53,14 @@
virtual ~FileLog();
};
+class SysLog : public Log {
+ private:
+ SysLog(SysLog &) {}
+ SysLog * operator=(SysLog &) { return *this; }
+ public:
+ SysLog() { }
+ void log(const char *msg, ...);
+ virtual ~SysLog() { }
+};
+
#endif
Show replies by date