Skip to content

Commit 3857f08

Browse files
committed
exec offline hook before unexpected exit
1 parent 20b1ba1 commit 3857f08

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/auth.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void loginToGetServerMAC(uint8_t recv_data[]) {
379379
// 初始化服务器MAC地址
380380
memcpy(EthHeader, recv_data + 6, 6);
381381
if(auth_8021x_Handler(recv_data))
382-
exit(EXIT_FAILURE); //这里不需要考虑重拨的问题,正常第一个请求是Identity,不会失败。
382+
exit_with_hook(EXIT_FAILURE); //这里不需要考虑重拨的问题,正常第一个请求是Identity,不会失败。
383383
return;
384384
} else {
385385
continue;
@@ -391,7 +391,7 @@ void loginToGetServerMAC(uint8_t recv_data[]) {
391391
LogWrite(DOT1X, ERROR, "Error! No Response");
392392
// 确保下线
393393
auth_8021x_Logoff();
394-
exit(EXIT_FAILURE);
394+
exit_with_hook(EXIT_FAILURE);
395395
}
396396

397397
times--;
@@ -644,7 +644,7 @@ int auth_8021x_Handler(uint8_t recv_data[]) {
644644
return 1;
645645
} else {
646646
LogWrite(DOT1X, ERROR, "Reconnection failed. Server: errtype=0x%02hhx", errtype);
647-
exit(EXIT_FAILURE);
647+
exit_with_hook(EXIT_FAILURE);
648648
}
649649
} else if ((EAP_Code) recv_data[18] == SUCCESS) {
650650
LogWrite(DOT1X, INF, "Server: Success.");
@@ -669,3 +669,9 @@ int auth_8021x_Handler(uint8_t recv_data[]) {
669669
}
670670
return 0;
671671
}
672+
673+
void exit_with_hook(int a) {
674+
if (OfflineHookCmd)
675+
system(OfflineHookCmd);
676+
exit(a);
677+
}

src/auth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ int Drcom_UDP_Handler(uint8_t *recv_data);
4646
void initAuthenticationInfo();
4747
void loginToGetServerMAC(uint8_t recv_data[]);
4848
void printIfInfo();
49-
49+
void exit_with_hook(int a);

0 commit comments

Comments
 (0)