Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: REALLY Private Methods in perl: Is Perl Flexible enough to be made Inflexible?

by broquaint (Abbot)
on Sep 23, 2002 at 14:13 UTC ( #200106=note: print w/replies, xml ) Need Help??


in reply to REALLY Private Methods in perl: Is Perl Flexible enough to be made Inflexible?

The only way you can have truly private methods is through lexically scoped subrefs. This is because you can always fake being in another package with package. This doesn't bode well for inheritance, but as clintp suggests you can get around it. There's also miyagawa's wonderful Attribute::Protected, but that can be bypassed if you really want to.
HTH

_________
broquaint

  • Comment on Re: REALLY Private Methods in perl: Is Perl Flexible enough to be made Inflexible?

Replies are listed 'Best First'.
Re: Re: REALLY Private Methods in perl: Is Perl Flexible enough to be made Inflexible?
by diotalevi (Canon) on Sep 23, 2002 at 21:41 UTC

    And that only works until your attacker starts using magic (generally via B (something like (this is off the top of my head) B::svref_2object($obj)->PADLIST->ARRAY) to get access to your lexicals anyway. From what I can tell - if you can get a code ref to it then you can get it's lexicals. At that point there isn't any protection unless...

    Ok, maybe... if you fork your process and orphan your objects via circular references and maybe if you are doing threading (which I gather is mostly a perl 5.8ism) you can still keep running code in those objects in a different process. Yeah, that's the ticket. (keep in mind this is just speculation)

    Not that I think that would actually work but you have to go to some interesting lengths to keep your lexicals really, really private.

    Update On further consideration just forking the process and allowing the private stuff to fall out of scope in the original process is enough to hide your stuff. Now you just have to do some sort of IPC to communicate back to the mother ship. ;-)

      Ok, maybe... if you fork your process and orphan your objects via circular references and maybe if you are doing threading (which I gather is mostly a perl 5.8ism) you can still keep running code in those objects in a different process. Yeah, that's the ticket. (keep in mind this is just speculation)
      Then we'll just write perl modules to r00t your system. Once w3 0wn j00z, we'll go on to install loadable kernel modules to tinker in your process space directly. We'll use your lexicals from the inside out!

      :) for the humor-impaired

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://200106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2020-03-30 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (176 votes). Check out past polls.

    Notices?