FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 02-05-2009, 03:32 PM
Chris Lumens
 
Default Strip invalid characters from autoamtically made VG/LV names (#483571).

We make names from mount points and host names, both of which can contain
characters that are invalid to LVM. The dash is the most promiment case here.
Checks get run when the user enters these bad characters, but not when anaconda
made up the names automatically. So strip dashes out of the generated names
before feeding them to LVM.
---
autopart.py | 6 +++---
lvm.py | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/autopart.py b/autopart.py
index b1c7644..1e859fa 100644
--- a/autopart.py
+++ b/autopart.py
@@ -24,6 +24,7 @@ import parted
import copy
import string, sys
import fsset
+import re
import lvm
import logging
from anaconda_log import logger, logFile
@@ -1674,9 +1675,8 @@ def autoCreateLVMPartitionRequests(autoreq):
else:
tmp = string.strip(mntpt)
tmp = tmp.replace('/', '_')
-
- while tmp.startswith('_'):
- tmp = tmp[1:]
+ tmp = re.sub("[^0-9a-zA-Z._]", "", tmp)
+ tmp = tmp.lstrip("_")

lvtemplate = "lv_%s" % (tmp,)
else:
diff --git a/lvm.py b/lvm.py
index 0e07a1f..e409aec 100644
--- a/lvm.py
+++ b/lvm.py
@@ -24,6 +24,7 @@ import os,sys
import string
import math
import isys
+import re

from flags import flags

@@ -540,8 +541,10 @@ def createSuggestedVGName(partitions, network):
if hn == 'localhost' or hn == 'localhost.localdomain':
vgtemplate = "VolGroup"
elif hn.find('.') != -1:
+ hn = re.sub("[^0-9a-zA-Z._]", "", hn)
vgtemplate = "vg_%s" % (hn.split('.')[0].lower(),)
else:
+ hn = re.sub("[^0-9a-zA-Z._]", "", hn)
vgtemplate = "vg_%s" % (hn.lower(),)
else:
vgtemplate = "VolGroup"
--
1.6.0.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 02:33 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org