From 0b62193d92e1969af809e4a1127d1b2f118e0d5a Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 29 Apr 2022 17:17:43 -0500 Subject: [PATCH] Add new error code for security https://github.com/Hamlib/Hamlib/issues/813 --- include/hamlib/rig.h | 5 +++-- src/rig.c | 9 ++++++--- tests/rigctl_parse.c | 5 ++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 736e737ac..9b6e5811e 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -157,7 +157,8 @@ enum rig_errcode_e { RIG_EARG, /*!< 15 NULL RIG handle or any invalid pointer parameter in get arg */ RIG_EVFO, /*!< 16 Invalid VFO */ RIG_EDOM, /*!< 17 Argument out of domain of func */ - RIG_EDEPRECATED /*!< 18 Function deprecated */ + RIG_EDEPRECATED,/*!< 18 Function deprecated */ + RIG_ESECURITY /*!< 19 Security error */ }; /** @@ -167,7 +168,7 @@ enum rig_errcode_e { */ #define RIG_IS_SOFT_ERRCODE(errcode) (errcode == RIG_EINVAL || errcode == RIG_ENIMPL || errcode == RIG_ERJCTED \ || errcode == RIG_ETRUNC || errcode == RIG_ENAVAIL || errcode == RIG_ENTARGET \ - || errcode == RIG_EVFO || errcode == RIG_EDOM) + || errcode == RIG_EVFO || errcode == RIG_EDOM || errcode == RIG_ESECURITY) /** * \brief Token in the netrigctl protocol for returning error code diff --git a/src/rig.c b/src/rig.c index a8a908a7e..8fe2828ae 100644 --- a/src/rig.c +++ b/src/rig.c @@ -195,7 +195,8 @@ static const char *const rigerror_table[] = "NULL RIG handle or invalid pointer parameter", "Invalid VFO", "Argument out of domain of func", - "Function deprecated" + "Function deprecated", + "Security error password not provided or crypto failure" }; @@ -1950,9 +1951,11 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) *freq += rig->state.lo_freq; } - rig_cache_show(rig, __func__, __LINE__); + if (retcode == RIG_OK) + rig_cache_show(rig, __func__, __LINE__); rig_set_cache_freq(rig, vfo, *freq); - rig_cache_show(rig, __func__, __LINE__); + if (retcode == RIG_OK) + rig_cache_show(rig, __func__, __LINE__); ELAPSED2; return (retcode); diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index ba8261e69..0487e0de4 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1702,10 +1702,9 @@ readline_repeat: if (use_password && !is_passwordOK && (cmd_entry->arg1 != NULL) && !preCmd) { - rig_debug(RIG_DEBUG_ERR, "%s: need password=%s for cmd=%s\n", __func__, - rigctld_password, cmd_entry->arg1); + rig_debug(RIG_DEBUG_ERR, "%s: password has not been provided\n", __func__) fflush(fin); - retcode = -RIG_EPROTO; + retcode = -RIG_ESECURITY; } else