summaryrefslogtreecommitdiff
path: root/mysql-test/lib/My/Platform.pm
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.mysql.com>2008-04-21 18:32:32 +0200
committerunknown <msvensson@pilot.mysql.com>2008-04-21 18:32:32 +0200
commit3d861b6724a49cf44fece923b3ada6cdf5fed45a (patch)
tree9c42c4adb8eb8cf3e5ba34380b32636077a294ea /mysql-test/lib/My/Platform.pm
parent857a6dc14c53fd377110b8c795f4edaad99d554a (diff)
downloadmariadb-git-3d861b6724a49cf44fece923b3ada6cdf5fed45a.tar.gz
Add check for unix socket path truncation
Don't allow unix socket path to be truncated mysql-test/lib/My/Platform.pm: Add check for unix socket path truncation mysql-test/mysql-test-run.pl: Don't allow socket path to be truncated. Fail and ask user to correct the problem by using a shorter path with --tmpdir
Diffstat (limited to 'mysql-test/lib/My/Platform.pm')
-rw-r--r--mysql-test/lib/My/Platform.pm40
1 files changed, 39 insertions, 1 deletions
diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm
index 27543d55adf..a70f6bb2359 100644
--- a/mysql-test/lib/My/Platform.pm
+++ b/mysql-test/lib/My/Platform.pm
@@ -20,7 +20,8 @@ use strict;
use base qw(Exporter);
our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL
- native_path posix_path mixed_path);
+ native_path posix_path mixed_path
+ check_socket_path_length);
BEGIN {
if ($^O eq "cygwin") {
@@ -50,6 +51,15 @@ BEGIN {
}
}
+BEGIN {
+ if (eval "use IO::Socket::UNIX; 1") {
+ eval 'sub HAVE_UNIX_SOCKET { 1 }';
+ }
+ else {
+ eval 'sub HAVE_UNIX_SOCKET { 0 }';
+ }
+}
+
#
# native_path
@@ -91,5 +101,33 @@ sub posix_path {
}
+sub check_socket_path_length {
+ my ($path)= @_;
+ my $truncated= 0;
+
+ if (HAVE_UNIX_SOCKET){
+ require IO::Socket::UNIX;
+
+ my $sock = new IO::Socket::UNIX
+ (
+ Local => $path,
+ Listen => 1,
+ ) or die $!;
+ if ($path ne $sock->hostpath()){
+ # Path was truncated
+ $truncated= 1;
+ # Output diagnostic messages
+ print "path: '$path', length: ", length($path) ,"\n";
+ print "hostpath: '", $sock->hostpath(),
+ "', length: ", length($sock->hostpath()), "\n";
+ }
+ $sock= undef;
+ unlink($path);
+ return $truncated;
+ };
+ # All paths OK!
+ return $truncated;
+}
+
1;