From joop.boonen at credativ.de Tue Sep 2 14:20:45 2025 From: joop.boonen at credativ.de (Joop Boonen) Date: Tue, 2 Sep 2025 13:20:45 +0000 Subject: [pkg-bacula-devel] Bug#1113777: Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken Message-ID: <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> Package: bacula-director-pgsql Version: 15.0.3-3 When I invoke sudo -u postgres /usr/share/bacula-director/update_postgresql_tables -d The Baculadatabase isnt' upgraded due to a few "errors" in the script. The First error the psql dump is created without a -q, this causes that header data ends up in the file. Because of this the restore fails. Secondly the postgresql do $$ is not correctly escaped. Therefore bash replaces the $$ to the current process id. I suggest the following patch: --- /usr/share/bacula-director/update_postgresql_tables.orig 2025-04-24 15:00:09.000000000 +0000 +++ /usr/share/bacula-director/update_postgresql_tables 2025-09-02 11:44:35.755581836 +0000 @@ -186,7 +186,7 @@ echo " doesn't have write permission on the current directory," echo " or if the system doesn't have enough space to store a" echo " compressed export of the File table" - psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, Ma rkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1017.data + psql -q --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, MarkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1017.data if [ $? -ne 0 ]; then echo "Error while dumping file table to $PWD/file1017.data" @@ -285,7 +285,7 @@ echo " doesn't have write permission on the current directory," echo " or if the system doesn't have enough space to store a" echo " compressed export of the File table" - psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, Ma rkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1016.data + psql -q --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, MarkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1016.data if [ $? -ne 0 ]; then echo "Error while dumping file table to $PWD/file1016.data" @@ -642,7 +642,7 @@ -- Need to add postgresql-contrib to the dependency list -do $$ +do \$\$ declare selected_ext pg_extension%rowtype; begin @@ -654,7 +654,7 @@ if not found then CREATE EXTENSION pg_trgm; end if; -end $$; +end \$\$; CREATE INDEX meta_emailowner on MetaEmail (EmailTenant, EmailOwner); CREATE INDEX meta_emailtime on MetaEmail (EmailTime); -- Regards, Joop Boonen. -- Joop Boonen Professional services consultant credativ IT Services GmbH Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz credativ IT Services GmbH, Trompeterallee 108, 41189 M?nchengladbach, Germany Handelsregister: AG M?nchengladbach HRB 23003 Gesch?ftsf?hrer: David Brauner Umsatzsteuer-ID: DE452151696 -------------- next part -------------- An HTML attachment was scrubbed... URL: From leo at debian.org Tue Sep 2 16:45:55 2025 From: leo at debian.org (Carsten Leonhardt) Date: Tue, 02 Sep 2025 17:45:55 +0200 Subject: [pkg-bacula-devel] Bug#1113777: Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken In-Reply-To: <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> (Joop Boonen's message of "Tue, 2 Sep 2025 13:20:45 +0000") References: <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> Message-ID: <87jz2grh70.fsf@arioch.leonhardt.eu> Control: forcemerge 1108272 -1 Hi Joop, thanks for your report. We have already addressed this in version 15.0.3-4, which unfortunately is not in the current Debian stable release (c.f. bug #1108272). We highly recommend letting dbconfig-common handle the databases. Regards Carsten Joop Boonen writes: > Package: bacula-director-pgsql > > Version: 15.0.3-3 > > When I invoke > > sudo -u postgres /usr/share/bacula-director/update_postgresql_tables -d > The Baculadatabase isnt' upgraded due to a few "errors" in the script. > > > > The First error the psql dump is created without a -q, this causes that header data ends up in the file. Because of this the restore fails. > > > > Secondly the postgresql do $$ is not correctly escaped. Therefore bash replaces the $$ to the current process id. > > > > > > > > > I suggest the following patch: > > > > --- /usr/share/bacula-director/update_postgresql_tables.orig 2025-04-24 15:00:09.000000000 +0000 > +++ /usr/share/bacula-director/update_postgresql_tables 2025-09-02 11:44:35.755581836 +0000 > @@ -186,7 +186,7 @@ > echo " doesn't have write permission on the current directory," > echo " or if the system doesn't have enough space to store a" > echo " compressed export of the File table" > - psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, Ma > rkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1017.data > + psql -q --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, > MarkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1017.data > > if [ $? -ne 0 ]; then > echo "Error while dumping file table to $PWD/file1017.data" > @@ -285,7 +285,7 @@ > echo " doesn't have write permission on the current directory," > echo " or if the system doesn't have enough space to store a" > echo " compressed export of the File table" > - psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, Ma > rkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1016.data > + psql -q --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, > MarkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1016.data > > if [ $? -ne 0 ]; then > echo "Error while dumping file table to $PWD/file1016.data" > @@ -642,7 +642,7 @@ > > -- Need to add postgresql-contrib to the dependency list > > -do $$ > +do \$\$ > declare > selected_ext pg_extension%rowtype; > begin > @@ -654,7 +654,7 @@ > if not found then > CREATE EXTENSION pg_trgm; > end if; > -end $$; > +end \$\$; > > CREATE INDEX meta_emailowner on MetaEmail (EmailTenant, EmailOwner); > CREATE INDEX meta_emailtime on MetaEmail (EmailTime); > > -- > > Regards, > > > > Joop Boonen. > > > -- > > Joop Boonen > > Professional services consultant > > credativ IT Services GmbH > > > > Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz > > > credativ IT Services GmbH, Trompeterallee 108, 41189 M?nchengladbach, Germany > > Handelsregister: AG M?nchengladbach HRB 23003 > > Gesch?ftsf?hrer: David Brauner > > Umsatzsteuer-ID: DE452151696 From owner at bugs.debian.org Tue Sep 2 16:47:05 2025 From: owner at bugs.debian.org (Debian Bug Tracking System) Date: Tue, 02 Sep 2025 15:47:05 +0000 Subject: [pkg-bacula-devel] Processed: Re: Bug#1113777: Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken References: <87jz2grh70.fsf@arioch.leonhardt.eu> <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> Message-ID: Processing control commands: > forcemerge 1108272 -1 Bug #1108272 {Done: Carsten Leonhardt } [bacula-director-pgsql] bacula-director-pgsql: update_postgresql_tables script fails due to bad shell quoting Bug #1113777 [bacula-director-pgsql] Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken Marked Bug as done Marked as fixed in versions bacula/15.0.3-4. Marked as found in versions bacula/15.0.3-1~bpo12+1. Merged 1108272 1113777 -- 1108272: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1108272 1113777: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1113777 Debian Bug Tracking System Contact owner at bugs.debian.org with problems From leo at debian.org Tue Sep 2 17:03:07 2025 From: leo at debian.org (Carsten Leonhardt) Date: Tue, 02 Sep 2025 18:03:07 +0200 Subject: [pkg-bacula-devel] Bug#1113777: Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken In-Reply-To: <87jz2grh70.fsf@arioch.leonhardt.eu> (Carsten Leonhardt's message of "Tue, 02 Sep 2025 17:45:55 +0200") References: <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> <87jz2grh70.fsf@arioch.leonhardt.eu> <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> Message-ID: <87frd4rgec.fsf@arioch.leonhardt.eu> Control: unmerge -1 Control: reopen -1 Hi Joop, actually, we fixed the escaping, but this is the first time we hear about the "-q" parameter problem. We'll need to investigate that. Regards Carsten Carsten Leonhardt writes: > Control: forcemerge 1108272 -1 > > Hi Joop, > > thanks for your report. We have already addressed this in version > 15.0.3-4, which unfortunately is not in the current Debian stable > release (c.f. bug #1108272). > > We highly recommend letting dbconfig-common handle the databases. > > Regards > > Carsten > > > Joop Boonen writes: > >> Package: bacula-director-pgsql >> >> Version: 15.0.3-3 >> >> When I invoke >> >> sudo -u postgres /usr/share/bacula-director/update_postgresql_tables -d >> The Baculadatabase isnt' upgraded due to a few "errors" in the script. >> >> >> >> The First error the psql dump is created without a -q, this causes that header data ends up in the file. Because of this the restore fails. >> >> >> >> Secondly the postgresql do $$ is not correctly escaped. Therefore bash replaces the $$ to the current process id. >> >> >> >> >> >> >> >> >> I suggest the following patch: >> >> >> >> --- /usr/share/bacula-director/update_postgresql_tables.orig 2025-04-24 15:00:09.000000000 +0000 >> +++ /usr/share/bacula-director/update_postgresql_tables 2025-09-02 11:44:35.755581836 +0000 >> @@ -186,7 +186,7 @@ >> echo " doesn't have write permission on the current directory," >> echo " or if the system doesn't have enough space to store a" >> echo " compressed export of the File table" >> - psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, Ma >> rkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1017.data >> + psql -q --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, >> MarkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1017.data >> >> if [ $? -ne 0 ]; then >> echo "Error while dumping file table to $PWD/file1017.data" >> @@ -285,7 +285,7 @@ >> echo " doesn't have write permission on the current directory," >> echo " or if the system doesn't have enough space to store a" >> echo " compressed export of the File table" >> - psql --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, Ma >> rkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1016.data >> + psql -q --set ON_ERROR_STOP=1 -d ${db_name} $* -c "set work_mem='$WORKMEM';"'set enable_mergejoin to off ; set enable_hashjoin to off; copy (SELECT FileId, FileIndex, JobId, PathId, Filename.Name, DeltaSeq, >> MarkId, LStat, Md5 FROM File JOIN Filename USING (FilenameId)) TO STDOUT' | $COMP -1 -c > file1016.data >> >> if [ $? -ne 0 ]; then >> echo "Error while dumping file table to $PWD/file1016.data" >> @@ -642,7 +642,7 @@ >> >> -- Need to add postgresql-contrib to the dependency list >> >> -do $$ >> +do \$\$ >> declare >> selected_ext pg_extension%rowtype; >> begin >> @@ -654,7 +654,7 @@ >> if not found then >> CREATE EXTENSION pg_trgm; >> end if; >> -end $$; >> +end \$\$; >> >> CREATE INDEX meta_emailowner on MetaEmail (EmailTenant, EmailOwner); >> CREATE INDEX meta_emailtime on MetaEmail (EmailTime); >> >> -- >> >> Regards, >> >> >> >> Joop Boonen. >> >> >> -- >> >> Joop Boonen >> >> Professional services consultant >> >> credativ IT Services GmbH >> >> >> >> Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz >> >> >> credativ IT Services GmbH, Trompeterallee 108, 41189 M?nchengladbach, Germany >> >> Handelsregister: AG M?nchengladbach HRB 23003 >> >> Gesch?ftsf?hrer: David Brauner >> >> Umsatzsteuer-ID: DE452151696 From owner at bugs.debian.org Tue Sep 2 17:05:03 2025 From: owner at bugs.debian.org (Debian Bug Tracking System) Date: Tue, 02 Sep 2025 16:05:03 +0000 Subject: [pkg-bacula-devel] Processed: Re: Bug#1113777: Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken References: <87frd4rgec.fsf@arioch.leonhardt.eu> <10396164.EvYhyI6sBW@bjoop-lin-0.credativ.de> Message-ID: Processing control commands: > unmerge -1 Bug #1113777 {Done: Carsten Leonhardt } [bacula-director-pgsql] Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken Bug #1108272 {Done: Carsten Leonhardt } [bacula-director-pgsql] bacula-director-pgsql: update_postgresql_tables script fails due to bad shell quoting Disconnected #1113777 from all other report(s). > reopen -1 Bug #1113777 {Done: Carsten Leonhardt } [bacula-director-pgsql] Bacula update script /usr/share/bacula-director/update_postgresql_tables is broken 'reopen' may be inappropriate when a bug has been closed with a version; all fixed versions will be cleared, and you may need to re-add them. Bug reopened No longer marked as fixed in versions bacula/15.0.3-4. -- 1108272: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1108272 1113777: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1113777 Debian Bug Tracking System Contact owner at bugs.debian.org with problems