summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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;
}
}