Browse Source

[iSCSI] Offer CHAP authentication only if we have a username and password

Some EMC targets will fail if we advertise that we can authenticate with
CHAP, but the target is configured to allow unauthenticated access to that
target.  We advertise AuthMethod=CHAP,None; the target should (I think)
select AuthMethod=None for unprotected targets.  IETD does this, but an
EMC Celerra NS83 doesn't.

Fix by offering only AuthMethod=None if the user hasn't supplied a
username and password; this means that we won't be offering CHAP
authentication unless the user is expecting to use it (in which case the
target is presumably configured appropriately).

Many thanks to Alessandro Iurlano <alessandro.iurlano@gmail.com> for
reporting and helping to diagnose this problem.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
00ed567069
1 changed files with 5 additions and 4 deletions
  1. 5
    4
      src/net/tcp/iscsi.c

+ 5
- 4
src/net/tcp/iscsi.c View File

456
 				    "InitiatorName=%s%c"
456
 				    "InitiatorName=%s%c"
457
 				    "TargetName=%s%c"
457
 				    "TargetName=%s%c"
458
 				    "SessionType=Normal%c"
458
 				    "SessionType=Normal%c"
459
-				    "AuthMethod=CHAP,None%c",
459
+				    "AuthMethod=%sNone%c",
460
 				    iscsi_initiator_iqn(), 0,
460
 				    iscsi_initiator_iqn(), 0,
461
-				    iscsi->target_iqn, 0, 0, 0 );
461
+				    iscsi->target_iqn, 0, 0,
462
+				    ( ( iscsi->username && iscsi->password ) ?
463
+				      "CHAP," : "" ), 0 );
462
 	}
464
 	}
463
 
465
 
464
 	if ( iscsi->status & ISCSI_STATUS_STRINGS_CHAP_ALGORITHM ) {
466
 	if ( iscsi->status & ISCSI_STATUS_STRINGS_CHAP_ALGORITHM ) {
465
 		used += ssnprintf ( data + used, len - used, "CHAP_A=5%c", 0 );
467
 		used += ssnprintf ( data + used, len - used, "CHAP_A=5%c", 0 );
466
 	}
468
 	}
467
 	
469
 	
468
-	if ( ( iscsi->status & ISCSI_STATUS_STRINGS_CHAP_RESPONSE ) &&
469
-	     iscsi->username ) {
470
+	if ( ( iscsi->status & ISCSI_STATUS_STRINGS_CHAP_RESPONSE ) ) {
470
 		used += ssnprintf ( data + used, len - used,
471
 		used += ssnprintf ( data + used, len - used,
471
 				    "CHAP_N=%s%cCHAP_R=0x",
472
 				    "CHAP_N=%s%cCHAP_R=0x",
472
 				    iscsi->username, 0 );
473
 				    iscsi->username, 0 );

Loading…
Cancel
Save