[subterfugue-cvs-commits] CVS: subterfugue/tricks CallDelayTrick.py,1.1,1.2
Status: Alpha
Brought to you by:
mkc
From: Martin M. <mar...@us...> - 2003-04-13 22:50:53
|
Update of /cvsroot/subterfugue/subterfugue/tricks In directory sc8-pr-cvs1:/tmp/cvs-serv23018 Modified Files: CallDelayTrick.py Log Message: cleanup Index: CallDelayTrick.py =================================================================== RCS file: /cvsroot/subterfugue/subterfugue/tricks/CallDelayTrick.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CallDelayTrick.py 12 Apr 2003 23:39:30 -0000 1.1 --- CallDelayTrick.py 13 Apr 2003 22:50:50 -0000 1.2 *************** *** 12,17 **** def usage(self): return """ ! Add minimal delay between calls. ! The 'delay' parameter is required (in seconds). """ --- 12,20 ---- def usage(self): return """ ! Prevents calling syscalls more often than the 'delay' parameter ! (required, in seconds). ! The (voluntary) 'call' parameter is a list of interested-only calls. ! ! sf -t CallDelay:'delay = 20 ; call = ["execve"]' <PROGRAM> """ *************** *** 23,31 **** % (self.__class__.__name__, self.usage())) self.last_time = -1 def callbefore(self, pid, call, args): now = int(time.time()) since = now - self.last_time ! if since < self.delay: ! time.sleep(self.delay - since) self.last_time = now --- 26,46 ---- % (self.__class__.__name__, self.usage())) self.last_time = -1 + self.options = options def callbefore(self, pid, call, args): now = int(time.time()) since = now - self.last_time ! delay = self.delay - since ! if delay > 0: ! print "Delaying %s() for %d seconds ..." % (call, delay) ! time.sleep(delay) self.last_time = now + + def callmask(self): + if self.options.has_key('call'): + mask = {} + for c in self.options['call']: + mask[c] = 1 + return mask + else: + return None |