summaryrefslogtreecommitdiff
path: root/sysutils/puppet/patches/patch-ae
blob: 751a28e218ccbef0c3af01c1c3ee9bd12102de55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$NetBSD: patch-ae,v 1.6 2021/12/12 13:38:01 taca Exp $

Fix detection of useradd user management under NetBSD.

NetBSD doesn't have chage but can use the -e and -f flags to passwd to
achieve the same.

--- lib/puppet/provider/user/useradd.rb.orig	2021-12-05 14:14:58.639678002 +0000
+++ lib/puppet/provider/user/useradd.rb
@@ -12,14 +12,23 @@ Puppet::Type.type(:user).provide :userad
     To use the `forcelocal` parameter, you need to install the `libuser` package (providing
     `/usr/sbin/lgroupadd` and `/usr/sbin/luseradd`)."
 
-  commands :add => "useradd", :delete => "userdel", :modify => "usermod", :password => "chage", :chpasswd  => "chpasswd"
+  if %w{NetBSD}.include? Facter.value(:operatingsystem)
+    commands :add => "useradd", :delete => "userdel", :modify => "usermod", :password => "passwd"
+  else
+    commands :add => "useradd", :delete => "userdel", :modify => "usermod", :password => "chage", :chpasswd  => "chpasswd"
+  end
 
   options :home, :flag => "-d", :method => :dir
   options :comment, :method => :gecos
   options :groups, :flag => "-G"
-  options :password_min_age, :flag => "-m", :method => :sp_min
-  options :password_max_age, :flag => "-M", :method => :sp_max
-  options :password_warn_days, :flag => "-W", :method => :sp_warn
+  if %w{NetBSD}.include? Facter.value(:operatingsystem)
+    options :password_min_age, :flag => "-e"
+    options :password_max_age, :flag => "-f"
+  else
+    options :password_min_age, :flag => "-m", :method => :sp_min
+    options :password_max_age, :flag => "-M", :method => :sp_max
+    options :password_warn_days, :flag => "-W", :method => :sp_warn
+  end
   options :password, :method => :sp_pwdp
   options :expiry, :method => :sp_expire,
     :munge => proc { |value|