Class: Arver::RefreshAction
- Inherits:
-
Action
- Object
- Action
- Arver::RefreshAction
show all
- Defined in:
- lib/arver/refresh_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, #needs_target_user?, #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) ⇒ RefreshAction
Returns a new instance of RefreshAction.
4
5
6
7
8
|
# File 'lib/arver/refresh_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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/arver/refresh_action.rb', line 24
def execute_partition( partition )
Arver::Log.info( "Generating a new key for partition #{partition.device}" )
slot_of_user = Arver::Config.instance.slot( Arver::LocalConfig.instance.username )
newkey = generator.generate_key( partition )
caller = Arver::LuksWrapper.changeKey( slot_of_user.to_s, partition )
caller.execute( key + "\n" + newkey )
unless( caller.success? )
Arver::Log.error( "Warning: i believe that i could not change the key on #{partition.path}, therefore i kept the old one!" )
Arver::Log.error( "Maybe the version of cryptsetup on that host does not yet support the luksChangeKey command. " )
Arver::Log.error( "Please verify that the old one still works. If the changeKey did in fact succeed, the plaintext key would now be: #{key}" )
Arver::Log.debug( "The output was: #{caller.output}" )
generator.remove_key( partition )
end
end
|
#post_action ⇒ Object
42
43
44
|
# File 'lib/arver/refresh_action.rb', line 42
def post_action
self.generator.dump( self.keystore )
end
|
#pre_action ⇒ Object
10
11
12
13
14
|
# File 'lib/arver/refresh_action.rb', line 10
def pre_action
tl = ""
target_list.each { |t| tl += ( tl.empty? ? "": ", " )+t.name }
Arver::Log.info( "refresh was called with target(s) #{tl}" )
end
|
#verify?(partition) ⇒ Boolean
16
17
18
19
20
21
22
|
# File 'lib/arver/refresh_action.rb', line 16
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
|