Jason,
        That is the output mailed to me from the run out of crontab when I took
off the redirect to /dev/null.  When I run it as root, outside of cron,
it works fine.  This is all for the version of sync_users in OSCAR 2.3
(sync_users-oscar-1.5-5).

On Wed, 2003-11-05 at 02:40, Jason Brechin wrote:
> On Tue, 2003-11-04 at 04:51, Frank Crawford wrote:
> > Folks,
> >     After poking around a bit, I've found that sync_users fails when it is
> > run out of /etc/crontab with the following error:
> > 
> > Traceback (most recent call last):
> >   File "/opt/c3-4/cpush", line 216, in ?
> >     defusername = os.environ[ 'USER' ]
> >   File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__
> >     def __getitem__(self, key): return self.data[key]
> > KeyError: USER
> > Can't push file /etc/gshadow to /etc/gshadow! 
> > 
> > The basic problem seems to be that USER is not defined in the
> > environment when run out of crontab.  Now, this can be seen as an error
> > in opium, c3 or cron, but either way it is a big problem for sync_users.
> 
> I have not seen this happen.  In addition, the command should be getting
> run as root.
> 
> > In addition, I found another "feature" of sync_users that makes this
> > more difficult to fix, that of sync_users updating /etc/crontab on every
> > run!  What is worse it resets any changes back to the "default" which
> > hides any errors!  This also runs the risk of corrupting /etc/crontab
> > due to an ill-timed update.
> 
> sync_users will check to see if it needs to change crontab, it does not
> change it every time (IIRC).  It will change it to what is in the config
> file.  If you want to change its run interval, change sync_users.conf,
> not /etc/crontab.

No, it rewrites it every time.  This is the crontab update routine in
the sync_users I've installed, which is always called as the last step
in sync_users:

# Simple crontab update routine
sub cronupdate {
  if ( $crondelay > 0 ) {
    if ( $crondelay > 59 ) {
      print "Your cron delay is too big, setting back to 59\n";
      $crondelay = 59;
    }
  }
  $cronline = "*/$crondelay * * * * root /opt/opium/bin/sync_users
>/dev/null 2>&1\n";
  open(CRONTABIN, "$crontab") or die "Couldn't read $crontab! $!\n";
  @crontabin = <CRONTABIN>;
  close CRONTABIN;
  foreach $line (@crontabin) {
    chomp $line;
    if ( $line eq $cronline ) { $found = 1; }
    elsif ( $line =~ /\/opt\/opium\/bin\/sync_users/ ) {
      $line = $cronline;
      $found = 1;
    }
  }
  if ( $found == 0 ) { push @crontabin, $cronline; }
  if ( $verbose > 1 ) { print join("\n", @crontabin) . "\n"; }

  open(CRONTABOUT,">$crontab") or die "Couldn't write $crontab! $!\n";
  print CRONTABOUT join("\n", @crontabin);
  close CRONTABOUT;
}

You can see that every time it rewrites crontab, even if it is only with
what was previously there.  Worse, if you change the sync_users line, it
puts it back to what it believes is the "correct one".

> Jason

Frank
-- 
ac3
Suite G16, Bay 7, Locomotive Workshop   Phone:  02 9209 4600
Australian Technology Park              Fax:    02 9209 4611
Eveleigh   NSW   1430



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Oscar-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/oscar-users

Reply via email to