// Implementation static boolean record_transaction_log(SSL *ssl_client, char *desired_username, char *desired_user_authority_name, char *object_description, char *event_description) { SSL *ssl_conn_AS = NULL; char buffer[BUFFER_LENGTH + 1]; char phr_owner_name[USER_NAME_LENGTH + 1]; char current_date_time[DATETIME_STR_LENGTH + 1]; char client_ip_address[IP_ADDRESS_LENGTH + 1]; // Get certificate owner's name, current date/time and client's IP address get_cert_ownername(ssl_client, GLOBAL_authority_name, phr_owner_name, NULL); get_current_date_time(current_date_time); SSL_get_peer_address(ssl_client, client_ip_address, NULL); // Connect to Audit Server if(!connect_to_transaction_log_recording_service(&ssl_conn_AS)) goto ERROR; // Send a request type write_token_into_buffer("request_type", EVENT_LOG_RECORDING, true, buffer); if(!SSL_send_buffer(ssl_conn_AS, buffer, strlen(buffer))) { fprintf(stderr, "Sending a request type failed\n"); goto ERROR; } // Send a transaction log write_token_into_buffer("actor_name", phr_owner_name, true, buffer); write_token_into_buffer("actor_authority_name", GLOBAL_authority_name, false, buffer); write_token_into_buffer("does_actor_is_admin_flag", "0", false, buffer); write_token_into_buffer("object_owner_name", desired_username, false, buffer); write_token_into_buffer("object_owner_authority_name", desired_user_authority_name, false, buffer); write_token_into_buffer("does_object_owner_is_admin_flag", "0", false, buffer); write_token_into_buffer("affected_username", NO_REFERENCE_USERNAME, false, buffer); write_token_into_buffer("affected_user_authority_name", GLOBAL_authority_name, false, buffer); write_token_into_buffer("does_affected_user_is_admin_flag", "0", false, buffer); write_token_into_buffer("object_description", object_description, false, buffer); write_token_into_buffer("event_description", event_description, false, buffer); write_token_into_buffer("date_time", current_date_time, false, buffer); write_token_into_buffer("actor_ip_address", client_ip_address, false, buffer); if(!SSL_send_buffer(ssl_conn_AS, buffer, strlen(buffer))) { fprintf(stderr, "Sending a transaction (access permission) log failed\n"); goto ERROR; } SSL_cleanup(ssl_conn_AS); ssl_conn_AS = NULL; return true; ERROR: if(ssl_conn_AS) { SSL_cleanup(ssl_conn_AS); ssl_conn_AS = NULL; } return false; }
static boolean record_transaction_incomplete_login_log(BIO *bio_client) { SSL *ssl_conn_AS = NULL; char buffer[BUFFER_LENGTH + 1]; char current_date_time[DATETIME_STR_LENGTH + 1]; char client_ip_address[IP_ADDRESS_LENGTH + 1]; // Get current date/time and client's IP address get_current_date_time(current_date_time); BIO_get_peer_address(bio_client, client_ip_address, NULL); // Connect to Audit Server if(!connect_to_transaction_log_recording_service(&ssl_conn_AS)) goto ERROR; // Send a request type write_token_into_buffer("request_type", LOGIN_LOG_RECORDING, true, buffer); if(!SSL_send_buffer(ssl_conn_AS, buffer, strlen(buffer))) { fprintf(stderr, "Sending a request type failed\n"); goto ERROR; } // Send a transaction log write_token_into_buffer("username", INVALID_USERNAME, true, buffer); write_token_into_buffer("is_admin_flag", "0", false, buffer); write_token_into_buffer("date_time", current_date_time, false, buffer); write_token_into_buffer("ip_address", client_ip_address, false, buffer); if(!SSL_send_buffer(ssl_conn_AS, buffer, strlen(buffer))) { fprintf(stderr, "Sending a transaction log failed\n"); goto ERROR; } SSL_cleanup(ssl_conn_AS); ssl_conn_AS = NULL; return true; ERROR: if(ssl_conn_AS) { SSL_cleanup(ssl_conn_AS); ssl_conn_AS = NULL; } return false; }
void setup_dtconf() { GtkWidget *utccheckbutton = lookup_widget(MainWindow,"checkbutton2"); if (!read_zone_info()) { debug("Error: Can't read zone info, exitting\n"); exit(1); } struct tm *dt = get_current_date_time(); set_date_time(*dt); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(utccheckbutton),check_system_utc()); debug("Set date/time\n"); set_ntp_server_list(); do_ntp_server(); setup_timezone_list(); read_current_timezone(); if (read_tz != NULL) { set_readin_tz(); } setup_timezone_list_cb(); debug("Set up ntp\n"); realised = TRUE; g_timeout_add(1000,sec_timeout,NULL); }
/************** RPC server *************/ static const std::string get_current_date_time() { time_t now = time(0); struct tm tstruct; char buf[80]; tstruct = *localtime(&now); strftime(buf, sizeof(buf), "%b %d %Y @ %X", &tstruct); return buf; } const std::string TrexRpcServer::s_server_uptime = get_current_date_time(); TrexRpcServer::TrexRpcServer(const TrexRpcServerConfig *req_resp_cfg) { m_req_resp = NULL; /* add the request response server */ if (req_resp_cfg) { if (req_resp_cfg->get_protocol() == TrexRpcServerConfig::RPC_PROT_MOCK) { m_req_resp = new TrexRpcServerReqResMock(*req_resp_cfg); } else { m_req_resp = new TrexRpcServerReqRes(*req_resp_cfg); } m_servers.push_back(m_req_resp);
gboolean sec_timeout(gpointer data) { struct tm *dt = get_current_date_time(); set_time(*dt); return TRUE; }