Dakota Pilot
2018-09-02 20:54:26 UTC
I'm working on getting Dan's script running as a separate job (https://groups.google.com/forum/#!topic/bareos-users/hFD6wxgDbGk) and having issues with it. I've created a script and put it in /etc/bareos/scripts (the directory and contents are owned by user and group bareos. The script runs fine from the command line (as root) with ./consolidatefix.sh.
However, when I set up a job which is bascially only to run this script and do a Run Script I get an su authentication failure on bconsole for the postgress line. The /var/log/messages show Bareos is evidently running it as root. I've been banging my head on this one but gotten nowhere so any help is appreciated.
The job file is this. I've also tried sh -c "the command" but got the same result.
BOF
Job{
Name = ConsolidateFix
Description = "Fix for consolidate job not pruning (bug in Bareos)."
Type = Admin
client = bareos1
Fileset = SelfTest
Pool = LinuxWS
# Schedule = Fixes
Messages = Corporate
Enabled = No
Run Script {
Runs On Client = No
Runs When = Before
Fail Job On Error = Yes
Command = "/etc/bareos/scripts/consolidatefix.sh"
}
}
EOF
The script contains this line to run the command and this runs fine when run in the script from the command line. It's only when run by a Bareos job that it fails.
emptyVols=$(su postgres -c "psql -d bareos -t -c \"select m.VolumeName from Media m where m.VolStatus not in ('Append','Purged') and not exists (Select 1 from JobMedia jm where jm.MediaId=m.MediaID);\"")
1. When Bareos runs does it run as user root or as bareos?
2. I've played with the database pg_hba.conf with no luck.
3. I installed my Bareos from the bareos latest release and notice the user baeros for the database has no password - should it and if so what do I have to do to add one. I assume I*have to update the postgresql bareos user and update the MyCatalog.conf but is there anything else or is there another procedure to do that so things don't break?
Here is the bconsole output from run ConsolidateFix yes.
BOF
2-Sep 16:14 bareos-dir JobId 1632: shell command: run BeforeJob "/etc/bareos/scripts/consolidatefix.sh"
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: Catalog file: /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db Type: postgresql
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db Name: bareos
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db User: bareos
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db Password:
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: Database password:
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: Password: su: Authentication failure
02-Sep 16:14 bareos-dir JobId 1632: Start Admin JobId 1632, Job=ConsolidateFix.2018-09-02_16.14.48_04
02-Sep 16:14 bareos-dir JobId 1632: BAREOS 17.2.4 (21Sep17): 02-Sep-2018 16:14:51
JobId: 1632
Job: ConsolidateFix.2018-09-02_16.14.48_04
Scheduled time: 02-Sep-2018 16:14:48
Start time: 02-Sep-2018 16:14:51
End time: 02-Sep-2018 16:14:51
Termination: Admin OK
EOF
However, when I set up a job which is bascially only to run this script and do a Run Script I get an su authentication failure on bconsole for the postgress line. The /var/log/messages show Bareos is evidently running it as root. I've been banging my head on this one but gotten nowhere so any help is appreciated.
The job file is this. I've also tried sh -c "the command" but got the same result.
BOF
Job{
Name = ConsolidateFix
Description = "Fix for consolidate job not pruning (bug in Bareos)."
Type = Admin
client = bareos1
Fileset = SelfTest
Pool = LinuxWS
# Schedule = Fixes
Messages = Corporate
Enabled = No
Run Script {
Runs On Client = No
Runs When = Before
Fail Job On Error = Yes
Command = "/etc/bareos/scripts/consolidatefix.sh"
}
}
EOF
The script contains this line to run the command and this runs fine when run in the script from the command line. It's only when run by a Bareos job that it fails.
emptyVols=$(su postgres -c "psql -d bareos -t -c \"select m.VolumeName from Media m where m.VolStatus not in ('Append','Purged') and not exists (Select 1 from JobMedia jm where jm.MediaId=m.MediaID);\"")
1. When Bareos runs does it run as user root or as bareos?
2. I've played with the database pg_hba.conf with no luck.
3. I installed my Bareos from the bareos latest release and notice the user baeros for the database has no password - should it and if so what do I have to do to add one. I assume I*have to update the postgresql bareos user and update the MyCatalog.conf but is there anything else or is there another procedure to do that so things don't break?
Here is the bconsole output from run ConsolidateFix yes.
BOF
2-Sep 16:14 bareos-dir JobId 1632: shell command: run BeforeJob "/etc/bareos/scripts/consolidatefix.sh"
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: Catalog file: /etc/bareos/bareos-dir.d/catalog/MyCatalog.conf
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db Type: postgresql
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db Name: bareos
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db User: bareos
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: db Password:
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: Database password:
02-Sep 16:14 bareos-dir JobId 1632: BeforeJob: Password: su: Authentication failure
02-Sep 16:14 bareos-dir JobId 1632: Start Admin JobId 1632, Job=ConsolidateFix.2018-09-02_16.14.48_04
02-Sep 16:14 bareos-dir JobId 1632: BAREOS 17.2.4 (21Sep17): 02-Sep-2018 16:14:51
JobId: 1632
Job: ConsolidateFix.2018-09-02_16.14.48_04
Scheduled time: 02-Sep-2018 16:14:48
Start time: 02-Sep-2018 16:14:51
End time: 02-Sep-2018 16:14:51
Termination: Admin OK
EOF
--
You received this message because you are subscribed to the Google Groups "bareos-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bareos-users+***@googlegroups.com.
To post to this group, send email to bareos-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "bareos-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bareos-users+***@googlegroups.com.
To post to this group, send email to bareos-***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.