View | Details | Raw Unified
Collapse All | Expand All

(-) pam_pkcs11-0.5.3/src/common/pkcs11.c (-2 / +5 lines)
 Lines 82-88   int init_pkcs11_module(pkcs11_handle_t * Link Here 
  /* initialise the module */
  /* initialise the module */
  rv = h->fl->C_Initialize(NULL);
  rv = h->fl->C_Initialize(NULL);
  if (rv != CKR_OK) {
  if (rv == CKR_OK)
    h->should_finalize = 1;
  else if (rv != CKR_CRYPTOKI_ALREADY_INITIALIZED) {
    set_error("C_Initialize() failed: %x", rv);
    set_error("C_Initialize() failed: %x", rv);
    return -1;
    return -1;
  }
  }
 Lines 170-176   void release_pkcs11_module(pkcs11_handle Link Here 
{
{
  /* finalise pkcs #11 module */
  /* finalise pkcs #11 module */
  if (h->fl != NULL)
  if (h->fl != NULL)
    h->fl->C_Finalize(NULL);
    if (h->should_finalize)
	    h->fl->C_Finalize(NULL);
  /* unload the module */
  /* unload the module */
  if (h->module_handle != NULL)
  if (h->module_handle != NULL)
    dlclose(h->module_handle);
    dlclose(h->module_handle);
(-) pam_pkcs11-0.5.3/src/common/pkcs11.h (+1 lines)
 Lines 136-141   typedef struct { Link Here 
typedef struct {
typedef struct {
  void *module_handle;
  void *module_handle;
  CK_FUNCTION_LIST_PTR fl;
  CK_FUNCTION_LIST_PTR fl;
  int should_finalize;
  slot_t *slots; 
  slot_t *slots; 
  CK_ULONG slot_count;
  CK_ULONG slot_count;
  CK_SESSION_HANDLE session;
  CK_SESSION_HANDLE session;
(-) pam_pkcs11-0.5.3/src/tools/pkcs11_eventmgr.c (-10 / +14 lines)
 Lines 283-297   int main(int argc, char *argv[]) { Link Here 
        return 1;
        return 1;
    }
    }
    /* open pkcs11 sesion */
    DBG("initialising pkcs #11 module...");
    rv = ph.fl->C_Initialize(NULL);
    if (rv != 0) {
        release_pkcs11_module(&ph);
        DBG1("C_Initialize() failed: %d", rv);
        return 1;
    }
    /* put my self into background if flag is set */
    /* put my self into background if flag is set */
    if (daemonize) {
    if (daemonize) {
	DBG("Going to be daemon...");
	DBG("Going to be daemon...");
 Lines 303-308   int main(int argc, char *argv[]) { Link Here 
	}
	}
    }
    }
    /* open pkcs11 sesion */
    DBG("initialising pkcs #11 module...");
    rv = ph.fl->C_Initialize(NULL);
    if (rv != 0) {
        release_pkcs11_module(&ph);
	if (ctx) scconf_free(ctx);
        DBG1("C_Initialize() failed: %d", rv);
        return 1;
    }
    ph.should_finalize = 1;
    /* 
    /* 
     * Wait endlessly for all events in the list of readers
     * Wait endlessly for all events in the list of readers
     * We only stop in case of an error
     * We only stop in case of an error
 Lines 324-330   int main(int argc, char *argv[]) { Link Here 
	   new_state = get_a_token();
	   new_state = get_a_token();
	   if (new_state == CARD_ERROR) {
	   if (new_state == CARD_ERROR) {
    		DBG("Error trying to get a token");
    		DBG("Error trying to get a token");
    		break;
    		rv = ph.fl->C_Finalize(NULL);
    		rv = ph.fl->C_Initialize(NULL);
		continue;
	   }
	   }
	   if (old_state == new_state ) { /* state unchanged */
	   if (old_state == new_state ) { /* state unchanged */
		/* on card not present, increase and check expire time */
		/* on card not present, increase and check expire time */