Check-in [6db637b204]
Overview
Comment:Added basic stub for adding support for checking if LOGIN_REQUIRED is needed
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | require-login-if-needed
Files: files | file ages | folders
SHA1:6db637b2046c57faaefe56d1a8d223ce5e9e41f8
User & Date: rkeene on 2012-07-24 15:55:06
Other Links: manifest | tags
Context
2015-05-04
16:02
Merged in trunk check-in: 6938f7a82c user: rkeene tags: require-login-if-needed
2012-07-24
15:55
Added basic stub for adding support for checking if LOGIN_REQUIRED is needed check-in: 6db637b204 user: rkeene tags: require-login-if-needed
2012-07-22
15:55
Create new branch named "require-login-if-needed" check-in: 459f215faf user: rkeene tags: require-login-if-needed
Changes

Modified cackey.c from [1be2f8a22e] to [711a90f529].

   833    833   
   834    834   	CACKEY_DEBUG_PRINTF("Returning 0x%lx", retval);
   835    835   
   836    836   	return(retval);
   837    837   }
   838    838   
   839    839   /* PC/SC Related Functions */
          840  +static cackey_ret cackey_login_required(struct cackey_slot *slot) {
          841  +	return(CACKEY_PCSC_E_NEEDLOGIN);
          842  +}
          843  +
   840    844   /*
   841    845    * SYNPOSIS
   842    846    *     void cackey_slots_disconnect_all(void);
   843    847    *
   844    848    * ARGUMENTS
   845    849    *     None
   846    850    *
................................................................................
  1002   1006   }
  1003   1007   
  1004   1008   /*
  1005   1009    * SYNPOSIS
  1006   1010    *     void cackey_mark_slot_reset(struct cackey_slot *slot);
  1007   1011    *
  1008   1012    * ARGUMENTS
  1009         - *     None
         1013  + *     ...
  1010   1014    *
  1011   1015    * RETURN VALUE
  1012   1016    *     None
  1013   1017    *
  1014   1018    * NOTES
  1015   1019    *     This function marks a slot has having been reset, to later be cleaned up.
  1016   1020    *     Cleanup only happens when a PKCS#11 client calls C_FindObjectsInit.
  1017   1021    *
  1018   1022    */
  1019   1023   static void cackey_mark_slot_reset(struct cackey_slot *slot) {
         1024  +	int login_required = -1;
         1025  +
  1020   1026   	if (slot == NULL) {
  1021   1027   		return;
  1022   1028   	}
  1023   1029   
  1024   1030   	CACKEY_DEBUG_PRINTF("Called.");
  1025   1031   
  1026   1032   	if (slot->pcsc_card_connected) {
  1027   1033   		SCardDisconnect(slot->pcsc_card, SCARD_LEAVE_CARD);
  1028   1034   	}
  1029   1035   
  1030   1036   	slot->slot_reset = 1;
  1031   1037   	slot->pcsc_card_connected = 0;
  1032         -	slot->token_flags = CKF_LOGIN_REQUIRED;
         1038  +	slot->token_flags = 0;
         1039  +
         1040  +	if (login_required == -1) {
         1041  +		if (cackey_login_required(slot) != CACKEY_PCSC_S_OK) {
         1042  +			login_required = 1;
         1043  +		} else {
         1044  +			login_required = 0;
         1045  +		}
         1046  +	}
         1047  +
         1048  +	if (login_required) {
         1049  +		slot->token_flags |= CKF_LOGIN_REQUIRED;
         1050  +	}
  1033   1051   
  1034   1052   	CACKEY_DEBUG_PRINTF("Returning.");
  1035   1053   
  1036   1054   	return;
  1037   1055   }
  1038   1056   
  1039   1057   /*
................................................................................
  2394   2412   			/* End transaction */
  2395   2413   			cackey_end_transaction(slot);
  2396   2414   
  2397   2415   			if (respcode == 0x6982) {
  2398   2416   				CACKEY_DEBUG_PRINTF("Security status not satisified.  Returning NEEDLOGIN");
  2399   2417   
  2400   2418   				cackey_mark_slot_reset(slot);
  2401         -				slot->token_flags = CKF_LOGIN_REQUIRED;
  2402   2419   
  2403   2420   				return(CACKEY_PCSC_E_NEEDLOGIN);
  2404   2421   			}
  2405   2422   
  2406   2423   			if (send_ret == CACKEY_PCSC_E_TOKENABSENT) {
  2407   2424   				CACKEY_DEBUG_PRINTF("Token absent.  Returning TOKENABSENT");
  2408   2425   
  2409   2426   				cackey_mark_slot_reset(slot);
  2410         -				slot->token_flags = CKF_LOGIN_REQUIRED;
  2411   2427   
  2412   2428   				return(CACKEY_PCSC_E_TOKENABSENT);
  2413   2429   			}
  2414   2430   
  2415   2431   			return(-1);
  2416   2432   		}
  2417   2433   
................................................................................
  3732   3748   					/* Only update the list of slots if we are actually being asked supply the slot information */
  3733   3749   					if (pSlotList) {
  3734   3750   						cackey_slots[currslot].active = 1;
  3735   3751   						cackey_slots[currslot].pcsc_reader = strdup(pcsc_readers);
  3736   3752   						cackey_slots[currslot].pcsc_card_connected = 0;
  3737   3753   						cackey_slots[currslot].transaction_depth = 0;
  3738   3754   						cackey_slots[currslot].transaction_need_hw_lock = 0;
  3739         -						cackey_slots[currslot].slot_reset = 1;
  3740         -						cackey_slots[currslot].token_flags = CKF_LOGIN_REQUIRED;
         3755  +						cackey_slots[currslot].token_flags = 0;
  3741   3756   						cackey_slots[currslot].label = NULL;
  3742   3757   
  3743   3758   						cackey_mark_slot_reset(&cackey_slots[currslot]);
  3744   3759   					}
  3745   3760   					currslot++;
  3746   3761   
  3747   3762   					pcsc_readers += curr_reader_len + 1;