Default DocumentRoot migration occurs even if /var/www/html was already being used

Bug #1416885 reported by Chaskiel Grundman on 2015-02-01
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
apache2 (Ubuntu)
Medium
Unassigned

Bug Description

the postinst for apache2 2.4.7-1ubuntu4.1 copies an index.html into /var/www/html if it cannot find one in */var/www*
I upgraded a server from lucid->precise->trusty today, and the top page was broken at the end due to this (my site was already in /var/www/html)

install_default_files()
{
        if is_fresh_install $@ || we_are_upgrading_from_wheezy $@ ; then
                if [ ! -e /var/www/index.html -a \
                        ! -h /var/www/index.html -a \
                        ! -e /var/www/index.cgi -a \
                        ! -e /var/www/index.pl -a \
                        ! -e /var/www/index.php -a \
                        ! -e /var/www/index.xhtml -a \
                        ! -e /var/www/index.htm ] ; then
                                cp /usr/share/apache2/default-site/index.html /var/www/html/index.html
                fi
        fi
}
---
Apache2ConfdDirListing: []
ApportVersion: 2.14.1-0ubuntu3.6
Architecture: amd64
DistroRelease: Ubuntu 14.04
InstallationDate: Installed on 2010-07-27 (1650 days ago)
InstallationMedia: Ubuntu-Server 10.04 LTS "Lucid Lynx" - Release amd64 (20100427)
Package: apache2 2.4.7-1ubuntu4.1
PackageArchitecture: amd64
ProcEnviron:
 LC_CTYPE=en_US.UTF-8
 TERM=xterm
 PATH=(custom, no user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 3.13.0-45.74-generic 3.13.11-ckt13
Tags: trusty
Uname: Linux 3.13.0-45-generic x86_64
UpgradeStatus: Upgraded to trusty on 2015-02-01 (0 days ago)
UserGroups:

_MarkForUpload: True
modified.conffile..etc.apache2.conf.available.charset.conf: [modified]
mtime.conffile..etc.apache2.conf.available.charset.conf: 2011-01-07T14:46:11

apport information

tags: added: apport-collected trusty
description: updated

apport information

apport information

apport information

apport information

Thank you for taking the time to report this bug and helping to make Ubuntu better.

Please could you explain this bug in more detail? What relevant files existed before your upgrade, what existed after, how did this break your server, what did you expect the upgrade to do and what did it do instead?

When done, please change the bug status back to New. Thanks!

Changed in apache2 (Ubuntu):
status: New → Incomplete
Chaskiel Grundman (cg2v) wrote :

I don't have my vmware snapshots restored yet, so I cannot state this with absolute certainty, but I believe this is what I had before:

root@www-01:~# ls -l /var/www
total 8
drwxr-xr-x 3 root root 4096 Oct 19 2010 cmu.edu
drwxr-xr-x 9 1001 root 4096 Feb 1 13:40 html

root@www-01:~# ls -l /var/www/html/
total 44
drwxr-xr-x 2 1001 users 4096 Jul 20 2010 css
drwxrwsr-x 4 1001 admin 4096 Aug 18 2010 docs
drwxr-xr-x 2 1001 users 4096 Aug 20 2010 images
drwxr-xr-x 2 1001 users 4096 Aug 5 2011 include
-rw-rw-r-- 1 1001 admin 5108 Jul 28 2014 index.php
-rw-r--r-- 1 root root 5107 Jul 28 2014 index.php.backup
lrwxrwxrwx 1 root root 20 Jul 27 2010 mediawiki -> /usr/share/mediawiki
drwxrwsr-x 4 vanmeeuwen root 4096 Jul 28 2014 releases
-rw-r--r-- 1 root root 593 Sep 14 2010 robots.txt
drwxr-xr-x 2 1001 users 4096 Nov 23 2010 scripts

After the upgrade to apache2 2.4.7-1ubuntu4.1, there was an index.html in /var/www/html, and it was used preferentially to index.php

Changed in apache2 (Ubuntu):
status: Incomplete → New
Chaskiel Grundman (cg2v) wrote :

OK, I got the snapshots online:
root@ftp-01:~# ls -l /media/lucid/var/www
total 8
drwxr-xr-x 3 root root 4096 Oct 19 2010 cmu.edu
drwxr-xr-x 9 1001 root 4096 Jul 28 2014 html
(this is the same as current)

root@ftp-01:~# ls -l /media/lucid/var/www/html/
total 44
drwxr-xr-x 2 1001 users 4096 Jul 20 2010 css
drwxrwsr-x 4 1001 admin 4096 Aug 18 2010 docs
drwxr-xr-x 2 1001 users 4096 Aug 20 2010 images
drwxr-xr-x 2 1001 users 4096 Aug 5 2011 include
-rw-rw-r-- 1 1001 admin 5108 Jul 28 2014 index.php
-rw-r--r-- 1 root root 5107 Jul 28 2014 index.php.backup
lrwxrwxrwx 1 root root 20 Jul 27 2010 mediawiki -> /usr/share/mediawiki
drwxrwsr-x 4 vanmeeuwen root 4096 Jul 28 2014 releases
-rw-r--r-- 1 root root 593 Sep 14 2010 robots.txt
drwxr-xr-x 2 1001 users 4096 Nov 23 2010 scripts

root@ftp-01:~# ls -l /media/precise/var/www/html/
total 44
drwxr-xr-x 2 1001 users 4096 Jul 20 2010 css
drwxrwsr-x 4 1001 admin 4096 Aug 18 2010 docs
drwxr-xr-x 2 1001 users 4096 Aug 20 2010 images
drwxr-xr-x 2 1001 users 4096 Aug 5 2011 include
-rw-rw-r-- 1 1001 admin 5108 Jul 28 2014 index.php
-rw-r--r-- 1 root root 5107 Jul 28 2014 index.php.backup
lrwxrwxrwx 1 root root 20 Jul 27 2010 mediawiki -> /usr/share/mediawiki
drwxrwsr-x 4 vanmeeuwen root 4096 Jul 28 2014 releases
-rw-r--r-- 1 root root 593 Sep 14 2010 robots.txt
drwxr-xr-x 2 1001 users 4096 Nov 23 2010 scripts

root@ftp-01:~# ls -l /media/trusty/var/www/html/
total 56
drwxr-xr-x 2 1001 users 4096 Jul 20 2010 css
drwxrwsr-x 4 1001 admin 4096 Aug 18 2010 docs
drwxr-xr-x 2 1001 users 4096 Aug 20 2010 images
drwxr-xr-x 2 1001 users 4096 Aug 5 2011 include
-rw-r--r-- 1 root root 11510 Feb 1 12:07 index.html
-rw-rw-r-- 1 1001 admin 5108 Jul 28 2014 index.php
-rw-r--r-- 1 root root 5107 Jul 28 2014 index.php.backup
lrwxrwxrwx 1 root root 20 Jul 27 2010 mediawiki -> /usr/share/mediawiki
drwxrwsr-x 4 vanmeeuwen root 4096 Jul 28 2014 releases
-rw-r--r-- 1 root root 593 Sep 14 2010 robots.txt
drwxr-xr-x 2 1001 users 4096 Nov 23 2010 scripts

Robie Basak (racb) wrote :

Thanks. It would perhaps be reasonable to test /var/www/html/index.* as well, perhaps, and skip the move if any of those exist, presuming that the user is already using /var/www/html. I can see this might fail if somebody is using a DocumentRoot of /var/www and simply has an html/ directory being served with further files in it.

This needs checking against Debian and a bug filed there if relevant. Whichever way Debian concludes is the best way to do this is what Ubuntu should do as well.

summary: - postinst checks wrong path when installing default index.html
+ Default DocumentRoot migration occurs even if /var/www/html was already
+ being used
ChristianEhrhardt (paelzer) wrote :

I agree to Robies summary that this should be filed and discussed with Debian first to avoid getting a Delta for this.

Chaskiel, could I ask you to be so kind and open/discuss that with Debian.
Especially since you own the system where this happened first.

Thanks in advance if you do so, and let us know of the Debian bug numer.
We can link that here and get tracking as soon as it is resolved with Debian to consider pulling it into Ubuntu as well.

Changed in apache2 (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Chaskiel Grundman (cg2v) wrote :

Jessie's apache2 2.4.10 looks very different:

        if is_fresh_install $@ || we_are_upgrading_from_wheezy $@ ; then
                local do_copy=true
                local dir ext
                for dir in /var/www /var/www/html ; do
                        for ext in html cgi pl php xhtml htm ; do
                                if [ -e $dir/index.$ext ] ; then
                                        do_copy=false
                                        break 2
                                fi
                        done
                        if [ -h $dir/index.html ] ; then
                                do_copy=false
                                break
                        fi
                done
                if $do_copy ; then
                        cp /usr/share/apache2/default-site/index.html /var/www/html/index.html
                fi
     fi

A possible source of this change is:
apache2 (2.4.9-2) unstable; urgency=medium

  * Fix logic in postinst to detect existing index.* files in both
    DocumentRoots, the old /var/www and the new /var/www/html. Also
    change the compiled in default DocumentRoot to /var/www/html.
    Closes: #743915

(but the bug description does not match this change)

Note that if you decide to request that I interact with debian anyway, just close the bug instead. I made this report as a courtesy so that other users could avoid being affected, not so I could do more work.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers