Class: Arver::AdduserAction
- Inherits:
-
Action
- Object
- Action
- Arver::AdduserAction
show all
- Defined in:
- lib/arver/adduser_action.rb
Instance Attribute Summary
Attributes inherited from Action
#generator, #key, #keystore, #slot_of_target_user, #target_list, #target_user
Instance Method Summary
collapse
Methods inherited from Action
#load_key, #new_key_generator, #on_user, #open_keystore, #post_host, #post_partition, #pre_host, #pre_partition, #run_on, #verify_key_on_target
Constructor Details
#initialize(target_list) ⇒ AdduserAction
Returns a new instance of AdduserAction.
4
5
6
7
8
|
# File 'lib/arver/adduser_action.rb', line 4
def initialize( target_list )
super( target_list )
self.open_keystore
self.new_key_generator
end
|
Instance Method Details
#execute_partition(partition) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/arver/adduser_action.rb', line 28
def execute_partition( partition )
Arver::Log.info( "Generating keys for partition #{partition.device}" )
Arver::Log.debug( "generate_key (#{target_user},#{partition.path})" )
newkey = generator.generate_key( partition )
caller = Arver::LuksWrapper.addKey( slot_of_target_user.to_s, partition )
caller.execute( key + "\n" + newkey )
unless( caller.success? )
Arver::Log.error( "Could not add user to #{partition.path} \n #{caller.output}" )
generator.remove_key( partition )
end
end
|
#needs_target_user? ⇒ Boolean
16
17
18
|
# File 'lib/arver/adduser_action.rb', line 16
def needs_target_user?
true
end
|
#post_action ⇒ Object
45
46
47
|
# File 'lib/arver/adduser_action.rb', line 45
def post_action
self.generator.dump( Keystore.for( target_user ) )
end
|
#pre_action ⇒ Object
10
11
12
13
14
|
# File 'lib/arver/adduser_action.rb', line 10
def pre_action
tl = ""
target_list.each { |t| tl += ( tl.empty? ? "": ", " )+t.name }
Arver::Log.info( "adduser was called with target(s) #{tl} and user #{target_user} (slot-no #{slot_of_target_user})" )
end
|
#verify?(partition) ⇒ Boolean
20
21
22
23
24
25
26
|
# File 'lib/arver/adduser_action.rb', line 20
def verify?( partition )
unless Arver::RuntimeConfig.instance.ask_password
return load_key( partition )
end
self.key= ask("Enter the password for the volume: #{partition.device}") {|q| q.echo = false}
true
end
|