Class: Specinfra::Command::Freebsd::Base::User
Class Method Summary
collapse
Methods inherited from Base::User
check_belongs_to_group, check_belongs_to_primary_group, check_exists, check_has_authorized_key, check_has_home_directory, check_has_login_shell, check_has_uid, get_gid, get_home_directory, get_login_shell, get_uid
Methods inherited from Base
escape
Class Method Details
.add(user, options) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 35
def add(user, options)
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 << '-u' << escape(options[:uid]) if options[:uid]
if options[:password]
command.concat(['&&', 'chpass', '-p', "\'#{options[:password]}\'", escape(user)])
end
command.join(' ')
end
|
.create(os_info = nil) ⇒ Object
3
4
5
6
7
8
9
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 3
def create(os_info=nil)
if (os_info || os)[:release].to_i < 7
Specinfra::Command::Freebsd::V6::User
else
self
end
end
|
.get_encrypted_password(user) ⇒ Object
52
53
54
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 52
def get_encrypted_password(user)
"getent passwd #{escape(user)} | awk -F: '{ print $2 }'"
end
|
.get_maximum_days_between_password_change(user) ⇒ Object
15
16
17
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 15
def get_maximum_days_between_password_change(user)
"pw usershow -n #{escape(user)} | cut -d':' -f 6"
end
|
.get_minimum_days_between_password_change(user) ⇒ Object
11
12
13
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 11
def get_minimum_days_between_password_change(user)
'echo 0'
end
|
.update_encrypted_password(user, encrypted_password) ⇒ Object
48
49
50
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 48
def update_encrypted_password(user, encrypted_password)
"chpass -p \'#{encrypted_password}\' #{escape(user)}"
end
|
.update_gid(user, gid) ⇒ Object
31
32
33
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 31
def update_gid(user, gid)
"pw user mod #{escape(user)} -g #{escape(gid)}"
end
|
.update_home_directory(user, directory) ⇒ Object
19
20
21
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 19
def update_home_directory(user, directory)
"pw user mod #{escape(user)} -d #{escape(directory)}"
end
|
.update_login_shell(user, shell) ⇒ Object
23
24
25
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 23
def update_login_shell(user, shell)
"pw user mod #{escape(user)} -s #{escape(shell)}"
end
|
.update_uid(user, uid) ⇒ Object
27
28
29
|
# File 'lib/specinfra/command/freebsd/base/user.rb', line 27
def update_uid(user, uid)
"pw user mod #{escape(user)} -u #{escape(uid)}"
end
|