]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/gnome2-console/authenticate.c
Added wx-console.exe and .conf.
[bacula/bacula] / bacula / src / gnome2-console / authenticate.c
index 0aa3f7d3659c443395e8ea631d863814fbc5a859..f1c6febd746da12f039b0d88a06550ec45a854b4 100644 (file)
@@ -45,21 +45,31 @@ static char OKhello[]   = "1000 OK:";
 /*
  * Authenticate Director
  */
-int authenticate_director(JCR *jcr, DIRRES *director, char *name)
+int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons)
 {
    BSOCK *dir = jcr->dir_bsock;
    int ssl_need = BNET_SSL_NONE;
    char bashed_name[MAX_NAME_LENGTH];
+   char *password;
 
    /* 
     * Send my name to the Director then do authentication
     */
-   bstrncpy(bashed_name, name, sizeof(bashed_name));
-   bash_spaces(bashed_name);
+   if (cons) {
+      bstrncpy(bashed_name, cons->hdr.name, sizeof(bashed_name));
+      bash_spaces(bashed_name);
+      password = cons->password;
+   } else {
+      bstrncpy(bashed_name, "*UserAgent*", sizeof(bashed_name));
+      password = director->password;
+   }
+   /* Timeout Hello after 5 mins */
+   btimer_t *tid = start_bsock_timer(dir, 60 * 5);
    bnet_fsend(dir, hello, bashed_name);
 
-   if (!cram_md5_get_auth(dir, director->password, ssl_need) || 
-       !cram_md5_auth(dir, director->password, ssl_need)) {
+   if (!cram_md5_get_auth(dir, password, ssl_need) || 
+       !cram_md5_auth(dir, password, ssl_need)) {
+      stop_bsock_timer(tid);
       printf(_("%s: Director authorization problem.\n"), my_name);
       set_text(_("Director authorization problem.\n"), -1);
       return 0;
@@ -67,6 +77,7 @@ int authenticate_director(JCR *jcr, DIRRES *director, char *name)
 
    Dmsg1(6, ">dird: %s", dir->msg);
    if (bnet_recv(dir) <= 0) {
+      stop_bsock_timer(tid);
       set_textf(_("Bad response to Hello command: ERR=%s\n"),
         bnet_strerror(dir));
       printf(_("%s: Bad response to Hello command: ERR=%s\n"),
@@ -74,6 +85,7 @@ int authenticate_director(JCR *jcr, DIRRES *director, char *name)
       set_text(_("The Director is probably not running.\n"), -1);
       return 0;
    }
+  stop_bsock_timer(tid);
    Dmsg1(10, "<dird: %s", dir->msg);
    if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) {
       set_text(_("Director rejected Hello command\n"), -1);