summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0>2007-02-14 19:54:01 +0000
committerrrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0>2007-02-14 19:54:01 +0000
commit84c646a01a46e1ae40bfedc907816cac962a7ada (patch)
treed739270b361f15664322acf214fbb6b9d89bc5ef /src
parent7f320dfff9bb284c5cb46e35785c4cdf3e9b8b62 (diff)
Add optional SYSLOG logging for Linux and Mac.
Allow CAC cards which have only one cert to operate. git-svn-id: http://svn.fedorahosted.org/svn/coolkey/trunk@51 fba4d07e-fe0f-4d7f-8147-e0026e666dc0
Diffstat (limited to 'src')
-rw-r--r--src/coolkey/coolkey.cpp11
-rw-r--r--src/coolkey/log.cpp30
-rw-r--r--src/coolkey/log.h4
-rw-r--r--src/coolkey/slot.cpp2
4 files changed, 41 insertions, 6 deletions
diff --git a/src/coolkey/coolkey.cpp b/src/coolkey/coolkey.cpp
index e129169..458c264 100644
--- a/src/coolkey/coolkey.cpp
+++ b/src/coolkey/coolkey.cpp
@@ -225,10 +225,15 @@ C_Initialize(CK_VOID_PTR pInitArgs)
}
}
char * logFileName = getenv("COOL_KEY_LOG_FILE");
- if (logFileName)
- log = new FileLog(logFileName);
- else
+ if (logFileName) {
+ if (strcmp(logFileName,"SYSLOG") == 0) {
+ log = new SysLog();
+ } else {
+ log = new FileLog(logFileName);
+ }
+ } else {
log = new DummyLog();
+ }
log->log("Initialize called, hello %d\n", 5);
CKY_SetName("coolkey");
slotList = new SlotList(log);
diff --git a/src/coolkey/log.cpp b/src/coolkey/log.cpp
index bfe312e..66aaab5 100644
--- a/src/coolkey/log.cpp
+++ b/src/coolkey/log.cpp
@@ -24,6 +24,9 @@
#include "log.h"
#include <cstdarg>
#include "PKCS11Exception.h"
+#ifndef _WIN32
+#include "syslog.h"
+#endif
FileLog::FileLog(const char *filename )
@@ -81,3 +84,30 @@ FileLog::~FileLog()
{
fclose(file);
}
+
+
+void
+SysLog::log(const char *msg, ...)
+{
+#ifndef _WIN32
+
+#define COOLKEY_PREFIX "libcoolkey:"
+ va_list ap;
+ char *msg2;
+
+ va_start(ap, msg);
+
+ msg2 = (char *)malloc(strlen(msg)+sizeof(COOLKEY_PREFIX));
+ if (msg2) {
+ strcpy(msg2, COOLKEY_PREFIX);
+ strcat(msg2, msg);
+
+ vsyslog(LOG_WARNING, msg2, ap);
+ free(msg2);
+ } else {
+ vsyslog(LOG_WARNING, msg, ap);
+ }
+
+ va_end(ap);
+#endif
+}
diff --git a/src/coolkey/log.h b/src/coolkey/log.h
index 015c7bf..b3c8b59 100644
--- a/src/coolkey/log.h
+++ b/src/coolkey/log.h
@@ -58,9 +58,9 @@ class SysLog : public Log {
SysLog(SysLog &) {}
SysLog & operator=(SysLog &) { return *this; }
public:
- SysLog() { }
+ SysLog() {}
void log(const char *msg, ...);
- virtual ~SysLog() { }
+ virtual ~SysLog() {}
};
#endif
diff --git a/src/coolkey/slot.cpp b/src/coolkey/slot.cpp
index af151c3..08deebe 100644
--- a/src/coolkey/slot.cpp
+++ b/src/coolkey/slot.cpp
@@ -2082,7 +2082,7 @@ Slot::loadCACCert(CKYByte instance)
* is now valid */
shmem.setValid();
}
-
+ return;
}
}