[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#375161: marked as done (partman-lvm: check LV and VG names before trying to create them)



Your message dated Thu, 31 Aug 2006 14:51:50 -0700
with message-id <E1GIuRy-0006Xe-3a@spohr.debian.org>
and subject line Bug#375161: fixed in partman-lvm 46
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: partman-lvm
Version: 40
Severity: wishlist
Tags: patch

The attached patch allows partman-lvm to check the names given for VG's and LV's before trying to create them. The checks have been derived from reading the lvm2 sources and bug #254630.

The only thing that bothers me a bit is that the lvm tools use isalnum() as part of their checks which (if I understood things correctly) will work differently depending on locale. However, the use of [:alnum:] in the sed script should accomplish the same thing.

Regards,
David

Index: debian/partman-lvm.templates
===================================================================
--- debian/partman-lvm.templates	(revision 38366)
+++ debian/partman-lvm.templates	(working copy)
@@ -176,6 +176,16 @@
  No name for the volume group has been entered.  Please enter a
  name.
 
+Template: partman-lvm/vgcreate_badnamegiven
+Type: error
+_Description: Invalid volume group name entered
+ An invalid name for the volume group has been entered. Please choose
+ another name.
+ .
+ Names may only contain alphanumeric characters, hyphen, plus, period
+ and underscore. They must be 128 characters or less and may not begin
+ with a hyphen. The names "." and ".." are not allowed.
+
 Template: partman-lvm/vgcreate_nameused
 Type: error
 _Description: Volume group name already in use
@@ -317,6 +327,17 @@
  No name for the logical volume has been entered.  Please enter a
  name.
 
+Template: partman-lvm/lvcreate_badnamegiven
+Type: error
+_Description: Invalid logical volume name entered
+ An invalid name for the logical volume has been entered. Please choose
+ another name.
+ .
+ Names may only contain alphanumeric characters, hyphen, plus, period
+ and underscore. They must be 128 characters or less and may not begin
+ with a hyphen. The names "." and ".." as well as any name starting with
+ "snapshot" are not allowed.
+
 Template: partman-lvm/lvcreate_exists
 Type: error
 _Description: Error while creating a new logical volume
Index: lvm_tools.sh
===================================================================
--- lvm_tools.sh	(revision 38366)
+++ lvm_tools.sh	(working copy)
@@ -132,7 +132,46 @@
 	return 0
 }	
 
+# Common checks for VG and LV names
+# Rules:
+# 1) At least one character
+# 2) Only alphanumeric characters (isalnum()) and "._-+"
+# 3) May not be "." or ".."
+# 4) must not start with a hyphen
+# 5) maximum name length 128 characters
+# See lvm2 source and bug #254630 for details
+lvm_name_ok() {
+	local name
+	name="$1"
 
+	# Rule 1
+	if [ -z "$name" ]; then
+		return 1
+	fi
+
+	# Rule 2
+	if [ "$(echo -n "$name" | sed 's/[^-+_\.[:alnum:]]//g')" != "$name" ]; then
+		return 1
+	fi
+
+	# Rule 3
+	if [ "$name" = "." -o "$name" = ".." ]; then
+		return 1
+	fi
+
+	# Rule 4
+	if [ "$(echo -n "$name" | sed 's/^-//')" != "$name" ]; then
+		return 1
+	fi
+
+	# Rule 5
+	if [ $(echo -n "$name" | wc -c) -gt 128 ]; then
+		return 1
+	fi
+
+	return 0
+}
+
 ###############################################################################
 #                                
 # Physical Volume utility functions
@@ -285,7 +324,26 @@
 	return $?
 }
 
+# Checks that a logical volume name is ok
+# Rules:
+# 1) The common rules (see lvm_name_ok)
+# 2) must not start with "snapshot"
+# See lvm2 source and bug #254630 for details
+lv_name_ok() {
+	local lvname
+	lvname="$1"
 
+	# Rule 1
+	lvm_name_ok "$lvname" || return 1
+
+	# Rule 2
+	if [ "${lvname#snapshot}" != "$lvname" ]; then
+		return 1
+	fi
+
+	return 0
+}
+
 ###############################################################################
 #                                
 # Volume Group utility functions
@@ -393,3 +451,17 @@
 	log-output -t partman-lvm vgreduce "$vg" "$pv"
 	return $?
 }
+
+# Checks that a logical volume name is ok
+# Rules:
+# 1) The common rules (see lvm_name_ok)
+# See lvm2 source and bug #254630 for details
+vg_name_ok() {
+	local vgname
+	vgname="$1"
+
+	# Rule 1
+	lvm_name_ok "$vgname" || return 1
+
+	return 0
+}
Index: choose_partition/lvm/do_option
===================================================================
--- choose_partition/lvm/do_option	(revision 38366)
+++ choose_partition/lvm/do_option	(working copy)
@@ -109,6 +109,8 @@
 	[ $? -eq 30 ] && return
 	db_get partman-lvm/vgcreate_name
 	vg="$RET"
+
+	# Check VG name
 	if [ -z "$vg" ]; then
 		db_set partman-lvm/vgcreate_nonamegiven "false"
 		db_input critical partman-lvm/vgcreate_nonamegiven
@@ -116,6 +118,13 @@
 		return
 	fi
 
