|
Dillo v3.2.0-151-g90488cbf
|
#include <sys/types.h>#include <sys/socket.h>#include <sys/stat.h>#include <sys/un.h>#include <netinet/in.h>#include <fcntl.h>#include <unistd.h>#include <errno.h>#include <stddef.h>#include <string.h>#include <stdlib.h>#include <stdio.h>#include <time.h>#include <limits.h>#include <netdb.h>#include <signal.h>#include "dpiutil.h"#include "../dpip/dpip.h"
Go to the source code of this file.
Macros | |
| #define | _MSG(...) |
| #define | MSG(...) printf("[cookies dpi]: " __VA_ARGS__) |
| #define | a_List_add(list, num_items, alloc_step) |
| #define | LINE_MAXLEN 4096 |
| #define | MAX_DOMAIN_COOKIES 20 |
| #define | MAX_TOTAL_COOKIES 1200 |
Enumerations | |
| enum | CookieControlAction { COOKIE_ACCEPT , COOKIE_ACCEPT_SESSION , COOKIE_DENY } |
Functions | |
| static CookieControlAction | Cookies_control_check_domain (const char *domain) |
| static int | Cookie_control_init (void) |
| static void | Cookies_add_cookie (CookieData_t *cookie) |
| static int | Cookies_cmp (const void *a, const void *b) |
| static int | Domain_node_cmp (const void *v1, const void *v2) |
| static int | Domain_node_by_domain_cmp (const void *v1, const void *v2) |
| static void | Cookies_delete_node (DomainNode *node) |
| static FILE * | Cookies_fopen (const char *filename, const char *mode, const char *init_str) |
| static void | Cookies_free_cookie (CookieData_t *cookie) |
| static void | Cookies_tm_init (struct tm *tm) |
| static void | Cookies_load_cookies (FILE *stream) |
| static void | Cookies_init (void) |
| static void | Cookies_save_and_free (void) |
| static bool_t | Cookies_get_month (struct tm *tm, const char **str) |
| static int | Cookies_get_timefield (const char **str) |
| static bool_t | Cookies_get_time (struct tm *tm, const char **str) |
| static bool_t | Cookies_get_day (struct tm *tm, const char **str) |
| static bool_t | Cookies_get_year (struct tm *tm, const char **str) |
| static bool_t | Cookies_date_delim (char c) |
| static struct tm * | Cookies_parse_date (const char *date) |
| static CookieData_t * | Cookies_get_LRU (Dlist *cookies) |
| static int | Cookies_rm_expired_cookies (DomainNode *node) |
| static void | Cookies_too_many (DomainNode *node) |
| static char * | Cookies_parse_attr (char **cookie_str) |
| static char * | Cookies_parse_value (char **cookie_str) |
| static void | Cookies_eat_value (char **cookie_str) |
| static double | Cookies_server_timediff (const char *server_date) |
| static void | Cookies_unquote_string (char *str) |
| static CookieData_t * | Cookies_parse (char *cookie_str, const char *server_date) |
| static bool_t | Cookies_domain_is_ip (const char *domain) |
| static bool_t | Cookies_path_matches (const char *url_path, const char *cookie_path) |
| static void | Cookies_validate_path (CookieData_t *cookie, const char *url_path) |
| static bool_t | Cookies_domain_matches (char *A, char *B) |
| static uint_t | Cookies_internal_dots_required (const char *host) |
| static bool_t | Cookies_validate_domain (CookieData_t *cookie, char *host) |
| static int | Cookies_set (char *cookie_string, char *url_host, char *url_path, char *server_date) |
| static bool_t | Cookies_match (CookieData_t *cookie, const char *url_path, bool_t host_only_val, bool_t is_tls) |
| static void | Cookies_add_matching_cookies (const char *domain, const char *url_path, bool_t host_only_val, Dlist *matching_cookies, bool_t is_tls) |
| static char * | Cookies_get (char *url_host, char *url_path, char *url_scheme) |
| static int | srv_parse_tok (Dsh *sh, ClientInfo *client, char *Buf) |
| static void | cleanup (void) |
| static void | termination_handler (int signum) |
| int | main (void) |
Variables | |
| static Dlist * | all_cookies |
| static Dlist * | domains |
| static CookieControl * | ccontrol = NULL |
| static int | num_ccontrol = 0 |
| static int | num_ccontrol_max = 1 |
| static CookieControlAction | default_action = COOKIE_DENY |
| static long | cookies_use_counter = 0 |
| static bool_t | disabled |
| static FILE * | file_stream |
| static const char *const | cookies_txt_header_str |
| static struct tm | cookies_epoch_tm = {0, 0, 0, 1, 0, 70, 0, 0, 0, 0, 0} |
| static time_t | cookies_epoch_time |
| static time_t | cookies_future_time |
| #define a_List_add | ( | list, | |
| num_items, | |||
| alloc_step | |||
| ) |
| enum CookieControlAction |
|
static |
Definition at line 1619 of file cookies.c.
References Cookies_save_and_free(), and MSG.
Referenced by main().
|
static |
Definition at line 1417 of file cookies.c.
References a_List_add, ccontrol, COOKIE_ACCEPT, COOKIE_ACCEPT_SESSION, COOKIE_DENY, Cookies_fopen(), default_action, dFree(), dGethomedir(), dIsspace(), dStrAsciiCasecmp(), dStrconcat(), dStrdup(), dStrerror, dStrstrip(), FALSE, LINE_MAXLEN, MSG, num_ccontrol, num_ccontrol_max, and TRUE.
Referenced by a_Cookies_init(), and Cookies_init().
|
static |
Definition at line 724 of file cookies.c.
References _MSG, all_cookies, Cookies_cmp(), Cookies_delete_node(), Cookies_free_cookie(), Cookies_rm_expired_cookies(), Cookies_too_many(), cookies_use_counter, dList_append(), dList_find_custom(), dList_find_sorted(), dList_insert_sorted(), dList_length(), dList_new(), dList_remove(), dList_remove_fast(), dNew, Domain_node_by_domain_cmp(), Domain_node_cmp(), domains, dStrdup(), MAX_DOMAIN_COOKIES, and MAX_TOTAL_COOKIES.
Referenced by Cookies_load_cookies(), and Cookies_set().
|
static |
Definition at line 1272 of file cookies.c.
References _MSG, all_cookies, Cookies_delete_node(), Cookies_free_cookie(), Cookies_match(), cookies_use_counter, dList_find_sorted(), dList_insert_pos(), dList_length(), dList_nth_data(), dList_remove(), dList_remove_fast(), Domain_node_by_domain_cmp(), and domains.
Referenced by Cookies_get().
|
static |
Definition at line 1013 of file cookies.c.
Referenced by Cookies_add_cookie().
|
static |
Definition at line 1512 of file cookies.c.
References ccontrol, default_action, dStrAsciiCasecmp(), and num_ccontrol.
Referenced by Cookies_control_check(), Cookies_load_cookies(), and Cookies_set().
|
static |
Definition at line 587 of file cookies.c.
Referenced by Cookies_parse_date().
|
static |
Definition at line 178 of file cookies.c.
References dFree(), dList_free(), dList_remove(), and domains.
Referenced by Cookies_add_cookie(), Cookies_add_matching_cookies(), Cookies_rm_expired_cookies(), Cookies_save_and_free(), and Cookies_too_many().
|
static |
Definition at line 1025 of file cookies.c.
References _MSG, FALSE, MSG, and TRUE.
Referenced by Cookies_domain_matches(), and Cookies_get().
|
static |
Definition at line 1095 of file cookies.c.
References Cookies_domain_is_ip(), dStrAsciiCasecmp(), FALSE, and TRUE.
Referenced by Cookies_validate_domain().
|
static |
Definition at line 846 of file cookies.c.
Referenced by Cookies_parse().
|
static |
Definition at line 190 of file cookies.c.
References dStrerror, and MSG.
Referenced by Cookie_control_init(), and Cookies_init().
|
static |
Definition at line 224 of file cookies.c.
References dFree().
Referenced by Cookies_add_cookie(), Cookies_add_matching_cookies(), Cookies_load_cookies(), Cookies_rm_expired_cookies(), Cookies_save_and_free(), Cookies_set(), and Cookies_too_many().
|
static |
Definition at line 1320 of file cookies.c.
References Cookies_add_matching_cookies(), Cookies_domain_is_ip(), cookies_use_counter, dFree(), disabled, dList_free(), dList_length(), dList_new(), dList_nth_data(), dStr_append(), dStr_free(), dStr_new(), dStr_sprintfa(), dStrAsciiCasecmp(), dStrconcat(), dStrdup(), FALSE, MSG, Dstr::str, and TRUE.
Referenced by srv_parse_tok().
|
static |
Definition at line 533 of file cookies.c.
References Cookies_get_timefield(), FALSE, and TRUE.
Referenced by Cookies_parse_date().
|
static |
Definition at line 655 of file cookies.c.
References dList_length(), and dList_nth_data().
Referenced by Cookies_too_many().
|
static |
Definition at line 459 of file cookies.c.
References _MSG, dStrnAsciiCasecmp(), FALSE, and TRUE.
Referenced by Cookies_parse_date().
|
static |
Definition at line 507 of file cookies.c.
References Cookies_get_timefield(), FALSE, and TRUE.
Referenced by Cookies_parse_date().
|
static |
Definition at line 484 of file cookies.c.
References dIsdigit().
Referenced by Cookies_get_day(), and Cookies_get_time().
|
static |
Definition at line 547 of file cookies.c.
References dIsdigit(), FALSE, and TRUE.
Referenced by Cookies_parse_date().
|
static |
Definition at line 334 of file cookies.c.
References Cookie_control_init(), cookies_epoch_time, cookies_epoch_tm, Cookies_fopen(), cookies_future_time, Cookies_load_cookies(), cookies_txt_header_str, dFree(), dGethomedir(), disabled, dStrconcat(), file_stream, MSG, and TRUE.
Referenced by main().
|
static |
Definition at line 1135 of file cookies.c.
References _MSG, and dStrnAsciiCasecmp().
Referenced by Cookies_validate_domain().
|
static |
Definition at line 247 of file cookies.c.
References all_cookies, COOKIE_ACCEPT_SESSION, COOKIE_DENY, Cookies_add_cookie(), Cookies_control_check_domain(), Cookies_free_cookie(), Cookies_tm_init(), dList_length(), dList_new(), dNew0, domains, dStrdup(), dStrerror, dStrsep(), dStrstrip(), FALSE, LINE_MAXLEN, MSG, and TRUE.
Referenced by Cookies_init().
|
static |
Definition at line 1254 of file cookies.c.
References Cookies_path_matches(), FALSE, and TRUE.
Referenced by Cookies_add_matching_cookies().
|
static |
Definition at line 891 of file cookies.c.
References _MSG, Cookies_eat_value(), cookies_future_time, Cookies_parse_attr(), Cookies_parse_date(), Cookies_parse_value(), Cookies_server_timediff(), Cookies_unquote_string(), dFree(), dIsdigit(), dNew0, dStrAsciiCasecmp(), FALSE, MSG, and TRUE.
Referenced by Cookies_set().
|
static |
Definition at line 798 of file cookies.c.
References dIsspace(), and dStrndup().
Referenced by Cookies_parse().
|
static |
Definition at line 605 of file cookies.c.
References Cookies_date_delim(), Cookies_get_day(), Cookies_get_month(), Cookies_get_time(), Cookies_get_year(), dFree(), dNew0, FALSE, and MSG.
Referenced by Cookies_parse(), and Cookies_server_timediff().
|
static |
Definition at line 819 of file cookies.c.
References dIsspace(), and dStrndup().
Referenced by Cookies_parse().
|
static |
Definition at line 1053 of file cookies.c.
Referenced by Cookies_match().
|
static |
Definition at line 676 of file cookies.c.
References all_cookies, Cookies_delete_node(), Cookies_free_cookie(), dList_find_sorted(), dList_length(), dList_nth_data(), dList_remove(), dList_remove_fast(), Domain_node_by_domain_cmp(), and domains.
Referenced by Cookies_add_cookie().
|
static |
Definition at line 389 of file cookies.c.
References all_cookies, Cookies_delete_node(), cookies_epoch_time, Cookies_free_cookie(), cookies_txt_header_str, disabled, dList_free(), dList_nth_data(), domains, dStrerror, file_stream, LINE_MAXLEN, and MSG.
Referenced by cleanup().
|
static |
Definition at line 856 of file cookies.c.
References Cookies_parse_date(), and dFree().
Referenced by Cookies_parse().
|
static |
Definition at line 1215 of file cookies.c.
References COOKIE_ACCEPT_SESSION, COOKIE_DENY, Cookies_add_cookie(), Cookies_control_check_domain(), Cookies_free_cookie(), Cookies_parse(), Cookies_validate_domain(), Cookies_validate_path(), disabled, MSG, and TRUE.
Referenced by srv_parse_tok().
|
static |
Definition at line 233 of file cookies.c.
References cookies_epoch_tm.
Referenced by Cookies_load_cookies().
|
static |
Definition at line 707 of file cookies.c.
References all_cookies, Cookies_delete_node(), Cookies_free_cookie(), Cookies_get_LRU(), dList_find_sorted(), dList_length(), dList_remove(), dList_remove_fast(), Domain_node_by_domain_cmp(), domains, and MSG.
Referenced by Cookies_add_cookie().
|
static |
Definition at line 874 of file cookies.c.
Referenced by Cookies_parse().
|
static |
Definition at line 1180 of file cookies.c.
References _MSG, Cookies_domain_matches(), Cookies_internal_dots_required(), dStrdup(), FALSE, MSG, and TRUE.
Referenced by Cookies_set().
|
static |
Definition at line 1075 of file cookies.c.
References dFree(), dStrdup(), and dStrndup().
Referenced by Cookies_set().
|
static |
Definition at line 167 of file cookies.c.
References dStrAsciiCasecmp().
Referenced by Cookies_add_cookie(), Cookies_add_matching_cookies(), Cookies_rm_expired_cookies(), and Cookies_too_many().
|
static |
Definition at line 157 of file cookies.c.
References dStrAsciiCasecmp().
Referenced by Cookies_add_cookie().
| int main | ( | void | ) |
Definition at line 1638 of file cookies.c.
References _MSG, a_Dpip_dsh_close(), a_Dpip_dsh_free(), a_Dpip_dsh_new(), a_Dpip_dsh_read_token(), cleanup(), Cookies_init(), dFree(), disabled, dNew, MSG, sh, srv_parse_tok(), Dsh::status, and termination_handler().
|
static |
Definition at line 1544 of file cookies.c.
References _MSG, a_Dpip_build_cmd(), a_Dpip_check_auth(), a_Dpip_dsh_write_str(), a_Dpip_get_attr_l(), Cookies_get(), Cookies_set(), dFree(), MSG, path(), and sh.
Referenced by main().
|
static |
|
static |
Definition at line 120 of file cookies.c.
Referenced by Cookies_add_cookie(), Cookies_add_matching_cookies(), Cookies_load_cookies(), Cookies_rm_expired_cookies(), Cookies_save_and_free(), and Cookies_too_many().
|
static |
Definition at line 126 of file cookies.c.
Referenced by Cookie_control_init(), and Cookies_control_check_domain().
|
static |
Definition at line 143 of file cookies.c.
Referenced by Cookies_init(), and Cookies_save_and_free().
|
static |
Definition at line 142 of file cookies.c.
Referenced by Cookies_init(), and Cookies_tm_init().
|
static |
Definition at line 143 of file cookies.c.
Referenced by Cookies_init(), and Cookies_parse().
|
static |
Definition at line 134 of file cookies.c.
Referenced by Cookies_init(), and Cookies_save_and_free().
|
static |
Definition at line 131 of file cookies.c.
Referenced by Cookies_add_cookie(), Cookies_add_matching_cookies(), and Cookies_get().
|
static |
Definition at line 129 of file cookies.c.
Referenced by Cookie_control_init(), and Cookies_control_check_domain().
|
static |
Definition at line 132 of file cookies.c.
Referenced by a_Cookies_get_query(), a_Cookies_init(), a_Cookies_set(), Cookies_get(), Cookies_init(), Cookies_save_and_free(), Cookies_set(), and main().
|
static |
Definition at line 123 of file cookies.c.
Referenced by Cookies_add_cookie(), Cookies_add_matching_cookies(), Cookies_delete_node(), Cookies_load_cookies(), Cookies_rm_expired_cookies(), Cookies_save_and_free(), and Cookies_too_many().
|
static |
Definition at line 133 of file cookies.c.
Referenced by Cookies_init(), and Cookies_save_and_free().
|
static |
Definition at line 127 of file cookies.c.
Referenced by Cookie_control_init(), and Cookies_control_check_domain().
|
static |
Definition at line 128 of file cookies.c.
Referenced by Cookie_control_init().