summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-09-07 09:29:48 -0700
committerZac Medico <zmedico@gentoo.org>2011-09-07 09:29:48 -0700
commitd3aebd49c1a6b893b078f5593677f295a8e77903 (patch)
treef6a3c8e3143016239f5ec8c459e5528be48dd8d7
parentf55f1714c7e2855ca4cbb45f9d8ae6cee126af17 (diff)
downloadportage-d3aebd49c1a6b893b078f5593677f295a8e77903.tar.gz
portage-d3aebd49c1a6b893b078f5593677f295a8e77903.tar.bz2
portage-d3aebd49c1a6b893b078f5593677f295a8e77903.zip
egencache: validate cache dir more
-rwxr-xr-xbin/egencache22
1 files changed, 19 insertions, 3 deletions
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)