mailwatch / MailWatch

MailWatch for MailScanner is a web-based front-end to MailScanner
http://mailwatch.org/
GNU General Public License v2.0
117 stars 66 forks source link

Issue: MailWatch unable to detect that MailScanner is running or tally the children processes #1254

Closed hifihedgehog closed 1 year ago

hifihedgehog commented 2 years ago

Issue summary

image

Steps to reproduce

  1. Run latest CyberPanel (v2.3.1 Stable) and OpenLiteSpeed (1.7.16)?

Expected result

It should detect MailScanner service and enumerate the running child processes. I can see from the terminal and the logs that MailScanner is screening and filtering out spam, but MailWatch cannot see the processes. Postfix is not impacted.

Actual result

image

Installation

Version and method

Server configuration

Client configuration

Skywalker-11 commented 2 years ago

Can you try to run ps ax | grep MailScanner | grep -v grep The output should look like

  87605 ?        Ss     0:00 MailScanner: starting child
 133399 ?        S      0:03 MailScanner: waiting for messages
 134075 ?        S      0:03 MailScanner: waiting for messages
 134464 ?        S      0:04 MailScanner: waiting for messages
 135000 ?        S      0:04 MailScanner: waiting for messages
 135440 ?        S      0:03 MailScanner: waiting for messages
 135568 ?        S      0:03 MailScanner: waiting for messages
 136507 ?        S      0:02 MailScanner: waiting for messages
 141682 ?        S      0:01 MailScanner: waiting for messages
 141826 ?        S      0:01 MailScanner: waiting for messages
 142111 ?        S      0:01 MailScanner: waiting for messages

Also check if the same command works when run as the web server user

usmannasir commented 2 years ago

@hifihedgehog is this resolved on your end?

I've made some changes to our Mailscanner install script, still MailWatch can not detect it.

Skywalker-11 commented 2 years ago

@usmannasir do you use the same server configuration? What is the output of the above command? Also try creating a php file with the following code and check the output:

<?php
exec('ps ax | grep MailScanner | grep -v grep', $output);
var_dump($output);
hifihedgehog commented 2 years ago

@hifihedgehog is this resolved on your end?

I've made some changes to our Mailscanner install script, still MailWatch can not detect it.

@usmannasir, no, not resolved as of yet. MailWatch otherwise works. It just can't see the MailScanner processes.

hifihedgehog commented 2 years ago

Can you try to run ps ax | grep MailScanner | grep -v grep The output should look like

  87605 ?        Ss     0:00 MailScanner: starting child
 133399 ?        S      0:03 MailScanner: waiting for messages
 134075 ?        S      0:03 MailScanner: waiting for messages
 134464 ?        S      0:04 MailScanner: waiting for messages
 135000 ?        S      0:04 MailScanner: waiting for messages
 135440 ?        S      0:03 MailScanner: waiting for messages
 135568 ?        S      0:03 MailScanner: waiting for messages
 136507 ?        S      0:02 MailScanner: waiting for messages
 141682 ?        S      0:01 MailScanner: waiting for messages
 141826 ?        S      0:01 MailScanner: waiting for messages
 142111 ?        S      0:01 MailScanner: waiting for messages

Also check if the same command works when run as the web server user

@Skywalker-11, ah, I think I see the problem. If I run as the web server user which is "nobody" under OpenLiteSpeed and CyberPanel, I get no output:

sudo -u nobody ps ax | grep MailScanner | grep -v grep

No output.

@usmannasir, the nobody user is not able to see the MailScanner processes with the command above.

hifihedgehog commented 2 years ago

Responding to this, @Skywalker-11:

<?php
exec('ps ax | grep MailScanner | grep -v grep', $output);
var_dump($output);

I get the following when I try running this in a php file.

array(0) { }

The issue is the nobody user is not able to see the MailScanner processes.

shawniverson commented 2 years ago

nobody is a special that is not supposed to be able to do this. Have you considered running php-fpm and setting up a user for this purpose?

hifihedgehog commented 2 years ago

@shawniverson, that is how CyberPanel installs and manages MailWatch and MailScanner automatically, so that would be a question best fielded to @usmannasir. Do bear in mind that I am running LiteSpeed, specifically OpenLiteSpeed, and LSAPI is highly preferred over PHP-FPM in that environment.

@usmannasir, I uninstalled and reinstalled MailWatch and MailScanner with your latest script. The latest script did not fix and this issue and additionally it broke MailWatch's ability to see the scan queue for me. Let me know and I can create a ticket with you in CyberPanel so you can take a look at my server.

hifihedgehog commented 2 years ago

@usmannasir, note Ticket #ZY5NQ2DNI.

usmannasir commented 2 years ago

@hifihedgehog thanks for your research. Due to security reasons we've put a restriction in that others users can not see processes run by other users.

Did you figure out why It can't see the scan queue?

hifihedgehog commented 2 years ago

Did you figure out why It can't see the scan queue?

No, I have not. It simply stopped after uninstalling and reinstalling with the latest script.

usmannasir commented 2 years ago

@hifihedgehog

Sorry for my late reply.

If I comment out following line from /etc/fstab

proc /proc proc defaults,hidepid=2 0 0

then mailscanner is able to see the processes.

usmannasir commented 2 years ago

@hifihedgehog

MailScanner is still not scanning mails for you?

hexitnz commented 1 year ago

A fresh install of CP on Ubunutu 20.04 and then install spamassin then Mailwatch. Going to the Mailwatch webui I get the following:

MailScanner: NO Postfix: NO

When I use @hifihedgehog suggestion of commenting out fstab proc /proc proc defaults,hidepid=2 0 0, I get the following:

MailScanner: YES Postfix: YES

But I don't know what elese the commenting out is effecting. Any suggetions why this mod is needed and any correct way to fix the issue?

endelwar commented 1 year ago

hidepid is a system hardening measure, read more on this link https://linux-audit.com/linux-system-hardening-adding-hidepid-to-proc/

If you hide process pids MailWatch can't enumerate the running processes.