The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
running X-11 programs as root Allasso UNIX for Advanced & Expert Users 8 12-28-2007 03:22 PM
Command Not running in script Dastard Shell Programming and Scripting 2 05-21-2007 05:08 PM
running multiple rsh command in a script lweegp Shell Programming and Scripting 0 10-31-2006 02:37 AM
PS command does not display shell script running hadarot Shell Programming and Scripting 4 09-15-2005 05:56 AM
running a scr in rc3.d not as root, can i? kymberm UNIX for Advanced & Expert Users 6 11-12-2002 11:50 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-25-2005
rm-r rm-r is offline
Registered User
  
 

Join Date: May 2005
Location: Montreal
Posts: 17
Question Running a command or script as root

I'm writing an application (Progress language) that needs to:
1) load the contents of a cron table into the Progress application;
2) display this information in a human manner and allow a select group of people to update it (these people are logged in as themselves, not as root);
3) save everything back to the cron table (probably just overwrite the existing file with the newly generated one).

My questions relate to (1) and (3). The cron file is located in a directory called /var/spool/cron/crontabs/
-r-------- 1 root sys 1978 May 24 10:58 qadbatch

As you can see, only root can Read and Write to this file (and we like it this way!!).

Any ideas on how to read and overwrite this file without being root?

Notes:
A- The Progress application can run any Unix commands or scripts and retrieve their output (but it cannot run interactive commands such as 'crontab -e').

B- Users do not have access to the crontab command.

Thanks!!

Réal
  #2 (permalink)  
Old 05-26-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511
Quote:
Any ideas on how to read and overwrite this file without being root?

No way ...
  #3 (permalink)  
Old 05-26-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
maybe you could try ...


1. write a cron script --- running under root --- that would ...

a. regularly copy /var/spool/cron/crontabs/qadbatch to /somedir/somefile
b. regularly check for changes in /somedir/somefile as compared to /var/spool/cron/crontabs/qadbatch. changes made to /somedir/somefile are incorporated into the qadbatch crontab.


2. write a script that lets the users edit /somedir/somefile and logs those edits. since the possibility of mischief exists, you might want to add more security checks to the edit script --- i.e., require a random password that you give to the users, etc. --- just to be on the safe side.
  #4 (permalink)  
Old 05-27-2005
rm-r rm-r is offline
Registered User
  
 

Join Date: May 2005
Location: Montreal
Posts: 17
OK, I found a few ways to do that but I was approaching the problem from the wrong angle.

You cannot modify the cron file owned by root, or so it says in man. You have to use the crontab command. This being established, how do I allow a user to modify another user's cron table? I first thought of sudo but it's not installed here and I would have to convince the sys-admins to do this - more problems...

Remote Shell! That is the way to go! You setup the user who owns the cron table to accept remote access from select users (create a .rhosts file in this user's home dir).

Then, those select users can rsh (remsh on certain systems) their way into the owner's crontab entry:
$ rsh <server-name> -l <cron-userid> "crontab <new-cron-file>"

Voila!

Thanks to those who replied.

Réal
Closed Thread

Bookmarks

Tags
unix commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0