Current time: 11-27-2024, 09:59 PM Hello There, Guest! (LoginRegister)


Post Reply 
[HowTo] Cron for customers
Author Message
Blondak Offline
Junior Member
*****
Dev Team

Posts: 84
Joined: May 2008
Reputation: 5
Post: #1
[HowTo] Cron for customers
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
(This post was last modified: 11-25-2008 03:05 AM by BeNe.)
10-08-2008 02:10 AM
Visit this user's website Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #2
RE: Cron for customers
-> MOVED to HowTo

Greez BeNe
10-08-2008 03:20 AM
Visit this user's website Find all posts by this user Quote this message in a reply
FeG Offline
Banned

Posts: 222
Joined: Aug 2007
Post: #3
RE: Cron for customers
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
10-11-2008 06:24 AM
Find all posts by this user Quote this message in a reply
data-stream.ru Offline


Posts: 4
Joined: Dec 2008
Reputation: 0
Post: #4
RE: [HowTo] Cron for customers
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
12-16-2008 05:30 PM
Find all posts by this user Quote this message in a reply
mishas Offline
Newbie
*

Posts: 5
Joined: Jul 2009
Reputation: 0
Post: #5
RE: [HowTo] Cron for customers
(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
07-07-2009 10:08 PM
Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #6
RE: [HowTo] Cron for customers
The GUI is done - but there is no function in it and also not in the engine.
Maybe in later Versions.

Greez BeNe
07-08-2009 02:34 AM
Visit this user's website Find all posts by this user Quote this message in a reply
aseques Offline
Member
*****
Dev Team

Posts: 330
Joined: May 2008
Reputation: 4
Post: #7
RE: [HowTo] Cron for customers
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 '{}' \;
07-09-2009 09:05 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)