/etc/init.d/apache2 doesn't do "chown www-data /var/lock/apache2" after directory creation

Bug #109250 reported by Jyrki Muukkonen
6
Affects Status Importance Assigned to Milestone
apache2 (Debian)
Fix Released
Unknown
apache2 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: apache2.2-common

It looks like /etc/init.d/apache2 has a one-liner to fix missing /var/lock/apache2 directory. This is useful for example when /var/lock is on tmpfs. However, the init script doesn't change the ownership of newly created /var/lock/apache2 directory.

Here's a snippet from /var/lib/dpkg/info/apache2.2-common.postinst:
# Make sure /var/lock/apache2 has the correct permissions
if [ -d /var/lock/apache2 ]; then
        chown www-data /var/lock/apache2
fi

But the /etc/init.d/apache2 does only the directory creation:
[ -d /var/lock/apache2 ] || mkdir -p /var/lock/apache2

I think copying (or even moving) the "if [ -d ..." block from the postinst script to init.d script would be the correct fix.

For example dav_fs tries to create a lock file, but fails:
[Mon Apr 23 14:53:27 2007] [error] [client 127.0.0.1] The locks could not be queried for verification against a possible "If:" header. [500, #0]
[Mon Apr 23 14:53:27 2007] [error] [client 127.0.0.1] Could not open the lock database. [500, #400]
[Mon Apr 23 14:53:27 2007] [error] [client 127.0.0.1] (13)Permission denied: Could not open property database. [500, #1]

I'm currently running a fresh AMD64 Kubuntu Feisty installation.

Revision history for this message
Maurizio Parton (parton) wrote :

I confirm this bug. Moreover, in the package apache2-common for edgy, the line is present:

------------/etc/init.d/apache2--------from package apache2-common_2.0.55-4ubuntu4_i386.deb (edgy)

case $1 in
 start)
  [ -f /etc/apache2/httpd.conf ] || touch /etc/apache2/httpd.conf
  # ssl_scache shouldn't be here if we're just starting up.
  [ -f /var/run/apache2/ssl_scache ] && rm -f /var/run/apache2/*ssl_scache*
  # /var/run and /var/lock could be on a tmpfs
  [ ! -d /var/run/apache2 ] && mkdir /var/run/apache2
  [ ! -d /var/lock/apache2 ] && mkdir /var/lock/apache2
  # Make sure /var/lock/apache2 has the correct permissions
  chown www-data /var/lock/apache2

  log_begin_msg "Starting apache 2.0 web server..."
  if $APACHE2CTL startssl; then
                        log_end_msg 0
                else
                        log_end_msg 1
                fi
 ;;

------------/etc/init.d/apache2--------from package apache2.2-common_2.2.3-3.2build1_i386.deb (feisty)

case $1 in
 start)
  [ -f /etc/apache2/httpd.conf ] || touch /etc/apache2/httpd.conf
  [ -d /var/run/apache2 ] || mkdir -p /var/run/apache2
  [ -d /var/lock/apache2 ] || mkdir -p /var/lock/apache2
  #ssl_scache shouldn't be here if we're just starting up.
  [ -f /var/run/apache2/ssl_scache ] && rm -f /var/run/apache2/*ssl_scache*
  log_begin_msg "Starting web server (apache2)..."
  if $APACHE2CTL start; then
                        log_end_msg 0
                else
                        log_end_msg 1
                fi
 ;;

Not yet solved in gutsy:
------------/etc/init.d/apache2--------from package apache2.2-common_2.2.3-4_i386.deb (gutsy)

case $1 in
 start)
  [ -f /etc/apache2/httpd.conf ] || touch /etc/apache2/httpd.conf
  [ -d /var/run/apache2 ] || mkdir -p /var/run/apache2
  [ -d /var/lock/apache2 ] || mkdir -p /var/lock/apache2
  #ssl_scache shouldn't be here if we're just starting up.
  [ -f /var/run/apache2/ssl_scache ] && rm -f /var/run/apache2/*ssl_scache*
  log_begin_msg "Starting web server (apache2)..."
  if $APACHE2CTL start; then
                        log_end_msg 0
                else
                        log_end_msg 1
                fi
 ;;

Changed in apache2:
status: Unknown → Fix Committed
Revision history for this message
Rob Caskey (rcaskey) wrote :

Indeed, same problem following upgrade from edgy=>feisty, fixed by a chown/chmod.

Changed in apache2:
status: Unconfirmed → Confirmed
Changed in apache2:
status: Fix Committed → Fix Released
Revision history for this message
Mathias Gug (mathiaz) wrote :

Thanks taking the time to report this bug and helping to make Ubuntu better. However, I am closing it because the bug has been fixed in the latest development version of Ubuntu - the Gutsy Gibbon.

If you need a fix for the bug in previous versions of Ubuntu, please follow the instructions for "How to request new packages" at https://help.ubuntu.com/community/UbuntuBackports#request-new-packages .

Changed in apache2:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.