On Wed, Jun 27, 2012 at 10:12 AM, salamond <[email protected]> wrote: > Hi, guys. > > I want An agent on machine, so that it can fake user actions. > > class Agent > def initialize(user, dir) > @user = user > @dir = dir > end > def mkdir(dir) > bak = Process.euid > `mkdir` > Process.euid = bak > end > def create_file(file, content) > bak = Process.euid > `echo #{content} > #{file}` > Process.euid = bak > end > end > > My problem is, I have a very long list of actions, like mv, touch, mkdir, > rm, etc. > I don't want to add save and restore euid for all methods.
Btw, your code is not safe as it does not restore on exception. > Any one been here before? Could be that AspectR is for you. I also once created code to insert methods before and after a method invocation but I can't seem to find it in the archives. A simple solution could look like this https://gist.github.com/3002732 Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
