1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

vgchange: Additional system ID warnings.

Also prompt before setting a system ID on a VG when none is set
on the host.
Put quotes round system ID in messages where it could be blank.
This commit is contained in:
Alasdair G Kergon 2015-03-09 19:03:11 +00:00
parent 1334ea214e
commit 458b0210d1

View File

@ -536,42 +536,45 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
} }
if (!strcmp(vg->system_id, system_id)) { if (!strcmp(vg->system_id, system_id)) {
log_error("Volume Group system ID is already %s", vg->system_id); log_error("Volume Group system ID is already \"%s\".", vg->system_id);
return 0; return 0;
} }
if (cmd->system_id && strcmp(system_id, cmd->system_id)) { if (!*system_id && cmd->system_id && strcmp(system_id, cmd->system_id)) {
if (!*system_id) { log_warn("WARNING: Removing the system ID allows unsafe access from other hosts.");
log_warn("WARNING: Removing the system ID allows unsafe access from other hosts.");
if (!arg_count(cmd, yes_ARG) && if (!arg_count(cmd, yes_ARG) &&
yes_no_prompt("Remove system ID %s on volume group %s? [y/n]: ", yes_no_prompt("Remove system ID %s from volume group %s? [y/n]: ",
vg->system_id, vg->name) == 'n') { vg->system_id, vg->name) == 'n') {
log_error("Volume group %s system ID not changed.", vg->name); log_error("System ID of volume group %s not changed.", vg->name);
return 0; return 0;
}
} else {
if (lvs_in_vg_activated(vg)) {
log_error("Logical Volumes in VG %s must be deactivated before system ID can be changed.",
vg->name);
return 0;
}
log_warn("WARNING: Requested system ID %s does not match local system ID %s",
system_id, cmd->system_id);
log_warn("WARNING: Volume group %s might become inaccessible from this machine.",
vg->name);
if (!arg_count(cmd, yes_ARG) &&
yes_no_prompt("Set foreign system ID %s on volume group %s? [y/n]: ",
system_id, vg->name) == 'n') {
log_error("Volume group %s system ID not changed.", vg->name);
return 0;
}
} }
} }
log_verbose("Changing system ID for VG %s from %s to %s.", if (*system_id && (!cmd->system_id || strcmp(system_id, cmd->system_id))) {
if (lvs_in_vg_activated(vg)) {
log_error("Logical Volumes in VG %s must be deactivated before system ID can be changed.",
vg->name);
return 0;
}
if (cmd->system_id)
log_warn("WARNING: Requested system ID %s does not match local system ID %s.",
system_id, cmd->system_id ? : "");
else
log_warn("WARNING: No local system ID is set.");
log_warn("WARNING: Volume group %s might become inaccessible from this machine.",
vg->name);
if (!arg_count(cmd, yes_ARG) &&
yes_no_prompt("Set foreign system ID %s on volume group %s? [y/n]: ",
system_id, vg->name) == 'n') {
log_error("Volume group %s system ID not changed.", vg->name);
return 0;
}
}
log_verbose("Changing system ID for VG %s from \"%s\" to \"%s\".",
vg->name, vg->system_id, system_id); vg->name, vg->system_id, system_id);
vg->system_id = system_id; vg->system_id = system_id;