2018-06-19 11:32:16 +08:00
|
|
|
/*************************************************************************
|
|
|
|
|
> File Name: cert_server.c
|
|
|
|
|
> Author: fengweihao
|
2018-07-05 14:05:28 +08:00
|
|
|
> Mail:
|
2018-06-19 11:32:16 +08:00
|
|
|
> Created Time: Tue 29 May 2018 06:45:23 PM PDT
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2018-07-12 10:56:13 +08:00
|
|
|
#include <signal.h>
|
2019-11-05 11:38:40 +08:00
|
|
|
#include <unistd.h>
|
2018-06-19 11:32:16 +08:00
|
|
|
|
|
|
|
|
#include "rt_string.h"
|
|
|
|
|
#include "rt_common.h"
|
2019-11-05 11:38:40 +08:00
|
|
|
#include <cert_conf.h>
|
|
|
|
|
#include <cert_session.h>
|
2018-06-19 11:32:16 +08:00
|
|
|
#include "logging.h"
|
|
|
|
|
|
2019-11-05 11:38:40 +08:00
|
|
|
#include <MESA/MESA_prof_load.h>
|
2018-06-19 11:32:16 +08:00
|
|
|
|
2018-11-13 10:31:21 +08:00
|
|
|
#define CERT_BASIC_CFG "./conf/cert_store.ini"
|
2018-06-19 11:32:16 +08:00
|
|
|
|
2019-11-05 11:38:40 +08:00
|
|
|
/* VERSION STRING */
|
|
|
|
|
#ifdef TARGET_GIT_VERSION
|
|
|
|
|
static __attribute__((__used__)) const char * git_ver = TARGET_GIT_VERSION;
|
2018-11-30 21:17:04 +08:00
|
|
|
#else
|
2019-11-05 11:38:40 +08:00
|
|
|
static __attribute__((__used__)) const char * git_ver = "1.1";
|
2018-11-30 21:17:04 +08:00
|
|
|
#endif
|
|
|
|
|
|
2019-11-05 11:38:40 +08:00
|
|
|
const char * version()
|
|
|
|
|
{
|
|
|
|
|
return git_ver;
|
|
|
|
|
}
|
2018-06-19 11:32:16 +08:00
|
|
|
|
|
|
|
|
enum syslog_display_format{
|
|
|
|
|
FORMAT_CONSOLE,
|
|
|
|
|
FORMAT_FILE,
|
|
|
|
|
FORMAT_SYSLOG
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-20 16:24:49 +08:00
|
|
|
static
|
|
|
|
|
void cert_preview ()
|
|
|
|
|
{
|
|
|
|
|
struct config_bucket_t *rte = cert_default_config();
|
|
|
|
|
|
|
|
|
|
printf("\r\nBasic Configuration of CertStore \n");
|
2019-08-21 14:03:53 +08:00
|
|
|
printf("%30s:%45s\n", "Run Mode", (rte->mode == 1)?"rsync":"sync");
|
2018-06-20 16:24:49 +08:00
|
|
|
printf("%30s:%45d\n", "The Threads", rte->thread_nu);
|
2018-10-22 11:15:57 +08:00
|
|
|
printf("%30s:%45s\n", "Store Redis Ip", rte->addr_t.store_ip);
|
|
|
|
|
printf("%30s:%45d\n", "Store Redis Port", rte->addr_t.store_port);
|
|
|
|
|
printf("%30s:%45s\n", "Maat Redis Ip", rte->addr_t.maat_ip);
|
|
|
|
|
printf("%30s:%45d\n", "Maat Redis Port", rte->addr_t.maat_port);
|
|
|
|
|
printf("%30s:%45d\n", "Maat Redis index", rte->addr_t.dbindex);
|
2018-09-10 10:01:27 +08:00
|
|
|
printf("%30s:%45d\n", "Libevent Port", rte->addr_t.e_port);
|
2018-12-13 10:12:24 +08:00
|
|
|
printf("%30s:%45s\n", "Cert Path", rte->ca_path);
|
|
|
|
|
printf("%30s:%45s\n", "Uninsec cert Path", rte->uninsec_path);
|
2018-09-10 10:01:27 +08:00
|
|
|
printf("%30s:%45s\n", "Log Directory", logging_sc_lid.run_log_path);
|
2018-09-18 14:48:55 +08:00
|
|
|
printf("%30s:%45s\n", "Table Info", rte->maat_t.info_path);
|
|
|
|
|
if (rte->maat_t.maat_json_switch == 1){
|
|
|
|
|
printf("%30s:%45s\n", "Pxy Obj Keyring", rte->maat_t.pxy_path);
|
|
|
|
|
}
|
|
|
|
|
if (rte->maat_t.maat_json_switch == 0){
|
2018-10-22 11:15:57 +08:00
|
|
|
printf("%30s:%45d\n", "Scan Interval", rte->maat_t.effective_interval_s);
|
2018-09-18 14:48:55 +08:00
|
|
|
printf("%30s:%45s\n", "Full Cfg Path", rte->maat_t.full_cfg_dir);
|
|
|
|
|
printf("%30s:%45s\n", "Inc Cfg Path", rte->maat_t.inc_cfg_dir);
|
|
|
|
|
|
|
|
|
|
}
|
2018-06-20 16:24:49 +08:00
|
|
|
printf("\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-19 11:32:16 +08:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
2019-11-05 11:38:40 +08:00
|
|
|
int opt = 0;
|
|
|
|
|
while ((opt = getopt(argc, argv, "v")) != -1)
|
|
|
|
|
{
|
|
|
|
|
switch (opt)
|
|
|
|
|
{
|
|
|
|
|
case 'v':
|
|
|
|
|
fprintf(stderr, "Welcome to certstore, Version: %s\n", version());
|
|
|
|
|
return 0;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-19 11:32:16 +08:00
|
|
|
cert_syslog_init(CERT_BASIC_CFG);
|
|
|
|
|
|
2018-06-20 16:24:49 +08:00
|
|
|
cert_init_config(CERT_BASIC_CFG);
|
|
|
|
|
|
|
|
|
|
cert_preview();
|
2019-11-05 11:38:40 +08:00
|
|
|
|
|
|
|
|
mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "Cert server init success");
|
|
|
|
|
|
2018-06-19 11:32:16 +08:00
|
|
|
cert_session_init();
|
|
|
|
|
|
2018-09-06 19:51:23 +08:00
|
|
|
signal(SIGINT, sigproc);
|
|
|
|
|
|
2018-06-19 11:32:16 +08:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|