diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03146ac7a439244d8057f6e9ae5d660f075b85e3..df790d0dcd3c41abde7f6a1e767bb94c8dfb323e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,19 @@ +variables: + SOURCE_FOLDER: "src" + include: - project: 'iopsys/gitlab-ci-pipeline' file: '/static-code-analysis.yml' - ref: '0.31' + ref: '1.2' stages: - static_code_analysis + - compilation_test -variables: - DEBUG: 'TRUE' - SOURCE_FOLDER: "./src" - FLAWFINDER_OPTIONS: "-m 4 --error-level=5" - CPPCHECK_OPTIONS: "--enable=all --error-exitcode=1" - COMPILE: "./gitlab-ci/compile.sh" +run_compilation_test: + image: ${COMMON_IMAGE} + stage: compilation_test + allow_failure: false + script: + - "./gitlab-ci/compile.sh" diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh new file mode 100755 index 0000000000000000000000000000000000000000..285cc185721796dab4b7e8dba2c5292c8a88c21f --- /dev/null +++ b/gitlab-ci/install-dependencies.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "install dependencies for tests" +source ./gitlab-ci/shared.sh + +# install bbfdm +install_bbfdm diff --git a/gitlab-ci/shared.sh b/gitlab-ci/shared.sh index f098751729cd67463d6d4912bc1bf7ffab42ee40..dc606510de3df2aea40656ed8fb4bd4c8a414169 100644 --- a/gitlab-ci/shared.sh +++ b/gitlab-ci/shared.sh @@ -13,7 +13,7 @@ function exec_cmd() function install_bbfdm() { - [ -d "/opt/dev/bbfdm" ] && rm -rf /opt/dev/bbfdm + [ -d "/opt/dev/bbfdm" ] && return 0 if [ -n "${BBFDM_BRANCH}" ]; then exec_cmd git clone -b ${BBFDM_BRANCH} https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm diff --git a/src/sshmngr.c b/src/sshmngr.c index bbccd1eabb01de9a3d52dd42ada1a187f98c94dd..59fa163a6ae2974b4530b8cfd0103c3365562a03 100644 --- a/src/sshmngr.c +++ b/src/sshmngr.c @@ -141,26 +141,9 @@ static int addObjSSHServer(char *refparam, struct dmctx *ctx, void *data, char * static int delObjSSHServer(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action) { - struct uci_section *s = NULL, *stmp = NULL; - - switch (del_action) { - case DEL_INST: - close_active_sessions(((struct dm_data *)data)->config_section); - dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL); - dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL); - break; - case DEL_ALL: - uci_foreach_sections_safe(BACKEND_UCI, BACKEND_SECTION_TYPE, stmp, s) { - struct uci_section *dmmap_section = NULL; - - get_dmmap_section_of_config_section("dmmap_sshmngr", BACKEND_SECTION_TYPE, section_name(s), &dmmap_section); - dmuci_delete_by_section(dmmap_section, NULL, NULL); - - close_active_sessions(s); - dmuci_delete_by_section(s, NULL, NULL); - } - break; - } + close_active_sessions(((struct dm_data *)data)->config_section); + dmuci_delete_by_section(((struct dm_data *)data)->config_section, NULL, NULL); + dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL); return 0; } @@ -174,23 +157,11 @@ static int addObjSSHKey(char *refparam, struct dmctx *ctx, void *data, char **in static int delObjSSHKey(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action) { - struct uci_section *s = NULL, *stmp = NULL; char *value = NULL; - switch (del_action) { - case DEL_INST: - dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "pubkey", &value); - remove_pubkey(value); - dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL); - break; - case DEL_ALL: - uci_path_foreach_sections_safe(bbfdm, "dmmap_sshmngr", "authkey", stmp, s) { - dmuci_get_value_by_section_string(s, "pubkey", &value); - remove_pubkey(value); - dmuci_delete_by_section(s, NULL, NULL); - } - break; - } + dmuci_get_value_by_section_string(((struct dm_data *)data)->dmmap_section, "pubkey", &value); + remove_pubkey(value); + dmuci_delete_by_section(((struct dm_data *)data)->dmmap_section, NULL, NULL); return 0; } @@ -344,7 +315,7 @@ static int get_ssh_key_num(char *refparam, struct dmctx *ctx, void *data, char * static int get_ssh_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = "Enabled"; + *value = dmstrdup("Enabled"); return 0; } @@ -599,7 +570,7 @@ static int get_ssh_server_pid(char *refparam, struct dmctx *ctx, void *data, cha struct uci_section *s = ((struct dm_data *)data)->config_section; char *en = dmuci_get_value_by_section_fallback_def(s, "enable", "0"); - *value = "0"; + *value = dmstrdup("0"); string_to_bool(en, &b); if (!b) return 0;