]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/authenticate.c
Use the command line utility dropdb instead of the psql command
[bacula/bacula] / bacula / src / stored / authenticate.c
index 5d4d670901f11418cca20975c474108d4e3e1e0b..5b0ce30e9eac0a0c098eedb1258c792b80a78c40 100644 (file)
@@ -41,13 +41,15 @@ static int authenticate(int rcode, BSOCK *bs)
 {
    POOLMEM *dirname;
    DIRRES *director = NULL;
+   int ssl_need = BNET_SSL_NONE;
 
    if (rcode != R_DIRECTOR) {
       Emsg1(M_FATAL, 0, _("I only authenticate Directors, not %d\n"), rcode);
       return 0;
    }
    if (bs->msglen < 25 || bs->msglen > 200) {
-      Emsg0(M_FATAL, 0, _("Bad Hello command from Director.\n"));
+      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s. Len=%d.\n"), 
+           bs->who, bs->msglen);
       return 0;
    }
    dirname = get_pool_memory(PM_MESSAGE);
@@ -55,7 +57,8 @@ static int authenticate(int rcode, BSOCK *bs)
 
    if (sscanf(bs->msg, "Hello Director %127s calling\n", dirname) != 1) {
       bs->msg[100] = 0;
-      Emsg1(M_FATAL, 0, _("Bad Hello command from Director: %s\n"), bs->msg);
+      Emsg2(M_FATAL, 0, _("Bad Hello command from Director at %s: %s\n"), 
+           bs->who, bs->msg);
       return 0;
    }
    director = NULL;
@@ -67,11 +70,12 @@ static int authenticate(int rcode, BSOCK *bs)
    }
    UnlockRes();
    if (!director) {
-      Emsg1(M_FATAL, 0, _("Connection from unknown Director %s rejected.\n"), dirname);
+      Emsg2(M_FATAL, 0, _("Connection from unknown Director %s at %s rejected.\n"), 
+           dirname, bs->who);
       goto bail_out;
    }
-   if (!cram_md5_auth(bs, director->password) ||
-       !cram_md5_get_auth(bs, director->password)) {
+   if (!cram_md5_auth(bs, director->password, ssl_need) ||
+       !cram_md5_get_auth(bs, director->password, ssl_need)) {
       Emsg0(M_FATAL, 0, _("Incorrect password given by Director.\n"));
       goto bail_out;
    }
@@ -101,8 +105,8 @@ int authenticate_director(JCR *jcr)
 
    if (!authenticate(R_DIRECTOR, dir)) {
       bnet_fsend(dir, "%s", Dir_sorry);
-      Emsg0(M_ERROR, 0, _("Unable to authenticate Director\n"));
-      sleep(5);
+      Emsg1(M_ERROR, 0, _("Unable to authenticate Director at %s.\n"), dir->who);
+      bmicrosleep(5, 0);
       return 0;
    }
    return bnet_fsend(dir, "%s", OK_hello);
@@ -111,13 +115,15 @@ int authenticate_director(JCR *jcr)
 int authenticate_filed(JCR *jcr)
 {
    BSOCK *fd = jcr->file_bsock;
+   int ssl_need = BNET_SSL_NONE;
 
-   if (cram_md5_auth(fd, jcr->sd_auth_key) &&
-       cram_md5_get_auth(fd, jcr->sd_auth_key)) {
+   if (cram_md5_auth(fd, jcr->sd_auth_key, ssl_need) &&
+       cram_md5_get_auth(fd, jcr->sd_auth_key, ssl_need)) {
       jcr->authenticated = TRUE;
    }
    if (!jcr->authenticated) {
-      Jmsg(jcr, M_FATAL, 0, _("Incorrect authorization key from File daemon rejected.\n"));
+      Jmsg(jcr, M_FATAL, 0, _("Incorrect authorization key from File daemon at %s rejected.\n"), 
+          fd->who);
    }
    return jcr->authenticated;
 }