4 * Kern Sibbald, October 2000
10 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of
15 the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public
23 License along with this program; if not, write to the Free
24 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
32 static char Dir_sorry[] = "3999 No go\n";
33 static char OK_hello[] = "3000 OK Hello\n";
36 /*********************************************************************
40 static int authenticate(int rcode, BSOCK *bs)
45 if (rcode != R_DIRECTOR) {
46 Emsg1(M_FATAL, 0, _("I only authenticate Directors, not %d\n"), rcode);
49 name = (char *) get_pool_memory(PM_MESSAGE);
50 name = (char *) check_pool_memory_size(name, bs->msglen);
52 if (sscanf(bs->msg, "Hello Director %127s calling\n", name) != 1) {
53 free_pool_memory(name);
54 Emsg1(M_FATAL, 0, _("Authentication failure: %s\n"), bs->msg);
59 while ((director=(DIRRES *)GetNextRes(rcode, (RES *)director))) {
60 if (strcmp(director->hdr.name, name) == 0)
64 if (director && (!cram_md5_auth(bs, director->password) ||
65 !cram_md5_get_auth(bs, director->password))) {
68 free_pool_memory(name);
69 return (director != NULL);
73 * Inititiate the message channel with the Director.
74 * He has made a connection to our server.
76 * Basic tasks done here:
77 * Assume the Hello message is already in the input
78 * buffer. We then authenticate him.
79 * Get device, media, and pool information from Director
81 * This is the channel across which we will send error
82 * messages and job status information.
84 int authenticate_director(JCR *jcr)
86 BSOCK *dir = jcr->dir_bsock;
88 if (!authenticate(R_DIRECTOR, dir)) {
89 bnet_fsend(dir, "%s", Dir_sorry);
90 Emsg0(M_ERROR, 0, _("Unable to authenticate Director\n"));
93 return bnet_fsend(dir, "%s", OK_hello);
96 int authenticate_filed(JCR *jcr)
98 BSOCK *fd = jcr->file_bsock;
100 if (cram_md5_auth(fd, jcr->sd_auth_key) &&
101 cram_md5_get_auth(fd, jcr->sd_auth_key)) {
102 jcr->authenticated = TRUE;
104 return jcr->authenticated;