diff -u bacula-2.2.8/debian/rules bacula-2.2.8/debian/rules --- bacula-2.2.8/debian/rules +++ bacula-2.2.8/debian/rules @@ -124,6 +124,8 @@ [ ! -f patch-stamp ] || patch -R -p0 -i debian/patches/ubuntu_bacula-dir.conf.patch [ ! -f patch-stamp ] || patch -R -p0 -i debian/patches/ubuntu_mtx-changer.patch + [ ! -f patch-stamp ] || patch -R -p0 -i debian/patches/ubuntu_grant_privileges.patch + [ ! -f patch-stamp ] || patch -R -p0 -i debian/patches/ubuntu_strippath.patch $(RM) *stamp* dh_clean @@ -255,6 +257,8 @@ patch -p0 -i debian/patches/ubuntu_bacula-dir.conf.patch patch -p0 -i debian/patches/ubuntu_mtx-changer.patch + patch -p0 -i debian/patches/ubuntu_grant_privileges.patch + patch -p0 -i debian/patches/ubuntu_strippath.patch touch patch-stamp diff -u bacula-2.2.8/debian/control bacula-2.2.8/debian/control --- bacula-2.2.8/debian/control +++ bacula-2.2.8/debian/control @@ -47,7 +47,7 @@ Package: bacula-director-common Architecture: any Pre-Depends: debconf (>= 1.4.30) | debconf-2.0, bacula-common (= ${source:Version}) -Depends: ${shlibs:Depends}, adduser, mailx +Depends: ${shlibs:Depends}, adduser, mailx, gawk Description: Network backup, recovery and verification (Director common files) Bacula is a set of computer programs that permit you to manage backup, recovery, and verification of computer data across a network of computers @@ -122,7 +122,7 @@ Package: bacula-client Architecture: all -Depends: bacula-console (>= ${source:Version}), bacula-fd (>= ${source:Version}), gawk +Depends: bacula-console (>= ${source:Version}), bacula-fd (>= ${source:Version}) Recommends: bacula-traymonitor Description: Network backup, recovery and verification (Client meta-package) Minimal Bacula system client (File Daemon and Console only) @@ -141,7 +141,7 @@ Package: bacula-server Architecture: all -Depends: bacula-director-mysql (>= ${source:Version})|bacula-director, bacula-sd (>= ${source:Version}), bacula-sd-mysql (>= ${source:Version})|bacula-sd-tools, gawk +Depends: bacula-director-mysql (>= ${source:Version})|bacula-director, bacula-sd (>= ${source:Version}), bacula-sd-mysql (>= ${source:Version})|bacula-sd-tools Recommends: bacula-fd Description: Network backup, recovery and verification (Server meta-package) Bacula system server: SQL-based catalog (SQLite, MySQL, or PgSQL) and diff -u bacula-2.2.8/debian/make_catalog_backup_awk.mysql bacula-2.2.8/debian/make_catalog_backup_awk.mysql --- bacula-2.2.8/debian/make_catalog_backup_awk.mysql +++ bacula-2.2.8/debian/make_catalog_backup_awk.mysql @@ -49,5 +49,5 @@ if (dbsocket != "") printf " socket=%s\n",dbsocket >> "/var/lib/bacula/.my.cnf" - system(sprintf ("mysqldump %s > /var/lib/bacula/bacula.sql",dbname)) + system(sprintf ("HOME=/var/lib/bacula mysqldump %s > /var/lib/bacula/bacula.sql",dbname)) } } diff -u bacula-2.2.8/debian/bacula-director-pgsql.postinst bacula-2.2.8/debian/bacula-director-pgsql.postinst --- bacula-2.2.8/debian/bacula-director-pgsql.postinst +++ bacula-2.2.8/debian/bacula-director-pgsql.postinst @@ -31,7 +31,7 @@ ## Globals LOGDIR="/var/log/bacula" -GRANT_SQL_PRIVS="/usr/share/bacula-director/grant_pgsql_privileges" +GRANT_SQL_PRIVS="/usr/share/bacula-director/grant_postgresql_privileges" POSTINST_COMMON="/usr/share/bacula-director/postinst-common" DEFCONFIG="/usr/share/bacula-common/defconfig" CFGFILE="/etc/bacula/bacula-dir.conf" @@ -79,7 +79,7 @@ case "$1" in configure) - if dpkg --compare-versions lt 2.2.8-5ubuntu1 + if dpkg --compare-versions "$2" lt 2.2.8-5ubuntu1 then get_config db_stop @@ -93,14 +93,15 @@ else id "$dbu_name" 2> /dev/null || adduser --system --no-create-home --disabled-login "$dbu_name" su -c "psql --command \"CREATE ROLE $dbu_name PASSWORD '$dbu_password' NOSUPERUSER CREATEDB NOCREATEROLE INHERIT LOGIN;\"" postgres - su -c "createdb -E UTF8 -O \"$dbu_name\" \"$db_name\"" postgres + su -c "createdb -E SQL_ASCII -O \"$dbu_name\" \"$db_name\"" postgres + su -c /usr/share/bacula-director/make_postgresql_tables postgres 1> /dev/null + su -c "USER=\"$dbu_name\" db_name=\"$db_name\" $GRANT_SQL_PRIVS" postgres 1> /dev/null fi sed -e "s/dbname = bacula;/dbname = $db_name; DB Address = \"$db_host\";/" \ -e "s/@db_user@/$dbu_name/" -e "s/@db_pswd@/$dbu_password/" \ $DEFCONFIG/bacula-dir.conf > $TARGET - su -c /usr/share/bacula-director/make_postgresql_tables postgres 1> /dev/null /bin/sh $POSTINST_COMMON echo "Ok." diff -u bacula-2.2.8/debian/changelog bacula-2.2.8/debian/changelog --- bacula-2.2.8/debian/changelog +++ bacula-2.2.8/debian/changelog @@ -1,3 +1,30 @@ +bacula (2.2.8-5ubuntu7.2) hardy-proposed; urgency=low + + * Create Postgre database with SQL_ASCII encoding + * Create Postgre tables localy only if postgres uses exist + * Fixed pm_strcpy in strippath.patch + * Moved strippath patch to debian, keeping source clean + + -- Ante Karamatic Sat, 04 Sep 2008 16:48:38 +0200 + +bacula (2.2.8-5ubuntu7.1) hardy-proposed; urgency=low + + [Ante Karamatic] + * Export $HOME in /etc/bacula/scripts/make_catalog_backup_awk + - Thanks to Hanno Stock. (LP: #227410) + * debian/bacula-director-pgsql.postinst + - Really compare versions. (LP: #228693) + * debian/bacula-directory-pgsql.postinst: + - grant all privileges to new user on the new new database. + * patches/ubuntu_grant_privileges.patch + - test if $USER and $db_name are set in grant_postgresql_privileges. + + [Chuck Short] + * Applied upstream's 2.2.8-strippath.patch. (http://bacula.svn.sourceforge.net/viewvc/bacula?view=rev&revision=6867) + - Fix strippath bug that created a buffer overrun and crash the FD. (LP: #227613) + + -- Chuck Short Mon, 19 May 2008 04:21:16 -0400 + bacula (2.2.8-5ubuntu7) hardy; urgency=low * patches/ubuntu_mtx-changer.patch: diff -u bacula-2.2.8/debian/make_catalog_backup_awk.pgsql bacula-2.2.8/debian/make_catalog_backup_awk.pgsql --- bacula-2.2.8/debian/make_catalog_backup_awk.pgsql +++ bacula-2.2.8/debian/make_catalog_backup_awk.pgsql @@ -47,5 +47,5 @@ if (dbport != "") printf " port=%s\n",dbport >> "/var/lib/bacula/pg_service.conf" - system("PGSERVICE=bacula PGSYSCONFDIR=/tmp pg_dump > /var/lib/bacula/bacula.sql") + system("HOME=/var/lib/bacula PGSERVICE=bacula PGSYSCONFDIR=/var/lib/bacula pg_dump > /var/lib/bacula/bacula.sql") } } diff -u bacula-2.2.8/debian/make_catalog_backup_awk.sqlite3 bacula-2.2.8/debian/make_catalog_backup_awk.sqlite3 --- bacula-2.2.8/debian/make_catalog_backup_awk.sqlite3 +++ bacula-2.2.8/debian/make_catalog_backup_awk.sqlite3 @@ -1,3 +1,3 @@ -#!/bin/bash +#!/usr/bin/gawk -f -echo ".dump" | /usr/bin/sqlite3 bacula.db > bacula.sql +system("echo '.dump' | /usr/bin/sqlite3 /var/lib/bacula/bacula.db > /var/lib/bacula/bacula.sql") diff -u bacula-2.2.8/debian/make_catalog_backup_awk.sqlite bacula-2.2.8/debian/make_catalog_backup_awk.sqlite --- bacula-2.2.8/debian/make_catalog_backup_awk.sqlite +++ bacula-2.2.8/debian/make_catalog_backup_awk.sqlite @@ -1,3 +1,3 @@ -#!/bin/bash +#!/usr/bin/gawk -f -echo ".dump" | /usr/bin/sqlite bacula.db > bacula.sql +system("echo '.dump' | /usr/bin/sqlite /var/lib/bacula/bacula.db > /var/lib/bacula/bacula.sql") only in patch2: unchanged: --- bacula-2.2.8.orig/debian/patches/ubuntu_grant_privileges.patch +++ bacula-2.2.8/debian/patches/ubuntu_grant_privileges.patch @@ -0,0 +1,18 @@ +--- src/cats/grant_postgresql_privileges.in-old 2008-05-18 12:00:38.000000000 +0200 ++++ src/cats/grant_postgresql_privileges.in 2008-05-18 12:00:38.000000000 +0200 +@@ -2,9 +2,13 @@ + # + # shell script to grant privileges to the bacula database + # +-USER=@db_user@ ++if [ ! -n "$USER" ]; then ++ USER=@db_user@ ++fi + bindir=@SQL_BINDIR@ +-db_name=@db_name@ ++if [ ! -n "$db_name" ]; then ++ db_name=@db_name@ ++fi + + if $bindir/psql -f - -d ${db_name} $* <link_save = get_pool_memory(PM_FNAME); + } + pm_strcpy(ff_pkt->fname_save, ff_pkt->fname); ++ if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { ++ pm_strcpy(ff_pkt->link_save, ff_pkt->link); ++ Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save), ++ strlen(ff_pkt->link)); ++ sm_check(__FILE__, __LINE__, true); ++ } + + /* + * Strip path. If it doesn't succeed put it back. If + * it does, and there is a different link string, + * attempt to strip the link. If it fails, back them + * both back. +- * Don't strip symlinks. ++ * Do not strip symlinks. + * I.e. if either stripping fails don't strip anything. + */ +- if (do_strip(ff_pkt->strip_path, ff_pkt->fname)) { +- if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { +- pm_strcpy(ff_pkt->link_save, ff_pkt->link); +- if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) { +- pm_strcpy(ff_pkt->link, ff_pkt->link_save); +- pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); +- } +- } +- } else { +- pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); ++ if (!do_strip(ff_pkt->strip_path, ff_pkt->fname)) { ++ unstrip_path(ff_pkt); ++ goto rtn; + } +- Dmsg2(200, "fname=%s stripped=%s\n", ff_pkt->fname_save, ff_pkt->fname); ++ /* Strip links but not symlinks */ ++ if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { ++ if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) { ++ unstrip_path(ff_pkt); ++ } ++ } ++ ++rtn: ++ Dmsg3(100, "fname=%s stripped=%s link=%s\n", ff_pkt->fname_save, ff_pkt->fname, ++ ff_pkt->link); + } + + static void unstrip_path(FF_PKT *ff_pkt) +@@ -1170,8 +1182,13 @@ + if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) { + return; + } +- pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); ++ strcpy(ff_pkt->fname, ff_pkt->fname_save); + if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { +- pm_strcpy(ff_pkt->link, ff_pkt->link_save); ++ Dmsg2(500, "strcpy link=%s link_save=%s\n", ff_pkt->link, ++ ff_pkt->link_save); ++ strcpy(ff_pkt->link, ff_pkt->link_save); ++ Dmsg2(500, "strcpy link=%d link_save=%d\n", strlen(ff_pkt->link), ++ strlen(ff_pkt->link_save)); ++ sm_check(__FILE__, __LINE__, true); + } + } only in patch2: unchanged: --- bacula-2.2.8.orig/debian/patches/ubuntu_strippath.patch +++ bacula-2.2.8/debian/patches/ubuntu_strippath.patch @@ -0,0 +1,91 @@ +--- src/filed/backup.c 2008-09-27 08:11:30.000000000 +0200 ++++ src/filed/backup.c.orig 2008-09-27 08:36:47.000000000 +0200 +@@ -1102,9 +1102,9 @@ + + /* Copy to first path separator -- Win32 might have c: ... */ + while (*in && !IsPathSeparator(*in)) { +- *out++ = *in++; ++ out++; in++; + } +- *out++ = *in++; ++ out++; in++; + numsep++; /* one separator seen */ + for (stripped=0; strippedlink_save = get_pool_memory(PM_FNAME); + } + pm_strcpy(ff_pkt->fname_save, ff_pkt->fname); ++ if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { ++ pm_strcpy(ff_pkt->link_save, ff_pkt->link); ++ Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save), ++ strlen(ff_pkt->link)); ++ sm_check(__FILE__, __LINE__, true); ++ } + + /* + * Strip path. If it doesn't succeed put it back. If + * it does, and there is a different link string, + * attempt to strip the link. If it fails, back them + * both back. +- * Don't strip symlinks. ++ * Do not strip symlinks. + * I.e. if either stripping fails don't strip anything. + */ +- if (do_strip(ff_pkt->strip_path, ff_pkt->fname)) { +- if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { +- pm_strcpy(ff_pkt->link_save, ff_pkt->link); +- if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) { +- pm_strcpy(ff_pkt->link, ff_pkt->link_save); +- pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); +- } +- } +- } else { +- pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); ++ if (!do_strip(ff_pkt->strip_path, ff_pkt->fname)) { ++ unstrip_path(ff_pkt); ++ goto rtn; + } +- Dmsg2(200, "fname=%s stripped=%s\n", ff_pkt->fname_save, ff_pkt->fname); ++ /* Strip links but not symlinks */ ++ if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { ++ if (!do_strip(ff_pkt->strip_path, ff_pkt->link)) { ++ unstrip_path(ff_pkt); ++ } ++ } ++ ++rtn: ++ Dmsg3(100, "fname=%s stripped=%s link=%s\n", ff_pkt->fname_save, ff_pkt->fname, ++ ff_pkt->link); + } + + static void unstrip_path(FF_PKT *ff_pkt) +@@ -1170,8 +1182,13 @@ + if (!(ff_pkt->flags & FO_STRIPPATH) || ff_pkt->strip_path <= 0) { + return; + } +- pm_strcpy(ff_pkt->fname, ff_pkt->fname_save); ++ strcpy(ff_pkt->fname, ff_pkt->fname_save); + if (ff_pkt->type != FT_LNK && ff_pkt->fname != ff_pkt->link) { +- pm_strcpy(ff_pkt->link, ff_pkt->link_save); ++ Dmsg2(500, "strcpy link=%s link_save=%s\n", ff_pkt->link, ++ ff_pkt->link_save); ++ strcpy(ff_pkt->link, ff_pkt->link_save); ++ Dmsg2(500, "strcpy link=%d link_save=%d\n", strlen(ff_pkt->link), ++ strlen(ff_pkt->link_save)); ++ sm_check(__FILE__, __LINE__, true); + } + }