[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

modules bug with pre-scanning for a user

From: Ted Zlatanov
Subject: modules bug with pre-scanning for a user
Date: 11 Jun 2001 19:45:13 -0400
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.0.100

I want cfengine to quietly define a class if a user exists on the

My first try was:

 JoeFound = ( "/bin/grep joe /etc/passwd" )

  "/bin/echo found Joe"

Which works, but always prints out the passwd line for Joe when
cfengine runs.  grep -c was a little better (prints out 1 or 0), but
still annoying.

I then wrote a plugin "grepper" module, which basically should do a
grep but without printing anything out:

#!/usr/bin/perl -w

use strict;

my $pattern = shift @ARGV;
my $file    = shift @ARGV;
my $class   = shift @ARGV or die "invoke as '$0 PATTERN FILE CLASS'";

open FILE, "<$file" or die "Couldn't open file $file: $!";

while (<FILE>)
 print "+$class" if $_ =~ /$pattern/;

And I invoke it as:

  actionsequence = ( "module:grepper joe /etc/passwd JoeFound" )

All the settings are correct; cfengine -v shows that JoeFound gets
defined when joe is in the /etc/passwd file and doesn't get defined

Now, the problem.  The following files: section

  /home/joe mode=0777 owner=joe recurse=inf action=fixdirs

generates an error whether Joe is or isn't in the /etc/passwd file,
whether the JoeFound class is or isn't defined; complaining

"Unknown user joe
ice:cfengine.conf:78: Warning: User is not known in this passwd domain"

Which I know, so I don't need the warning.  As a matter of fact, the
whole exercise was in order to eliminate that warning.  My guess is
that the user name is checked before the module is run.

JoeFound is in the AddInstallable list of classes.  cfengine version

I could fix this by using the grepper module by name as a script in
the classes section, of course.  I would like to get modules and
dynamically generated classes working for my own benefit, however, and
I would like to know if this is a bug or expected behavior.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]