Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=22579b4451b00b50…
Commit: 22579b4451b00b50ad7e6acacf9265fa41620449
Parent: 28e4bf0b6dae2cad6bb996c0c87d41b256f59517
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 27 10:35:51 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 27 13:06:23 2014 +0100
lv_rename: validate renamed sublv
Use proper vgmem memory pool for allocation of LV name in the vg
and check if new renamed LV is a valid name.
TODO: validation should really use also VG name, othewise we are not
able to tell "vgname-lvname" will be valid.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 007fb75..71b074a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Validate name for renamed sub LVs.
When lvrename fails on argument parsing return invalid cmd line error (5->3).
Fix exit code regression in failing pvchange command (2.02.66).
Include 'lvm dumpconfig --type missing' and '--type diff' output to lvmdump.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6e4ba71..ae0bef2 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3225,7 +3225,7 @@ static int _rename_sub_lv(struct cmd_context *cmd,
* a new name for main LV is "lvol1"
*/
len = strlen(lv_name_new) + strlen(suffix) + 1;
- new_name = dm_pool_alloc(cmd->mem, len);
+ new_name = dm_pool_alloc(lv->vg->vgmem, len);
if (!new_name) {
log_error("Failed to allocate space for new name");
return 0;
@@ -3235,6 +3235,12 @@ static int _rename_sub_lv(struct cmd_context *cmd,
return 0;
}
+ if (!validate_name(new_name)) { *
+ log_error("Cannot rename \"%s\". New logical volume name \"%s\" is invalid.",
+ lv->name, new_name);
+ return 0;
+ }
+
/* Rename it */
return _rename_single_lv(lv, new_name);
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=80fe100afa3bb2cb…
Commit: 80fe100afa3bb2cbbc81bb4517a762159f0ebe65
Parent: 2a93eba68e518fff7f0c16406b5a9e802d732e1d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Mar 27 11:27:42 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Mar 27 13:01:51 2014 +0100
pvchange: fix exit code regression
Commit 1a832398a7caa96faab2ccbac773cc4047c8f9c1 moved
some code from _pvchange_single() to main pvchange() and
introduced exit code regression as return codes have not
been properly changed, thus pvchange command exited
with '0' exit code, even though it has reported error.
Also there is a missing vg unlock in error path.
Fix it by counting the total number of expected calls before
checking for pvname and also unlock and relase vg when
pv is not found.
---
WHATS_NEW | 1 +
tools/pvchange.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e6fa1d7..a9289b5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix exit code regression in failing pvchange command (2.02.66).
Include 'lvm dumpconfig --type missing' and '--type diff' output to lvmdump.
Return failure when specifying negative size for pvresize.
Fix memory corruption in cmd context refresh if clvmd leaks opened device.
diff --git a/tools/pvchange.c b/tools/pvchange.c
index d2a3d9b..5c05db6 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -184,6 +184,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
if (argc) {
log_verbose("Using physical volume(s) on command line");
for (; opt < argc; opt++) {
+ total++;
pv_name = argv[opt];
dm_unescape_colons_and_at_signs(pv_name, NULL, NULL);
vg_name = find_vgname_from_pvname(cmd, pv_name);
@@ -200,12 +201,12 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
}
pvl = find_pv_in_vg(vg, pv_name);
if (!pvl || !pvl->pv) {
+ unlock_and_release_vg(cmd, vg, vg_name);
log_error("Unable to find %s in %s",
pv_name, vg_name);
continue;
}
- total++;
done += _pvchange_single(cmd, vg,
pvl->pv, NULL);
unlock_and_release_vg(cmd, vg, vg_name);