Diff

Differences From Artifact [b4f00ff994]:

To Artifact [1a206186e3]:


  5208   5208   	}
  5209   5209   
  5210   5210   	pincmd = cackey_pin_command;
  5211   5211   	if (pincmd != NULL) {
  5212   5212   		CACKEY_DEBUG_PRINTF("CACKEY_PIN_COMMAND = %s", pincmd);
  5213   5213   
  5214   5214   		if (pPin != NULL) {
  5215         -			CACKEY_DEBUG_PRINTF("Error.  Protected authentication path in effect and PIN provided !?");
  5216         -
  5217         -			cackey_mutex_unlock(cackey_biglock);
  5218         -
  5219         -			return(CKR_GENERAL_ERROR);
         5215  +			CACKEY_DEBUG_PRINTF("Protected authentication path in effect and PIN provided !?");
  5220   5216   		}
  5221   5217   
  5222   5218   		pinfd = popen(pincmd, "r");
  5223   5219   		if (pinfd == NULL) {
  5224   5220   			CACKEY_DEBUG_PRINTF("Error.  %s: Unable to run", pincmd);
  5225   5221   
  5226   5222   			cackey_mutex_unlock(cackey_biglock);
         5223  +
         5224  +			CACKEY_DEBUG_PRINTF("Returning CKR_PIN_INCORRECT (%i)", (int) CKR_PIN_INCORRECT);
  5227   5225   
  5228   5226   			return(CKR_PIN_INCORRECT);
  5229   5227   		}
  5230   5228   
  5231   5229   		fgets_ret = fgets(pinbuf, sizeof(pinbuf), pinfd);
  5232   5230   		if (fgets_ret == NULL) {
  5233   5231   			pinbuf[0] = '\0';
................................................................................
  5235   5233   
  5236   5234   		pclose_ret = pclose(pinfd);
  5237   5235   		if (pclose_ret != 0) {
  5238   5236   			CACKEY_DEBUG_PRINTF("Error.  %s: exited with non-zero status of %i", pincmd, pclose_ret);
  5239   5237   
  5240   5238   			cackey_mutex_unlock(cackey_biglock);
  5241   5239   
         5240  +			CACKEY_DEBUG_PRINTF("Returning CKR_PIN_INCORRECT (%i)", (int) CKR_PIN_INCORRECT);
         5241  +
  5242   5242   			return(CKR_PIN_INCORRECT);
  5243   5243   		}
  5244   5244   
  5245   5245   		if (strlen(pinbuf) < 1) {
  5246   5246   			CACKEY_DEBUG_PRINTF("Error.  %s: returned no data", pincmd);
  5247   5247   
  5248   5248   			cackey_mutex_unlock(cackey_biglock);
         5249  +
         5250  +			CACKEY_DEBUG_PRINTF("Returning CKR_PIN_INCORRECT (%i)", (int) CKR_PIN_INCORRECT);
  5249   5251   
  5250   5252   			return(CKR_PIN_INCORRECT);
  5251   5253   		}
  5252   5254   
  5253   5255   		if (pinbuf[strlen(pinbuf) - 1] == '\n') {
  5254   5256   			pinbuf[strlen(pinbuf) - 1] = '\0';
  5255   5257   		}
................................................................................
  5263   5265   		cackey_mutex_unlock(cackey_biglock);
  5264   5266   
  5265   5267   		if (login_ret == CACKEY_PCSC_E_LOCKED) {
  5266   5268   			CACKEY_DEBUG_PRINTF("Error.  Token is locked.");
  5267   5269   
  5268   5270   			cackey_slots[slotID].token_flags |= CKF_USER_PIN_LOCKED;
  5269   5271   
         5272  +			CACKEY_DEBUG_PRINTF("Returning CKR_PIN_LOCKED (%i)", (int) CKR_PIN_LOCKED);
         5273  +
  5270   5274   			return(CKR_PIN_LOCKED);
  5271   5275   		} else if (login_ret == CACKEY_PCSC_E_BADPIN) {
  5272   5276   			CACKEY_DEBUG_PRINTF("Error.  Invalid PIN.");
  5273   5277   
  5274   5278   			cackey_slots[slotID].token_flags |= CKF_USER_PIN_COUNT_LOW;
  5275   5279   
  5276   5280   			if (tries_remaining == 1) {
  5277   5281   				cackey_slots[slotID].token_flags |= CKF_USER_PIN_FINAL_TRY;
  5278   5282   			}
         5283  +
         5284  +			CACKEY_DEBUG_PRINTF("Returning CKR_PIN_INCORRECT (%i)", (int) CKR_PIN_INCORRECT);
  5279   5285   
  5280   5286   			return(CKR_PIN_INCORRECT);
  5281   5287   		}
  5282   5288   
  5283   5289   		CACKEY_DEBUG_PRINTF("Error.  Unknown error returned from cackey_login() (%i)", login_ret);
  5284   5290   
  5285   5291   		return(CKR_GENERAL_ERROR);