Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

mod_pagespeed cache directory is unwritable by default #945

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

mod_pagespeed cache directory is unwritable by default #945

GoogleCodeExporter opened this issue Apr 6, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

  • Added labels: Milestone-v31, release-note

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant