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

procfs needed by process component as of Piwik 2.2 #5041

Closed
peterbo opened this issue Apr 25, 2014 · 11 comments
Closed

procfs needed by process component as of Piwik 2.2 #5041

peterbo opened this issue Apr 25, 2014 · 11 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@peterbo
Copy link
Contributor

peterbo commented Apr 25, 2014

As of Piwik 2.2, the locking mechanics of the new process component uses "ps -e" to check for a given PID.

Therefore, the process environment needs a mounted proc file system, which is not present on all servers.

So we should check for the presence of procfs.

@mattab
Copy link
Member

mattab commented Apr 25, 2014

This may work: @is_resource(fopen('/proc', 'r'))

@peterbo
Copy link
Contributor Author

peterbo commented Apr 26, 2014

In c076fdb: Fixes #5041 - check if procfs is mounted

@peterbo
Copy link
Contributor Author

peterbo commented Apr 26, 2014

In 7631a79: Fixes #5041 - ditch negative semantic, that's more readable

@anonymous-matomo-user
Copy link

I need to reopen this issue because this check is not sufficient and I think it is not requried.

The problem with the current solution is that it does not check if procfs is mounted. For example I have a shared hosting with no procfs:

$ mount
none on /proc type proc (rw)

A mounted /proc and not mounted /proc has both a "stream" resource type. So is_resource() is not sufficient enough to test if /proc is really mounted or not.
Create an empty folder somehwere and then compare

get_resource_type(@fopen('/proc', 'r')
get_resource_type(@fopen('/empty/folder', 'r')

See http://www.php.net/manual/en/resource.php

But there is an error anyway when ps is executed under such conditions

$ ps
Cannot find /proc/version - is /proc mounted?
$ echo $?
1

So the check returnsSuccessCode('ps') should already handle this situation. Or was there a case where this check was wrong?

@mattab
Copy link
Member

mattab commented May 9, 2014

Or was there a case where this check was wrong?
yes, Peter added the new check after the 'ps' check was already in place, in commit above.

get_resource_type(@fopen('/proc', 'r')
get_resource_type(@fopen('/empty/folder', 'r')

What output do you get from these commands? maybe you know how we can patch the is_resource line?

@anonymous-matomo-user
Copy link

What output do you get from these commands? maybe you know how we can patch the is_resource line?
both commands return a resource_type "stream" because fopen() always returns a stream or false. fopen() returns false if the folder /proc does not exist or you have no read permission for /proc.

Maybe it is possible to check if /proc/version or something like that exists and can be read? Would be interesting why the returnSuccessCode('ps') is true if /proc can not be accessed.

@peterbo
Copy link
Contributor Author

peterbo commented May 13, 2014

What is the response to the following command on your console?

ps > /dev/null 2>&1 & echo $?

@anonymous-matomo-user
Copy link

I think that line is the problem. Why haven't I seen this before?

ps > /dev/null 2>&1 & echo $?

the single & brings ps to the background which is successfull and returns always 0. But the return value of ps itself is 1 in my case. But that is not checked with this command. This line should do the trick:

ps > /dev/null 2>&1; echo $?

@mattab
Copy link
Member

mattab commented May 14, 2014

In 6b18957: fixes #5041 Fix typo. Kuddos @KlausKW for the find!

@anonymous-matomo-user
Copy link

For what it's worth, this continues to be a problem on FreeBSD.

RELEASE FreeBSD 8.2-RELEASE !#0

Sorry I don't have the technical chops to explain why. I have patched core/CliMulti/Process.php to always return false, and Piwik is working fine.

The error reported by Piwik whenever cron runs console core:archive:

ps: Process environment requires procfs(5)

@peterbo peterbo added this to the 2.3.0 - Piwik 2.3.0 milestone Jul 8, 2014
@peterbo peterbo self-assigned this Jul 8, 2014
@mattab
Copy link
Member

mattab commented Jul 9, 2014

can you please create another ticket? we will investigate why it does not work yet on Freebsd

sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants