From 10e668a87cd0e1fba125d04bcf93465600c81ba6 Mon Sep 17 00:00:00 2001 From: solsTiCe d'Hiver Date: Mon, 9 Jul 2012 15:25:13 +0200 Subject: [PATCH] Fix issue #175 Force world-readable permission on files and directory of the themes installed by pelican-themes. Only on posix system i.e. mostly non Windows Rationale: If the theme's files have only -rw------- permissions, once installed system wide and owned by root, they will not be accessible to any user but only root. --- pelican/tools/pelican_themes.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pelican/tools/pelican_themes.py b/pelican/tools/pelican_themes.py index 6a021ecc..0083dd50 100755 --- a/pelican/tools/pelican_themes.py +++ b/pelican/tools/pelican_themes.py @@ -180,8 +180,19 @@ def install(path, v=False, u=False): print("Copying `{p}' to `{t}' ...".format(p=path, t=theme_path)) try: shutil.copytree(path, theme_path) - except Exception, e: + + if os.name == 'posix': + for root, dirs, files in os.walk(theme_path): + for d in dirs: + dname = os.path.join(root, d) + os.chmod(dname, 0755) + for f in files: + fname = os.path.join(root, f) + os.chmod(fname, 0644) + except shutil.Error, e: err("Cannot copy `{p}' to `{t}':\n{e}".format(p=path, t=theme_path, e=str(e))) + except OSError, e: + err("Cannot change permissions of files or directory in `{r}':\n{e}".format(r=theme_path, e=str(e)), die=False) def symlink(path, v=False):