X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fgnome2-console%2Fauthenticate.c;h=382f5e86e364d29b14945785bcd2fd9df00f80b9;hb=377bf815eefec1e61a1e97469ae972a52aefde58;hp=3fe7a2f1beb3b252a3c3079f7e471b1572464918;hpb=0dcaf01f9eea3947355c3915e6a455824a2d70d6;p=bacula%2Fbacula diff --git a/bacula/src/gnome2-console/authenticate.c b/bacula/src/gnome2-console/authenticate.c index 3fe7a2f1be..382f5e86e3 100644 --- a/bacula/src/gnome2-console/authenticate.c +++ b/bacula/src/gnome2-console/authenticate.c @@ -13,22 +13,32 @@ * */ /* - Copyright (C) 2000, 2001 Kern Sibbald and John Walker + Bacula® - The Network Backup Solution - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. + Copyright (C) 2001-2006 Free Software Foundation Europe e.V. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of Kern Sibbald. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ #include "bacula.h" #include "console.h" @@ -45,32 +55,54 @@ static char OKhello[] = "1000 OK:"; /* * Authenticate Director */ -int authenticate_director(JCR *jcr, DIRRES *director) +int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons) { BSOCK *dir = jcr->dir_bsock; - int ssl_need = BNET_SSL_NONE; + int tls_local_need = BNET_TLS_NONE; + int tls_remote_need = BNET_TLS_NONE; + int compatible = true; + char bashed_name[MAX_NAME_LENGTH]; + char *password; - /* + /* * Send my name to the Director then do authentication */ - bnet_fsend(dir, hello, "UserAgent"); + if (cons) { + bstrncpy(bashed_name, cons->hdr.name, sizeof(bashed_name)); + bash_spaces(bashed_name); + password = cons->password; + } else { + bstrncpy(bashed_name, "*UserAgent*", sizeof(bashed_name)); + password = director->password; + } + /* Timeout Hello after 5 mins */ + btimer_t *tid = start_bsock_timer(dir, 60 * 5); + bnet_fsend(dir, hello, bashed_name); - if (!cram_md5_get_auth(dir, director->password, ssl_need) || - !cram_md5_auth(dir, director->password, ssl_need)) { + /* respond to Dir challenge */ + if (!cram_md5_respond(dir, password, &tls_remote_need, &compatible) || + /* Now challenge dir */ + !cram_md5_challenge(dir, password, tls_local_need, compatible)) { + stop_bsock_timer(tid); printf(_("%s: Director authorization problem.\n"), my_name); set_text(_("Director authorization problem.\n"), -1); + set_text(_( + "Please see http://www.bacula.org/en/rel-manual/Bacula_Freque_Asked_Questi.html#SECTION003760000000000000000 for help.\n"), + -1); return 0; } Dmsg1(6, ">dird: %s", dir->msg); if (bnet_recv(dir) <= 0) { + stop_bsock_timer(tid); set_textf(_("Bad response to Hello command: ERR=%s\n"), - bnet_strerror(dir)); + bnet_strerror(dir)); printf(_("%s: Bad response to Hello command: ERR=%s\n"), - my_name, bnet_strerror(dir)); + my_name, bnet_strerror(dir)); set_text(_("The Director is probably not running.\n"), -1); return 0; } + stop_bsock_timer(tid); Dmsg1(10, "msg); if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) { set_text(_("Director rejected Hello command\n"), -1);