Re: freeBSD User provider

ADNET Ghislain
Fri, 15 Jun 2007 06:19:22 -0000

Luke Kanies a écrit :
> On Jun 11, 2007, at 3:10 AM, ADNET Ghislain wrote:
>
>
>> Hello,
>>
>>  from the doc it seems that the User  type has a provider of
''pw''
>> for FreeBSD.  It seems the provider does not allow dupelicate, does
>> not allow to manage the homedir and to manage password.
>>
>>
>>  in the code the duplicate uid is set so it seems the doc is out of
>> date on this :)
>>
>> - manage home directory, i don''t really understand what is
that
>> parameter. The docs says ''allow to manage home
directory'' so i will
>> make a guess as it means that if we purge the user it purge the
>> directory, if so then:
>>
>>    (aqadmin)> pw user add help
>>    ....
>>            -d directory   home directory
>>            -m [ -k dir ]  create and set up home
>>
>>    (aqadmin)> pw user del help
>>    ...
>>            -r             remove home & contents
>>
>>
>>       so to create this is -m and to destroy this is -r
>>
>>
>>
>> - password. This one is tricky as the pw command does not allow
>> specificaly to give the password on the command line encrypted. It
>> requires the chpass utility:
>>
>>    chpass [-a list] [-p encpass] [-e expiretime] [-s newshell] [user]
>>
>>
>> it is installed on all my freeBSD servers but i don''t know if
this
>> is the same package and if this is by default :)
>>
>> So here is what i think for the provider:
>>
>> puppet-0.22.4/lib/puppet/provider/user/pw.rb
>>
>> add line:
>>
>> +    has_features :manages_homedir, :allows_duplicates
>>
>>
>> change this command (+ on the lines addedd)
>>
>>    def addcmd
>>        cmd = [command(:pw), "useradd", @model[:name]]
>>        @model.class.validproperties.each do |property|
>>            next if property == :ensure
>>            # the value needs to be quoted, mostly because -c might
>>            # have spaces in it
>>            if value = @model.should(property) and value != ""
>>                cmd << flag(property) << value
>>            end
>>        end
>>
>>        if @model[:allowdupe] == :true
>>            cmd << "-o"
>>        end
>>
>> +        if @model.managehome?
>> +            cmd << "-m"
>> +        end
>>
>>        return cmd
>>    end
>>
>>
>> i see that the provider user [:allowdupe] == :true while the linux
>> one use  allowdupe? so i don''t know which is best... Also i do
not
>> see where is the command to delete a user so perhaps user purging
>> is not set.
>>
>
> Can you file this as a patch on an enhancement request?
>
>
as a patch i am not sure to know how to do this...
i''
> You''re correct about what ''managehome'' means.
It looks like you''ve
> got the right stuff for adding the dir at user creation time, you
> just need to also add the -r option or whatever at user removal time.
>
>
hummm yes but i could not find the removal part in the
provider...
>> Also i do not know how to add a parameter for this provider to
>> define the freeBSD user class (-L ...) of the user. Could be handy
>> to make this available :)
>>
>
> What is this feature?  I''ve not encountered it before.
yes, you can define a user class in login.conf (see man login.conf for
details):

DESCRIPTION
     login.conf contains various attributes and capabilities of login
classes.
     A login class (an optional annotation against each record in the user
     account database, /etc/master.passwd) determines session accounting,
     resource limits and user environment settings.  It is used by various
     programs in the system to set up a user''s login environment and to
     enforce policy, accounting and administrative restrictions.  It
also pro
     vides the means by which users are able to be authenticated to the
system
     and the types of authentication available.


and then put the user in this class. This set quite a lot of thing for
the user like timezone, lang setting, ressource limits, umask etc....

so in freeBSD it could be handy but realy i don''t know how to add this
simple thing to the provider.