]> git.sur5r.net Git - ngadmin/blobdiff - cli/admin.c
Cli: fix crash when interrupting an automatic login attempt
[ngadmin] / cli / admin.c
index b40bbd99d5b45e2ea6d9765171159ecfb2b81fae..40f5431ba8df0a95eb9af189cd2483888f02e9ff 100644 (file)
@@ -15,8 +15,6 @@
 #define MAXCOM 32
 
 
-int main_loop_continue = 1;
-
 
 static const struct TreeNode* getSubCom (char **com, int n, int *t)
 {
@@ -107,6 +105,7 @@ static char** my_completion (const char *text, int start, int end UNUSED)
 }
 
 
+int main_loop_continue;
 static struct ngadmin *nga;
 static sigjmp_buf jmpbuf;
 static struct termios orig_term;
@@ -125,7 +124,7 @@ NORET static void handler (int sig)
                current_term.c_lflag |= ECHO;
                tcsetattr(STDIN_FILENO, TCSANOW, &current_term);
                
-               if (!batch)
+               if (!batch && main_loop_continue)
                        siglongjmp(jmpbuf, 1);
        
        default:
@@ -151,7 +150,7 @@ static int pre_login (const struct ether_addr *mac, int retries)
                err = ngadmin_scan(nga);
                if (err < 0) {
                        printErrCode(err);
-                       continue;
+                       return err;
                }
                
                /* search switch with requested MAC */
@@ -331,6 +330,7 @@ int main (int argc, char **argv)
                sigsetjmp(jmpbuf, 1);
        }
        
+       main_loop_continue = 1;
        while (main_loop_continue) {
                /* read user input */
                line = NULL;