]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/console/console.c
Restore all/done updates
[bacula/bacula] / bacula / src / console / console.c
index 51f49961d02c90f223b7f2641b887023253fb0d2..f61f9e5e58ae8726f0c8db837c84416eac572de2 100644 (file)
@@ -51,7 +51,7 @@ extern int rl_catch_signals;
 #endif
 
 /* Imported functions */
-int authenticate_director(JCR *jcr, DIRRES *director);
+int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
 
 
 
@@ -196,10 +196,19 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
       }
       if (tty_input) {
         stat = get_cmd(input, prompt, UA_sock, 30);
-        clrbrk();
+        if (usrbrk() == 1) {
+           clrbrk();
+        }
+        if (usrbrk()) {
+           break;
+        }
       } else {
+        /* Reading input from a file */
         int len = sizeof_pool_memory(UA_sock->msg) - 1;
-        if (fgets(UA_sock->msg, len, input) == NULL || usrbrk()) {
+        if (usrbrk()) {
+           break;
+        }
+        if (fgets(UA_sock->msg, len, input) == NULL) {
            stat = -1;
         } else {
            sendit(UA_sock->msg);  /* echo to terminal */
@@ -245,6 +254,11 @@ static void read_and_process_input(FILE *input, BSOCK *UA_sock)
            sendit(UA_sock->msg);
         }
       }
+      if (usrbrk() > 1) {
+        break;
+      } else {
+        clrbrk();
+      }
       if (!stop) {
         fflush(stdout);
       }
@@ -359,7 +373,9 @@ Without that I don't how to speak to the Director :-(\n"), configfile);
 
 
    if (ndir > 1) {
-      UA_sock = init_bsock(NULL, 0, "", "", 0);
+      struct sockaddr_in client_addr;
+      memset(&client_addr, 0, sizeof(client_addr));
+      UA_sock = init_bsock(NULL, 0, "", "", 0, &client_addr);
 try_again:
       sendit(_("Available Directors:\n"));
       LockRes();
@@ -398,7 +414,12 @@ try_again:
       return 1;
    }
    jcr.dir_bsock = UA_sock;
-   if (!authenticate_director(&jcr, dir)) {
+
+   LockRes();
+   CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, (RES *)NULL);
+   UnlockRes();
+   /* If cons==NULL, default console will be used */
+   if (!authenticate_director(&jcr, dir, cons)) {
       fprintf(stderr, "ERR=%s", UA_sock->msg);
       terminate_console(0);
       return 1;