mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-09 20:32:38 +01:00
Cherry-picked "fixes for mysql handler for mysqld inside a vserver"
This commit (64edfccf76
) was wrongly committed to
the debian branch.
Conflicts:
handlers/mysql.in
This commit is contained in:
parent
d4c5f73ad7
commit
d65fa0c058
@ -88,29 +88,35 @@ defaultsfile=""
|
||||
|
||||
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
|
||||
then
|
||||
if [ $usevserver = yes ]
|
||||
then
|
||||
vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
|
||||
home="$vroot$vhome"
|
||||
else
|
||||
home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
|
||||
fi
|
||||
if [ $usevserver = yes ]
|
||||
then
|
||||
home=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
|
||||
else
|
||||
home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
|
||||
fi
|
||||
|
||||
[ -d $home ] || fatal "Can't find root's home directory ($home)."
|
||||
[ -d $home ] || fatal "Can't find root's home directory ($home)."
|
||||
|
||||
mycnf="$home/.my.cnf"
|
||||
|
||||
mycnf="$home/.my.cnf"
|
||||
if [ $usevserver = yes ]
|
||||
then
|
||||
workcnf="$vroot$mycnf"
|
||||
else
|
||||
workcnf="$mycnf"
|
||||
fi
|
||||
|
||||
if [ -f $mycnf ]
|
||||
then
|
||||
# rename temporarily
|
||||
tmpcnf="$home/my.cnf.disable"
|
||||
debug "mv $mycnf $tmpcnf"
|
||||
mv $mycnf $tmpcnf
|
||||
fi
|
||||
|
||||
oldmask=`umask`
|
||||
umask 077
|
||||
cat > $mycnf <<EOF
|
||||
if [ -f $workcnf ]
|
||||
then
|
||||
# rename temporarily
|
||||
tmpcnf="$workcnf.disable"
|
||||
debug "mv $workcnf $tmpcnf"
|
||||
mv $workcnf $tmpcnf
|
||||
fi
|
||||
|
||||
oldmask=`umask`
|
||||
umask 077
|
||||
cat > $workcnf <<EOF
|
||||
# auto generated backupninja mysql conf
|
||||
[mysql]
|
||||
host=$dbhost
|
||||
@ -126,14 +132,14 @@ password="$dbpassword"
|
||||
host=$dbhost
|
||||
user=$dbusername
|
||||
password="$dbpassword"
|
||||
|
||||
[mysqladmin]
|
||||
host=$dbhost
|
||||
user=$dbusername
|
||||
password="$dbpassword"
|
||||
EOF
|
||||
umask $oldmask
|
||||
if [ $usevserver = yes ]
|
||||
then
|
||||
defaultsfile="--defaults-extra-file=$vhome/.my.cnf"
|
||||
else
|
||||
defaultsfile="--defaults-extra-file=$mycnf"
|
||||
fi
|
||||
umask $oldmask
|
||||
defaultsfile="--defaults-extra-file=$mycnf"
|
||||
fi
|
||||
|
||||
# if a user is not set, use $configfile, otherwise use $mycnf
|
||||
@ -141,27 +147,28 @@ if [ "$user" == "" ]; then
|
||||
user=root;
|
||||
defaultsfile="--defaults-extra-file=$configfile"
|
||||
else
|
||||
userset=true;
|
||||
if [ $usevserver = yes ]
|
||||
then
|
||||
vuserhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
fatal "User $user not found in /etc/passwd"
|
||||
fi
|
||||
userhome="$vroot$vuserhome"
|
||||
else
|
||||
userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
fatal "User $user not found in /etc/passwd"
|
||||
fi
|
||||
fi
|
||||
|
||||
debug "User home set to: $userhome"
|
||||
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
|
||||
defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
|
||||
debug "using $defaultsfile"
|
||||
userset=true;
|
||||
if [ $usevserver = yes ]
|
||||
then
|
||||
userhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
fatal "User $user not found in /etc/passwd"
|
||||
fi
|
||||
debug "User home set to: $vroot$userhome"
|
||||
[ -f $vroot$userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
|
||||
else
|
||||
userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
fatal "User $user not found in /etc/passwd"
|
||||
fi
|
||||
debug "User home set to: $userhome"
|
||||
[ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
|
||||
fi
|
||||
|
||||
defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
|
||||
debug "using $defaultsfile"
|
||||
fi
|
||||
|
||||
#######################################################################
|
||||
@ -308,14 +315,14 @@ fi
|
||||
# clean up tmp config file
|
||||
if [ "$dbusername" != "" -a "$dbpassword" != "" ]
|
||||
then
|
||||
## clean up tmp config file
|
||||
debug "rm $mycnf"
|
||||
rm $mycnf
|
||||
if [ -f "$tmpcnf" ]
|
||||
then
|
||||
debug "mv $tmpcnf $mycnf"
|
||||
mv $tmpcnf $mycnf
|
||||
fi
|
||||
## clean up tmp config file
|
||||
debug "rm $workcnf"
|
||||
rm $workcnf
|
||||
if [ -f "$tmpcnf" ]
|
||||
then
|
||||
debug "mv $tmpcnf $workcnf"
|
||||
mv $tmpcnf $workcnf
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
Loading…
Reference in New Issue
Block a user