mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
ensure that in all cases the tun fd is closed
This commit is contained in:
@@ -128,11 +128,9 @@ int handle_script_exit(main_server_st *s, struct proc_st *proc, int code)
|
||||
* The parent doesn't need to keep the tunfd, and if it does,
|
||||
* it causes issues to client.
|
||||
*/
|
||||
if (proc->tun_lease.name[0] != 0) {
|
||||
if (proc->tun_lease.fd >= 0)
|
||||
close(proc->tun_lease.fd);
|
||||
proc->tun_lease.fd = -1;
|
||||
}
|
||||
if (proc->tun_lease.fd >= 0)
|
||||
close(proc->tun_lease.fd);
|
||||
proc->tun_lease.fd = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ void mslog_hex(const main_server_st * s, const struct proc_st* proc,
|
||||
int priority, const char *prefix, uint8_t* bin, unsigned bin_size, unsigned b64);
|
||||
|
||||
int open_tun(main_server_st* s, struct proc_st* proc);
|
||||
int close_tun(main_server_st* s, struct proc_st* proc);
|
||||
void close_tun(main_server_st* s, struct proc_st* proc);
|
||||
int set_tun_mtu(main_server_st* s, struct proc_st * proc, unsigned mtu);
|
||||
|
||||
int send_cookie_auth_reply(main_server_st* s, struct proc_st* proc,
|
||||
|
||||
11
src/tun.c
11
src/tun.c
@@ -436,9 +436,9 @@ int open_tun(main_server_st * s, struct proc_st *proc)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int close_tun(main_server_st * s, struct proc_st *proc)
|
||||
void close_tun(main_server_st * s, struct proc_st *proc)
|
||||
{
|
||||
int fd = -1, ret = 0;
|
||||
int fd = -1;
|
||||
|
||||
#ifdef SIOCIFDESTROY
|
||||
int e;
|
||||
@@ -463,5 +463,10 @@ int close_tun(main_server_st * s, struct proc_st *proc)
|
||||
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
return ret;
|
||||
|
||||
if (proc->tun_lease.fd >= 0) {
|
||||
close(proc->tun_lease.fd);
|
||||
proc->tun_lease.fd = -1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user