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

Nagios checks for pureftpd symlink root folders #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sapes
Copy link

@sapes sapes commented Apr 8, 2020

Created nagios check that will trigger an alert in case that there are FTP
accounts with the root folder aiming to symlink.
Resolves [PROD-2278]

Created nagios check that will trigger an alert in case that there are FTP
accounts with the root folder aiming to symlink.
Resolves [PROD-2278]
Copy link
Contributor

@NVitanovic NVitanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the comments.

LOGFILE=/var/log/symlink.log
TS=`date '+%Y-%m-%d %H:%M:%S'`
sylinks=0
$MYSQL --defaults-file=/etc/mysql/debian.cnf -N -e "use pureftpd; select Dir from users;" | \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work on RHEL based systems. You don't need the --defaults-file=/etc/mysql/debian.cnf specified. By default on our systems you can login without password if the script is running as root. This is not that secure but is the way that we are using it at the moment.

Comment on lines +11 to +19
echo "$TS $dir1 is symlink" >> $LOGFILE
((sylinks++))
fi
done

if [[ $sylinks -gt 0 ]]
then
echo "CRITICAL - Number of ftp accounts with symlinks as root is $sylinks" >> $LOGFILE
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case you had CRITICAL state in the log file /var/log/symlink.log and it recovered to OK, you will still have CRITICAL in the log.

I suggest having two files:

  1. The lock file that will have CRITICAL or OK at one moment i.e. /var/log/symlink.lock
  2. The next log that will check if CRITICAL accounts are found can be /var/log/symlink.log

On line 18, you could log CRITICAL only to the lock file with > so the lock will get overridden.

Issue with this would be if, an attacker was fast enough and Nagios does not alert for 1 CRITICAL. It can be configured differently in Nagios.

LOGFILE=/var/log/symlink.log
TS=`date '+%Y-%m-%d %H:%M:%S'`

OUTPUT=`grep CRITICAL $LOGFILE | tail -1`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check here maybe in the lock file instead of the log.

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.

2 participants