Просмотр исходного кода

u-a: Verify that the alternative used in --set has been registered

Give a proper error message instead of failing with an undefined
value when calling the slave method. Additionally verify the alternative
before switching to manual mode, avoiding this way unneeded log messages
in case of error.

Closes: #554136
Guillem Jover лет назад: 16
Родитель
Сommit
4b0a933f75
2 измененных файлов с 12 добавлено и 1 удалено
  1. 6 0
      debian/changelog
  2. 6 1
      scripts/update-alternatives.pl

+ 6 - 0
debian/changelog

@@ -1,8 +1,14 @@
 dpkg (1.15.5.3) UNRELEASED; urgency=low
 
+  [ Raphael Hertzog ]
   * Avoid usage of IO::String in dpkg-scanpackages, rely on Dpkg::IPC
     instead to directly get a pipe file descriptor. Closes: #557013
 
+  [ Guillem Jover ]
+  * Verify that the alternative used in update-alternatives --set has been
+    registered instead of failing with an undefined value in the slave
+    method. Closes: #554136
+
  -- Raphael Hertzog <hertzog@debian.org>  Sat, 21 Nov 2009 14:57:50 +0100
 
 dpkg (1.15.5.2) unstable; urgency=low

+ 6 - 1
scripts/update-alternatives.pl

@@ -291,8 +291,13 @@ if ($alternative->has_current_link()) {
 
 my $new_choice;
 if ($action eq 'set') {
+    if ($alternative->has_choice($path)) {
+        $new_choice = $path;
+    } else {
+        error(_g("alternative %s for %s not registered, not setting."),
+              $path, $alternative->name());
+    }
     $alternative->set_status('manual');
-    $new_choice = $path;
 } elsif ($action eq 'auto') {
     $alternative->set_status('auto');
     $new_choice = $alternative->best();