[root@jaydee tmp]# python Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38) [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os, tempfile, shutil, subprocess >>> import selinux # try/except block around this to see if the issue will happen >>> temp_fd, a_temp_file = tempfile.mkstemp() >>> shutil.move(a_temp_file,'/usr/lib/python2.5/site-packages/broken.egg') >>> # Don't know how to do this in Python ... subprocess.call(("restorecon", "-nv", "/usr/lib/python2.5/site-packages/broken.egg")) restorecon reset /usr/lib/python2.5/site-packages/broken.egg context unconfined_u:object_r:user_tmp_t:s0->system_u:object_r:lib_t:s0 0 >>> # But I do know how to fix them in python ... selinux.restorecon("/usr/lib/python2.5/site-packages/broken.egg") >>> # No more output because the context is now correct ... subprocess.call(("restorecon", "-nv", "/usr/lib/python2.5/site-packages/broken.egg")) 0 >>> # Calling it if context was already correct because user had an insane selinux policy does no harm either ... selinux.restorecon("/usr/lib/python2.5/site-packages/broken.egg") >>> os.close(temp_fd) >>> os.remove("/usr/lib/python2.5/site-packages/broken.egg") >>> quit()