[apparmor] [patch] try to make subdomain.pm a little less smelly.

Jesse Michael jesse at lonelyrhinoceros.com
Wed Oct 6 07:51:56 BST 2010


Hey, I took a bit of time to try to start cleaning up the horror that
is SubDomain.pm.  It definitely should be replaced with something less
terrible, but until that can happen, I figured I'd try to clean it up
a little and here are a few patches to get things started.

  missing-eval-check.diff
    - one of the uses of eval { } wasn't checking $@ for errors, so
      if something bad happened, it'd be silently ignored.  this just
      adds in an extra check to die if we hit a failure.

  add-prototypes.diff
    - this just adds prototypes to all functions to make further cleanup
      slightly easier by getting perl to complain if not enough args
      are passed to a function.  perl doesn't appear to complain about
      this in every case even with prototypes, which is kind of annoying.

  the following three patches are a start to cleaning up some of the
  ugliness with all the global variables that were being used so that
  it's more apparent what's being used where and so that unit tests
  could eventually be added to cover different parts of the functionality.

    deglobal-profiledir.diff
      - get rid of global $profiledir variable and explictly pass it into
        functions that use it
  
    deglobal-logfile.diff
      - get rid of global $logfile variable and explictly pass it into
        functions that use it
  
    deglobal-sd.diff
      - get rid of global %sd hash and explictly pass $sd hashref into
        functions that use it

I've tried to test the basic functionality of these changes, but it
wouldn't surprise me if I've missed stuff since I didn't really exercise
the repository code.  I'm mainly looking for feedback for whether 
people think this is worthwhile and any other suggestions.

-Jesse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: missing-eval-check.diff
Type: text/x-diff
Size: 596 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/apparmor/attachments/20101005/99583179/attachment-0005.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-prototypes.diff
Type: text/x-diff
Size: 10789 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/apparmor/attachments/20101005/99583179/attachment-0006.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deglobal-profiledir.diff
Type: text/x-diff
Size: 49748 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/apparmor/attachments/20101005/99583179/attachment-0007.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deglobal-logfile.diff
Type: text/x-diff
Size: 3772 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/apparmor/attachments/20101005/99583179/attachment-0008.diff 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deglobal-sd.diff
Type: text/x-diff
Size: 44342 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/apparmor/attachments/20101005/99583179/attachment-0009.diff 


More information about the AppArmor mailing list