Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=05ac8367980afb0b…
Commit: 05ac8367980afb0b660fc312b228337e256a38e8
Parent: d3ca18e489d48cc7c7b2a877b95b5a9a324e8e30
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Nov 30 11:46:55 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Nov 30 11:46:55 2015 -0600
system_id: refactor check for allowed system_id
Refactor the code that checks for an allowable system_id
so that it can be used from other places.
---
lib/metadata/metadata-exported.h | 2 +
lib/metadata/metadata.c | 49 ++++++++++++++++++++++++-------------
2 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f009687..8242db1 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1238,4 +1238,6 @@ int validate_vg_rename_params(struct cmd_context *cmd,
int is_lockd_type(const char *lock_type);
+int is_system_id_allowed(struct cmd_context *cmd, const char *system_id);
+
#endif
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 7ee928d..bf030d3 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4854,39 +4854,53 @@ static int _access_vg_lock_type(struct cmd_context *cmd, struct volume_group *vg
return 1;
}
-static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
+int is_system_id_allowed(struct cmd_context *cmd, const char *system_id)
{
/*
- * LVM1 VGs must not be accessed if a new-style LVM2 system ID is set.
+ * A VG without a system_id can be accessed by anyone.
*/
- if (cmd->system_id && systemid_on_pvs(vg)) {
- log_error("Cannot access VG %s with LVM1 system ID %s when host system ID is set.",
- vg->name, vg->lvm1_system_id);
- return 0;
- }
+ if (!system_id || !system_id[0])
+ return 1;
/*
- * A VG without a system_id can be accessed by anyone.
+ * Allowed if the host and VG system_id's match.
*/
- if (!vg->system_id || !vg->system_id[0])
+ if (cmd->system_id && !strcmp(cmd->system_id, system_id))
return 1;
/*
- * A few commands allow read-only access to foreign VGs.
+ * Allowed if a host's extra system_id matches.
*/
- if (cmd->include_foreign_vgs)
+ if (cmd->system_id && _allow_extra_system_id(cmd, system_id))
return 1;
/*
- * A host can access a VG with a matching system_id.
+ * Not allowed if the host does not have a system_id
+ * and the VG does, or if the host and VG's system_id's
+ * do not match.
*/
- if (cmd->system_id && !strcmp(vg->system_id, cmd->system_id))
- return 1;
+ return 0;
+}
+
+static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
+{
/*
- * A host can access a VG if the VG's system_id is in extra_system_ids list.
+ * LVM1 VGs must not be accessed if a new-style LVM2 system ID is set.
*/
- if (cmd->system_id && _allow_extra_system_id(cmd, vg->system_id))
+ if (cmd->system_id && systemid_on_pvs(vg)) {
+ log_error("Cannot access VG %s with LVM1 system ID %s when host system ID is set.",
+ vg->name, vg->lvm1_system_id);
+ return 0;
+ }
+
+ /*
+ * A few commands allow read-only access to foreign VGs.
+ */
+ if (cmd->include_foreign_vgs)
+ return 1;
+
+ if (is_system_id_allowed(cmd, vg->system_id))
return 1;
/*
@@ -4901,7 +4915,8 @@ static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
}
/*
- * A host without a system_id cannot access a VG with a system_id.
+ * Print an error when reading a VG that has a system_id
+ * and the host system_id is unknown.
*/
if (!cmd->system_id || cmd->unknown_system_id) {
log_error("Cannot access VG %s with system ID %s with unknown local system ID.",
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3a73164f53486e5c…
Commit: 3a73164f53486e5c75a34f420c120ad2703ddcf8
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2015-11-28 01:28 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2015-11-28 01:28 +0000
annotated tag: v2_02_136 has been created
at 3a73164f53486e5c75a34f420c120ad2703ddcf8 (tag)
tagging b4a3aaf910fc2216635c443deed5c26c535ab742 (commit)
replaces v2_02_135
Release 2.02.136.
Another development release. Do not ship this release.
36 files changed, 613 insertions(+), 529 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAlZZAysACgkQIoGRwVZ+LBfh5wCfSVEnKWytXE0BvDHgkGEfiCiP
o8QAoIUBRoj6Te+eYC/mI5bYj4qK1sto
=wsdv
-----END PGP SIGNATURE-----
Alasdair G Kergon (2):
post-release
pre-release
David Teigland (1):
man lvmcache: include chunk size
Peter Rajnoha (1):
lvmconfig: add --sinceversion for --type new
Zdenek Kabelac (20):
libdm: drop extra space from cache target line
libdm: enhance thin-pool preload
memlock: add more libs on ignore list
thin: work with active thin-pool
cleanup: move towards using direct LV pointers
thin: skip detach preload from pools
cleanup: use display_lvname
tests: data correctness after thin-pool resize
tests: improve teardown
thin: fix previous update of partial tree building
cleanup: rename vg_ondisk to vg_committed
cleanup: change ondisk committed
cleanup: rename lv_ondisk to lv_committed
libdm: const raid params and error for unsupported type
cleanup: avoid allocation for vg_name
cleanup: remove unused code
cleanup: using display_lvname
debug: show LV name where dlid creation failed
cleanup: clean gcc shadow declaration of version warning
tests: make unit testing usable again