ispCP - Board - Support
[HowTo] Cron for customers - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Contributions Area (/forum-40.html)
+--- Forum: Howtos (/forum-41.html)
+--- Thread: [HowTo] Cron for customers (/thread-4637.html)



[HowTo] Cron for customers - Blondak - 10-08-2008 02:10 AM

Hi,
i have small script for support cron on virtual accounts just create file and add to cron

Code:
#!/bin/bash

CRON_BASE_DIR=/var/www/virtual/
CRON_BASE_PERM=/var/www/virtual/
MODE=daily

if [ "$1" ==  "exec" ]; then
    if [ ! -f "$2" ]; then
    exit 1
    fi
    
    owner="$( echo $2 | sed "s^\($CRON_BASE_PERM[^/]\+\).*^\1^g" )"
    owner="$( stat -c %U "$owner" )"
    base="$( dirname $2 )"
    cwd="$( pwd )"
    cd "$base"
    sudo -u $owner "$2"
    cd "$cwd"
    exit 0
fi

find "$CRON_BASE_DIR" -regex ".*\/\(cron/$MODE\)\/.*" -type f -perm /0111 -exec $0 exec '{}' \;

this script looks in domain folder for folder cron/daily and if found some executable exec as user who owns /var/www/virtual/domain.tld


RE: Cron for customers - BeNe - 10-08-2008 03:20 AM

-> MOVED to HowTo

Greez BeNe


RE: Cron for customers - FeG - 10-11-2008 06:24 AM

Hi,

without having checked the script more than reading through it, I just want to note that like this and without any further security measures, users can escape their boundaries which are by default set for php and ftp.
I.e. a cron job could easily read /etc/passwd or other world-readable files; the commands which may be executed on the shell are much less controllable than the things a user could do with php.

These are things to keep in mind if one uses this script.. (which doesn't mean the idea or the script would be bad!)

Regards
FeG


RE: [HowTo] Cron for customers - data-stream.ru - 12-16-2008 05:30 PM

What about planes to write continuesly
cronjobs_overview.php
cronjobs_add.php
cronjobs_edit.php
???

This panel seens to be castrated without this necessary functions Sad


RE: [HowTo] Cron for customers - mishas - 07-07-2009 10:08 PM

(12-16-2008 05:30 PM)data-stream.ru Wrote:  What about planes to write continuesly
cronjobs_overview.php
cronjobs_add.php
cronjobs_edit.php
???

This panel seens to be castrated without this necessary functions Sad

this will be very usefull


RE: [HowTo] Cron for customers - BeNe - 07-08-2009 02:34 AM

The GUI is done - but there is no function in it and also not in the engine.
Maybe in later Versions.

Greez BeNe


RE: [HowTo] Cron for customers - aseques - 07-09-2009 09:05 PM

I am using a modified version of this cron, since I allow only my users to use php scripts, I scan their /var/www/virtual/domain.com/cron/daily/ and run whatever php script they have in there with their own permissions.
So far I haven't had the need to allow them to change crontab frequency.

Quote:#!/bin/bash

CRON_BASE_DIR=/var/www/virtual/
CRON_BASE_PERM=/var/www/virtual/
MODE=daily

if [ "$1" == "exec" ]; then
if [ ! -f "$2" ]; then
exit 1
fi

owner="$( echo $2 | sed "s^\($CRON_BASE_PERM[^/]\+\).*^\1^g" )"
owner="$( stat -c %U "$owner" )"
base="$( dirname $2 )"
cwd="$( pwd )"
cd "$base"
sudo -u $owner "php" "$2"
cd "$cwd"
exit 0
fi

find "$CRON_BASE_DIR" -regex ".*\/\(cron/$MODE\)\/.*" -type f -perm /0111 -exec $0 exec '{}' \;