develooper Front page | perl.perl5.porters | Postings from August 2008

[perl #57552] Problem with copying files in a Safe compartment

Thread Next
From:
tggbiz
Date:
August 3, 2008 17:57
Subject:
[perl #57552] Problem with copying files in a Safe compartment
Message ID:
rt-3.6.HEAD-29759-1217785538-120.57552-75-0@perl.org
# New Ticket Created by  "tggbiz" 
# Please include the string:  [perl #57552]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=57552 >


Message-Id: <5.8.8_2712_1217784362@DADDYSPC>

This is a bug report for perl from tggbiz@ntlworld.com,
generated with the help of perlbug 1.35 running under perl v5.8.8.


-----------------------------------------------------------------
[Please enter your report here]

Copying files does not work in a Safe compartment,
despite an empty deny only list.

In order to reproduce the results just paste the code into 2 files
(SafeCopyDemo.pl, rdo.pl) as indicated.

# File: SafeCopyDemo.pl
#
use strict;
use warnings;

use Safe;

print "Running SafeCopyDemo\n";

do_copy_file(@ARGV);


sub some_sub
{
}

sub do_copy_file
{
    if (@_ != 2)
    {
        print ("Usage: SafeCopyDemo.pl from_file to_file\n");
        return;
    }
    my ($from_filespec, $to_filespec) = @_;
    print "do_copy_file: Copying from $from_filespec to $to_filespec\n";
    my $cpt = load_compartment(__PACKAGE__, 'some_sub');

    if (defined($cpt) && exists &{$cpt->varglob('copy_file')})
    {
        print "do_copy_file: Calling rdo.pl copy_file\n";
        &{$cpt->varglob('copy_file')}($from_filespec, $to_filespec);
    }
}

sub load_compartment
{
    my ($package, @subs) = @_;
    my $cpt;
    print "load_compartment\n";
    if (-f 'rdo.pl')
    {
        $cpt = new Safe;
        print "load_compartment: Doing rdo.pl\n";
        $cpt->share_from('main', [ '%ENV' ]);
        $cpt->share_from($package, [ @subs ]);
        $cpt->deny_only();
        $cpt->rdo('rdo.pl');
        if ($@)
        {
            die "Thrown exception from rdo.pl: $@\n";
        }
    }
    return $cpt;
}

# File rdo.pl
#
use strict;
use warnings;

use File::Copy;

print "Loading rdo.pl\n";

sub copy_file
{
    my ($from_filespec, $to_filespec) = @_;

    copy ($from_filespec, $to_filespec);

    print "\tCopied $from_filespec to $to_filespec\n";
}

# Begin File::Copy Test on Perl 5.8

Running SafeCopyDemo
do_copy_file: Copying from XXX to YYY
load_compartment
load_compartment: Doing rdo.pl
Loading rdo.pl
do_copy_file: Calling rdo.pl copy_file
Unable to create sub named "*Config::launcher" at C:/Perl/lib/Config.p
+m line 71.

# End File::Copy Test on Perl 5.8

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=high
---
Site configuration information for perl v5.8.8:

Configured by SYSTEM at Tue Jul 31 19:34:29 2007.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='12.00.8804', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth=\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl58.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    Iin_load_module moved for compatibility with build 806
    Avoid signal flag SA_RESTART for older versions of HP-UX
    PerlEx support in CGI::Carp
    Less verbose ExtUtils::Install and Pod::Find
    Patch for CAN-2005-0448 from Debian with modifications
    Rearrange @INC so that 'site' is searched before 'perl'
    Partly reverted 24733 to preserve binary compatibility
    MAINT31223 plus additional changes
    31490 Problem bootstraping Win32CORE
    31324 Fix DynaLoader::dl_findfile() to locate .so files again
    31214 Win32::GetLastError fails when first called
    31211 Restore Windows NT support
    31188 Problem killing a pseudo-forked child on Win32
    29732 ANSIfy the PATH environment variable on Windows
    27527,29868 win32_async_check() can loop indefinitely
    26970 Make Passive mode the default for Net::FTP
    26379 Fix alarm() for Windows 2003
    24699 ICMP_UNREACHABLE handling in Net::Ping

---
@INC for perl v5.8.8:
    C:/Perl/site/lib
    C:/Perl/lib
    .

---
Environment for perl v5.8.8:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Microsoft.NET\SDK\v1.1\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\bin\prerelease;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\bin;C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322;C:\WINDOWS\system32;;C:\Program Files\Java\jdk1.5.0_04\bin;C:\Program Files\Java\apache-ant-1.6.5\bin;C:\Program Files\Java\Apache Software Foundation\ActiveMQ\apache-activemq-4.1.1\bin;C:\Program Files\Java\java_ee_sdk-5_03\bin;C:\Perl\bin;C:\Documents and Settings\Daddy\My Documents\Work\auto\glb\tool\Windows\bin
    PERLPATH=C:\Perl
    PERL_BADLANG (unset)
    SHELL (unset)

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About