mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-03-13 06:48:13 +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,
|
* The parent doesn't need to keep the tunfd, and if it does,
|
||||||
* it causes issues to client.
|
* it causes issues to client.
|
||||||
*/
|
*/
|
||||||
if (proc->tun_lease.name[0] != 0) {
|
if (proc->tun_lease.fd >= 0)
|
||||||
if (proc->tun_lease.fd >= 0)
|
close(proc->tun_lease.fd);
|
||||||
close(proc->tun_lease.fd);
|
proc->tun_lease.fd = -1;
|
||||||
proc->tun_lease.fd = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
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 priority, const char *prefix, uint8_t* bin, unsigned bin_size, unsigned b64);
|
||||||
|
|
||||||
int open_tun(main_server_st* s, struct proc_st* proc);
|
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 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,
|
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;
|
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
|
#ifdef SIOCIFDESTROY
|
||||||
int e;
|
int e;
|
||||||
@@ -463,5 +463,10 @@ int close_tun(main_server_st * s, struct proc_st *proc)
|
|||||||
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
close(fd);
|
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