From fa96937a1bdd95fc08bc925ec3105cff10f132be Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Tue, 18 Sep 2018 13:35:19 +0000 Subject: [PATCH] Bug 20929: Create and Use CNF file Rather than have hostname, username, and passwords on the command line, visible with a ps, use a CNF file so that mysqldump knows them more securely. TEST PLAN ---------- 1) start kohadevbox 2) reset_all 3) sudo systemctl deamon-reload 4) git bz apply 20929 -- choose just this patch 5) restart_all 6) perl /home/vagrant/misc4dev/cp_debian_files.pl 7) sudo koha-dump kohadev 8) ls -la /var/spool/koha/kohadev -- there is a koha-dump.cnf file with rw owner only perms 9) sudo cat /var/spool/koha/kohadev/koha-dump.cnf -- the host, username, and password should match what are in the koha-conf.xml file. 10) zcat the backup to make sure the backup has meaningful data in it. BONUS TEST: Change the kohadev DB password, make the koha-conf.xml file match, confirm your kohadev still works, and that a retest has the new username/password in the koha-dump.cnf file. --- debian/scripts/koha-dump | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump index ff171a0..2ed08cf 100755 --- a/debian/scripts/koha-dump +++ b/debian/scripts/koha-dump @@ -68,10 +68,17 @@ dump_instance() backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' $kohaconfig || true )" [ -z "$backupdir" ] && backupdir="/var/spool/koha/$name" dbdump="$backupdir/$name-$date.sql.gz" + dboptions="$backupdir/koha-dump.cnf" + # Overwrite each time, in case they change the username + # or password. + echo "[mysqldump]" > $dboptions + echo "host=$mysqlhost" >> $dboptions + echo "user=$mysqluser" >> $dboptions + echo "password=$mysqlpass" >> $dboptions + chmod 600 $dboptions [ "$quiet" = "no" ] && echo "* DB to $dbdump" - mysqldump --databases --host="$mysqlhost" \ - --user="$mysqluser" --password="$mysqlpass" "$mysqldb" | - gzip > "$dbdump" + mysqldump --defaults-file="$dboptions" \ + --databases "$mysqldb" | gzip > "$dbdump" chown "root:$name-koha" "$dbdump" chmod g+r "$dbdump" -- 2.1.4