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

Cron mode security #50

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Conversation

Asenar
Copy link

@Asenar Asenar commented Jul 17, 2017

This PR replace the #46 «mode cron + base config in .example file»

Changes:

  • Moved conf/esm.config.json to conf.esm.config.json.example
  • Moved all commands into configuration file
  • Improved Config class
  • Added Misc::exec, Misc::shellexec, Misc::ago
  • Added last_sftp_login information
  • Added cron mode

Theses are the same commits with some fix due to the rebase. I removed the commit 8cfbf82 Last login: Show more relevant information from @QuentinCG because the new version seemed to works fine (I just typed in a shell so maybe I'm wrong).

The main improvement is still the cron mode to give a more secure way to retrieve information.

Cron Mode

Installation

  • In your conf/esm.config.json check the value of mode is set to cron. Any other value will make ezServerMonitor works as before.
  • use crontab -e as root to execute the script cron/cron-monitoring every 5 minutes (or more, or less, according to the precision you want).

The cron script run each libs/*.php file and store the result in cache file. Alternatively, you can run each php script separately.

Usage

just open the main index.php into a browser, the interface will show you the last cron update

QuentinCG and others added 23 commits July 17, 2017 11:48
A ping which is not possible resulted in a "0 ms" value which
is not consistent with the reality. A "+Infinity" is more
appropriate.
Since a ping may fail, it is relevant to use the w15p class
in order to show if the ping was successful or not. Moreover,
showing the time of a not valid ping is not relevant and it
means the server is offline.
Default json config example should not have the name
of the real file.
    Misc::cache($name, $data = null, $lifetime = 0) is a simple cache filesystem
    which will serialize $data to a file in write operation, or return
    the values in read operation. Writes are made if the argument
    `--save` is used when running the command.

    Misc::exec() and Misc::shellexec() will first check if
    a result is in cache for that command, and return it if exists.
    Otherwise, command will be executed then eventually saved in cache
    for next call (if `--save` argument has been used).
@QuentinCG
Copy link

I'll have a look and give my feedback, it seems promising ;)

@Asenar
Copy link
Author

Asenar commented Jul 17, 2017

To be more precise, it's about the commit 2866dfb (18 months ago) where you made this change:

-    if (!(exec('/usr/bin/lastlog --time 365 | /usr/bin/awk -F\' \' \'{ print $1";"$5, $4, $8, $6}\'', $users)))
+    if (!(exec('/usr/bin/lastlog --time 365 | /usr/bin/awk -F\' \' \'{ print $1" ("$3");"$5, $6, $9, $7}\'', $users)))

But the current master contains this :

if (!(exec('/usr/bin/lastlog --time 365 | awk \'{ printf $1";"; for (i=4; i<NF; i++) printf $i" "; print $NF; }\'', $users)))

I compared the 3 command and found than the newest «official version» was better (with my local config, debian 9) I didn't checked anywhere else.

By the way about that unix command, it tells me locally my last connection was the 22th may (and not today), but from the server I installed ezWeb I have more accurate dates :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants