@debian: "Package: dpkg
Version: 83.161.120.155
Severity: important
File: /usr/bin/update-alternatives
Tags: sid squeeze
Hi,
update-alternatives happily removes regular files that are in place of
alternative slave links if the currently selected alternative does not
have that particular slave. This is a regression from lenny (which had
the perl implementation of update-alternatives).
The following script demonstrates the problem:
===== alternative-delete-file.sh =====
#!/bin/sh
set -x
master=${1:-master}
touch /tmp/without-slave /tmp/with-slave
echo slave-file > /tmp/slave
echo different-file > /tmp/$master-slave
ls -la /tmp/$master-slave
cat /tmp/$master-slave
update-alternatives install /tmp/$master $master /tmp/with-slave    10 slave /tmp/$master-slave $master-slave /tmp/slave
# not replacing ... with a link => OK
update-alternatives remove $master /tmp/with-slave
# not deleting => OK
ls -la /tmp/$master-slave
cat /tmp/$master-slave
update-alternatives install /tmp/$master $master /tmp/without-slave  1
update-alternatives install /tmp/$master $master /tmp/with-slave    10 slave /tmp/$master-slave $master-slave /tmp/slave
# not replacing ... with a link => OK
ls -la /tmp/$master-slave
cat /tmp/$master-slave
update-alternatives display $master
update-alternatives set $master /tmp/without-slave
# OOPS, the file (which was there instead of a link) was removed
ls -la /tmp/$master-slave
cat /tmp/$master-slave
update-alternatives display $master
===== =====
# ./alternative-delete-file.sh test5
+ master=test5
+ touch /tmp/without-slave /tmp/with-slave
+ echo slave-file
+ echo different-file
+ ls -la /tmp/test5-slave
-rw-rr 1 root root 15 Jul 12 08:09 /tmp/test5-slave
+ cat /tmp/test5-slave
different-file
+ update-alternatives install /tmp/test5 test5 /tmp/with-slave 10 slave /tmp/test5-slave test5-slave /tmp/slave
update-alternatives: using /tmp/with-slave to provide /tmp/test5 (test5) in auto mode.
update-alternatives: warning: not replacing /tmp/test5-slave with a link.
+ update-alternatives remove test5 /tmp/with-slave
+ ls -la /tmp/test5-slave
-rw-rr 1 root root 15 Jul 12 08:09 /tmp/test5-slave
+ cat /tmp/test5-slave
different-file
+ update-alternatives install /tmp/test5 test5 /tmp/without-slave 1
update-alternatives: using /tmp/without-slave to provide /tmp/test5 (test5) in auto mode.
+ update-alternatives install /tmp/test5 test5 /tmp/with-slave 10 slave /tmp/test5-slave test5-slave /tmp/slave
update-alternatives: using /tmp/with-slave to provide /tmp/test5 (test5) in auto mode.
update-alternatives: warning: not replacing /tmp/test5-slave with a link.
+ ls -la /tmp/test5-slave
-rw-rr 1 root root 15 Jul 12 08:09 /tmp/test5-slave
+ cat /tmp/test5-slave
different-file
+ update-alternatives display test5
test5 - auto mode
  link currently points to /tmp/with-slave
/tmp/with-slave - priority 10
  slave test5-slave: /tmp/slave
/tmp/without-slave - priority 1
Current 'best' version is '/tmp/with-slave'.
+ update-alternatives set test5 /tmp/without-slave
update-alternatives: using /tmp/without-slave to provide /tmp/test5 (test5) in manual mode.
+ ls -la /tmp/test5-slave
ls: cannot access /tmp/test5-slave: No such file or directory
+ cat /tmp/test5-slave
cat: /tmp/test5-slave: No such file or directory
+ update-alternatives display test5
test5 - manual mode
  link currently points to /tmp/without-slave
/tmp/with-slave - priority 10
  slave test5-slave: /tmp/slave
/tmp/without-slave - priority 1
Current 'best' version is '/tmp/with-slave'.
Andreas
 System Information:
