@@ -559,10 +559,7 @@ static void add_nas_ip_address(AUTH_HDR *request, CONST char *hostname) {
559
559
}
560
560
561
561
/*
562
- * Add a RADIUS password attribute to the packet. Some magic is done here.
563
- *
564
- * If it's an PW_OLD_PASSWORD attribute, it's encrypted using the encrypted
565
- * PW_USER_PASSWORD attribute as the initialization vector.
562
+ * Add a RADIUS password attribute to the packet.
566
563
*
567
564
* If the password attribute already exists, it's over-written. This allows
568
565
* us to simply call add_password to update the password for different
@@ -593,12 +590,7 @@ static void add_password(AUTH_HDR *request, uint8_t type, CONST char *password,
593
590
} /* 16*N maps to itself */
594
591
595
592
attr = find_attribute (request , PW_USER_PASSWORD );
596
-
597
- if (type == PW_USER_PASSWORD ) {
598
- vector = request -> vector ;
599
- } else {
600
- vector = attr -> data ; /* attr CANNOT be NULL here. */
601
- }
593
+ vector = request -> vector ;
602
594
603
595
/* ************************************************************ */
604
596
/* encrypt the password */
@@ -618,14 +610,10 @@ static void add_password(AUTH_HDR *request, uint8_t type, CONST char *password,
618
610
xor (& hashed [i * AUTH_PASS_LEN ], misc , AUTH_PASS_LEN );
619
611
}
620
612
621
- if (type == PW_OLD_PASSWORD ) {
622
- attr = find_attribute (request , PW_OLD_PASSWORD );
623
- }
624
-
625
613
if (!attr ) {
626
614
add_attribute (request , type , hashed , length );
627
615
} else {
628
- memcpy (attr -> data , hashed , length ); /* overwrite the packet */
616
+ memcpy (attr -> data , hashed , length ); /* overwrite the old value of the attribute */
629
617
}
630
618
}
631
619
@@ -976,7 +964,7 @@ static void build_radius_packet(AUTH_HDR *request, CONST char *user, CONST char
976
964
* Send a packet and get the response
977
965
*/
978
966
static int talk_radius (radius_conf_t * conf , AUTH_HDR * request , AUTH_HDR * response ,
979
- char * password , char * old_password , int tries )
967
+ char * password , int tries )
980
968
{
981
969
int total_length ;
982
970
#ifdef HAVE_POLL_H
@@ -1139,8 +1127,6 @@ static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *respons
1139
1127
1140
1128
/* there's data, see if it's valid */
1141
1129
} else {
1142
- CONST char * p = server -> secret ;
1143
-
1144
1130
if ((ntohs (response -> length ) != total_length ) ||
1145
1131
(ntohs (response -> length ) > BUFFER_SIZE )) {
1146
1132
_pam_log (LOG_ERR , "RADIUS packet from server %s is corrupted" ,
@@ -1149,13 +1135,6 @@ static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *respons
1149
1135
break ;
1150
1136
}
1151
1137
1152
- /* Check if we have the data OK. We should also check request->id */
1153
- if (password ) {
1154
- if (old_password ) {
1155
- p = old_password ; /* what it should be */
1156
- }
1157
- }
1158
-
1159
1138
/*
1160
1139
* Check that the response ID matches the request ID.
1161
1140
*/
@@ -1182,7 +1161,7 @@ static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *respons
1182
1161
break ;
1183
1162
}
1184
1163
1185
- if (!verify_packet (p , response , request )) {
1164
+ if (!verify_packet (server -> secret , response , request )) {
1186
1165
_pam_log (LOG_ERR , "packet from RADIUS server %s failed verification: "
1187
1166
"The shared secret is probably incorrect." , server -> hostname );
1188
1167
ok = FALSE;
@@ -1222,12 +1201,7 @@ static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *respons
1222
1201
/* update passwords, as appropriate */
1223
1202
if (password ) {
1224
1203
get_random_vector (request -> vector );
1225
- if (old_password ) { /* password change request */
1226
- add_password (request , PW_USER_PASSWORD , password , old_password );
1227
- add_password (request , PW_OLD_PASSWORD , old_password , old_password );
1228
- } else { /* authentication request */
1229
- add_password (request , PW_USER_PASSWORD , password , server -> secret );
1230
- }
1204
+ add_password (request , PW_USER_PASSWORD , password , server -> secret );
1231
1205
}
1232
1206
}
1233
1207
continue ;
@@ -1439,7 +1413,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
1439
1413
1440
1414
DPRINT (LOG_DEBUG , "Sending RADIUS request code %d (%s)" , request -> code , get_packet_name (request -> code ));
1441
1415
1442
- retval = talk_radius (& config , request , response , password , NULL , config .retries + 1 );
1416
+ retval = talk_radius (& config , request , response , password , config .retries + 1 );
1443
1417
PAM_FAIL_CHECK ;
1444
1418
1445
1419
DPRINT (LOG_DEBUG , "Got RADIUS response code %d (%s)" , response -> code , get_packet_name (response -> code ));
@@ -1507,7 +1481,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
1507
1481
/* copy the state over from the servers response */
1508
1482
add_attribute (request , PW_STATE , a_state -> data , a_state -> length - 2 );
1509
1483
1510
- retval = talk_radius (& config , request , response , resp2challenge , NULL , 1 );
1484
+ retval = talk_radius (& config , request , response , resp2challenge , 1 );
1511
1485
PAM_FAIL_CHECK ;
1512
1486
1513
1487
DPRINT (LOG_DEBUG , "Got response to challenge code %d" , response -> code );
@@ -1714,7 +1688,7 @@ static int pam_private_session(pam_handle_t *pamh, UNUSED int flags, int argc, C
1714
1688
add_attribute (request , PW_CALLING_STATION_ID , (const uint8_t * ) rhost , strlen (rhost ));
1715
1689
}
1716
1690
1717
- retval = talk_radius (& config , request , response , NULL , NULL , 1 );
1691
+ retval = talk_radius (& config , request , response , NULL , 1 );
1718
1692
PAM_FAIL_CHECK ;
1719
1693
1720
1694
/* oops! They don't have the right password. Complain and die. */
0 commit comments