return writable_dirs
+def apply_whitelist(writable_dirs, whitelist):
+ """Removes all directories that are contained in the list whitelist from the list writable_dirs.
+ It returns the modified writable_dirs.
+
+ :param writable_dirs: List of directories
+ :param whitelist: List of directories that should be removed from writable_dirs.
+ :return: list of writable directories."""
+ return sorted(list(set(writable_dirs).difference(whitelist)))
+
+
if __name__ == '__main__':
uids = [33] # user ids of the user whos write permissions should be found
gids = [33, 42, 121, 127] # group ids of the user whos write permissions should be found
rootdir = '/home' # directory where the seach is started
+ whitelist = [] # list of directories that are known to be writable and that should not be reported.
# collect and summarize writable directories
writable_dirs = collect_writable_dirs(rootdir, uids, gids)
writable_dirs = summarize_dirs(writable_dirs)
+ writable_dirs = apply_whitelist(writable_dirs, whitelist)
# print writable directories
for d in writable_dirs: