mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 16:57:00 +08:00
remove_proc() calls remove_from_script_list().
This will prevent a race in the case where a proc is deleted (i.e., user is disconnected) but a running script terminates afterwards and tries to reference the deleted proc.
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include <route-add.h>
|
||||
#include <ip-lease.h>
|
||||
#include <ipc.pb-c.h>
|
||||
#include <script-list.h>
|
||||
|
||||
#include <vpn.h>
|
||||
#include <cookies.h>
|
||||
@@ -270,6 +271,7 @@ void remove_proc(main_server_st* s, struct proc_st *proc, unsigned k)
|
||||
if (k)
|
||||
kill(proc->pid, SIGTERM);
|
||||
|
||||
remove_from_script_list(s, proc);
|
||||
user_disconnected(s, proc);
|
||||
|
||||
/* close the intercomm fd */
|
||||
|
||||
@@ -422,10 +422,10 @@ struct script_wait_st *stmp = NULL, *spos;
|
||||
list_for_each_safe(&s->script_list.head, stmp, spos, list) {
|
||||
if (stmp->pid == pid) {
|
||||
mslog(s, stmp->proc, LOG_DEBUG, "%s-script exit status: %u", stmp->up?"connect":"disconnect", estatus);
|
||||
list_del(&stmp->list);
|
||||
ret = handle_script_exit(s, stmp->proc, estatus);
|
||||
if (ret < 0)
|
||||
remove_proc(s, stmp->proc, 1);
|
||||
list_del(&stmp->list);
|
||||
free(stmp);
|
||||
break;
|
||||
}
|
||||
@@ -1021,7 +1021,6 @@ fork_failed:
|
||||
if (FD_ISSET(ctmp->fd, &rd_set)) {
|
||||
ret = handle_commands(&s, ctmp);
|
||||
if (ret < 0) {
|
||||
remove_from_script_list(&s, ctmp);
|
||||
remove_proc(&s, ctmp, (ret!=ERR_WORKER_TERMINATED)?1:0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user