Add aaa-12 log-sched启动时增加console配置的初始化(目前console初始化工作包含更改tty文件权限)
RCA: SOL: 修改人:liangxia 检视人:
This commit is contained in:
parent
08c053afd7
commit
fd9b5fffe0
|
@ -17,6 +17,10 @@
|
||||||
#define SERIAL_NO_DRIVER_KEY SERIAL_DRIVER_PREFIX":unknown"
|
#define SERIAL_NO_DRIVER_KEY SERIAL_DRIVER_PREFIX":unknown"
|
||||||
#define SERIAL_PREFIX "ttyS"
|
#define SERIAL_PREFIX "ttyS"
|
||||||
|
|
||||||
|
#ifndef CM_LOG_CONF_CONSOLE_FILE
|
||||||
|
#define CM_LOG_CONF_CONSOLE_FILE "/etc/rsyslog.d/log-console.conf"
|
||||||
|
#endif
|
||||||
|
|
||||||
static int write_console_content(FILE *fp, const u8 level, const char *filter_mod, void *arg)
|
static int write_console_content(FILE *fp, const u8 level, const char *filter_mod, void *arg)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
@ -126,3 +130,72 @@ void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ret_code console_initial()
|
||||||
|
{
|
||||||
|
ret_code ret = RET_ERR;
|
||||||
|
FILE *fp = NULL;
|
||||||
|
char *pos = NULL;
|
||||||
|
char *pos2 = NULL;
|
||||||
|
char ttyfile_str[128] = "";
|
||||||
|
int str_len = 0;
|
||||||
|
|
||||||
|
fp = fopen(CM_LOG_CONF_CONSOLE_FILE, "r");
|
||||||
|
if (NULL == fp) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fseek(fp, 0, SEEK_SET) == -1)
|
||||||
|
{
|
||||||
|
ULOG_ERR(g_log, "Seeknig config to begin is faiure:%s", strerror(errno));
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t n;
|
||||||
|
char *line = NULL;
|
||||||
|
while ((getline(&line, &n, fp)) != -1)
|
||||||
|
{
|
||||||
|
pos = strstr(line, "/");
|
||||||
|
if (pos != NULL)
|
||||||
|
{
|
||||||
|
if ((pos2 = strstr(pos, " ")) != NULL)
|
||||||
|
{
|
||||||
|
str_len = strlen(pos) - strlen(pos2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str_len = strlen(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(ttyfile_str, 0, sizeof(ttyfile_str));
|
||||||
|
strncpy(ttyfile_str, pos, str_len);
|
||||||
|
|
||||||
|
/* Â˳ýµô¶ÎβµÄ»Ø³µ»»ÐÐ */
|
||||||
|
if ('\n' == ttyfile_str[strlen(ttyfile_str)-1])
|
||||||
|
{
|
||||||
|
ttyfile_str[strlen(ttyfile_str)-1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(modify_authorizing(ttyfile_str) == RET_OK)
|
||||||
|
{
|
||||||
|
ULOG_DEBUG(g_log, "Modify authorizing %s successed.", ttyfile_str);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ULOG_DEBUG(g_log, "Modify authorizing %s failed.", ttyfile_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = RET_OK;
|
||||||
|
if (NULL != fp)
|
||||||
|
{
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,7 @@
|
||||||
#include "rpc_common.h"
|
#include "rpc_common.h"
|
||||||
|
|
||||||
void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer data);
|
void rpc_conf_log_console(rpc_conn *conn, pointer input, int input_len, pointer data);
|
||||||
|
ret_code console_initial();
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,17 @@ ulog_t *g_log = NULL;
|
||||||
FILE *g_conf_fp;
|
FILE *g_conf_fp;
|
||||||
char g_conf_file[MAX_PATH_SZ];
|
char g_conf_file[MAX_PATH_SZ];
|
||||||
|
|
||||||
|
typedef ret_code (*initial_cb)();
|
||||||
|
typedef struct _log_initial {
|
||||||
|
char type[20];
|
||||||
|
initial_cb cb;
|
||||||
|
} log_initial_t;
|
||||||
|
|
||||||
|
log_initial_t g_log_initial[] = {
|
||||||
|
{"console", console_initial}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void signal_exit()
|
void signal_exit()
|
||||||
{
|
{
|
||||||
log_sev_exit();
|
log_sev_exit();
|
||||||
|
@ -65,6 +76,11 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 各类配置初始化 */
|
||||||
|
for (int i = 0; i < (sizeof(g_log_initial) / sizeof(log_initial_t)); i++) {
|
||||||
|
g_log_initial[i].cb();
|
||||||
|
}
|
||||||
|
|
||||||
rpc_server *server = rpc_server_create_ex(RPC_MODULE_SYSLOG_NAME);
|
rpc_server *server = rpc_server_create_ex(RPC_MODULE_SYSLOG_NAME);
|
||||||
if (server == NULL)
|
if (server == NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue