Red Hat Bugzilla – Bug 1182955
The prompt for removal of LV accepts more characters than the stated y/n
Last modified: 2018-04-10 11:17:48 EDT
Description of problem: If you try to remove an active LV you will be prompted with: Do you really want to remove active logical volume <volname>? [y/n]: But it accepts whole words which do not make sense, and which could lead to accidental removal of an LV sometimes. If there us a y/n prompt it should I hope accept only y/n. Version-Release number of selected component (if applicable): lvm2-2.02.114-5.el7.x86_64 How reproducible: Everytime Steps to Reproduce: Try to remove an active LV: [root@virt-140 ~]# lvremove vg/stripe Do you really want to remove active logical volume stripe? [y/n]: maybe Logical volume "stripe" successfully removed Actual results: The LV gets removed as soon as it finds a 'y' wherever in the supplied word or even sentence. Expected results: It should only accept single character 'y' and 'n' (or uppercase) as written in the prompt. Or additionally whole words 'yes' or 'no'. Anything else makes no sense, since by accidentally pasting a clipboard which has a 'y' and enter in it, the LV would get removed. Additional info:
Prompts are not read by 'words', just single letters from 'stdin' (so i.e. script could push in letters') So the stdin stream is not split into words and IMHO it may possibly cause some other regressions if some users are pushing letters into lvm2's stdin input and they would be split by some control characters into some sections ? For now first appearance of letter 'y' or 'n' wins.
(In reply to Zdenek Kabelac from comment #2) Still, if we ask for a one letter confirmation, we should stay by those rules and accept y or n, alternatively Y or N. > For now first appearance of letter 'y' or 'n' wins. That is not completely true. If you provide a sentence with both 'y' and 'n' none wins, and the prompt is repeated. For example: Do you really want to remove active logical volume <volname>? [y/n]: maybe, I don't know it will just repeat the prompt, so the first 'y' did not really win in this case (it matched an 'n' in "don't know" as well).
The current proposal is to tidy this up as follows: 1) We will accept '^[ ^t]*([Yy]([Ee]([Ss]|)|)|[Nn]([Oo]|))[ ^t]*$' - optional whitespace before and after - y / ye / yes - n / no - case-independent 2) We will confirm the selection made e.g. by printing [y] [n] or [?] on stderr
Already upstream with commit 35612bd27c203774948c84005c9fb9237746c34a (lvm2 2.02.156)
Marking verified with latest rpms. Prompt now only accepts options specified in Comment 5. Do you really want to remove active logical volume vg/lv? [y/n]: maybe WARNING: Invalid input 'maybe'. Do you really want to remove active logical volume vg/lv? [y/n]: yesno WARNING: Invalid input 'yesno'. Do you really want to remove active logical volume vg/lv? [y/n]: no Logical volume vg/lv not removed. [root@virt-371 yum.repos.d]# lvremove vg/lv Do you really want to remove active logical volume vg/lv? [y/n]: ye Logical volume "lv" successfully removed 3.10.0-727.el7.x86_64 lvm2-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 lvm2-libs-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 lvm2-cluster-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-libs-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-event-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-event-libs-1.02.144-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017 device-mapper-persistent-data-0.7.3-2.el7 BUILT: Tue Oct 10 11:00:07 CEST 2017 cmirror-2.02.175-2.el7 BUILT: Fri Oct 13 13:31:22 CEST 2017
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHEA-2018:0853