Fix vendor log upload

This commit is contained in:
suvendhu 2022-11-04 10:18:21 +05:30
parent 61131746e2
commit 641a98fc37
4 changed files with 31 additions and 13 deletions

View file

@ -63,8 +63,8 @@
#define MAX_NBRE_SERVICES 256
#define FIREWALL_CWMP "/etc/firewall.cwmp"
#define CWMP_VARSTATE_UCI_PACKAGE "/var/state/cwmp"
#define DM_PPP_INTERFACE_PATH "Device.PPP.Interface."
#define DM_IP_INTERFACE_PATH "Device.IP.Interface."
#define DM_PPP_INTERFACE_PATH "Device\\.PPP\\.Interface\\."
#define DM_IP_INTERFACE_PATH "Device\\.IP\\.Interface\\."
#define foreach_elt_in_strlist(elt, str, delim) \
char *tmpchr; \

View file

@ -50,8 +50,8 @@ static bool interface_reset_req(char *param_name, char *value)
if (param_name == NULL || value == NULL)
return false;
char reg_exp[60] = {0};
snprintf(reg_exp, sizeof(reg_exp), "^(%s|%s)[0-9]+.Reset$", DM_IP_INTERFACE_PATH, DM_PPP_INTERFACE_PATH);
char reg_exp[100] = {0};
snprintf(reg_exp, sizeof(reg_exp), "^(%s|%s)[0-9]+\\.Reset$", DM_IP_INTERFACE_PATH, DM_PPP_INTERFACE_PATH);
if (match_reg_exp(reg_exp, param_name) == false)
return false;

View file

@ -407,8 +407,8 @@ end:
static int validate_inform_parameter_name(struct list_head *parameters_values_list)
{
struct cwmp_dm_parameter *param_value = NULL;
char reg_exp[65] = {0};
snprintf(reg_exp, sizeof(reg_exp), "^Device.ManagementServer.InformParameter.[0-9]+.ParameterName$");
char reg_exp[100] = {0};
snprintf(reg_exp, sizeof(reg_exp), "^Device\\.ManagementServer\\.InformParameter\\.[0-9]+\\.ParameterName$");
list_for_each_entry(param_value, parameters_values_list, list) {
if (param_value->name == NULL || param_value->value == NULL)

View file

@ -79,10 +79,17 @@ int upload_file(const char *file_path, const char *url, const char *username, co
CWMP_LOG(ERROR, "upload %s: url is null", __FUNCTION__);
return -1;
}
if (file_path == NULL) {
file_path = "/tmp/upload_file";
CWMP_LOG(ERROR, "upload file name unknown");
return -1;
}
stat(file_path, &file_info);
if (0 != stat(file_path, &file_info)) {
CWMP_LOG(ERROR, "upload file %s not exists", file_path);
return -1;
}
fd_upload = fopen(file_path, "rb");
if (fd_upload == NULL) {
CWMP_LOG(ERROR, "Failed to open url[%s] for upload", file_path);
@ -199,12 +206,20 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
cwmp_uci_export(file_path, UCI_STANDARD_CONFIG);
cwmp_uci_exit();
} else if (pupload->file_type[0] == '2') {
snprintf(file_path, sizeof(file_path), "/tmp/syslog");
copy("/var/log/syslog", file_path);
lookup_vlf_name(1, &name);
if (name && strlen(name) > 0) {
snprintf(file_path, sizeof(file_path), "/tmp/messages");
// cppcheck-suppress uninitvar
if (copy(name, file_path) != 0) {
error = FAULT_CPE_UPLOAD_FAILURE;
FREE(name);
}
FREE(name);
} else
error = FAULT_CPE_UPLOAD_FAILURE;
} else if (pupload->file_type[0] == '3') {
lookup_vcf_name(pupload->f_instance, &name);
if (name && strlen(name) > 0) {
// cppcheck-suppress uninitvar
snprintf(file_path, sizeof(file_path), "/tmp/%s", name);
cwmp_uci_init();
cwmp_uci_export_package(name, file_path, UCI_STANDARD_CONFIG);
@ -217,8 +232,11 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
} else { //file_type is 4
lookup_vlf_name(pupload->f_instance, &name);
if (name && strlen(name) > 0) {
snprintf(file_path, sizeof(file_path), "/tmp/%s", name);
copy(name, file_path);
snprintf(file_path, sizeof(file_path), "/tmp/.cwmp_upload");
if (copy(name, file_path) != 0) {
error = FAULT_CPE_UPLOAD_FAILURE;
FREE(name);
}
FREE(name);
} else
error = FAULT_CPE_UPLOAD_FAILURE;