int main(void) { int filefd; int filefd_out; loff_t off = 0; filefd = open(token_file, O_RDWR | O_CREAT | O_TRUNC, 0600); filefd_out = open(token_file, O_RDWR | O_CREAT | O_TRUNC, 0600); write(filefd, TOKEN, TOKEN_SIZE); sendfile64(filefd_out, filefd, &off, TOKEN_SIZE); atomic_printf( "sendfile %zu bytes from %d to %d; off changed from 0 to %" PRId64 "\n", TOKEN_SIZE, filefd, filefd_out, off); lseek(filefd_out, 0, SEEK_SET); verify_token(filefd_out); lseek(filefd, 0, SEEK_SET); sendfile64(filefd_out, filefd, NULL, TOKEN_SIZE); atomic_printf("sendfile %zu bytes from %d to %d\n", TOKEN_SIZE, filefd, filefd_out); lseek(filefd_out, 0, SEEK_SET); verify_token(filefd_out); /* The test driver will clean up after us if the test failed * before this. */ unlink(token_file); unlink(token_file_out); atomic_puts("EXIT-SUCCESS"); return 0; }
static handler_t mod_status_handler(server *srv, connection *con, void *p_d) { inform_proxy1_arrival(); // Communicating arrival of a request to Proxy1 (BTP) //For verifying if token is authentic //if(verify_token((con->uri.query)->ptr) == 0) // return HANDLER_ERROR; //modified if(verify_token((con->uri.query)->ptr) == 0) { con->http_status = 404; con->file_finished = 1; return HANDLER_FINISHED; } gettimeofday(&(con->tv_temp),NULL); con->start_time = ((con->tv_temp).tv_sec)*1000000 + ((con->tv_temp).tv_usec); plugin_data *p = p_d; mod_status_patch_connection(srv, con, p); if (!buffer_is_empty(p->conf.status_url) && buffer_is_equal(p->conf.status_url, con->uri.path)) { return mod_status_handle_server_status(srv, con, p_d); } else if (!buffer_is_empty(p->conf.config_url) && buffer_is_equal(p->conf.config_url, con->uri.path)) { return mod_status_handle_server_config(srv, con, p_d); } else if (!buffer_is_empty(p->conf.statistics_url) && buffer_is_equal(p->conf.statistics_url, con->uri.path)) { return mod_status_handle_server_statistics(srv, con, p_d); } return HANDLER_GO_ON; }
void wo_login(char *url) { unsigned char mac[6]; char ifname[128]; const char *jsonpcallback = webcgi_get("jsonpcallback"); const char *token = webcgi_get("token"); if (strlen(token) >= 32) { if (verify_token(token) != 1) { if (jsonpcallback) { web_printf("%s ({ \"msg\":\"Invaild Token!\", \"ret\": \"0\" })\n", jsonpcallback); }else web_printf("{ \"msg\":\"Invaild Token!\", \"ret\": \"0\" }\n"); return; } }else { if (jsonpcallback) { web_printf("%s ({ \"msg\":\"Invaild Token!\", \"ret\": \"0\" })\n", jsonpcallback); }else web_printf("{ \"msg\":\"Invaild Token!\", \"ret\": \"0\" }\n"); return; } if (get_client_info2(mac, ifname)) { ioctl_wrapper(CMD_ADDUSER, mac); if (jsonpcallback) { web_printf("%s ({ \"msg\":\"Login OK!\", \"ret\": \"1\" })\n", jsonpcallback); }else web_printf("{ \"msg\":\"Login OK!\", \"ret\": \"1\" }\n"); }else { if (jsonpcallback) { web_printf("%s ({ \"msg\":\"Login Failed!\", \"ret\": \"0\" })\n", jsonpcallback); }else web_printf("{ \"msg\":\"Login Failed!\", \"ret\": \"0\" }\n"); } }