mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
when we detect user disconnection, set the proper expiration time on their cookies
This commit is contained in:
@@ -257,8 +257,10 @@ struct cookie_entry_st *find_cookie_entry(struct cookie_entry_db_st* db, void *c
|
||||
if (e == NULL)
|
||||
return NULL;
|
||||
|
||||
if (e->expiration != -1 && e->expiration < time(0))
|
||||
if (e->expiration != -1 && e->expiration < time(0)) {
|
||||
delete_cookie(db, e);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -293,3 +295,15 @@ struct cookie_entry_st *new_cookie_entry(struct cookie_entry_db_st* db, proc_st
|
||||
talloc_free(t);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void delete_cookie(struct cookie_entry_db_st* db, struct cookie_entry_st *e)
|
||||
{
|
||||
if (e->proc) {
|
||||
syslog(LOG_ERR, "found proc that references cookie to be deleted!");
|
||||
e->proc->cookie_ptr = NULL;
|
||||
}
|
||||
htable_del(db->db, rehash(e, NULL), e);
|
||||
db->total--;
|
||||
talloc_free(e);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ void cookie_db_deinit(struct cookie_entry_db_st* db);
|
||||
void expire_cookies(struct cookie_entry_db_st* db);
|
||||
struct cookie_entry_st *new_cookie_entry(struct cookie_entry_db_st* db, proc_st *proc, void *cookie, unsigned cookie_size);
|
||||
struct cookie_entry_st *find_cookie_entry(struct cookie_entry_db_st* db, void *cookie, unsigned cookie_len);
|
||||
void delete_cookie(struct cookie_entry_db_st* db, struct cookie_entry_st *e);
|
||||
|
||||
inline static void revive_cookie(struct cookie_entry_st * e)
|
||||
{
|
||||
|
||||
@@ -174,7 +174,7 @@ time_t now = time(0);
|
||||
gnutls_datum_t key = {s->cookie_key, sizeof(s->cookie_key)};
|
||||
char str_ip[MAX_IP_STR+1];
|
||||
PROTOBUF_ALLOCATOR(pa, proc);
|
||||
struct cookie_entry_st *old;
|
||||
struct cookie_entry_st *old = NULL;
|
||||
|
||||
if (req->cookie.len == 0) {
|
||||
mslog(s, proc, LOG_INFO, "error in cookie size");
|
||||
|
||||
@@ -372,10 +372,7 @@ void remove_proc(main_server_st * s, struct proc_st *proc, unsigned k)
|
||||
/* expire any available cookies */
|
||||
if (proc->cookie_ptr) {
|
||||
proc->cookie_ptr->proc = NULL;
|
||||
/* if we use session control and we closed the session we
|
||||
* need to invalidate the cookie, so that a new session is
|
||||
* used on the next connection */
|
||||
proc->cookie_ptr->expiration = 1;
|
||||
proc->cookie_ptr->expiration = time(0) + s->config->cookie_timeout;
|
||||
}
|
||||
|
||||
close_tun(s, proc);
|
||||
|
||||
Reference in New Issue
Block a user