mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-14 21:10:02 +01:00
For config download, use downloaded filename as import name if it exists in system
This commit is contained in:
parent
1bab0c6a4f
commit
9be8502c31
2 changed files with 23 additions and 10 deletions
|
|
@ -1,5 +1,5 @@
|
|||
variables:
|
||||
CFLAGS: "-DBBF_VENDOR_PREFIX=\\\"X_IOWRT_EU_\\\""
|
||||
CFLAGS: "-DBBF_VENDOR_PREFIX=\\\"X_IOWRT_EU_\\\" -DICWMP_ENABLE_OPCONF_SUPPORT -DICWMP_ENABLE_VENDOR_EXTN -DICWMP_ENABLE_SMM_SUPPORT"
|
||||
#VERBOSE: true
|
||||
SOURCE_FOLDER: "."
|
||||
COMPILATION_FIXUP: "cmake ."
|
||||
|
|
|
|||
|
|
@ -533,7 +533,7 @@ static int cwmp_apply_multiple_firmware(enum download_filetypes filetype, bool a
|
|||
int bank_id = get_available_bank_id();
|
||||
char buffer[32] = {0};
|
||||
int keep_opconf = -1, keep_userconf = -1;
|
||||
char *config_scope = NULL;
|
||||
const char *config_scope = NULL;
|
||||
|
||||
if (bank_id <= 0)
|
||||
return -1;
|
||||
|
|
@ -838,20 +838,22 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
|
|||
|
||||
is_opconf = is_downloaded_file_opconf(file_path);
|
||||
if (is_opconf == false) { // handle normal uci download
|
||||
char buffer[1024] = {0};
|
||||
|
||||
// First run the macro_engine.sh to resolve the macros in uci (if present)
|
||||
if (file_exists(MACRO_ENGINE) == true) {
|
||||
char cmd[1024] = {0};
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "%s %s", MACRO_ENGINE, file_path);
|
||||
run_cmd(cmd, NULL, 0);
|
||||
snprintf(buffer, sizeof(buffer), "%s %s", MACRO_ENGINE, file_path);
|
||||
run_cmd(buffer, NULL, 0);
|
||||
}
|
||||
|
||||
if (CWMP_STRSTR(download_file_name, ".uci.conf") != NULL ||
|
||||
CWMP_STRSTR(pdownload->target_file_name, ".uci.conf") != NULL) {
|
||||
err = import_uci_package(NULL, file_path);
|
||||
} else {
|
||||
// If the downloaded filename is one of the uci name, use named import
|
||||
snprintf(buffer, sizeof(buffer), "/etc/config/%s", download_file_name);
|
||||
if (file_exists(buffer) == true) {
|
||||
err = import_uci_package(download_file_name, file_path);
|
||||
} else {
|
||||
err = import_uci_package(NULL, file_path);
|
||||
}
|
||||
|
||||
if (err == CWMP_GEN_ERR) {
|
||||
error = FAULT_CPE_INTERNAL_ERROR;
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed to commit the config file changes");
|
||||
|
|
@ -864,11 +866,19 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
|
|||
err = cwmp_apply_opconf(file_path, pdownload->filetype);
|
||||
if (err != CWMP_OK) {
|
||||
snprintf(err_msg, sizeof(err_msg), "Failed to apply the opconf file");
|
||||
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
remove_file(file_path);
|
||||
// Trigger reboot/soft-reset only in case of its not operator default opconf file,
|
||||
// operator will trigger factory reset to apply it latter, triggering factoryreset
|
||||
// will break the DownloadRPC message flow
|
||||
#ifdef ICWMP_ENABLE_OPCONF_SUPPORT
|
||||
if (err == CWMP_OK && pdownload->filetype != DOWNLOAD_FILETYPE_OPERATOR_CONF_FILE) {
|
||||
#else
|
||||
if (err == CWMP_OK) {
|
||||
#endif
|
||||
if (is_opconf == true) {
|
||||
CWMP_LOG(INFO, "Trigger Soft Factory Reset to apply the opconf");
|
||||
cwmp_factory_reset(true);
|
||||
|
|
@ -906,6 +916,9 @@ int apply_downloaded_file(struct download *pdownload, char *download_file_name,
|
|||
if (error == FAULT_CPE_NO_FAULT) {
|
||||
set_rpc_parameter_key(pdownload->command_key);
|
||||
if (pdownload->filetype == DOWNLOAD_FILETYPE_WEB_CONTENT ||
|
||||
#ifdef ICWMP_ENABLE_OPCONF_SUPPORT
|
||||
pdownload->filetype == DOWNLOAD_FILETYPE_OPERATOR_CONF_FILE ||
|
||||
#endif
|
||||
pdownload->filetype == DOWNLOAD_FILETYPE_STORED_FIRMWARE_IMAGE) {
|
||||
|
||||
bkp_session_delete_element((ltype == TYPE_DOWNLOAD) ? "download" : "schedule_download", pdownload->id);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue