summaryrefslogtreecommitdiff
path: root/src/setup_system.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setup_system.c')
-rw-r--r--src/setup_system.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/setup_system.c b/src/setup_system.c
index fdff19e..e41da0b 100644
--- a/src/setup_system.c
+++ b/src/setup_system.c
@@ -167,11 +167,11 @@ static sa_error_e sa_inputfile_set_proxy_env(sa_proxy_s * proxy)
fd = open(ENVIRONMENT_PROXY_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd > 0) {
write(fd, writeBuff, strlen(writeBuff));
- close(fd);
} else {
ret = SA_ERROR_NOT_AVAILABLE;
_E("Cannot open file");
}
+ close(fd);
}
return ret;
@@ -228,11 +228,11 @@ static sa_error_e sa_inputfile_set_dockerd_opt(sa_dockerd_opt_s * opt)
fd = creat(CONFIG_DOCKERD_DAEMON_FILE, 0644);
if (fd > 0) {
write(fd, buf, strlen(buf));
- close(fd);
} else {
ret = SA_ERROR_NOT_AVAILABLE;
_E("Cannot create file");
}
+ close(fd);
if (buf != NULL)
free(buf);
@@ -355,17 +355,21 @@ void setup_user_certificates(void)
if (dir_info != NULL) {
while (dir_entry = readdir(dir_info)) {
if (__get_file_extension(dir_entry->d_name, &fileExt) == 0) {
- if (strncmp(fileExt, "crt", 3) == 0) {
- snprintf(file_name, sizeof(file_name), "%s%s", USER_CERT_DIR_PATH, dir_entry->d_name);
- if (__search_str_pattern(SYSTEM_CERT_FILE, file_name) != 0) { // un-matched file, need to be applied
- if (__apply_ca_cert_file(file_name) != 0)
- _D("File[%s]: apply error!!!", dir_entry->d_name);
- else
- _D("File[%s]: applied successfully ca-certificate!!!", dir_entry->d_name);
- } else
- _D("FILE[%s]: already applied!!!", dir_entry->d_name);
+ if (fileExt != NULL) {
+ if (strncmp(fileExt, "crt", 3) == 0) {
+ snprintf(file_name, sizeof(file_name), "%s%s", USER_CERT_DIR_PATH, dir_entry->d_name);
+ if (__search_str_pattern(SYSTEM_CERT_FILE, file_name) != 0) { // un-matched file, need to be applied
+ if (__apply_ca_cert_file(file_name) != 0)
+ _D("File[%s]: apply error!!!", dir_entry->d_name);
+ else
+ _D("File[%s]: applied successfully ca-certificate!!!", dir_entry->d_name);
+ } else {
+ _D("FILE[%s]: already applied!!!", dir_entry->d_name);
+ }
+ }
+ free(fileExt);
+ fileExt = NULL;
}
- free(fileExt);
} else
_D("File[%s]: Not valid certificate file", dir_entry->d_name);
}
@@ -617,6 +621,7 @@ int sa_get_os_info(os_info_s * os_info_h)
_D("platformVer[%s]", os_info_h->platformVer);
free(ret_buf);
+ ret_buf = NULL;
}
// get base OS version
ret = CLI_command(GET_BASEOS_VERSION_CMD, 1, &ret_buf);
@@ -628,6 +633,7 @@ int sa_get_os_info(os_info_s * os_info_h)
_D("baseOSVer[%s]", os_info_h->baseOSVer);
free(ret_buf);
+ ret_buf = NULL;
}
// get docker version
ret = CLI_command(GET_DOCKER_VERSION_CMD, 1, &ret_buf);
@@ -639,6 +645,7 @@ int sa_get_os_info(os_info_s * os_info_h)
_D("dockerVer[%s]", os_info_h->dockerVer);
free(ret_buf);
+ ret_buf = NULL;
}
}