From: Zac Medico Date: Wed, 7 Sep 2011 16:29:48 +0000 (-0700) Subject: egencache: validate cache dir more X-Git-Tag: v2.2.0_alpha55~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d3aebd49c1a6b893b078f5593677f295a8e77903;p=portage.git egencache: validate cache dir more --- diff --git a/bin/egencache b/bin/egencache index bf29474ef..66854e17e 100755 --- a/bin/egencache +++ b/bin/egencache @@ -163,9 +163,13 @@ def parse_args(args): parser.error("Not a directory: --config-root='%s'" % \ (options.config_root,)) - if options.cache_dir is not None and not os.path.isdir(options.cache_dir): - parser.error("Not a directory: --cache-dir='%s'" % \ - (options.cache_dir,)) + if options.cache_dir is not None: + if not os.path.isdir(options.cache_dir): + parser.error("Not a directory: --cache-dir='%s'" % \ + (options.cache_dir,)) + if not os.access(options.cache_dir, os.W_OK): + parser.error("Write access denied: --cache-dir='%s'" % \ + (options.cache_dir,)) if options.portdir_overlay is not None and \ options.repo is None: @@ -817,6 +821,18 @@ def egencache_main(args): level=logging.WARNING, noiselevel=-1) settings.features.add('metadata-transfer') + if options.update: + if options.cache_dir is not None: + # already validated earlier + pass + else: + if os.path.isdir(settings["PORTAGE_DEPCACHEDIR"]) and \ + not os.access(settings["PORTAGE_DEPCACHEDIR"], os.W_OK): + writemsg_level("ecachegen: error: " + \ + "write access denied: %s\n" % (settings["PORTAGE_DEPCACHEDIR"],), + level=logging.ERROR, noiselevel=-1) + return 1 + settings.lock() portdb = portage.portdbapi(mysettings=settings)