]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/authenticate.c
Massive SD calling sequence reorganization
[bacula/bacula] / bacula / src / dird / authenticate.c
index ad14435abf5a5371198c5e11c6c01ae7a12d7c31..dd6787c9ba4c7ffdab88629e398f0669058dc846 100644 (file)
@@ -11,7 +11,7 @@
  *
  */
 /*
-   Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+   Copyright (C) 2001-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -45,14 +45,14 @@ static char OKhello[]   = "3000 OK Hello\n";
 static char FDOKhello[] = "2000 OK Hello\n";
 
 /* Sent to User Agent */
-static char Dir_sorry[]  = N_("1999 You are not authorized.\n");
+static char Dir_sorry[]  = "1999 You are not authorized.\n";
 
 /* Forward referenced functions */
 
 /*
  * Authenticate Storage daemon connection
  */
-int authenticate_storage_daemon(JCR *jcr)
+bool authenticate_storage_daemon(JCR *jcr, STORE *store) 
 {
    BSOCK *sd = jcr->store_bsock;
    char dirname[MAX_NAME_LENGTH];
@@ -63,17 +63,18 @@ int authenticate_storage_daemon(JCR *jcr)
     */
    bstrncpy(dirname, director->hdr.name, sizeof(dirname));
    bash_spaces(dirname);
-   /* Timeout Hello after 5 mins */
-   btimer_t *tid = start_bsock_timer(sd, 60 * 5);
+   /* Timeout Hello after 1 min */
+   btimer_t *tid = start_bsock_timer(sd, 60);
    if (!bnet_fsend(sd, hello, dirname)) {
       stop_bsock_timer(tid);
       Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to Storage daemon. ERR=%s\n"), bnet_strerror(sd));
       return 0;
    }
-   if (!cram_md5_get_auth(sd, jcr->store->password, ssl_need) || 
-       !cram_md5_auth(sd, jcr->store->password, ssl_need)) {
+   if (!cram_md5_get_auth(sd, store->password, ssl_need) || 
+       !cram_md5_auth(sd, store->password, ssl_need)) {
       stop_bsock_timer(tid);
-      Jmsg0(jcr, M_FATAL, 0, _("Director and Storage daemon passwords or names not the same.\n"));
+      Jmsg0(jcr, M_FATAL, 0, _("Director and Storage daemon passwords or names not the same.\n"   
+       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
       return 0;
    }
    Dmsg1(116, ">stored: %s", sd->msg);
@@ -116,7 +117,8 @@ int authenticate_file_daemon(JCR *jcr)
    if (!cram_md5_get_auth(fd, jcr->client->password, ssl_need) || 
        !cram_md5_auth(fd, jcr->client->password, ssl_need)) {
       stop_bsock_timer(tid);
-      Jmsg(jcr, M_FATAL, 0, _("Director and File daemon passwords or names not the same.\n"));
+      Jmsg(jcr, M_FATAL, 0, _("Director and File daemon passwords or names not the same.\n"   
+       "Please see http://www.bacula.org/html-manual/faq.html#AuthorizationErrors for help.\n"));
       return 0;
    }
    Dmsg1(116, ">filed: %s", fd->msg);
@@ -145,6 +147,8 @@ int authenticate_user_agent(UAContext *uac)
    bool ok;    
    BSOCK *ua = uac->UA_sock;
 
+//  Emsg4(M_INFO, 0, _("UA Hello from %s:%s:%d is invalid. Len=%d\n"), ua->who,
+//         ua->host, ua->port, ua->msglen);
    if (ua->msglen < 16 || ua->msglen >= MAX_NAME_LENGTH + 15) {
       Emsg4(M_ERROR, 0, _("UA Hello from %s:%s:%d is invalid. Len=%d\n"), ua->who,
            ua->host, ua->port, ua->msglen);
@@ -157,8 +161,7 @@ int authenticate_user_agent(UAContext *uac)
            ua->host, ua->port, ua->msg);
       return 0;
    }
-// Dmsg2(000, "Console=%s addr=%s\n", name, inet_ntoa(ua->client_addr.sin_addr));
-   name[MAXSTRING-1] = 0;            /* terminate name */
+   name[sizeof(name)-1] = 0;            /* terminate name */
    if (strcmp(name, "*UserAgent*") == 0) {  /* default console */
       ok = cram_md5_auth(ua, director->password, ssl_need) &&
           cram_md5_get_auth(ua, director->password, ssl_need);