New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mod_pagespeed cache directory is unwritable by default #945

Closed
GoogleCodeExporter opened this Issue Apr 6, 2015 · 5 comments

Comments

Projects
None yet
1 participant
@GoogleCodeExporter
Copy link

GoogleCodeExporter commented Apr 6, 2015

The initial installation of mod_pagespeed results in it trying to use a cache 
directory that can only be written by root.

From a clean Debian instance (I used an empty Google Compute Engine "debian-7" 
image):

$ sudo apt-get update
$ sudo apt-get -y upgrade
$ sudo apt-get -y install apache2
$ curl -O 
https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-beta_current_amd64.deb
$ sudo dpkg -i mod-pagespeed-*.deb
$ sudo apt-get -f install

$ ls -la /var/cache/
total 32
drwxr-xr-x  8 root root 4096 May 14 13:32 .
drwxr-xr-x 12 root root 4096 May 14 13:31 ..
drwxr-xr-x  3 root root 4096 May 14 13:31 apache2
drwxr-xr-x  3 root root 4096 May 14 13:32 apt
drwxr-xr-x  2 root root 4096 May 14 13:31 debconf
drwx------  2 root root 4096 May 14 13:31 ldconfig
drwxr-sr-x 32 man  root 4096 May 14 13:31 man
drwxr-xr-x  2 root root 4096 Apr 29 18:05 mod_pagespeed
$ sudo apachectl restart

At this point, /etc/apache2/mods-enabled/pagespeed.conf contains:

   # The ModPagespeedFileCachePath directory must exist and be
 writable
   # by the apache user (as specified by the User directive).
   ModPagespeedFileCachePath            "/var/cache/mod_pagespeed/"

Yet that directory is only writable by root, not www-data.


Running:

$ sudo chown www-data:www-data /var/cache/mod_pagespeed/

trivially fixes it, but it would be nice to do this ourselves.

See also issue 776, which is talking about a similar problem with yum/CentOS.

Original issue reported on code.google.com by malcolm.rowe on 14 May 2014 at 2:14

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Yeah, this looks wrong: dpkg-deb --contents 
mod-pagespeed-beta_current_amd64.deb | grep "/var/"
drwxr-xr-x root/root         0 2014-04-29 14:05 ./var/
drwxr-xr-x root/root         0 2014-04-29 14:05 ./var/log/
drwxr-xr-x www-data/www-data 0 2014-04-29 14:05 ./var/log/pagespeed/
drwxr-xr-x root/root         0 2014-04-29 14:05 ./var/cache/
drwxr-xr-x root/root         0 2014-04-29 14:05 ./var/cache/mod_pagespeed/

Wonder why/when this regressed.
This might be good to fix for .3, pretty bad for fresh installs.

Original comment by morlov...@google.com on 15 May 2014 at 1:54

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Certainly seems to try to do the right thing:
do_package_in_fakeroot() {
  FAKEROOTFILE=$(mktemp -t fakeroot.tmp.XXXXXX) || exit 1
  fakeroot -s "${FAKEROOTFILE}" -- \
    chown -R ${APACHE_USER}:${APACHE_USER} ${STAGEDIR}${MOD_PAGESPEED_CACHE}
  fakeroot -s "${FAKEROOTFILE}" -- \
    chown -R ${APACHE_USER}:${APACHE_USER} ${STAGEDIR}${MOD_PAGESPEED_LOG}

Original comment by morlov...@google.com on 15 May 2014 at 2:13

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Aha, the second fakeroot needs an -i as well to remember results of the first 
one.

Original comment by morlov...@google.com on 15 May 2014 at 2:28

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Fixed in trunk in r3999. Of course won't do much good until new packages are 
built with it. (Might be worth backporting)

Original comment by morlov...@google.com on 15 May 2014 at 3:20

  • Changed state: Fixed
@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Original comment by jmara...@google.com on 15 May 2014 at 3:24

  • Added labels: Milestone-v31, release-note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment