Alex
Alex

Reputation: 1447

What permission needed for php?

I would like to check postfix active queue. I php script I use

$active = shell_exec('/bin/ls -1 /var/spool/postfix/active | /usr/bin/wc -l');

But in log I see

/bin/ls: cannot open directory /var/spool/postfix/active: Permission denied

What group I need to add php or postfix to avoid this error ?

Upvotes: 0

Views: 116

Answers (1)

Jon Lin
Jon Lin

Reputation: 143906

Typically, the postfix mail queues are mode 0700, so only postfix can directly read/write the queue directories. It looks like what you're trying to do is get a count of items in the active queue. You can sort of do this using the mailq (or postqueue -p) command, which you should be able to run as apache. It lists all the queue items for all of the queues, but like the man page says, ones in the active queue has a * after the queue ID. So you can try replacing your ls -l command with:

$active = shell_exec('/usr/sbin/postqueue -p | grep '^[A-F0-9]*\*' | wc -l');

Upvotes: 1

Related Questions