trouble writing a setuid script



Hi,

I'm trying to write a setuid script and can't make it happen. I've
trimmed it down to the very simple example below trying to have a
logger.pl script add a message to a log file. This is my Bash
transcript with all the pertinent details.

$ ls -Al
total 8
-rw-r--r-- 1 root wheel 0 29 Aug 23:52 log
-rwsr-xr-x 1 root wheel 145 29 Aug 23:52 logger.pl*
$ cat log
$ cat logger.pl
#!/usr/bin/perl -w

use strict;
use warnings;

my $FILE;
open(FILE, ">> log") or die "couldn't open: ";
print(FILE "hello, world");
close(FILE);
$ whoami
peter
$ ./logger.pl
couldn't open: at ./logger.pl line 7.
$ sudo ./logger.pl
Password:
$ cat log
hello, world

So the script works when I "sudo" but not when the script runs as my
normal "peter" user.

Any ideas why it doesn't work and what I need to change?

(I don't run into any errors when writing the same program in C.)

Thanks,
Peter
.



Relevant Pages

  • Re: delete files and create logfile
    ... My current script ): ... cd $PM/TgtFiles/DW ...
    (comp.unix.shell)
  • lk-changelog.pl 0.326
    ... This script is used by Linus and Marcelo to rearrange and reformat BK ... 'david:gibson.dropbear.id.au' => 'David Gibson', ... +'johansen:immunix.com' => 'John Johansen', ... 'pebl:math.ku.dk' => 'Peter Berg Larsen', ...
    (Linux-Kernel)
  • lk-changelog.pl 0.190
    ... This script is used by Linus and Marcelo to rearrange and reformat BK ... +'erik:harddisk-recovery.nl' => 'Erik Mouw', ... 'peter:cadcamlab.org' => 'Peter Samuelson', ...
    (Linux-Kernel)
  • lk-changelog.pl 0.314
    ... This script is used by Linus and Marcelo to rearrange and reformat BK ... ChangeSet logs into a more human-readable format, ... Peter Anvin', ... 'paul.clements:steeleye.com' => 'Paul Clements', ...
    (Linux-Kernel)
  • Re: Gruppo di =?ISO-8859-1?Q?continuit=E0eutenteRoot?=
    ... No, non va modificato lo script, si tratta di scrivere sudo davanti allo ... leggendo poi tra le varie FAQ e sul forum avevo trovato una procedura ... Non funziona male ma e proprietario, con tutti i difetti che questo ...
    (it.comp.macintosh)