[pkg-opensc-commit] [pkcs11-helper] 46/53: Add logout verb
Eric Dorland
eric at moszumanska.debian.org
Fri Jan 6 23:39:55 UTC 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to tag pkcs11-helper-1.03
in repository pkcs11-helper.
commit 233c7b4699f075ad62d898f01ec400bb082e9e35
Author: alonbl <alonbl at 485eb718-1723-0410-b8a9-88cf21a28c35>
Date: Sat Jun 9 16:38:13 2007 +0000
Add logout verb
---
ChangeLog | 2 +
include/pkcs11-helper-1.0/pkcs11h-core.h | 7 ++++
include/pkcs11-helper-1.0/pkcs11h-token.h | 10 +++++
lib/pkcs11h-core.c | 44 ++++++++++++++++++++
lib/pkcs11h-token.c | 67 +++++++++++++++++++++++++++++++
5 files changed, 130 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 7acff5a..9968155 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,8 @@ $Id$
* Allow several engines to co-exist, so application may select its
favorite.
+* Add logout verb.
+
2007-10-05 - Version 1.02
* Switch to free implementation of PKCS#11 headers.
diff --git a/include/pkcs11-helper-1.0/pkcs11h-core.h b/include/pkcs11-helper-1.0/pkcs11h-core.h
index efcb54a..c89fe7a 100644
--- a/include/pkcs11-helper-1.0/pkcs11h-core.h
+++ b/include/pkcs11-helper-1.0/pkcs11h-core.h
@@ -550,6 +550,13 @@ pkcs11h_forkFixup (void);
CK_RV
pkcs11h_plugAndPlay (void);
+/**
+ * @brief Logout from all sessions.
+ * @return CK_RV.
+ */
+CK_RV
+pkcs11h_logout (void);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/pkcs11-helper-1.0/pkcs11h-token.h b/include/pkcs11-helper-1.0/pkcs11h-token.h
index 0a1f4ae..6d081ce 100644
--- a/include/pkcs11-helper-1.0/pkcs11h-token.h
+++ b/include/pkcs11-helper-1.0/pkcs11h-token.h
@@ -126,6 +126,16 @@ pkcs11h_token_sameTokenId (
);
/**
+ * @brief Force logout.
+ * @param token_id Token to login into.
+ * @return CK_RV.
+ */
+CK_RV
+pkcs11h_token_logout (
+ IN const pkcs11h_token_id_t token_id
+);
+
+/**
* @brief Force login, avoid hooks.
* @param token_id Token to login into.
* @param readonly Should session be readonly.
diff --git a/lib/pkcs11h-core.c b/lib/pkcs11h-core.c
index 9f55852..2d79e64 100644
--- a/lib/pkcs11h-core.c
+++ b/lib/pkcs11h-core.c
@@ -64,6 +64,7 @@
#include "_pkcs11h-crypto.h"
#include "_pkcs11h-util.h"
#include "_pkcs11h-core.h"
+#include "_pkcs11h-session.h"
#include "_pkcs11h-slotevent.h"
/*======================================================================*
@@ -1038,6 +1039,49 @@ pkcs11h_plugAndPlay (void) {
return CKR_OK;
}
+CK_RV
+pkcs11h_logout (void) {
+ _pkcs11h_session_t current_session = NULL;
+ CK_RV rv = CKR_OK;
+
+ _PKCS11H_DEBUG (
+ PKCS11H_LOG_DEBUG2,
+ "PKCS#11: pkcs11h_logout entry"
+ );
+
+ for (
+ current_session = _g_pkcs11h_data->sessions;
+ current_session != NULL;
+ current_session = current_session->next
+ ) {
+ CK_RV _rv;
+
+#if defined(ENABLE_PKCS11H_THREADING)
+ if ((_rv = _pkcs11h_threading_mutexLock (¤t_session->mutex)) == CKR_OK) {
+#else
+ {
+#endif
+ _rv = _pkcs11h_session_logout (current_session);
+#if defined(ENABLE_PKCS11H_THREADING)
+ _pkcs11h_threading_mutexRelease (¤t_session->mutex);
+#endif
+ }
+
+ if (_rv != CKR_OK) {
+ rv = _rv;
+ }
+ }
+
+ _PKCS11H_DEBUG (
+ PKCS11H_LOG_DEBUG2,
+ "PKCS#11: pkcs11h_logout return rv=%lu-'%s'",
+ rv,
+ pkcs11h_getMessage (rv)
+ );
+
+ return rv;
+}
+
/*======================================================================*
* COMMON INTERNAL INTERFACE
*======================================================================*/
diff --git a/lib/pkcs11h-token.c b/lib/pkcs11h-token.c
index 5eb0e77..33aadd5 100644
--- a/lib/pkcs11h-token.c
+++ b/lib/pkcs11h-token.c
@@ -262,6 +262,73 @@ cleanup:
}
CK_RV
+pkcs11h_token_logout (
+ IN const pkcs11h_token_id_t token_id
+) {
+#if defined(ENABLE_PKCS11H_THREADING)
+ PKCS11H_BOOL mutex_locked = FALSE;
+#endif
+ CK_RV rv = CKR_FUNCTION_FAILED;
+
+ _pkcs11h_session_t session = NULL;
+
+ _PKCS11H_ASSERT (token_id!=NULL);
+
+ _PKCS11H_DEBUG (
+ PKCS11H_LOG_DEBUG2,
+ "PKCS#11: pkcs11h_token_logout entry token_id=%p\n",
+ (void *)token_id
+ );
+
+ if (
+ (rv = _pkcs11h_session_getSessionByTokenId (
+ token_id,
+ &session
+ )) != CKR_OK
+ ) {
+ goto cleanup;
+ }
+
+#if defined(ENABLE_PKCS11H_THREADING)
+ if ((rv = _pkcs11h_threading_mutexLock (&session->mutex)) != CKR_OK) {
+ goto cleanup;
+ }
+ mutex_locked = TRUE;
+#endif
+
+ if (
+ (rv = _pkcs11h_session_logout (session)) != CKR_OK
+ ) {
+ goto cleanup;
+ }
+
+ rv = CKR_OK;
+
+cleanup:
+
+#if defined(ENABLE_PKCS11H_THREADING)
+ if (mutex_locked) {
+ _pkcs11h_threading_mutexRelease (&session->mutex);
+ mutex_locked = FALSE;
+ }
+#endif
+
+ if (session != NULL) {
+ _pkcs11h_session_release (session);
+ session = NULL;
+ }
+
+ _PKCS11H_DEBUG (
+ PKCS11H_LOG_DEBUG2,
+ "PKCS#11: pkcs11h_token_logout return rv=%lu-'%s'",
+ rv,
+ pkcs11h_getMessage (rv)
+ );
+
+ return rv;
+}
+
+CK_RV
pkcs11h_token_login (
IN const pkcs11h_token_id_t token_id,
IN const PKCS11H_BOOL readonly,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/pkcs11-helper.git
More information about the pkg-opensc-commit
mailing list