You are not logged in.

#1 2010-01-05 06:19:46

pluckypigeon
Member
Registered: 2009-01-09
Posts: 86

Trying to deny users from using Cron

I am trying to set it so that only Root can use Cron.

I have tried 'touch /etc/cron.deny' and adding usernames but to no avail.

Anyone have any ideas?? Thanks in advance smile

Offline

#2 2010-01-05 06:45:06

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,355

Re: Trying to deny users from using Cron

Uh, isn't cron by default only editable by root?


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2010-01-05 06:48:12

pluckypigeon
Member
Registered: 2009-01-09
Posts: 86

Re: Trying to deny users from using Cron

ngoonee wrote:

Uh, isn't cron by default only editable by root?

Thanks for your response but no smile

I can log in as any user and type crontab -e

Offline

#4 2010-01-05 06:50:38

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: Trying to deny users from using Cron

/etc/cron.deny and /etc/cron.allow is for vixie cron and Arch uses dcron.  Not on Arch now but vixie cron is probably in the repos, as I don't think that dcron has this ability.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#5 2010-01-05 06:57:23

pluckypigeon
Member
Registered: 2009-01-09
Posts: 86

Re: Trying to deny users from using Cron

Gen2ly wrote:

/etc/cron.deny and /etc/cron.allow is for vixie cron and Arch uses dcron.  Not on Arch now but vixie cron is probably in the repos, as I don't think that dcron has this ability.

Thanks for your response, vixie cron is in the AUR. Does this mean I have to remove dcron or is there another way?

Offline

#6 2010-01-05 07:07:25

pluckypigeon
Member
Registered: 2009-01-09
Posts: 86

Re: Trying to deny users from using Cron

Ok, I found this on the LFS website smile

If you want to restrict access to cron, do:

    groupadd cron
    chown root.cron /usr/bin/crontab
    chmod 4750 /usr/bin/crontab
   
Now add every user that is allowed to use cron to the new group 'cron'.

http://www.linuxfromscratch.org/hints/d … /dcron.txt

Last edited by pluckypigeon (2010-01-05 07:09:08)

Offline

#7 2010-01-05 09:32:37

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,355

Re: Trying to deny users from using Cron

pluckypigeon wrote:
ngoonee wrote:

Uh, isn't cron by default only editable by root?

Thanks for your response but no smile

I can log in as any user and type crontab -e

Sorry, I edit by hand and assumed that crontab required root rights :shy:


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#8 2010-01-19 17:48:06

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: Trying to deny users from using Cron

pluckypigeon wrote:

Ok, I found this on the LFS website smile

If you want to restrict access to cron, do:

    groupadd cron
    chown root.cron /usr/bin/crontab
    chmod 4750 /usr/bin/crontab
   
Now add every user that is allowed to use cron to the new group 'cron'.

http://www.linuxfromscratch.org/hints/d … /dcron.txt

Or you can just do:

chgrp root /usr/bin/crontab
chmod 4750 /usr/bin/crontab

to add dcron's crontab to the "root" group (and reset its permissions, which get changed when you change its group). crontab is setuid, and will only allow users belonging to whatever group it's assigned to use it

The crontab directory should already be impossible for users without root privileges to modify.

Last edited by Profjim (2010-02-06 20:42:55)

Offline

#9 2010-01-19 18:53:36

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Trying to deny users from using Cron

Just to add more confusion to it all ...
I know this is true for slackware, but haven't tried it on arch ...

Each user can have his/her own crontab, so they can all do a 'crontab -e' - but ... it will not run with root priviledges

Offline

#10 2010-01-19 19:38:13

Cyrusm
Member
From: Bozeman, MT
Registered: 2007-11-15
Posts: 1,053

Re: Trying to deny users from using Cron

perbh wrote:

Just to add more confusion to it all ...
I know this is true for slackware, but haven't tried it on arch ...

Each user can have his/her own crontab, so they can all do a 'crontab -e' - but ... it will not run with root priviledges

that is true, each user has their own individual crontab that only they and root may edit.  This way, users have the power to create their own scheduled tasks (i.e. change wallpaper, run backups, yada yada).
obviously only root has access to the root crontab.
and crontab entries requiring root privelages must be run from the root crontab.  basically, if you don't want regular users changing the root crontab, make sure that they don't have root privelages. if you trust a user enough to give them root privelages, then tell them not to mess with the crontab.


Hofstadter's Law:
           It always takes longer than you expect, even when you take into account Hofstadter's Law.

Offline

#11 2010-01-19 21:26:40

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: Trying to deny users from using Cron

Yeah but I'm sure there are reasons for stopping the average user from using cron at all. I'm sure I could find some way to abuse system resources without needing root privileges.


neutral

Offline

#12 2010-01-21 13:16:11

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: Trying to deny users from using Cron

I'm the current developer of dcron. A crontab can be created _for_ any user in the password database; the user doesn't even need to have a login shell.

However, crontabs can only be created _by_ users who belong to the group that the /usr/bin/crontab binary is assigned to. In dcron 4.4, now in [testing], the default group is 'users', but several earlier posts in this thread explain how to change that to another group. So if you don't want users who can't su to root to be able to create crontabs, you can easily do that.

If you want your permission changes to /usr/bin/crontab to persist across updates, look into the customizepkg or customizepkg-new scripts in [aur]. These work hand-in-hand with yaourt; I'm not sure if any other pacman-enhancers also cooperate with them. But at worst, you can use these to script whatever mods you want to make to a PKGBUILD, and then always build upgrades for that package by hand, from abs, using your customizepkg-scripted mods, rather than installing the pre-built binaries for the upgrade with pacman. Building dcron takes only a few seconds.

Offline

Board footer

Powered by FluxBB