Commit 4c92f445 authored by anonym's avatar anonym
Browse files

Merge remote-tracking branch 'origin/test/5472-shutdown-on-boot-medium-removal' into testing

Fix-committed: #5472
parents 22094311 779d76c7
......@@ -85,6 +85,16 @@ Feature: Various checks
Given I have started Tails from DVD without network and logged in
Then tails-debugging-info is not susceptible to symlink attacks
Scenario: Tails shuts down on DVD boot medium removal
Given I have started Tails from DVD without network and logged in
When I eject the boot medium
Then Tails eventually shuts down
Scenario: Tails shuts down on USB boot medium removal
Given I have started Tails without network from a USB drive without a persistent partition and logged in
When I eject the boot medium
Then Tails eventually shuts down
Scenario: The Tails Greeter "disable all networking" option disables networking within Tails
Given I have started Tails from DVD without network and stopped at Tails Greeter's login screen
And I enable more Tails Greeter options
......
......@@ -957,3 +957,17 @@ end
Then /^I force Tor to use a new circuit( in Vidalia)?$/ do |with_vidalia|
force_new_tor_circuit(with_vidalia)
end
When /^I eject the boot medium$/ do
dev = boot_device
dev_type = device_info(dev)['ID_TYPE']
case dev_type
when 'cd'
$vm.remove_cdrom
when 'disk'
boot_disk_name = $vm.disk_name(dev)
$vm.unplug_drive(boot_disk_name)
else
raise "Unsupported medium type '#{dev_type}' for boot device '#{dev}'"
end
end
......@@ -116,12 +116,19 @@ def checkpoints
],
},
'usb-install-with-persistence-tails-greeter' => {
:description => "I have started Tails without network from a USB drive with a persistent partition and stopped at Tails Greeter's login screen",
'usb-install-logged-in' => {
:description => "I have started Tails without network from a USB drive without a persistent partition and logged in",
:parent_checkpoint => 'usb-install-tails-greeter',
:steps => [
'I log in to a new session',
'the Tails desktop is ready',
],
},
'usb-install-with-persistence-tails-greeter' => {
:description => "I have started Tails without network from a USB drive with a persistent partition and stopped at Tails Greeter's login screen",
:parent_checkpoint => 'usb-install-logged-in',
:steps => [
'I create a persistent partition',
'a Tails persistence partition exists on USB drive "__internal"',
'I shutdown Tails and wait for the computer to power off',
......
......@@ -360,12 +360,15 @@ def boot_device
return boot_dev
end
def boot_device_type
def device_info(dev)
# Approach borrowed from
# config/chroot_local_includes/lib/live/config/998-permissions
boot_dev_info = $vm.execute("udevadm info --query=property --name='#{boot_device}'").stdout.chomp
boot_dev_type = (boot_dev_info.split("\n").select { |x| x.start_with? "ID_BUS=" })[0].split("=")[1]
return boot_dev_type
info = $vm.execute("udevadm info --query=property --name='#{dev}'").stdout.chomp
info.split("\n").map { |e| e.split('=') } .to_h
end
def boot_device_type
device_info(boot_device)['ID_BUS']
end
Then /^Tails is running from (.*) drive "([^"]+)"$/ do |bus, name|
......
......@@ -137,28 +137,6 @@ class VM
set_network_link_state('down')
end
def set_cdrom_tray_state(state)
domain_xml = REXML::Document.new(@domain.xml_desc)
domain_xml.elements.each('domain/devices/disk') do |e|
if e.attribute('device').to_s == "cdrom"
e.elements['target'].attributes['tray'] = state
if is_running?
@domain.update_device(e.to_s)
else
update(domain_xml.to_s)
end
end
end
end
def eject_cdrom
set_cdrom_tray_state('open')
end
def close_cdrom
set_cdrom_tray_state('closed')
end
def set_boot_device(dev)
if is_running?
raise "boot settings can only be set for inactive vms"
......@@ -169,15 +147,20 @@ class VM
end
def set_cdrom_image(image)
image = nil if image == ''
domain_xml = REXML::Document.new(@domain.xml_desc)
domain_xml.elements.each('domain/devices/disk') do |e|
if e.attribute('device').to_s == "cdrom"
if ! e.elements['source']
e.add_element('source')
if image.nil?
e.elements.delete('source')
else
if ! e.elements['source']
e.add_element('source')
end
e.elements['source'].attributes['file'] = image
end
e.elements['source'].attributes['file'] = image
if is_running?
@domain.update_device(e.to_s, Libvirt::Domain::DEVICE_MODIFY_FORCE)
@domain.update_device(e.to_s)
else
update(domain_xml.to_s)
end
......@@ -186,7 +169,15 @@ class VM
end
def remove_cdrom
set_cdrom_image('')
set_cdrom_image(nil)
rescue Libvirt::Error => e
# While the CD-ROM is removed successfully we still get this
# error, so let's ignore it.
acceptable_error =
"Call to virDomainUpdateDeviceFlags failed: internal error: unable to " +
"execute QEMU command 'eject': (Tray of device '.*' is not open|" +
"Device '.*' is locked)"
raise e if not(Regexp.new(acceptable_error).match(e.to_s))
end
def set_cdrom_boot(image)
......@@ -195,7 +186,6 @@ class VM
end
set_boot_device('cdrom')
set_cdrom_image(image)
close_cdrom
end
def list_disk_devs
......@@ -288,6 +278,17 @@ class VM
return "/dev/" + rexml.elements['disk/target'].attribute('dev').to_s
end
def disk_name(dev)
dev = File.basename(dev)
domain_xml = REXML::Document.new(@domain.xml_desc)
domain_xml.elements.each('domain/devices/disk') do |e|
if /^#{e.elements['target'].attribute('dev').to_s}/.match(dev)
return File.basename(e.elements['source'].attribute('file').to_s)
end
end
raise "No such disk device '#{dev}'"
end
def udisks_disk_dev(name)
return disk_dev(name).gsub('/dev/', '/org/freedesktop/UDisks/devices/')
end
......
......@@ -143,15 +143,6 @@ tracked by tickets prefixed with `todo/test_suite:`.
* When we receive this bug report on the tails-bugs mailing-list,
Schleuder tells us that it was sent encrypted.
# Erase memory on shutdown
- After booting from DVD, remove Tails boot medium and check that the
memory erasure process is started (`Loading new kernel`, at least).
(automate: [[!tails_ticket 5472]])
- After booting from USB, remove Tails boot medium and check that the
memory erasure process is started (`Loading new kernel`, at least).
(automate: [[!tails_ticket 5472]])
# Root access control
* Check you cannot login as root with `su` neither with the `amnesia` password nor
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment