Skip to content

Commit 021bbfe

Browse files
committed
remove "Old-Password" support.
It has been deprecated since at least 1997 in RFC 2058
1 parent 186af5e commit 021bbfe

File tree

2 files changed

+9
-36
lines changed

2 files changed

+9
-36
lines changed

src/pam_radius_auth.c

+9-35
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,7 @@ static void add_nas_ip_address(AUTH_HDR *request, CONST char *hostname) {
559559
}
560560

561561
/*
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.
566563
*
567564
* If the password attribute already exists, it's over-written. This allows
568565
* 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,
593590
} /* 16*N maps to itself */
594591

595592
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;
602594

603595
/* ************************************************************ */
604596
/* encrypt the password */
@@ -618,14 +610,10 @@ static void add_password(AUTH_HDR *request, uint8_t type, CONST char *password,
618610
xor(&hashed[i * AUTH_PASS_LEN], misc, AUTH_PASS_LEN);
619611
}
620612

621-
if (type == PW_OLD_PASSWORD) {
622-
attr = find_attribute(request, PW_OLD_PASSWORD);
623-
}
624-
625613
if (!attr) {
626614
add_attribute(request, type, hashed, length);
627615
} else {
628-
memcpy(attr->data, hashed, length); /* overwrite the packet */
616+
memcpy(attr->data, hashed, length); /* overwrite the old value of the attribute */
629617
}
630618
}
631619

@@ -976,7 +964,7 @@ static void build_radius_packet(AUTH_HDR *request, CONST char *user, CONST char
976964
* Send a packet and get the response
977965
*/
978966
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)
980968
{
981969
int total_length;
982970
#ifdef HAVE_POLL_H
@@ -1139,8 +1127,6 @@ static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *respons
11391127

11401128
/* there's data, see if it's valid */
11411129
} else {
1142-
CONST char *p = server->secret;
1143-
11441130
if ((ntohs(response->length) != total_length) ||
11451131
(ntohs(response->length) > BUFFER_SIZE)) {
11461132
_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
11491135
break;
11501136
}
11511137

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-
11591138
/*
11601139
* Check that the response ID matches the request ID.
11611140
*/
@@ -1182,7 +1161,7 @@ static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *respons
11821161
break;
11831162
}
11841163

1185-
if (!verify_packet(p, response, request)) {
1164+
if (!verify_packet(server->secret, response, request)) {
11861165
_pam_log(LOG_ERR, "packet from RADIUS server %s failed verification: "
11871166
"The shared secret is probably incorrect.", server->hostname);
11881167
ok = FALSE;
@@ -1222,12 +1201,7 @@ static int talk_radius(radius_conf_t *conf, AUTH_HDR *request, AUTH_HDR *respons
12221201
/* update passwords, as appropriate */
12231202
if (password) {
12241203
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);
12311205
}
12321206
}
12331207
continue;
@@ -1439,7 +1413,7 @@ PAM_EXTERN int pam_sm_authenticate(pam_handle_t *pamh, UNUSED int flags, int arg
14391413

14401414
DPRINT(LOG_DEBUG, "Sending RADIUS request code %d (%s)", request->code, get_packet_name(request->code));
14411415

1442-
retval = talk_radius(&config, request, response, password, NULL, config.retries + 1);
1416+
retval = talk_radius(&config, request, response, password, config.retries + 1);
14431417
PAM_FAIL_CHECK;
14441418

14451419
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
15071481
/* copy the state over from the servers response */
15081482
add_attribute(request, PW_STATE, a_state->data, a_state->length - 2);
15091483

1510-
retval = talk_radius(&config, request, response, resp2challenge, NULL, 1);
1484+
retval = talk_radius(&config, request, response, resp2challenge, 1);
15111485
PAM_FAIL_CHECK;
15121486

15131487
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
17141688
add_attribute(request, PW_CALLING_STATION_ID, (const uint8_t *) rhost, strlen(rhost));
17151689
}
17161690

1717-
retval = talk_radius(&config, request, response, NULL, NULL, 1);
1691+
retval = talk_radius(&config, request, response, NULL, 1);
17181692
PAM_FAIL_CHECK;
17191693

17201694
/* oops! They don't have the right password. Complain and die. */

src/radius.h

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ typedef struct pw_auth_hdr {
8080
#define PW_LOGIN_HOST 14
8181
#define PW_LOGIN_SERVICE 15
8282
#define PW_LOGIN_TCP_PORT 16
83-
#define PW_OLD_PASSWORD 17
8483
#define PW_REPLY_MESSAGE 18
8584
#define PW_CALLBACK_NUMBER 19
8685
#define PW_CALLBACK_ID 20

0 commit comments

Comments
 (0)