lib/specinfra/command/freebsd/base/user.rb in specinfra-2.50.3 vs lib/specinfra/command/freebsd/base/user.rb in specinfra-2.50.4

- old
+ new

@@ -7,11 +7,11 @@ self end end def get_minimum_days_between_password_change(user) - "echo 0" + 'echo 0' end def get_maximum_days_between_password_change(user) "pw usershow -n #{escape(user)} | cut -d':' -f 6" end @@ -31,25 +31,24 @@ def update_gid(user, gid) "pw user mod #{escape(user)} -g #{escape(gid)}" end def add(user, options) - if options[:password] then - command = ['echo',"\'#{escape(options[:password])}\'",'|','pw','user','add',escape(user),'-H','0'] - else - command = ['pw','user','add',escape(user)] - end + command = ['pw', 'user', 'add', escape(user)] command << '-g' << escape(options[:gid]) if options[:gid] command << '-d' << escape(options[:home_directory]) if options[:home_directory] command << '-s' << escape(options[:shell]) if options[:shell] command << '-m' if options[:create_home] command << '-r' if options[:system_user] command << '-u' << escape(options[:uid]) if options[:uid] + if options[:password] + command.concat(['&&', 'chpass', '-p', "\'#{options[:password]}\'", escape(user)]) + end command.join(' ') end def update_encrypted_password(user, encrypted_password) - "echo \'#{escape(encrypted_password)}\' | sudo pw user mod #{escape(user)} -H 0" + "chpass -p \'#{encrypted_password}\' #{escape(user)}" end def get_encrypted_password(user) "getent passwd #{escape(user)} | awk -F: '{ print $2 }'" end