Skip to content
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

Can't restart apache, due to /var/lock/apache2 ACL issue #310

Closed
dennyzhang opened this issue Jan 22, 2015 · 14 comments
Closed

Can't restart apache, due to /var/lock/apache2 ACL issue #310

dennyzhang opened this issue Jan 22, 2015 · 14 comments

Comments

@dennyzhang
Copy link

Hi there

Below is the error message of running chef update.
I've checked the code, /var/lock/apache2 is changed to root on purpose.
Do you know what's the problem? My OS is Ubuntu 12.04.

---- Begin output of /etc/init.d/apache2 start ----
STDOUT: * Starting web server apache2
/var/lock/apache2 already exists but is not a directory owned by www-data.
Please fix manually. Aborting.
...fail!
STDERR:
---- End output of /etc/init.d/apache2 start ----
Ran /etc/init.d/apache2 start returned 1

@drpebcak
Copy link
Contributor

This doesn't happen when just running the apache2 cookbook. Can you post the full output of your chef run? Likely the nagios3 cookbook is doing something that apache2 does not expect.

@dennyzhang
Copy link
Author

@drpebcak

https://github.com/viverae-cookbooks/apache2/blob/master/recipes/default.rb#L115-L125
115 %W(
116 #{node['apache']['dir']}/ssl
117 #{node['apache']['cache_dir']}
118 #{node['apache']['lock_dir']}
119 ).each do |path|
120 directory path do
121 mode '0755'
122 owner 'root'
123 group node['apache']['root_group']
124 end
125 end

If I comment off Line 118 about lock_dir, I won't have the issue.
Above code change the ownership of /var/lock/apache2 to root, instead of www-data.

This looks like to be the root cause.

@joshuacox
Copy link

I'm getting the same error, now don't laugh at the sprunge url that really did come back:

http://sprunge.us/FLaW

@drpebcak
Copy link
Contributor

Huh, I take it back. This must be something that has changed recently. I'm going to check if this also happens with apache2.4

@drpebcak
Copy link
Contributor

Looks like this only happens with apache2.2

@svanzoest
Copy link
Contributor

This got set because of #296.

Related Directives:

@joshuacox
Copy link

after reading through #296 I'm a bit confused as this was working just fine a few months ago?

Just to check I threw this in my default attributes:

    "apache": {
      "user": "www-data",
      "group": "www-data"
    },

No, good. For now, I'm just implementing @dennyzhang 's suggestion, but that does not seem like the long term solution.

@dennyzhang
Copy link
Author

@joshuacox
It's currently a blocking issue of this cookbook in some scenario.
It would be nice, if we can resolve this asap.

I'm wondering why we set the ownership as "root", instead of "www-data"?
https://github.com/viverae-cookbooks/apache2/blob/master/recipes/default.rb#L122-L123
122 owner 'root'
123 group node['apache']['root_group']

@joshuacox
Copy link

@dennyzhang agreed on this being a blocker, I've got a temporary fork up, that merely deletes the line 118 you mentioned here:

https://github.com/joshuacox/apache2

and I'll work on a more permanent solution and post a pull request as soon as I find it.

@joshuacox
Copy link

ok, here on debian jessie, if I install apache2 from repos I have:

$ ls -lh /var/lock/|grep apache
drwxr-xr-x 2 www-data root 40 Jan 23 11:20 apache2

is there any consensus on best practice here? reading the link

Apache 2.2: LockFile

it does specifically note that you want to limit access to this lock directory, but it does not state that you should limit it to root only. As you can see I've got a possible fix at joshuacox@a2e20dc

but I'm thinking of removing the group line entirely to match what I got above from the repos. Any thoughts?

drpebcak added a commit that referenced this issue Jan 23, 2015
@drpebcak
Copy link
Contributor

Fixed with #312

@drpebcak
Copy link
Contributor

We can check back in on this if we find that other platforms require the same fix.

@dennyzhang
Copy link
Author

Verified. It works now.

Thanks guys.

meineerde added a commit to meineerde-cookbooks/apache2 that referenced this issue Oct 31, 2016
…bian/Ubuntu

The default `apache2ctl` script for both Apache 2.2 and 2.4 creates the
lock_dir in `/var/lock/apache2`. If the directory exists but is not owned
by `www-data`, the script fails, similar to what is described in sous-chefs#310
and sous-chefs#312.

This commit enhances the fix from sous-chefs#312 for Apache 2.4 in Debian/Ubuntu.
@lock
Copy link

lock bot commented Jul 24, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants