From 9efc4c7680c26a2016bb174f0edef2fca527b05f Mon Sep 17 00:00:00 2001 From: Justin McWilliams Date: Fri, 27 Apr 2012 16:59:15 -0400 Subject: [PATCH] Fix ccb5f6b6cc37 -- move skipdirs into global const that's a prepopulated set of exclusion dirs. --- code/client/munkilib/munkicommon.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/code/client/munkilib/munkicommon.py b/code/client/munkilib/munkicommon.py index 19969a34..31e8bda6 100644 --- a/code/client/munkilib/munkicommon.py +++ b/code/client/munkilib/munkicommon.py @@ -72,6 +72,13 @@ LOGINWINDOW = ( "/System/Library/CoreServices/loginwindow.app/Contents/MacOS/loginwindow") +# Always ignore these directories when discovering applications. +APP_DISCOVERY_EXCLUSION_DIRS = set([ + 'Volumes', 'tmp', '.vol', '.Trashes', '.MobileBackups', '.Spotlight-V100', + '.fseventsd', 'Network', 'net', 'home', 'cores', 'dev', 'private', + ]) + + class Error(Exception): """Class for domain specific exceptions.""" @@ -1169,7 +1176,7 @@ def parsePkgRefs(filename, path_to_pkg=None): thisdir = os.path.dirname(filename) pkgref_dict[pkgid]['file'] = os.path.join( thisdir, relativepath) - + for key in pkgref_dict.keys(): pkgref = pkgref_dict[key] if 'file' in pkgref: @@ -1180,7 +1187,7 @@ def parsePkgRefs(filename, path_to_pkg=None): if 'file' in pkgref: del pkgref['file'] info.append(pkgref_dict[key]) - + return info @@ -1697,13 +1704,10 @@ def isExcludedFilesystem(path, _retry=False): if not path: return None - # always ignore these directories - skipdirs = set('Volumes', 'tmp', '.vol', '.Trashes', '.MobileBackups', - '.Spotlight-V100', '.fseventsd', 'Network', 'net', - 'home', 'cores', 'dev', 'private') path_components = path.split('/') - if len(path_components) > 1 and path_components[1] in skipdirs: - return True + if len(path_components) > 1: + if path_components[1] in APP_DISCOVERY_EXCLUSION_DIRS: + return True if not FILESYSTEMS or _retry: FILESYSTEMS = getFilesystems() @@ -1813,7 +1817,7 @@ def getLSInstalledApplications(): applist = [] for app in apps: app_path = app.path() - if (app_path and not isExcludedFilesystem(app_path) and + if (app_path and not isExcludedFilesystem(app_path) and os.path.exists(app_path)): applist.append(app_path) @@ -1975,7 +1979,7 @@ def getConditions(): print >> sys.stderr, str(e) else: # /usr/local/munki/conditions does not exist - pass + pass if os.path.exists(conditionalitemspath) and validPlist(conditionalitemspath): # import conditions into CONDITIONS dict CONDITIONS = FoundationPlist.readPlist(conditionalitemspath)