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 > Redhat > Fedora Marketing

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

On Thursday, February 05 2009, Chris Lumens said:
> 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.

It looks okay, but rather than having the regex in a few places, we
should probably just have an lvm.safeLvmName() method?

Jeremy

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-05-2009, 05:18 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 | 8 ++------
lvm.py | 11 +++++++++++
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/autopart.py b/autopart.py
index b1c7644..a3ed44d 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
@@ -1672,12 +1673,7 @@ def autoCreateLVMPartitionRequests(autoreq):
if mntpt == '/':
lvtemplate = 'lv_root'
else:
- tmp = string.strip(mntpt)
- tmp = tmp.replace('/', '_')
-
- while tmp.startswith('_'):
- tmp = tmp[1:]
-
+ tmp = lvm.safeLvmName(mntpt)
lvtemplate = "lv_%s" % (tmp,)
else:
if ptype == fsset.fileSystemTypeGet("swap"):
diff --git a/lvm.py b/lvm.py
index 0e07a1f..520619f 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

@@ -528,6 +529,14 @@ def getMaxLVSize(pe):
else:
return (16*1024*1024) #Max is 16TiB

+def safeLvmName(str):
+ tmp = string.strip(str)
+ tmp = tmp.replace("/", "_")
+ tmp = re.sub("[^0-9a-zA-Z._]", "", str)
+ tmp = tmp.lstrip("_")
+
+ return tmp
+
def createSuggestedVGName(partitions, network):
"""Given list of partition requests, come up with a reasonable VG name

@@ -540,8 +549,10 @@ def createSuggestedVGName(partitions, network):
if hn == 'localhost' or hn == 'localhost.localdomain':
vgtemplate = "VolGroup"
elif hn.find('.') != -1:
+ hn = safeLvmName(hn)
vgtemplate = "vg_%s" % (hn.split('.')[0].lower(),)
else:
+ hn = safeLvmName(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
 
Old 02-05-2009, 05:44 PM
Jeremy Katz
 
Default Strip invalid characters from autoamtically made VG/LV names (#483571).

On Thursday, February 05 2009, Chris Lumens said:
> 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.

Thanks for the cleanup. Only other tiny thing is you don't need to
import re anymore in autopart.py, but otherwise, good to commit

Jeremy

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 02-05-2009, 05:46 PM
Chris Lumens
 
Default Strip invalid characters from autoamtically made VG/LV names (#483571).

> Thanks for the cleanup. Only other tiny thing is you don't need to
> import re anymore in autopart.py, but otherwise, good to commit

Yeah I caught that after I mailed and changed my patch, but didn't feel
like mailing again for that one line. Good times.

- Chris

_______________________________________________
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:27 AM.

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