The following commit has been merged in the master branch:
commit 638e259f69c1f3c0e1000979274562f8ffad4df9
Author: Raphaël Hertzog <hert...@debian.org>
Date:   Tue Jun 28 09:34:52 2011 +0200

    update-alternatives: do not allow to reuse a slave link in another slave 
alternative
    
    update-alternatives erroneously allowed to reuse a link in another slave
    alternative. Given the parsing code already catched this error, it would
    immediately result in update-alternatives being unusable to manipulate the
    broken alternative.
    
    Reported-by: Andreas Beckmann <deb...@abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index 683564c..902e952 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -54,6 +54,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     directives.
   * dpkg-buildflags(1): make it clear that DEB_*_(SET|APPEND) environment
     variables are meant for users and should not be used by packages.
+  * update-alternatives: do not allow to reuse a slave link in another
+    slave alternative. Closes: #631547
 
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
diff --git a/utils/t/100_update_alternatives.t 
b/utils/t/100_update_alternatives.t
index 667bcd0..97dfe2a 100644
--- a/utils/t/100_update_alternatives.t
+++ b/utils/t/100_update_alternatives.t
@@ -81,7 +81,7 @@ my @choices = (
 );
 my $nb_slaves = 4;
 plan tests => (4 * ($nb_slaves + 1) + 2) * 25 # number of check_choices
-               + 69;                         # rest
+               + 70;                         # rest
 
 sub cleanup {
     system("rm -rf $tmpdir && mkdir -p $admindir && mkdir -p $altdir");
@@ -385,6 +385,11 @@ call_ua(["--install", "$bindir/slave1", "testmaster", 
"/bin/date", "10"],
 call_ua(["--install", "$bindir/testmaster", "testmaster", "/bin/date", "10",
         "--slave", "$bindir/generic-test", "testslave", "/bin/true" ],
        expect_failure => 1, to_file => "/dev/null", error_to_file => 
"/dev/null");
+# try to reuse slave link in another slave alternative of another choice of
+# the same main alternative
+call_ua(["--install", $main_link, $main_name, "/bin/date", "10",
+        "--slave", "$bindir/slave1", "testslave", "/bin/true" ],
+       expect_failure => 1, to_file => "/dev/null", error_to_file => 
"/dev/null");
 # lack of absolute filenames in links or file path, non-existing path,
 call_ua(["--install", "../testmaster", "testmaster", "/bin/date", "10"],
         expect_failure => 1, to_file => "/dev/null", error_to_file => 
"/dev/null");
diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c
index c707bd5..0ad55a6 100644
--- a/utils/update-alternatives.c
+++ b/utils/update-alternatives.c
@@ -2280,6 +2280,17 @@ main(int argc, char **argv)
                                        "managed by %s."), sl->link,
                                      found->master_name);
                        }
+                       if (found) {
+                               struct slave_link *sl2;
+                               for (sl2 = found->slaves; sl2; sl2 = sl2->next)
+                                       if (strcmp(sl2->link, sl->link) == 0)
+                                               break;
+                               if (sl2 && strcmp(sl2->name, sl->name) != 0)
+                                       error(_("alternative link %s is already 
"
+                                               "managed by %s (slave of %s)."),
+                                             sl->link, sl2->name,
+                                             found->master_name);
+                       }
 
                        if (sl->link[0] != '/')
                                error(_("alternative link is not absolute as "

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to