Bug#444564: lvm2: vgcfgbackup does not handle templates correctly

Christian Garbs debian at cgarbs.de
Sat Sep 29 12:11:13 UTC 2007


Package: lvm2
Version: 2.02.06-4
Severity: normal

I have 4 volume groups on my system named "vg0", "sw1", "sw2" and "sw3".

When I use vgcfgbackup with a template filename like this, I get
errors:

yggdrasil:~# vgcfgbackup -f /tmp/vgbackup-%s
  Volume group "sw3" successfully backed up.
  VGs must be backed up into different files. Use %s in filename for VG name.
  VGs must be backed up into different files. Use %s in filename for VG name.
  Volume group "vg0" successfully backed up.

When I move the template character %s away from the end of the
template, it works:

yggdrasil:~# vgcfgbackup -f /tmp/vg-%s-backup
  Volume group "sw3" successfully backed up.
  Volume group "sw2" successfully backed up.
  Volume group "sw1" successfully backed up.
  Volume group "vg0" successfully backed up.

A quick look at the sourcecode shows the following in
lvm2-2.02.06/tools/vgcfgbackup.c starting in line 37:

        if (*last_filename && !strncmp(*last_filename, filename,
                                      strlen(template))) {
                log_error("VGs must be backed up into different files. "
                          "Use %%s in filename for VG name.");
                dm_free(filename);
                return NULL;
        }


The error seems to be in the strlen(template) part.  When I use 
"/tmp/vgbackup-%s" as a template, it gets expanded to
"/tmp/vgbackup-sw3"
"/tmp/vgbackup-sw2"
"/tmp/vgbackup-sw1"
"/tmp/vgbackup-vg0"

The expanded strings are one character longer than the template
string.  But because only the strlen(template) first characters are
compared, "/tmp/vgbackup-sw" is equal to "/tmp/vgbackup-sw" and the
error message appears.

Regards,
Christian

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.21
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)

Versions of packages lvm2 depends on:
ii  debconf [debconf-2.0]  1.5.11            Debian configuration management sy
ii  libc6                  2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii  libdevmapper1.02       2:1.02.08-1       The Linux Kernel Device Mapper use
ii  libncurses5            5.5-5             Shared libraries for terminal hand
ii  libreadline5           5.2-2             GNU readline and history libraries
ii  libselinux1            1.32-3            SELinux shared libraries
ii  libsepol1              1.14-2            Security Enhanced Linux policy lib
ii  lvm-common             1.5.20            The Logical Volume Manager for Lin

lvm2 recommends no packages.

-- debconf information:
  lvm2/snapshots:

-- 
....Christian.Garbs.....................................http://www.cgarbs.de

"Wenns zu Silvester stuermt und schneit,
 ist das neue Jahr nicht mehr weit."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/pkg-lvm-maintainers/attachments/20070929/6d30648a/attachment.pgp 


More information about the pkg-lvm-maintainers mailing list