1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!perl
use warnings;
use strict;
use Test::More;
use CGI::Fast;
use File::Temp;
my $OS;
unless ($OS = $^O) {
require Config;
$OS = $Config::Config{'osname'};
}
if ( $OS =~ /mswin|cygwin/i ) {
plan skip_all => "valid on unix-y servers only";
}
{ no warnings 'redefine'; sub FCGI::Accept ($) {} }
my $fh = File::Temp->new;
my $f = $fh->filename;
undef( $fh );
import CGI::Fast socket_path => $f;
ok( !-e $f, 'socket not exists' );
CGI::Fast->new();
ok( -e $f, 'socket was created' );
is( 0777 & (stat $f)[2], 0777 & ~umask, 'socket has default perms' );
unlink $f;
undef $CGI::Fast::Ext_Request;
import CGI::Fast socket_perm => 0777;
ok( !-e $f, 'socket not exists' );
CGI::Fast->new();
ok( -e $f, 'socket was created' );
is( 0777 & (stat $f)[2], 0777, 'socket has given perms' );
unlink $f;
undef $CGI::Fast::Ext_Request;
import CGI::Fast socket_perm => 0777;
ok( !-e $f, 'socket not exists' );
$ENV{FCGI_SOCKET_PERM} = 0666;
CGI::Fast->new();
ok( -e $f, 'socket was created' );
is( 0777 & (stat $f)[2], 0666, '$FCGI_SOCKET_PERM has higher priority' );
unlink $f;
undef $CGI::Fast::Ext_Request;
done_testing();
|