+	if ! vg_name_ok "$vg"; then
+		db_set partman-lvm/vgcreate_badnamegiven "false"
+		db_input critical partman-lvm/vgcreate_badnamegiven
+		db_go
+		return
+	fi
+
 	# Check whether the VG name is already in use
 	if vgs "$vg" > /dev/null 2>&1; then
 		db_set partman-lvm/vgcreate_nameused "false"
@@ -421,14 +430,23 @@
 	db_go
 	[ $? -eq 30 ] && return
 	db_get partman-lvm/lvcreate_name
-	if [ -z "$RET" ]; then
+	lv="$RET"
+
+	# Check LV name
+	if [ -z "$lv" ]; then
 		db_set partman-lvm/lvcreate_nonamegiven "false"
 		db_input critical partman-lvm/lvcreate_nonamegiven
 		db_go
 		return
 	fi
-	lv="$RET"
 
+	if ! lv_name_ok "$lv"; then
+		db_set partman-lvm/lvcreate_badnamegiven "false"
+		db_input critical partman-lvm/lvcreate_badnamegiven
+		db_go
+		return
+	fi
+
 	# Make sure the name isn't already in use
 	if lvs "/dev/$vg/$lv" > /dev/null 2>&1; then
 		db_subst partman-lvm/lvcreate_exists LV "$lv"

--- End Message ---
--- Begin Message ---
Source: partman-lvm
Source-Version: 46

We believe that the bug you reported is fixed in the latest version of
partman-lvm, which is due to be installed in the Debian FTP archive:

partman-lvm_46.dsc
  to pool/main/p/partman-lvm/partman-lvm_46.dsc
partman-lvm_46.tar.gz
  to pool/main/p/partman-lvm/partman-lvm_46.tar.gz
partman-lvm_46_all.udeb
  to pool/main/p/partman-lvm/partman-lvm_46_all.udeb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 375161@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Joey Hess <joeyh@debian.org> (supplier of updated partman-lvm package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Thu, 31 Aug 2006 17:22:21 -0400
Source: partman-lvm
Binary: partman-lvm
Architecture: source all
Version: 46
Distribution: unstable
Urgency: low
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Changed-By: Joey Hess <joeyh@debian.org>
Description: 
 partman-lvm - Adds support for LVM to partman (udeb)
Closes: 375161 383104
Changes: 
 partman-lvm (46) unstable; urgency=low
 .
   [ Frans Pop ]
   * Update reference to logs on errors. We no longer use VT3. Closes: #383104.
 .
   [ David Härdeman ]
   * Check validity of VG and LV names. Closes: #375161.
   * Add pv_delete() to lvm_tools.sh
 .
   [ Colin Watson ]
   * Disable backup while displaying current configuration.
 .
   [ Updated translations ]
   * Catalan (ca.po) by Jordi Mallach
   * Czech (cs.po) by Miroslav Kure
   * Danish (da.po) by Claus Hindsgaul
   * German (de.po) by Jens Seidel
   * Greek, Modern (1453-) (el.po) by quad-nrg.net
   * Spanish (es.po) by Javier Fernández-Sanguino Peña
   * Basque (eu.po) by Piarres Beobide
   * Finnish (fi.po) by Tapio Lehtonen
   * French (fr.po) by Christian Perrier
   * Galician (gl.po) by Jacobo Tarrio
   * Hebrew (he.po) by Lior Kaplan
   * Hungarian (hu.po) by SZERVÃ?C Attila
   * Indonesian (id.po) by Arief S Fitrianto
   * Icelandic (is.po) by David Steinn Geirsson
   * Italian (it.po) by Giuseppe Sacco
   * Japanese (ja.po) by Kenshi Muto
   * Khmer (km.po) by Khoem Sokhem
   * Korean (ko.po) by Sunjae park
   * Norwegian Bokmål (nb.po) by Bjørn Steensrud
   * Dutch (nl.po) by Bart Cornelis
   * Portuguese (pt.po) by Miguel Figueiredo
   * Romanian (ro.po) by Eddy PetriÅ?or
   * Russian (ru.po) by Yuri Kozlov
   * Northern Sami (se.po) by Børre Gaup
   * Swedish (sv.po) by Daniel Nylander
   * Tagalog (tl.po) by Eric Pareja
   * Ukrainian (uk.po) by Eugeniy Meshcheryakov
   * Wolof (wo.po) by Mouhamadou Mamoune Mbacke
   * Simplified Chinese (zh_CN.po) by Carlos Z.F. Liu
   * Traditional Chinese (zh_TW.po) by Tetralet
Files: 
 2a72e878e8f6f5b1d14de1b38c64ce14 625 debian-installer standard partman-lvm_46.dsc
 e7a0b85774a4ed129df7d4a0d4d73893 163481 debian-installer standard partman-lvm_46.tar.gz
 01612fd95d3e2b69cd1f9a3233aa731b 151146 debian-installer standard partman-lvm_46_all.udeb
Package-Type: udeb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFE91M42tp5zXiKP0wRAnAZAJ92vPpX/G4IB8Q3k1/NUZha/ENfbwCgnT5k
I3IVxLFD//Ckcguk740Y61M=
=x68P
-----END PGP SIGNATURE-----


--- End Message ---

Reply to: