Bacula-users

Re: [Bacula-users] bconsole can't talk to bacula-dir

2016-10-01 02:45:35
Subject: Re: [Bacula-users] bconsole can't talk to bacula-dir
From: "Hankins, Jonathan" <jhankins AT homewood.k12.al DOT us>
To: Jan Martin <fyzzics AT gmail DOT com>, Elias Pereira <empbilly AT gmail DOT com>
Date: Sat, 01 Oct 2016 06:44:26 +0000
So I've narrowed it down. If I build from Debian's patched source, but run ./configure myself, my flags in config.out look like:

Compiler flags:           -g -O2 -Wall -fno-strict-aliasing -fno-exceptions -fno-rtti
Linker flags:

However, if I build using debian's rules file, my flags in config.out look like:

Compiler flags:           -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-strict-aliasing -fno-exceptions -fno-rtti -fno-strict-aliasing -fno-exceptions -fno-rtti
Linker flags:             -Wl,-Bsymbolic-functions -Wl,-z,relro



So, I grabbed the *FLAGS variables from debian/rules, exported them manually, and re-ran ./configure myself, and got a bacula-dir that exhibits the same behavior we are seeing with the Mint (Debian) package version. 

export CFLAGS='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fno-strict-aliasing -fno-exceptions -fno-rtti'
export CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fno-exceptions -fno-rtti' # I don't know if this is used?
export LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro'

This is getting beyond my skills to troubleshoot...I could go through a process of elimination and narrow it down but I don't know if I'd know why it was causing the problem, even if I found out which flag it was. Maybe someone who knows something about those compiler flags can point me in the right direction?

Also, heading to the beach, so I will be out of pocket for a while.

