Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Perl Debugger rcfile on Windows

by VinsWorldcom (Prior)
on Jul 31, 2015 at 19:14 UTC ( [id://1137043]=perlquestion: print w/replies, xml ) Need Help??

VinsWorldcom has asked for the wisdom of the Perl Monks concerning the following question:

Windows Monks - has anyone gotten the Perl Debugger rcfile (.perldb / perldb.ini) to work on Windows? I can use the Perl debugger fine with 'perl -d <progfile> [args]', but if I have a .perldb (perldb.ini) file defined, I get mixed, unsatisfying results.

I'm on Windows 7 x64 with Strawberry 5.18.1.

Essentially I've tried .perldb and perldb.ini in both the current directory and my home directory. It seems only perldb.ini is recognized and when it finds it, regardless of location, I get the error:

perldb: Must not source insecure rcfile ./perldb.ini. You or the superuser must be the owner, and it must not be writable by anyone but its owner.

So I've tried to modify permissions of the perldb.ini file on Windows by breaking the parent inheritance on that file and making sure I'm the owner and the only one with "Full Permissions" - which still doesn't fix the problem.

The following transcript shows perldb.ini in current directory with the error, then moved to .perldb and no error, but no execution. Then moved .perldb to my home directory and the same as previous; finally moved .perldb to perldb.ini in home directory with the error again.

VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> ls Directory of C:\Users\VinsWorldcom\PerlDBTest [.] [..] perldb.ini 1 File(s) 0 bytes VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> perl -de 1 perldb: Must not source insecure rcfile ./perldb.ini. You or the superuser must be the owner, and it must not be writable by anyone but its owner. Loading DB routines from perl5db.pl version 1.39_10 Editor support available. Enter h or 'h h' for help, or 'perldoc perldebug' for more help. main::(-e:1): 1 DB<1> q VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> mv perldb.ini .perldb 1 file(s) moved. VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> perl -de 1 Loading DB routines from perl5db.pl version 1.39_10 Editor support available. Enter h or 'h h' for help, or 'perldoc perldebug' for more help. main::(-e:1): 1 DB<1> q VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> mv .perldb .. 1 file(s) moved. VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> perl -de 1 Loading DB routines from perl5db.pl version 1.39_10 Editor support available. Enter h or 'h h' for help, or 'perldoc perldebug' for more help. main::(-e:1): 1 DB<1> q VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> mv ..\.perldb ..\perldb +.ini 1 file(s) moved. VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest> perl -de 1 perldb: Must not source insecure rcfile C:\Users\VinsWorldcom/perldb.i +ni. You or the superuser must be the owner, and it must not be writable by anyone but its owner. Loading DB routines from perl5db.pl version 1.39_10 Editor support available. Enter h or 'h h' for help, or 'perldoc perldebug' for more help. main::(-e:1): 1 DB<1> q VinsWorldcom@C:\Users\VinsWorldcom\PerlDBTest>

Anyone get this working successfully?

UPDATE: I've narrowed it down in perl5db.pl.

'use vars qw($rcfile);' does a check which for Windows will return 'perldb.ini' regardless explaining why '.perldb' has no effect, despite POD about running interactive vs non- mode.

Then, that 'perldb.ini' file is (eventually) run through "sub is_safe_file" which does a 'stat()' and on Windows, is obviously not returning the proper value to create a false when bit-masked with 022. See the function in perl5db.pl for more details as well as POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linux, which has the mode value I'm getting "33206" on Windows.

That being said, I could do all sorts of things to fix this by editing perl5db.pl, but is there a way / argument /something to get this to work without me monkeying with a module's code?

Replies are listed 'Best First'.
Re: Perl Debugger rcfile on Windows (patch)
by tye (Sage) on Jul 31, 2015 at 20:24 UTC

    You can monkeypatch the DB:: sub. You can globally override stat.

    Personally, I'd fix perl5db.pl just so that I could produce a concrete patch to submit.

    - tye        

Re: Perl Debugger rcfile on Windows
by maxx27 (Novice) on Nov 29, 2017 at 03:55 UTC
    I have the same problem on Windows Strawberry Perl. Unfortunately I found only one way to make it work - patch perl5db.pl
    $ diff perl5db.pl.old perl5db.pl.new 1238c1238 < $rcfile = ((-e $dev_tty) ? ".perldb" : "perldb.ini"); --- > $rcfile = ".perldb"; 1289c1289,1291 < return 0 if $mode & 022; --- > if( $^O ne 'MSWin32' ) { > return 0 if $mode & 022; > } 1299a1302,1305 > elsif ( defined $ENV{HOMEDRIVE} && defined $ENV{HOMEPATH} && -f "$EN +V{HOMEDRIVE}$ENV{HOMEPATH}/$rcfile" ) { > safe_do("$ENV{HOMEDRIVE}$ENV{HOMEPATH}/$rcfile"); > } >
    I like more unix name ".perldb" instead of "perldb.ini". Also I have set "$ENV{HOMEDRIVE}$ENV{HOMEPATH}" rather than "$ENV{HOME}". Also I changed logic about file permission for Windows platform.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1137043]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found