From 432484551e730a8703501f81f3292789af575297 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 29 Jun 2014 17:09:21 +0100 Subject: [PATCH] Limit the maximum amount of pastebin content --- beaglebone.txt | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/beaglebone.txt b/beaglebone.txt index 0cfe0975..616f55e4 100644 --- a/beaglebone.txt +++ b/beaglebone.txt @@ -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