FWIW, I think if you install the Debian source (you have to enable source in Mint's package manager), edit your debian/rules file and change the CFLAGS and LDFLAGS lines, I think you will build a working bacula-dir. But I still don't know why. FWIW, when I was having an ignorant stab at using gdb to get a backtrace from the Mint bacula-dir, it noted that some of the functions on the stack were optimized out. I don't know if that would have been caused by any of the compiler flags above, or if it has any bearing on our issue.

-Jonathan Hankins

On Sat, Oct 1, 2016 at 12:50 AM Hankins, Jonathan <jhankins AT homewood.k12.al DOT us> wrote:
So I built the source package on Mint 18 (it's from Debian upstream) and it is still broken. Then, I extracted the original source from the Debian package, and didn't apply the debian patches (except switch-nonfree-sha1-to-openssl.patch, which I had to do to get it to build). I set prefix to /opt/bacula so I could install it without stomping on anything, and ran ./configure --with-sqlite3. Built, installed and ran /opt/bacula/sbin/bacula-dir -f -c /etc/bacula/bacula-dir.conf (the default file from the Mint/Debian package) and it works correctly. So I re-built, but this time let dpkg-source apply all of Debian's patches, but then manually built with ./configure --with-sqlite3, etc. and it works. So it's not Debian's patched.

I will check how Debian runs configure, and see what piece is breaking it.

FWIW, On the non-working Mint binary, strace and gdb show me that bconsole connects, writes the greeting message to the socket and then tries to read the reply from the dir. The dir hangs in a select() on the socket, and eventually the bconsole times out.

-Jonathan Hankins

On Fri, Sep 30, 2016 at 9:01 PM Hankins, Jonathan <jhankins AT homewood.k12.al DOT us> wrote:
Jan,

I am assuming you're on the latest Mint (18) -- my Mint 18 workstation loaded bacula 7.0.5 when I installed it just now. I am having the same issue with the default config, so let me play with it and see what I can come up with.

-Jonathan Hankins

On Fri, Sep 30, 2016 at 6:29 PM Jan Martin <fyzzics AT gmail DOT com> wrote:
Hi,

On my system, you are right.  dir runs as bacula:bacula, sd runs as
bacula:tape, and fd runs as root:root

trinity% bconsole -?
Copyright (C) 2000-2014 Free Software Foundation Europe e.V.

Version: 7.0.5 (28 July 2014) x86_64-pc-linux-gnu ubuntu 16.04

Usage: bconsole [-s] [-c config_file] [-d debug_level]
        -D <dir>    select a Director
        -l          list Directors defined
        -c <file>   set configuration file to file
        -d <nn>     set debug level to <nn>
        -dt         print timestamp in debug output
        -n          no conio
        -s          no signals
        -u <nn>     set command execution timeout to <nn> seconds
        -t          test - read configuration and exit
        -?          print this message.
So bconsole is definitely 7.0.5, and there is apparently only one, at
/usr/sbin/bconsole.  Trying with -d 200 turned on, I get:

trinity% sudo bconsole -d 200
Connecting to Director localhost:9101
bconsole: bsock.c:208-0 Current 127.0.0.1:9101 All 127.0.0.1:9101
bconsole: bsock.c:137-0 who=Director daemon host=localhost port=9101
bconsole: bsock.c:310-0 OK connected to server  Director daemon
localhost:9101.
Director authorization problem.
Most likely the passwords do not agree.
If you are using TLS, there may have been a certificate validation error
during the TLS handshake.

Just to be sure, I cut and pasted the Password entry from
bacula-dir.conf directly into bconsole.conf.

Thanks for the ideas, so far everything seems to be set up right.  The
debug messages from the console really look as if something is not right
in the authorization code since console connects to server OK.

-Jan

On 09/30/2016 03:44 PM, Hankins, Jonathan wrote:
> I believe the FD is the inly thing that needs to run as root. I think on
> Debian/Ubuntu/Mint, the dir runs as bacula:bacula and the SD as
> bacula:tape, but I may be wrong.
>
> Are you sure that your bconsole is 7.0.5 as well? Check everything with:
>
> dpkg -l \*bacula\*
>
> and:
>
> which bconsole
>
> ...Just to make sure you don't have an old 5.x bconsole somewhere, and
> that your dir is really 7.0.5.
>
> Also, bconsole has debug options. Note that, when I built 7.4.4 from
> source, there is a .../sbin/bconsole, but also a wrapper in
> .../etc/bconsole. If you want to specify debug flags, etc., you have to
> run the real bconsole binary.
>
> bconsole -\?
>
>
> On Fri, Sep 30, 2016 at 4:16 PM Elias Pereira <empbilly AT gmail DOT com
> <mailto:empbilly AT gmail DOT com>> wrote:
>
>     I'm not sure, but bacula services must be run as root both user and
>     group.
>
>
>     Em 30/09/2016 5:59 PM, "Jan Martin" <fyzzics AT gmail DOT com
>     <mailto:fyzzics AT gmail DOT com>> escreveu:
>
>         Hi,
>
>         OK, I just killed the currently running bacula-dir daemon (the
>         nice way, from the init.d script), and restarted it with the
>         same command line, but added -d200.  Got some extra stuff at the
>         beginning:
>
>         trinity% sudo /usr/sbin/bacula-dir -d200 -c
>         /etc/bacula/bacula-dir.conf -u bacula -g bacula
>         bacula-dir: dird.c:194-0 Debug level = 200
>         bacula-dir: address_conf.c:264-0 Initaddr 0.0.0.0:9101
>         <http://0.0.0.0:9101>
>         bacula-dir: runscript.c:284-0 runscript: debug
>         bacula-dir: runscript.c:285-0  --> RunScript
>         bacula-dir: runscript.c:286-0   -->
>         Command=/etc/bacula/scripts/make_catalog_backup.pl
>         <http://make_catalog_backup.pl> MyCatalog
>         bacula-dir: runscript.c:287-0   --> Target=
>         bacula-dir: runscript.c:288-0   --> RunOnSuccess=1
>         bacula-dir: runscript.c:289-0   --> RunOnFailure=0
>         bacula-dir: runscript.c:290-0   --> FailJobOnError=1
>         bacula-dir: runscript.c:291-0   --> RunWhen=2
>         bacula-dir: runscript.c:284-0 runscript: debug
>         bacula-dir: runscript.c:285-0  --> RunScript
>         bacula-dir: runscript.c:286-0   -->
>         Command=/etc/bacula/scripts/delete_catalog_backup
>         bacula-dir: runscript.c:287-0   --> Target=
>         bacula-dir: runscript.c:288-0   --> RunOnSuccess=1
>         bacula-dir: runscript.c:289-0   --> RunOnFailure=0
>         bacula-dir: runscript.c:290-0   --> FailJobOnError=1
>         bacula-dir: runscript.c:291-0   --> RunWhen=1
>         bacula-dir: jcr.c:128-0 read_last_jobs seek to 192
>         bacula-dir: jcr.c:135-0 Read num_items=0
>         bacula-dir: dir_plugins.c:148-0 Load dir plugins
>         bacula-dir: dir_plugins.c:150-0 No dir plugin dir!
>         trinity% bacula-dir: lockmgr.c:728-0 Exit check_deadlock.
>         bacula-dir: sql_create.c:345-0 In create mediatype
>         bacula-dir: sql_create.c:349-0 selectmediatype: SELECT
>         MediaTypeId,MediaType FROM MediaType WHERE MediaType='File1'
>         bacula-dir: sql_create.c:345-0 In create mediatype
>         bacula-dir: sql_create.c:349-0 selectmediatype: SELECT
>         MediaTypeId,MediaType FROM MediaType WHERE MediaType='File2'
>         bacula-dir: sql_create.c:345-0 In create mediatype
>         bacula-dir: sql_create.c:349-0 selectmediatype: SELECT
>         MediaTypeId,MediaType FROM MediaType WHERE MediaType='File3'
>         trinity-dir: dird.c:323-0 Start UA server
>         trinity-dir: bnet_server.c:87-0 Addresses 127.0.0.1:9101
>         <http://127.0.0.1:9101>
>         trinity-dir: job.c:1528-0 wstorage=File-trinity
>         trinity-dir: job.c:1537-0 wstore=File-trinity where=Job resource
>         trinity-dir: job.c:1211-0 JobId=0 created
>         Job=*JobMonitor*.2016-09-30_13.47.45_01
>         trinity-dir: dird.c:334-0 wait for next job
>
>         and when I started up bconsole only one more line appeared:
>
>         trinity-dir: bnet.c:566-0 who=client host=127.0.0.1 port=9101
>
>         and that's it.  The same result from bconsole as below...
>
>         Does any of this help?  Thanks.
>
>         -Jan Martin
>
>         On 09/30/2016 01:13 PM, Elias Pereira wrote:
>
>             You tried to execute bacula-dir in debug mode?
>
>             # bacula-dir -d200
>
>
>             Em 30/09/2016 4:49 PM, "Jan Martin" <fyzzics AT gmail DOT com
>             <mailto:fyzzics AT gmail DOT com>
>             <mailto:fyzzics AT gmail DOT com <mailto:fyzzics AT gmail DOT com>>> escreveu:
>
>                 Hello bacula-users!
>
>                 I'm having a problem that I can't figure out, so I hope
>             someone here can
>                 help out.
>
>                 I have been using bacula 5.2.x for backing up my Mint
>             linux box and a
>                 couple of Macs.  The latest version of Mint goes to
>             bacula v7.0.5, so I
>                 installed that after saving my old database and saving
>             all the old
>                 *.conf files.
>
>                 After fixing up the new *.conf files so they were
>             basically like the old
>                 ones (I didn't use any of the new virtual autochanger
>             stuff), I
>                 reinstalled the *.conf files in /etc/bacula, and
>             reconstituted the
>                 database in the usual way.  I'm using sqlite3 for the
>             database.
>
>                 All the daemons start up fine, no errors, but when I try
>             to start up
>                 bconsole, I get an authorization error:
>
>                 trinity% sudo bconsole
>                 [sudo] password for jmm:
>                 Connecting to Director localhost:9101
>                 Director authorization problem.
>                 Most likely the passwords do not agree.
>                 If you are using TLS, there may have been a certificate
>             validation error
>                 during the TLS handshake.
>                 Please see
>
>             http://www.bacula.org/en/rel-manual/Bacula_Freque_Asked_Questi.html#SECTION00260000000000000000
>
>             <http://www.bacula.org/en/rel-manual/Bacula_Freque_Asked_Questi.html#SECTION00260000000000000000>
>                 for help.
>
>                 Here are the relevant sections of bacula-dir.conf:
>
>                 Director {                            # define myself
>                    Name = trinity-dir
>                    DIRport = 9101                # where we listen for
>             UA connections
>                    QueryFile = "/etc/bacula/scripts/query.sql"
>                    WorkingDirectory = "/var/lib/bacula"
>                    PidDirectory = "/var/run/bacula"
>                    Maximum Concurrent Jobs = 20
>                    Password = "xxxyyyzzz"         # Console password
>                    Messages = Daemon
>                    DirAddress = 127.0.0.1
>                 }
>
>                 and bconsole.conf:
>
>                 Director {
>                    Name = trinity-dir
>                    DIRport = 9101
>                    address = localhost
>                    Password = "xxxyyyzzz"
>                 }
>
>                 The passwords are identical.  And the /etc/hosts file
>             has the line
>
>                 127.0.0.1       localhost
>
>                 And there is no firewall, so no port usage
>             restrictions.  Besides, all
>                 this is taking place on one machine.  There are network
>             clients, but are
>                 they relevant to this problem?
>
>                 I'm really confused.  I don't see how this can happen,
>             but maybe there's
>                 something out there that is failing a check, or
>             something.  I could
>                 really use some help - thanks in advance.
>
>                 You folks have always come through in the past, and I'm
>             hoping I've just
>                 messed up something that's different for the new version.
>
>                 -Jan Martin
>
>
>             ------------------------------------------------------------------------------
>                 Check out the vibrant tech community on one of the
>             world's most
>                 engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>                 _______________________________________________
>                 Bacula-users mailing list
>                 Bacula-users AT lists.sourceforge DOT net
>             <mailto:Bacula-users AT lists.sourceforge DOT net>
>                 <mailto:Bacula-users AT lists.sourceforge DOT net
>             <mailto:Bacula-users AT lists.sourceforge DOT net>>
>                 https://lists.sourceforge.net/lists/listinfo/bacula-users
>                 <https://lists.sourceforge.net/lists/listinfo/bacula-users>
>
>
>     ------------------------------------------------------------------------------
>     Check out the vibrant tech community on one of the world's most
>     engaging tech sites, SlashDot.org!
>     http://sdm.link/slashdot_______________________________________________
>     Bacula-users mailing list
>     Bacula-users AT lists.sourceforge DOT net
>     <mailto:Bacula-users AT lists.sourceforge DOT net>
>     https://lists.sourceforge.net/lists/listinfo/bacula-users
>
>
> This e-mail is intended only for the recipient and may contain 
> confidential or proprietary information. If you are not the intended 
> recipient, the review, distribution, duplication or retention of this 
> message and its attachments is prohibited. Please notify the sender of 
> this error immediately by reply e-mail, and permanently delete this 
> message and its attachments in any form in which they may have been 
> preserved.


This e-mail is intended only for the recipient and may contain confidential or proprietary information. If you are not the intended recipient, the review, distribution, duplication or retention of this message and its attachments is prohibited. Please notify the sender of this error immediately by reply e-mail, and permanently delete this message and its attachments in any form in which they may have been preserved.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users