From 1d2362e49300cdbe7d7492decade46006fe1ab46 Mon Sep 17 00:00:00 2001 From: Omar Kallel Date: Thu, 1 Nov 2018 13:43:36 +0100 Subject: [PATCH] Ticket refs #16060: TR-069: method to download ubus-x certificates/keys --- scripts/functions/common | 23 +++++++++++++++++++++++ scripts/icwmp.sh | 4 ++++ xml.c | 14 ++++++++------ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/scripts/functions/common b/scripts/functions/common index a86993f..51e36f9 100644 --- a/scripts/functions/common +++ b/scripts/functions/common @@ -177,3 +177,26 @@ icwmp_apply_vendor_configuration() fi } +icwmp_apply_ca_ssl_certificate_key() +{ + local fault_code="9000" + + local current_file="/tmp/owsd-repeater-control-cert.pem" +# if [ $# -gt 0 ]; then +# current_file="/tmp/$1" +# fi + cert=`uci get owsd.ubusproxy.peer_cert` +# i=1 +# test=true +# path="" +# while [[ $test ]] +# do +# i=$((i+1)) +# command="echo $cert | awk -F\"/\" '{print \$$i}'" +# dir=`eval $command` +# if [[ -z $dir ]]; then break; fi +# path=$path"/"$dir +# if [ ! -d $path ]; then mkdir $path; fi +# done + cp $current_file $cert +} diff --git a/scripts/icwmp.sh b/scripts/icwmp.sh index b18ac89..182e6ce 100644 --- a/scripts/icwmp.sh +++ b/scripts/icwmp.sh @@ -321,6 +321,9 @@ handle_action() { mv /tmp/icwmp_download /tmp/vendor_configuration_file.cfg 2> /dev/null fi icwmp_fault_output "" "$FAULT_CPE_NO_FAULT" + elif [ "$__arg3" = "6" ]; then + mv /tmp/icwmp_download /tmp/owsd-repeater-control-cert.pem 2> /dev/null + icwmp_fault_output "" "$FAULT_CPE_NO_FAULT" else let fault_code=$fault_code+$FAULT_CPE_DOWNLOAD_FAILURE icwmp_fault_output "" "$fault_code" @@ -433,6 +436,7 @@ handle_action() { icwmp_apply_vendor_configuration fi ;; + 6) icwmp_apply_ca_ssl_certificate_key ;; esac fi diff --git a/xml.c b/xml.c index 8be675c..e14a1dc 100644 --- a/xml.c +++ b/xml.c @@ -2521,7 +2521,7 @@ void *thread_cwmp_rpc_cpe_download (void *v) } free(fault_code); if((error == FAULT_CPE_NO_FAULT) && - (pdownload->file_type[0] == '1' || pdownload->file_type[0] == '3')) + (pdownload->file_type[0] == '1' || pdownload->file_type[0] == '3' || pdownload->file_type[0] == '6')) { exit(EXIT_SUCCESS); } @@ -2714,7 +2714,7 @@ void *thread_cwmp_rpc_cpe_schedule_download (void *v) } free(fault_code); if((error == FAULT_CPE_NO_FAULT) && - (current_download->file_type[0] == '1' || current_download->file_type[0] == '3')) + (current_download->file_type[0] == '1' || current_download->file_type[0] == '3' || current_download->file_type[0] == '6')) { exit(EXIT_SUCCESS); } @@ -2783,7 +2783,7 @@ void *thread_cwmp_rpc_cpe_schedule_download (void *v) } free(fault_code); if((error == FAULT_CPE_NO_FAULT) && - (current_download->file_type[0] == '1' || current_download->file_type[0] == '3')) + (current_download->file_type[0] == '1' || current_download->file_type[0] == '3' || current_download->file_type[0] == '6')) { exit(EXIT_SUCCESS); } @@ -2975,7 +2975,7 @@ void *thread_cwmp_rpc_cpe_apply_schedule_download (void *v) } free(fault_code); if((error == FAULT_CPE_NO_FAULT) && - (apply_download->file_type[0] == '1' || apply_download->file_type[0] == '3')) + (apply_download->file_type[0] == '1' || apply_download->file_type[0] == '3' || apply_download->file_type[0] == '6')) { exit(EXIT_SUCCESS); } @@ -4132,7 +4132,8 @@ int cwmp_handle_rpc_cpe_download(struct session *session, struct rpc *rpc) if(strcmp(file_type,"1 Firmware Upgrade Image") && strcmp(file_type,"2 Web Content") && - strcmp(file_type,"3 Vendor Configuration File")) + strcmp(file_type,"3 Vendor Configuration File") && + strcmp(file_type,"6 CWMP CA SSL Certificate File")) { error = FAULT_CPE_INVALID_ARGUMENTS; } @@ -4398,7 +4399,8 @@ int cwmp_handle_rpc_cpe_schedule_download(struct session *session, struct rpc *r strcmp(file_type,"2 Web Content") && strcmp(file_type,"3 Vendor Configuration File") && strcmp(file_type,"4 Tone File") && - strcmp(file_type,"5 Ringer File")) + strcmp(file_type,"5 Ringer File") && + strcmp(file_type,"6 CWMP CA SSL Certificate File")) { error = FAULT_CPE_INVALID_ARGUMENTS; }