al@ee.pitt.edu (Alan Martello) (03/02/90)
Ok, I regret not having followed the previous discussion concerning privledged "perl" programs, but anyway... I have a perl program which 1) kills processes (via the perl call 'kill') 2) attempts to unmount file systems 3) backs up the file systems which were successfully unmounted 4) remounts all file systems My perl script works fine when I run it as root interactively, however, when it is run from crontab (as root), I can kill the processes just fine, but the "umount", "dump" and "mount -av" commands all fail. I am calling these programs via a perl system() call. I was (finally) able to get it to work by copying the desired programs, (mount, umount, and dump) and making the PROGRAMS setuid (I also made the mode 700 for good measure). Now, the question I have is why did I have to do it this way? Is perl being too cautious when performing the "system" calls or is crontab getting in the way? Trying to use /usr/local/bin/suidperl didn't work any better since perl complained about the pipe which I was openned to /bin/mail to log information about the backups.... I'm running on a Sun 3 under 4.0.1 (perl patchlevel 6) A confused perl programmer... ******************************************************************* Alan R. Martello Electrical Engineering Dept. al@ee.pitt.edu University of Pittsburgh *******************************************************************
merlyn@iwarp.intel.com (Randal Schwartz) (03/02/90)
In article <6998@pitt.UUCP>, al@ee (Alan Martello) writes: | My perl script works fine when I run it as root interactively, | however, when it is run from crontab (as root), I can kill the | processes just fine, but the "umount", "dump" and | "mount -av" commands all fail. | | I am calling these programs via a perl system() call. I suspect you are running into a problem not with Perl, but with the shell. Specifically, umount, dump, and mount are all in /etc (or /usr/etc, depending on the time of day at Sun :-). Try something like: $ENV{'PATH'} = "/etc:/usr/etc:$ENV{'PATH'}"; in the first few lines of your Perl program. Cron's default path is more along the lines of /usr/ucb:/bin:/usr/bin. $ENV{'MOTD'}='Just another Perl hacker,';system('printenv MOTD'); -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
al@jupiter.ee.pitt.edu (Alan Martello) (03/02/90)
Boy do I feel stupid, here is the answer: ---------------------------------------------------- Return-Path: jones@emx.utexas.edu Return-Path: <jones@emx.utexas.edu> Date: Thu, 1 Mar 90 19:49:34 -0600 From: jones@emx.utexas.edu (William L. Jones) Posted-Date: Thu, 1 Mar 90 19:49:34 -0600 To: al@ee.pitt.edu Subject: Re: why does system() not work when from root's crontab? You should always be explict with paths form a script to be used with crontab. Crontab does not run .login and .profile files on a lot of machines. And dump, mount and umount are in /etc which is not in the default path. Bill ------------------------------------------------------ now if someone could only solve my STDERR problem... ******************************************************************* Alan R. Martello Electrical Engineering Dept. al@ee.pitt.edu University of Pittsburgh *******************************************************************