[web] fix css file generation permission bug (closes #17143773) 3.26
authorDavid Douard <david.douard@logilab.fr>
Thu, 19 Apr 2018 12:47:48 +0200
branch3.26
changeset 12288 2c582a242b66
parent 12287 547bb96ea2a8
child 12289 b86214011758
[web] fix css file generation permission bug (closes #17143773) PropertySheet.process_resource() uses mkstemp which enforce a 0600 mode on the output file, which is not the file permission we want for css files.
cubicweb/web/propertysheet.py
--- a/cubicweb/web/propertysheet.py	Thu Apr 19 12:45:24 2018 +0200
+++ b/cubicweb/web/propertysheet.py	Thu Apr 19 12:47:48 2018 +0200
@@ -109,6 +109,12 @@
             with os.fdopen(tmpfd, 'w') as stream:
                 stream.write(content)
             try:
+                mode = os.stat(sourcefile).st_mode
+                os.chmod(tmpfile, mode)
+            except IOError:
+                self.warning('Cannot set access mode for %s; you may encouter '
+                             'file permissions issues', cachefile)
+            try:
                 os.rename(tmpfile, cachefile)
             except OSError as err:
                 if err.errno != errno.EEXIST: