From 506091be70b3ebaed02c5d9c1c8fa991f4382182 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Tue, 18 Mar 2014 23:54:46 +0100 Subject: [PATCH] pv_vg_name: do not expose internal orphans to lvm2 users Check for orphan VG name and return just empty string, Use internally pv->vg_name if the real orphan name is needed. --- WHATS_NEW | 1 + lib/display/display.c | 2 +- lib/metadata/metadata.c | 2 +- lib/metadata/pv.c | 3 ++- lib/metadata/pv_manip.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index adf446a7b..24925982b 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.106 - ==================================== + Do not report internal orphan VG names when reporting pvdisplay/pvscan. Fix pvdisplay -c man page referencing KB instead of sectors. Skip redundant synchronization calls on local clvmd. Use correct PATH_MAX for locking dir path. diff --git a/lib/display/display.c b/lib/display/display.c index 66acb8892..d2450ddfe 100644 --- a/lib/display/display.c +++ b/lib/display/display.c @@ -362,7 +362,7 @@ void pvdisplay_colons(const struct physical_volume *pv) } log_print("%s:%s:%" PRIu64 ":-1:%" PRIu64 ":%" PRIu64 ":-1:%" PRIu32 ":%u:%u:%u:%s", - pv_dev_name(pv), pv->vg_name, pv->size, + pv_dev_name(pv), pv_vg_name(pv), pv->size, /* FIXME pv->pv_number, Derive or remove? */ pv->status, /* FIXME Support old or new format here? */ pv->status & ALLOCATABLE_PV, /* FIXME remove? */ diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index b5e2ed626..ff14e16c7 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -3947,7 +3947,7 @@ int pv_write(struct cmd_context *cmd __attribute__((unused)), if (!allow_non_orphan && (!is_orphan_vg(pv->vg_name) || pv->pe_alloc_count)) { log_error("Assertion failed: can't _pv_write non-orphan PV " - "(in VG %s)", pv->vg_name); + "(in VG %s)", pv_vg_name(pv)); return 0; } diff --git a/lib/metadata/pv.c b/lib/metadata/pv.c index 45acef4e9..774cedbc4 100644 --- a/lib/metadata/pv.c +++ b/lib/metadata/pv.c @@ -69,7 +69,8 @@ struct device *pv_dev(const struct physical_volume *pv) const char *pv_vg_name(const struct physical_volume *pv) { - return pv_field(pv, vg_name); + /* Avoid exposing internal orphan names to users */ + return (!is_orphan(pv)) ? pv_field(pv, vg_name) : ""; } const char *pv_dev_name(const struct physical_volume *pv) diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c index d0c3b4463..cb19be253 100644 --- a/lib/metadata/pv_manip.c +++ b/lib/metadata/pv_manip.c @@ -558,7 +558,7 @@ int pv_resize_single(struct cmd_context *cmd, uint64_t size = 0; int r = 0; const char *pv_name = pv_dev_name(pv); - const char *vg_name = pv_vg_name(pv); + const char *vg_name = pv->vg_name; struct volume_group *old_vg = vg; int vg_needs_pv_write = 0;