ice_ice_ice has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks:)

I need your help. I run a simple script - rotating log files from packet sniffer. For the rotating I use the Logfile::Rotate package. Unfortunately I have a big problem with this script. When root created new file by rotate function (root account is require to run packet sniffer), he set up user and group ownership to 200. I checked and I don't have any user with mentioned ID.

I made another simple test: just create simple script to check if everything is ok with rotating function. The result - new file with root as a user and group owner.

Monks have you ever seen something like this ?

Replies are listed 'Best First'.
Re: Wrong ownership of the file
by MidLifeXis (Monsignor) on Jan 04, 2012 at 19:31 UTC
      Thanks for reply and sorry for not clear question.

      You have right, chown made one error, because I received this communicate:

      error: chown failed: (sniffer.log.1) at test.pl line 150
      Right now I set up the object of Logfile::Rotate like this:
      my $log = new Logfile::Rotate( File => 'sniffer.log', + Pre => sub{close($LOG_ +FILE);}, +Post => sub{open( $LOG_FILE, '>', 'sniffer.log');}, + Flock => 'no', + Persist => 'no');

      The problem with chown call was solved but unfortunately I have another error:

      error: could not truncate sniffer.log: Permission denied at test.pl line 151

      I think that this is related to this files wrong ownership:

      -rw-r--r-- 1 root root 0 2012-01-04 20:51 sniffer.log -rw-r--r-- 1 200 200 0 2012-01-04 20:51 sniffer.log.1

      I tried the same algorithm without packet capture and everything was ok: no errors, files were created with correct ownership