3 * Bacula UA authentication. Provides authentication with
6 * Kern Sibbald, June MMI
10 * This routine runs as a thread and must be thread reentrant.
12 * Basic tasks done here:
16 Copyright (C) 2000, 2001 Kern Sibbald and John Walker
18 This program is free software; you can redistribute it and/or
19 modify it under the terms of the GNU General Public License
20 as published by the Free Software Foundation; either version 2
21 of the License, or (at your option) any later version.
23 This program is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 GNU General Public License for more details.
28 You should have received a copy of the GNU General Public License
29 along with this program; if not, write to the Free Software
30 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 /* Commands sent to Director */
38 static char hello[] = "Hello %s calling\n";
40 /* Response from Director */
41 static char OKhello[] = "1000 OK:";
43 /* Forward referenced functions */
46 * Authenticate Director
48 int authenticate_director(JCR *jcr, DIRRES *director, char *name)
50 BSOCK *dir = jcr->dir_bsock;
51 int ssl_need = BNET_SSL_NONE;
52 char bashed_name[MAX_NAME_LENGTH];
55 * Send my name to the Director then do authentication
57 bstrncpy(bashed_name, name, sizeof(bashed_name));
58 bash_spaces(bashed_name);
59 bnet_fsend(dir, hello, bashed_name);
61 if (!cram_md5_get_auth(dir, director->password, ssl_need) ||
62 !cram_md5_auth(dir, director->password, ssl_need)) {
63 printf(_("%s: Director authorization problem.\n"), my_name);
64 set_text(_("Director authorization problem.\n"), -1);
68 Dmsg1(6, ">dird: %s", dir->msg);
69 if (bnet_recv(dir) <= 0) {
70 set_textf(_("Bad response to Hello command: ERR=%s\n"),
72 printf(_("%s: Bad response to Hello command: ERR=%s\n"),
73 my_name, bnet_strerror(dir));
74 set_text(_("The Director is probably not running.\n"), -1);
77 Dmsg1(10, "<dird: %s", dir->msg);
78 if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) {
79 set_text(_("Director rejected Hello command\n"), -1);
82 set_text(dir->msg, dir->msglen);