[bugfix][T108] [bug-view-1663] modify sshd service and solve log_level_seting interface error
Only Configure: No
Affected branch: GSW_V1453
Affected module: sys
Self-test: yes
Doc Update: no
Change-Id: I31010d3975b7a815966a5fa18d6527f71fd677d7
diff --git a/mbtk/libgsw_lib/gsw_sys_interface.c b/mbtk/libgsw_lib/gsw_sys_interface.c
index 8b103ee..7aa2734 100755
--- a/mbtk/libgsw_lib/gsw_sys_interface.c
+++ b/mbtk/libgsw_lib/gsw_sys_interface.c
@@ -43,7 +43,7 @@
int gsw_sys_svr_ssh_start(const char *cfg)
{
int ret= GSW_HAL_SUCCESS;
- char command[128] = "/usr/sbin/dropbear &";
+ char command[128] = "/usr/sbin/sshd &";
if(NULL == cfg)
{
@@ -51,7 +51,7 @@
}
else
{
- sprintf(command, "/usr/sbin/dropbear %s &", cfg);
+ sprintf(command, "/usr/sbin/sshd %s &", cfg);
ret = system(command);
}
@@ -67,7 +67,7 @@
int gsw_sys_svr_ssh_stop()
{
int ret = GSW_HAL_SUCCESS;
- char command[] = "killall dropbear";
+ char command[] = "killall sshd";
ret = system(command);
if(ret != 0)
@@ -83,30 +83,42 @@
{
(void)log_lvl;
char command[256] = {0};
+ int level = 0;
+ char *log_level_params[8] = {"emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"};
+ char *log_level_values[8] = {"1", "2", "3", "4", "5", "6", "7", "8"};
snprintf(command, sizeof(command),
"grep -q 'setprop sys.default.loglevel' %s", LOG_LEVLE_CONFIG_FILE);
+ for(level = 0; level < 8; level++)
+ {
+ if(0 == strcmp(log_lvl, log_level_params[level]))
+ break;
+ }
+
+ if(8 == level)
+ {
+ printf("Parameter error\n");
+ return -1;
+ }
+
int exists = system(command);
if (exists != 0) {
printf("config option not exist.\n");
return GSW_HAL_NORMAL_FAIL;
}
- if(1 == strlen(log_lvl))
- {
- snprintf(command, sizeof(command),
- "sed -i 's/\\(setprop sys.default.loglevel \\)\\S*/\\1%s/' %s",
- log_lvl, LOG_LEVLE_CONFIG_FILE);
-
- int result = system(command);
- if (result != 0) {
- printf("command execution failed.\n");
- return GSW_HAL_SUCCESS;
- }
-
+ snprintf(command, sizeof(command),
+ "sed -i 's/\\(setprop sys.default.loglevel \\)\\S*/\\1%s/' %s",
+ log_level_values[level], LOG_LEVLE_CONFIG_FILE);
+
+ int result = system(command);
+ if (result != 0) {
+ printf("command execution failed.\n");
+ return GSW_HAL_SUCCESS;
}
+
return GSW_HAL_NORMAL_FAIL;
}