From: Pablo Neira Ayuso <[email protected]>

This patch adds several messages that would be displayed if:

* the Ki argument is missing.
* you pass an invalid Ki.
* the database fails to perform the operation (add/delete/update).

Before this patch, no messages were spotted on this errors.

I noticed this while adding Ki to the existing subscribers in the
nanoBTS setup: I introduced a wrong Ki but the VTY command line did
not report any error. A quick look at the database via sqlite
command confirmed that the new authkey information was not added.
---
 openbsc/src/libmsc/vty_interface_layer3.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/openbsc/src/libmsc/vty_interface_layer3.c 
b/openbsc/src/libmsc/vty_interface_layer3.c
index 2d3dd14..6ac2c65 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -575,6 +575,8 @@ DEFUN(ena_subscr_a3a8,
        } else {
                /* Unknown method */
                subscr_put(subscr);
+               vty_out(vty, "%% Unknown auth method %s%s",
+                               alg_str, VTY_NEWLINE);
                return CMD_WARNING;
        }
 
@@ -582,6 +584,8 @@ DEFUN(ena_subscr_a3a8,
                rc = hexparse(ki_str, ainfo.a3a8_ki, sizeof(ainfo.a3a8_ki));
                if ((rc > maxlen) || (rc < minlen)) {
                        subscr_put(subscr);
+                       vty_out(vty, "%% Wrong Ki `%s'%s",
+                               ki_str, VTY_NEWLINE);
                        return CMD_WARNING;
                }
                ainfo.a3a8_ki_len = rc;
@@ -589,6 +593,7 @@ DEFUN(ena_subscr_a3a8,
                ainfo.a3a8_ki_len = 0;
                if (minlen) {
                        subscr_put(subscr);
+                       vty_out(vty, "%% Missing Ki argument%s", VTY_NEWLINE);
                        return CMD_WARNING;
                }
        }
@@ -601,7 +606,11 @@ DEFUN(ena_subscr_a3a8,
        db_sync_lastauthtuple_for_subscr(NULL, subscr);
        subscr_put(subscr);
 
-       return rc ? CMD_WARNING : CMD_SUCCESS;
+       if (rc) {
+               vty_out(vty, "%% Operation has failed%s", VTY_NEWLINE);
+               return CMD_WARNING;
+       }
+       return CMD_SUCCESS;
 }
 
 DEFUN(subscriber_purge,
-- 
1.7.2.3


Reply via email to