Debian Release: 6.0.2
  APT prefers stable
  APT policy: (800, 'stable'), (750, 'oldstable'), (700, 'testing'), (600, 'unstable'), (500, 'stable-updates'), (130, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages dpkg depends on:
ii  coreutils               8.5-1            GNU core utilities
ii  libbz2-1.0              1.0.5-6          high-quality block-sorting file co
ii  libc6                   2.13-7           Embedded GNU C Library: Shared lib
ii  libselinux1             2.0.96-1         SELinux runtime shared libraries
ii  xz-utils                5.0.0-2          XZ-format compression utilities
ii  zlib1g                  1:83.161.120.155.dfsg-3 compression library - runtime
dpkg recommends no packages.
Versions of packages dpkg suggests:
ii  apt                    83.161.120.155+squeeze1 Advanced front-end for dpkg
 no debconf information
 System Information:
Debian Release: 6.0.2
  APT prefers stable
  APT policy: (800, 'stable'), (750, 'oldstable'), (700, 'testing'), (600, 'unstable'), (500, 'stable-updates'), (130, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages dpkg depends on:
ii  coreutils               8.5-1            GNU core utilities
ii  libbz2-1.0              1.0.5-6          high-quality block-sorting file co
ii  libc6                   2.13-7           Embedded GNU C Library: Shared lib
ii  libselinux1             2.0.96-1         SELinux runtime shared libraries
ii  xz-utils                5.0.0-2          XZ-format compression utilities
ii  zlib1g                  1:83.161.120.155.dfsg-3 compression library - runtime
dpkg recommends no packages.
Versions of packages dpkg suggests:
ii  apt                    83.161.120.155+squeeze1 Advanced front-end for dpkg
 no debconf information
To UNSUBSCRIBE, email to <email_address>
with a subject of "unsubscribe". Trouble? Contact <email_address>"
    @hertzog: "<quote>
Thank you for your report and your test script. Do you think you could
update the non-regression test-suite of update-alternatives to reproduce
the problem?
This is much more useful than just a test script and not much more
difficult. :-)
See utils/t/100_update_alternatives.t in the source package.
In the mean time, I will look into fixing this regression.
Cheers,
=20
Rapha=C3=ABl Hertzog =E2=97=88 Debian Developer
Follow my Debian News =E2=96=B6 <url> (English)
                      =E2=96=B6 <url> (Fran=C3=A7ais)
To UNSUBSCRIBE, email to <email_address>
with a subject of "unsubscribe". Trouble? Contact <email_address>"
    @hertzog: "<quote>
Thanks!
e
In fact set_choice() did not support passing supplementary parameters, I
fixed that.
nstalled as slave links");
This test was reversed, with force it must remove the file.
Thus this is useless.
Otherwise it was fine. I committed the fix and your tests.
Cheers,
=20
Rapha=C3=ABl Hertzog =E2=97=88 Debian Developer
Follow my Debian News =E2=96=B6 <url> (English)
                      =E2=96=B6 <url> (Fran=C3=A7ais)
To UNSUBSCRIBE, email to <email_address>
with a subject of "unsubscribe". Trouble? Contact <email_address>"
    @hertzog: "<quote>
To avoid any ambiguity I updated the manual page to indicate that force
also allows the removal of files which are in place where symlinks are
expected.
And I fixed remove-all to be consistent with this rule.
Cheers,
=20
Rapha=C3=ABl Hertzog =E2=97=88 Debian Developer
Follow my Debian News =E2=96=B6 <url> (English)
                      =E2=96=B6 <url> (Fran=C3=A7ais)
To UNSUBSCRIBE, email to <email_address>
with a subject of "unsubscribe". Trouble? Contact <email_address>"
{'source': 'USENET', 'other_information': '{"reply_count": 3, "forum_name": "linux.debian.maint.dpkg.20140814.mbox"}', 'file': 'data/output/usenet-linux.debian.parquet'}