2 Bacula® - The Network Backup Solution
4 Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation plus additions
11 that are listed in the file LICENSE.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of John Walker.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
31 * Bacula UA authentication. Provides authentication with
34 * Kern Sibbald, June MMI adapted to bat, Jan MMVI
44 /* Commands sent to Director */
45 static char hello[] = "Hello %s calling\n";
47 /* Response from Director */
48 static char OKhello[] = "1000 OK:";
50 /* Forward referenced functions */
53 * Authenticate Director
55 bool Console::authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons)
57 BSOCK *dir = jcr->dir_bsock;
58 int tls_local_need = BNET_TLS_NONE;
59 int tls_remote_need = BNET_TLS_NONE;
60 int compatible = true;
61 char bashed_name[MAX_NAME_LENGTH];
65 * Send my name to the Director then do authentication
68 bstrncpy(bashed_name, cons->hdr.name, sizeof(bashed_name));
69 bash_spaces(bashed_name);
70 password = cons->password;
72 bstrncpy(bashed_name, "*UserAgent*", sizeof(bashed_name));
73 password = director->password;
75 /* Timeout Hello after 5 mins */
76 btimer_t *tid = start_bsock_timer(dir, 60 * 5);
77 bnet_fsend(dir, hello, bashed_name);
79 /* respond to Dir challenge */
80 if (!cram_md5_respond(dir, password, &tls_remote_need, &compatible) ||
81 /* Now challenge dir */
82 !cram_md5_challenge(dir, password, tls_local_need, compatible)) {
83 stop_bsock_timer(tid);
84 printf(_("%s: Director authorization problem.\n"), my_name);
85 display_text(_("Director authorization problem.\n"));
87 "Please see http://www.bacula.org/rel-manual/faq.html#AuthorizationErrors for help.\n"));
91 Dmsg1(6, ">dird: %s", dir->msg);
92 if (bnet_recv(dir) <= 0) {
93 stop_bsock_timer(tid);
94 display_textf(_("Bad response to Hello command: ERR=%s\n"),
96 printf(_("%s: Bad response to Hello command: ERR=%s\n"),
97 my_name, bnet_strerror(dir));
98 display_text(_("The Director is probably not running.\n"));
101 stop_bsock_timer(tid);
102 Dmsg1(10, "<dird: %s", dir->msg);
103 if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) {
104 display_text(_("Director rejected Hello command\n"));
107 display_text(dir->msg);