Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1182955 - The prompt for removal of LV accepts more characters than the stated y/n
The prompt for removal of LV accepts more characters than the stated y/n
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: lvm2 (Show other bugs)
7.1
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Zdenek Kabelac
cluster-qe@redhat.com
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-16 05:13 EST by Nenad Peric
Modified: 2018-04-10 11:17 EDT (History)
9 users (show)

See Also:
Fixed In Version: lvm2-2.02.175-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-04-10 11:16:02 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:0853 None None None 2018-04-10 11:17 EDT

  None (edit)
Description Nenad Peric 2015-01-16 05:13:28 EST
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:
Comment 2 Zdenek Kabelac 2015-01-16 05:19:29 EST
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.
Comment 3 Nenad Peric 2015-01-21 16:21:14 EST
(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).
Comment 5 Alasdair Kergon 2016-06-09 19:39:17 EDT
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
Comment 6 Zdenek Kabelac 2017-08-25 08:37:07 EDT
Already upstream with commit 35612bd27c203774948c84005c9fb9237746c34a
(lvm2 2.02.156)
Comment 9 Roman Bednář 2017-10-16 06:32:35 EDT
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
Comment 12 errata-xmlrpc 2018-04-10 11:16:02 EDT
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

Note You need to log in before you can comment on or make changes to this bug.