mirror of
https://github.com/gophernicus/gophernicus.git
synced 2024-11-03 04:27:17 -05:00
Added $SESSION_ID environment variable for CGI scripts
This commit is contained in:
parent
26614a6efd
commit
74851cf592
@ -2,6 +2,7 @@
|
||||
|
||||
2014-11-10 Kim Holviala <kim@holviala.com>
|
||||
|
||||
* Added MacOSX 10.10 to the list of supported systems in INSTALL
|
||||
* Released version 1.6
|
||||
* Fix compiling for MacOS X Yosemite
|
||||
|
||||
|
2
Makefile
2
Makefile
@ -8,7 +8,7 @@
|
||||
NAME = gophernicus
|
||||
PACKAGE = $(NAME)
|
||||
BINARY = in.$(NAME)
|
||||
VERSION = 1.6
|
||||
VERSION = 1.7-alpha
|
||||
|
||||
SOURCES = $(NAME).c file.c menu.c string.c platform.c session.c options.c
|
||||
HEADERS = functions.h files.h
|
||||
|
4
file.c
4
file.c
@ -312,6 +312,10 @@ void setenv_cgi(state *st, char *script)
|
||||
setenv("LOCAL_ADDR", st->req_local_addr, 1);
|
||||
setenv("REMOTE_ADDR", st->req_remote_addr, 1);
|
||||
setenv("HTTP_REFERER", st->req_referrer, 1);
|
||||
#ifdef HAVE_SHMEM
|
||||
snprintf(buf, sizeof(buf), "%x", st->session_id);
|
||||
setenv("SESSION_ID", buf, 1);
|
||||
#endif
|
||||
setenv("HTTP_ACCEPT_CHARSET", strcharset(st->out_charset), 1);
|
||||
|
||||
/* Gophernicus extras */
|
||||
|
@ -490,6 +490,7 @@ int main(int argc, char *argv[])
|
||||
setlocale(LC_TIME, DATE_LOCALE);
|
||||
#endif
|
||||
init_state(&st);
|
||||
srand(time(NULL) / (getpid() + getppid()));
|
||||
|
||||
/* Handle command line arguments */
|
||||
parse_args(&st, argc, argv);
|
||||
|
@ -318,6 +318,7 @@ typedef struct {
|
||||
int session_timeout;
|
||||
int session_max_kbytes;
|
||||
int session_max_hits;
|
||||
int session_id;
|
||||
|
||||
/* Feature options */
|
||||
char opt_parent;
|
||||
@ -338,7 +339,7 @@ typedef struct {
|
||||
/* Shared memory for session & accounting data */
|
||||
#ifdef HAVE_SHMEM
|
||||
|
||||
#define SHM_KEY 0xbeeb0006 /* Unique identifier + struct version */
|
||||
#define SHM_KEY 0xbeeb0007 /* Unique identifier + struct version */
|
||||
#define SHM_MODE 0600 /* Access mode for the shared memory */
|
||||
#define SHM_SESSIONS 256 /* Max amount of user sessions to track */
|
||||
|
||||
@ -350,6 +351,7 @@ typedef struct {
|
||||
char req_selector[128];
|
||||
char req_remote_addr[64];
|
||||
char req_filetype;
|
||||
int session_id;
|
||||
|
||||
char server_host[64];
|
||||
int server_port;
|
||||
|
@ -97,6 +97,7 @@ void update_shm_session(state *st, shm_state *shm)
|
||||
sstrlcpy(shm->session[i].req_remote_addr, st->req_remote_addr);
|
||||
shm->session[i].hits = 0;
|
||||
shm->session[i].kbytes = 0;
|
||||
shm->session[i].session_id = rand();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -115,6 +116,9 @@ void update_shm_session(state *st, shm_state *shm)
|
||||
sstrlcpy(st->req_referrer, buf);
|
||||
}
|
||||
|
||||
/* Get public session id */
|
||||
st->session_id = shm->session[i].session_id;
|
||||
|
||||
/* Update session data */
|
||||
sstrlcpy(shm->session[i].server_host, st->server_host);
|
||||
shm->session[i].server_port = st->server_port;
|
||||
|
Loading…
Reference in New Issue
Block a user