On Tue, 2006-03-21 at 10:10 -0500, Brian E. Seppanen wrote:
> I have the following code
> 
> classes:
>          host_groupa::
>          usera        = ( ReturnsZero(/usr/bin/getent passwd usera) )
> 
> 
> shellcommands:
>       host_groupa.!usera::
>          "/usr/sbin/useradd -g usera -d /export/home/usera -s 
> /usr/local/bin/scponly -m -k /etc/skel usera"
> 
> 
> So what that would do is evaluate a class usera if /usr/bin/getent passwd 
> usera returns 0 if that user exists on the host.    The disadvantage of 
> this is that getent will provide output, which I don't want.   I'm only 
> interested in the return code.   I want any of the output to go to 
> /dev/null.   So that is the first question.    how can I take output from 
> the command passed to ReturnsZero and send it to /dev/null?

I switched from ReturnsZero(/usr/bin/getent ...) to a module to
accomplish the same thing.  As noted elsewhere, using /bin/sh -c and
lots of quotation marks makes things hard to read. 

> The second question is:   Does someone know of an easier way of testing 
> for the existence of a user that wouldn't require a call to getent? 
> Just wondering if there is a better solution out there.

I think getent is probably the best solution as that will use what you
have configured in /etc/nsswitch.conf.

.sf

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
http://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to