Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to sandbox a particular Python process, giving it access only to network communications and a select number of files on the file system. I followed the directions on the Ubuntu community docs site and the Chromium project's article on their sandboxing.

However, I only want to block some Python processes. To get aroundt this, I've symlinked the Python executable to another location (call it python sandbox) and applied an AppArmor profile to it.

When I launch python-sandbox, I am still able to open arbitrary files on the filesystem and read from them. What's wrong? I've done the following:

Created an AppArmor profile as follows:

#include <tunables/global>
/opt/python-sandbox {
    #include <abstractions/base>
    #include <abstractions/fonts>
    /proc/** r,
    /usr/lib/python2.7/** r,
    /usr/local/lib/python2.7/** r,
    network,
}

Copied it into the /etc/apparmor.d/ directory with the name opt.python-sandbox (since the symlink is to /opt/python-sandbox.

Run apparmor_parser /etc/apparmor.d/opt.python-sandbox.

Did I do something wrong? Should I consider another approach?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Aha! I missed something. Apparently it's known that AppArmor doesn't work on symlinks in general. Copying the Python executable over to /opt/python-sandbox worked fine.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.