Limit the maximum amount of pastebin content

This commit is contained in:
Bob Mottram 2014-06-29 17:09:21 +01:00
parent 8f8fda2963
commit 432484551e
1 changed files with 38 additions and 1 deletions

View File

@ -6607,8 +6607,11 @@ cd /tmp
git clone https://github.com/sametmax/0bin.git
cd 0bin
python setup.py install
chown -R zerobin:zerobin /usr/local/lib/python2.7/dist-packages/zerobin-0.4.1-py2.7.egg/zerobin/static
#+END_SRC
For the /chown/ command you may need to change the directory name within /dist-packages/, depending upon the version number of [[https://github.com/sametmax/0bin][0bin]].
Now create the daemon.
#+BEGIN_SRC: bash
@ -6718,7 +6721,41 @@ The encryption used here is really just intended to provide you with plausible d
service apache2 restart
#+END_SRC
You can now visit your new site and paste things for others to see, and vice versa. Uploads are limited to 256K in size to prevent your storage space from being used up.
You can now visit your new site and paste things for others to see, and vice versa. Uploads are limited to 256K in size to prevent your storage space from being used up. You can further limit the maximum amount of storage space by doing the following:
#+BEGIN_SRC: bash
editor /usr/bin/zerobinupdate
#+END_SRC
Add the following:
#+BEGIN_SRC: bash
#!/bin/bash
CONTENT=/usr/local/lib/python2.7/dist-packages/zerobin-0.4.1-py2.7.egg/zerobin/static/content
# Exit if there is no content directory
if [[ ! -d $CONTENT ]]; then
exit
fi
LOG=/home/zerobin/zerobin.log
CHECK=`du -hs $CONTENT`
regex="([0-9]+)G"
if [[ $CHECK =~ $regex && ${BASH_REMATCH[1]} -gt 1 ]]; then
echo "Directory size limit exceeded - removing zerobin content" >> $LOG
rm -rf $CONTENT/*
fi
#+END_SRC
Save and exit.
#+BEGIN_SRC: bash
chmod +x /usr/bin/zerobinupdate
echo "*/5 * * * * root /usr/bin/timeout 120 /usr/bin/zerobinupdate" >> /etc/crontab
service cron restart
#+END_SRC
** Install Tripwire