Class: Arver::CreateAction
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_action, #pre_host, #pre_partition, #run_on, #verify_key_on_target
Constructor Details
#initialize(target_list) ⇒ CreateAction
4
5
6
7
8
|
# File 'lib/arver/create_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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/arver/create_action.rb', line 19
def execute_partition( partition )
slot_of_user = Arver::Config.instance.slot( Arver::LocalConfig.instance.username )
caller = Arver::LuksWrapper.dump( partition )
caller.execute
if caller.output.include?('LUKS header information') then
Arver::Log.warn( "VERY DANGEROUS: the partition #{partition.device} is already formatted with LUKS - returning (continue with --violence)" )
Arver::Log.warn( "If you wish to integrate an existing disk into arver use --add-user #{Arver::LocalConfig.instance.username} instead." )
if Arver::RuntimeConfig.instance.violence then
Arver::Log.info( "you applied --violence, so we will continue ..." )
else
Arver::Log.info( "for more information see /tmp/luks_create_error.txt" )
system("echo \"#{caller.output}\" > /tmp/luks_create_error.txt")
throw( :abort_action ) if not Arver::RuntimeConfig.instance.violence
end
end
Arver::Log.info( "creating: "+partition.path )
Arver::Log.debug( "generating a new key for partition #{partition.device} on #{partition.path}" )
key = self.generator.generate_key( partition )
caller = Arver::LuksWrapper.create( slot_of_user.to_s, partition )
caller.execute( key )
unless( caller.success? )
Arver::Log.error( "Could not create Partition!" )
self.generator.remove_key( partition )
end
end
|
#post_action ⇒ Object
49
50
51
|
# File 'lib/arver/create_action.rb', line 49
def post_action
self.generator.dump( self.keystore )
end
|
#verify?(partition) ⇒ Boolean
10
11
12
13
14
15
16
17
|
# File 'lib/arver/create_action.rb', line 10
def verify?( partition )
key = self.keystore.luks_key( partition )
if( ! key.nil? and ! Arver::RuntimeConfig.instance.force )
Arver::Log.warn( "DANGEROUS: you do have already a key for partition #{partition.path} (apply --force to continue)" )
return false
end
true
end
|