Skip to contentSkip to conversation

master - systemid: Fix access restrictions.

PATCH Alasdair Kergon 1 participant 1 message Feb 23, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b18feb98e50093d66f03ff63120b6a0f14d7fddd
Commit:        b18feb98e50093d66f03ff63120b6a0f14d7fddd
Parent:        df227be37cb113a1093b2ed092af582c5a900315
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Mon Feb 23 23:19:36 2015 +0000
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Mon Feb 23 23:19:36 2015 +0000

systemid: Fix access restrictions.

When checking whether the system ID permits access to a VG, check for each permitted situation first, and only then issue the appropriate error message. Always issue a message for now. (We'll try to suppress some of those later when the VG concerned wasn't explicitly requested.)
Add more messages to try to ensure every return code is checked and every error path (and only an error path) contains a log_error(). Add self-correction to vgchange -c to deal with situations where the cluster state and system ID state are out-of-sync (e.g. if old tools were used).

---
 lib/format_text/import_vsn1.c |    9 ++--
 lib/metadata/metadata.c       |   46 ++++++++++------------
 tools/toollib.c               |   49 +++++++++++------------
 tools/vgchange.c              |   85 +++++++++++++++++++++++++++--------------
 4 files changed, 106 insertions(+), 83 deletions(-)
lib/format_text/import_vsn1.c +5 -4
index c6a0cf9..42ff451 100644
@@ -737,6 +737,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
 	struct volume_group *vg;
 	struct dm_hash_table *pv_hash = NULL, *lv_hash = NULL;
 	unsigned scan_done_once = use_cached_pvs;
+	char *system_id;
 
 	/* skip any top-level values */
 	for (vgn = cft->root; (vgn && vgn->v); vgn = vgn->sib)
@@ -750,8 +751,9 @@ static struct volume_group *_read_vg(struct format_instance *fid,
 	if (!(vg = alloc_vg("read_vg", fid->fmt->cmd, vgn->key)))
 		return_NULL;
 
-	if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
+	if (!(system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
 		goto_bad;
+	vg->system_id = system_id;
 
 	/*
 	 * The pv hash memorises the pv section names -> pv
@@ -773,9 +775,8 @@ static struct volume_group *_read_vg(struct format_instance *fid,
 
 	vgn = vgn->child;
 
-	if (dm_config_get_str(vgn, "system_id", &str)) {
-		strncpy(vg->system_id, str, NAME_LEN);
-	}
+	if (dm_config_get_str(vgn, "system_id", &str))
+		strncpy(system_id, str, NAME_LEN);
 
 	if (!_read_id(&vg->id, vgn, "id")) {
 		log_error("Couldn't read uuid for volume group %s.", vg->name);
lib/metadata/metadata.c +21 -25

87 lines not on this page · raw message

tools/toollib.c +24 -25

100 lines not on this page · raw message

tools/vgchange.c +56 -29

125 lines not on this page · raw message