From: "Mauricio Fernández" Date: 2003-02-05T08:11:50+09:00 Subject: Re: [contest] Code challenge On Wed, Feb 05, 2003 at 07:31:49AM +0900, Paul Brannan wrote: > On Wed, Feb 05, 2003 at 06:00:43AM +0900, Mauricio Fern�ndez wrote: > > But now, what happens if I do: > > > > ... > > def no_redef(*args) > > @no_override ||= [] > > args.each { |i| @no_override << i } > > @no_override.freeze > > end > > ... > > > > Is it impossible enough now? ;-) > > Not quite. Here are my 5 solutions: Ouch! > # Solution 1: Redefine Array#+ ... > # Solution 2: Redefine Array#index ... > # Solution 3: Redefine Fixnum#== ... > # Solution 4: Use alias_method to create an alias for alias_method so > # that I can still create aliases in the derived class. I guess I'd have to freeze _everything_ I use inside NoOverloading to prevent these and modify alias_method on Module... Another possibility is implementing my own cheap Array class. > # Solution 5: Use set_trace_func to capture all bindings; use this so > # that any method that any calls __no_redef_list__ are equivalent to > # "return". And remove Kernel.set_trace_func. > > > My ultimate goal with this contest is seeing if it is at all possible to > > prevent redefinition unconditionally, against all attacks. > > My suspicion is that this is not possible without modifying the > interpreter. I also suspect that protecting against all "attacks" is > unnecessary, and that protecting the programmer against shooting himself > in the foot is sufficient. Was rather thinking of another way to do Rubyrobots without using safe levels, that's all. At least I learned something in the process, and first thing: forget about doing code contests for some time until I know quite a lot more ;) I'll keep "closing holes" on the Wiki in case anybody is interested on seeing if this will ever work. -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com > Alan Cox wrote: [..] No I didnt. Someone else wrote that. Please keep attributions straight. -- From linux-kernel