Package: dpkg
Version: 1.15.7.1
Severity: normal
File: /usr/bin/dpkg-divert

Hi,

dpkg-divert --rename does useless tests on the writability of the
destination file if the source file does not exist. If these tests fail,
dpkg-diverts with an error for no reason, eventually breaking a
maintainer script.

Example to reproduce: 
- the source file 'bar' never exists

1. neither source nor destination directory exists:

# dpkg-divert --test --add --rename --package foo \
    --divert /tmp/foo/to/bar /tmp/foo/from/bar
Adding `diversion of /tmp/foo/from/bar to /tmp/foo/to/bar by foo'

2. the source directory does exist

# mkdir -p /tmp/foo/from
# dpkg-divert --test --add --rename --package foo \
    --divert /tmp/foo/to/bar /tmp/foo/from/bar
Adding `diversion of /tmp/foo/from/bar to /tmp/foo/to/bar by foo'
dpkg-divert: error checking `/tmp/foo/to/bar': No such file or directory

Of course, I can't write to the destination - but why do I care if I
don't have a source?

3. both directories exist

# mkdir -p /tmp/foo/to
# dpkg-divert --test --add --rename --package foo \
    --divert /tmp/foo/to/bar /tmp/foo/from/bar
Adding `diversion of /tmp/foo/from/bar to /tmp/foo/to/bar by foo'


Looking at the code in sub checkrename, I think immediately after
lstat($rsrc) failed with ENOENT $dorename should be disabled and the sub
should return return without doing any further checks.

The comment 

   # If the source file is not present and we are not going to do the
   # rename anyway there's no point in checking the target.

is incorrect because the code only checks for the existance of the
*directory* possibly containing the source file, not the source file
itself, so it covers only a part of the cases, not including the one I
experienced.


Andreas

-- System Information:
Debian Release: squeeze/sid
  APT prefers stable
  APT policy: (800, 'stable'), (700, 'testing'), (600, 'unstable'), (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-4                high-quality block-sorting file co
ii  libc6             2.10.2-6               Embedded GNU C Library: Shared lib
ii  libselinux1       2.0.94-1               SELinux runtime shared libraries
ii  xz-utils          4.999.9beta+20100307-1 XZ-format compression utilities
ii  zlib1g            1:1.2.3.4.dfsg-3       compression library - runtime

dpkg recommends no packages.

Versions of packages dpkg suggests:
ii  apt                           0.7.25.3   Advanced front-end for dpkg

-- no debconf information




-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to