Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/liuyu81/sandbox into dev…
Browse files Browse the repository at this point in the history
…elop
  • Loading branch information
Ubuntu committed Oct 10, 2012
2 parents 8af27a7 + 03ad008 commit dea6bab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions sample2.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ static void policy(const policy_t*, const event_t*, action_t*);
static action_t* _KILL_RF(const sandbox_t*, const event_t*, action_t*);
static action_t* _CONT(const sandbox_t*, const event_t*, action_t*);

/* white list of essential linux syscalls */
/* white list of essential linux syscalls for statically-linked C programs */
const int sc_safe[] =
{
#ifdef __x86_64__
0, 1, 5, 8, 9, 10, 11, 12, 16, 25, 63, 158, 231, -1,
0, 1, 5, 8, 9, 10, 11, 12, 16, 25, 63, 158, 219, 231,
#else /* __i386__ */
3, 4, 19, 45, 54, 90, 91, 122, 125, 140, 163, 192, 197, 224, 243, 252, -1,
0, 3, 4, 19, 45, 54, 90, 91, 122, 125, 140, 163, 192, 197, 224, 243, 252,
#endif /* __x86_64__ */
-1, /* sentinel */
};

void
Expand Down
8 changes: 5 additions & 3 deletions sample2.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ def main(args):
# mini sandbox with embedded policy
class MiniSandbox(SandboxPolicy,Sandbox):
sc_table = None
sc_safe = dict(i686 = set([3, 4, 19, 45, 54, 90, 91, 122, 125, 140, 163, \
192, 197, 224, 243, 252, ]), x86_64 = set([0, 1, 5, 8, 9, 10, 11, 12, \
16, 25, 63, 158, 231, ]), ) # white list of essential linux syscalls
# white list of essential linux syscalls for statically-linked C programs
sc_safe = dict(i686 = set([0, 3, 4, 19, 45, 54, 90, 91, 122, 125, 140, \
163, 192, 197, 224, 243, 252, ]), x86_64 = set([0, 1, 5, 8, 9, 10, \
11, 12, 16, 25, 63, 158, 219, 231, ]), )
def __init__(self, *args, **kwds):
# initialize table of system call rules
self.sc_table = [self._KILL_RF, ] * 1024
Expand Down Expand Up @@ -112,6 +113,7 @@ def _CONT(self, e, a): # continue
def _KILL_RF(self, e, a): # restricted func.
a.type, a.data = S_ACTION_KILL, S_RESULT_RF
return a
pass

if __name__ == "__main__":
if len(sys.argv) < 2:
Expand Down

0 comments on commit dea6bab

Please sign in to comment.