audit.c revision e0d98b5e6f4b658de5303bf8d74576d2555db68e
/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
#include "platform.h"
#include "am.h"
#include "utility.h"
#include "list.h"
#include "thread.h"
#include "net_client.h"
#define BATCH_SIZE 25
#define AUDIT_ENTRY_LINKS(offset) (&((struct am_audit_entry *) AM_GET_POINTER(audit_shm->pool, (offset)))->lh)
} else {\
}\
} while (0)
} else {\
}\
} else {\
}\
} while (0)
struct offset_list_hdr {
};
struct am_audit {
struct am_audit_config {
unsigned long instance_id;
int interval;
int last;
struct offset_list_hdr list_hdr;
char config_file[AM_PATH_SIZE];
char openam[AM_URI_SIZE];
};
struct am_audit_entry {
unsigned long instance_id;
struct offset_list lh;
char server_id[12];
char value[1];
};
struct am_audit_transfer {
unsigned long instance_id;
char *message;
char *server_id;
char *config_file;
};
static const char *AUDIT_REQ_MSG = "<Request><![CDATA[<logRecWrite reqid=\"%%d\"><log logName=\"%s\" sid=\"%s\">"
"</log><logRecord><level>800</level><recMsg>%s</recMsg><logInfoMap><logInfo><infoKey>LoginIDSid</infoKey>"
"<infoValue>%s</infoValue></logInfo></logInfoMap></logRecord></logRecWrite>]]></Request>%%s";
int am_audit_init(int id) {
sizeof (struct am_audit) + ((sizeof (struct am_audit_entry) + 800 /* an average logRecWrite entry size */) * 2048));
return AM_ERROR;
}
}
struct am_audit *audit_data = (struct am_audit *) am_shm_alloc(audit_shm, sizeof (struct am_audit));
if (audit_data == NULL) {
return AM_ENOMEM;
}
/* store table offset (for other processes) */
}
return AM_SUCCESS;
}
int am_audit_shutdown() {
return AM_SUCCESS;
}
static struct am_audit *get_audit_data() {
}
int i;
for (i = 0; i < AM_MAX_INSTANCES; i++) {
}
}
return NULL;
}
int offset;
struct am_audit_entry *audit_entry;
if (audit_entry == NULL) {
return AM_ENOMEM;
}
} else {
}
return AM_SUCCESS;
}
const char *agent_token_server_id, const char *file_name,
const char *user_token, const char *format, ...) {
struct am_audit_config *config;
return AM_EINVAL;
}
return AM_ENOMEM;
}
if (message_b64 == NULL) {
return AM_ENOMEM;
}
return AM_ENOMEM;
}
if (status != AM_SUCCESS) {
return status;
}
} else {
}
return status;
}
static const char *thisfunc = "extract_audit_entries():";
struct am_audit_entry *e;
int offset;
struct am_audit_config *config;
int i, c = 0;
struct am_audit_transfer *batch;
return AM_ENOMEM;
}
if (status != AM_SUCCESS)
return status;
return AM_EINVAL;
}
c++;
if (c == BATCH_SIZE) {
for (i = 0; i < c; i++) {
}
c = 0;
}
am_shm_free(audit_shm, e);
}
if (c) {
for (i = 0; i < c; i++) {
}
}
return status;
}
static am_status_t write_entries_to_server(const char *openam, int count, struct am_audit_transfer *batch) {
static const char *thisfunc = "write_entries_to_server():";
int i;
struct audit_worker_data *wd;
unsigned long instance_id;
return AM_EINVAL;
}
return AM_ENOMEM;
}
for (i = 0; i < count; i++) {
} else {
}
return AM_ENOMEM;
}
}
}
}
return AM_ERROR;
}
return AM_SUCCESS;
}
static void am_audit_tick(void *arg) {
static const char *thisfunc = "am_audit_tick():";
int i;
struct am_audit *audit_data;
int lock_status, status;
if (lock_status != AM_SUCCESS) {
return;
}
audit_data = get_audit_data();
if (audit_data == NULL) {
return;
}
for (i = 0; i < AM_MAX_INSTANCES; i++) {
/* reset run-count for this instance */
if (status != AM_SUCCESS) {
}
}
}
}
int am_audit_processor_init() {
if (audit_timer != NULL) {
return AM_SUCCESS;
}
if (audit_timer == NULL) {
return AM_ENOMEM;
}
if (audit_timer->error != 0) {
return AM_ERROR;
}
return AM_SUCCESS;
}
void am_audit_processor_shutdown() {
audit_timer = NULL;
}
int i;
struct am_audit *audit_data;
int lock_status;
const char *openam;
if (lock_status != AM_SUCCESS) {
return lock_status;
}
audit_data = get_audit_data();
if (audit_data == NULL) {
return AM_ENOMEM;
}
/* update existing instance configuration */
for (i = 0; i < AM_MAX_INSTANCES; i++) {
strncpy(audit_data->config[i].config_file, conf->config, sizeof (audit_data->config[i].config_file) - 1);
return AM_SUCCESS;
}
}
/* create instance configuration */
for (i = 0; i < AM_MAX_INSTANCES; i++) {
strncpy(audit_data->config[i].config_file, conf->config, sizeof (audit_data->config[i].config_file) - 1);
break;
}
}
return AM_SUCCESS;
}