freeBSD User provider

ADNET Ghislain
Mon, 11 Jun 2007 08:10:48 -0000

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.

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 :)