|
Lines 1-90
Link Here
|
| 1 |
--- scripts/mysqlaccess.sh.orig 2005-01-16 14:28:38 -08:00 |
|
|
| 2 |
+++ scripts/mysqlaccess.sh 2005-01-16 14:28:38 -08:00 |
| 3 |
@@ -2,7 +2,7 @@ |
| 4 |
# **************************** |
| 5 |
package MySQLaccess; |
| 6 |
#use strict; |
| 7 |
-use POSIX qw(tmpnam); |
| 8 |
+use File::Temp qw(tempfile tmpnam); |
| 9 |
use Fcntl; |
| 10 |
|
| 11 |
BEGIN { |
| 12 |
@@ -32,7 +32,6 @@ |
| 13 |
$ACCESS_U_BCK = 'user_backup'; |
| 14 |
$ACCESS_D_BCK = 'db_backup'; |
| 15 |
$DIFF = '/usr/bin/diff'; |
| 16 |
- $TMP_PATH = '/tmp'; #path to writable tmp-directory |
| 17 |
$MYSQLDUMP = '@bindir@/mysqldump'; |
| 18 |
#path to mysqldump executable |
| 19 |
|
| 20 |
@@ -432,7 +431,7 @@ |
| 21 |
# no caching on STDOUT |
| 22 |
$|=1; |
| 23 |
|
| 24 |
- $MYSQL_CNF = POSIX::tmpnam(); |
| 25 |
+ $MYSQL_CNF = tmpnam(); |
| 26 |
%MYSQL_CNF = (client => { }, |
| 27 |
mysql => { }, |
| 28 |
mysqldump => { }, |
| 29 |
@@ -577,8 +576,6 @@ |
| 30 |
push(@MySQLaccess::Grant::Error,'not_found_mysql') if !(-x $MYSQL); |
| 31 |
push(@MySQLaccess::Grant::Error,'not_found_diff') if !(-x $DIFF); |
| 32 |
push(@MySQLaccess::Grant::Error,'not_found_mysqldump') if !(-x $MYSQLDUMP); |
| 33 |
-push(@MySQLaccess::Grant::Error,'not_found_tmp') if !(-d $TMP_PATH); |
| 34 |
-push(@MySQLaccess::Grant::Error,'write_err_tmp') if !(-w $TMP_PATH); |
| 35 |
if (@MySQLaccess::Grant::Error) { |
| 36 |
MySQLaccess::Report::Print_Error_Messages() ; |
| 37 |
exit 0; |
| 38 |
@@ -1777,17 +1774,15 @@ |
| 39 |
@before = sort(@before); |
| 40 |
@after = sort(@after); |
| 41 |
|
| 42 |
- $before = "$MySQLaccess::TMP_PATH/$MySQLaccess::script.before.$$"; |
| 43 |
- $after = "$MySQLaccess::TMP_PATH/$MySQLaccess::script.after.$$"; |
| 44 |
- #$after = "/tmp/t0"; |
| 45 |
- open(BEFORE,"> $before") || |
| 46 |
- push(@MySQLaccess::Report::Errors,"Can't open temporary file $before for writing"); |
| 47 |
- open(AFTER,"> $after") || |
| 48 |
- push(@MySQLaccess::Report::Errors,"Can't open temporary file $after for writing"); |
| 49 |
- print BEFORE join("\n",@before); |
| 50 |
- print AFTER join("\n",@after); |
| 51 |
- close(BEFORE); |
| 52 |
- close(AFTER); |
| 53 |
+ ($hb, $before) = tempfile("$MySQLaccess::script.XXXXXX") or |
| 54 |
+ push(@MySQLaccess::Report::Errors,"Can't create temporary file: $!"); |
| 55 |
+ ($ha, $after) = tempfile("$MySQLaccess::script.XXXXXX") or |
| 56 |
+ push(@MySQLaccess::Report::Errors,"Can't create temporary file: $!"); |
| 57 |
+ |
| 58 |
+ print $hb join("\n",@before); |
| 59 |
+ print $ha join("\n",@after); |
| 60 |
+ close $hb; |
| 61 |
+ close $ha; |
| 62 |
|
| 63 |
# ---------------------------------- |
| 64 |
# compute difference |
| 65 |
@@ -1800,8 +1795,8 @@ |
| 66 |
|
| 67 |
# ---------------------------------- |
| 68 |
# cleanup temp. files |
| 69 |
- unlink(BEFORE); |
| 70 |
- unlink(AFTER); |
| 71 |
+ unlink($before); |
| 72 |
+ unlink($after); |
| 73 |
|
| 74 |
return \@diffs; |
| 75 |
} |
| 76 |
@@ -2316,14 +2311,6 @@ |
| 77 |
=> "The diff program <$MySQLaccess::DIFF> could not be found.\n" |
| 78 |
."+ Check your path, or\n" |
| 79 |
."+ edit the source of this script to point \$DIFF to the diff program.\n" |
| 80 |
- ,'not_found_tmp' |
| 81 |
- => "The temporary directory <$MySQLaccess::TMP_PATH> could not be found.\n" |
| 82 |
- ."+ create this directory (writeable!), or\n" |
| 83 |
- ."+ edit the source of this script to point \$TMP_PATH to the right directory.\n" |
| 84 |
- ,'write_err_tmp' |
| 85 |
- => "The temporary directory <$MySQLaccess::TMP_PATH> is not writable.\n" |
| 86 |
- ."+ make this directory writeable!, or\n" |
| 87 |
- ."+ edit the source of this script to point \$TMP_PATH to another directory.\n" |
| 88 |
,'Unrecognized_option' |
| 89 |
=> "Sorry,\n" |
| 90 |
."You are using an old version of the mysql-program,\n" |