Bug 5007 - csh init script binds backspace key incorrectly/inconsistently
Summary: csh init script binds backspace key incorrectly/inconsistently
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: x86_64 Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL:
Whiteboard:
Keywords: Junior_job, PATCH
Depends on:
Blocks:
 
Reported: 2012-03-18 15:14 CET by Martin Whitaker
Modified: 2013-08-27 09:33 CEST (History)
11 users (show)

See Also:
Source RPM: initscripts-9.34-9.mga2.src.rpm
CVE:
Status comment:


Attachments

Description Martin Whitaker 2012-03-18 15:14:46 CET
The script /etc/profile.d/10inputrc.csh contains the following lines:

  # the BackSpace key sends ^? or ^H, depending on config
  setenv BSNUM 14
  setenv BACKSPACE `dumpkeys |& grep "^keycode  $BSNUM" | awk '{print $4}'`
  if ($BACKSPACE == "BackSpace") then
     bindkey "^?" delete-char
     bindkey "^H" backward-delete-char
  else
     bindkey "^?" backward-delete-char
     bindkey "^H" delete-char
  endif

In Mageia 2 beta 2, dumpkeys fails when run as a normal user, with the message

  Couldn't get a file descriptor referring to the console

This results in the BACKSPACE variable being set to an empty string, and hence ^? gets bound to backward-delete-char.

However, when run as root, the output from

  dumpkeys |& grep "^keycode  $BSNUM"

on my machine is

keycode  14 = BackSpace Delete Delete Control_underscore Delete Delete Meta_Delete Meta_Delete Meta_Delete

(some white space removed for clarity) and hence ^H gets bound to backward-delete-char.

This makes it impossible to set gnome-terminal up so the backspace key works both before and after you use the su command.
Manuel Hiebel 2012-03-18 17:47:51 CET

CC: (none) => arnaud.patard, dmorganec, mageia, mageia, pterjan, thierry.vignaud, tmb

Remco Rijnders 2012-03-19 12:19:40 CET

CC: (none) => remco

Comment 1 Colin Guthrie 2012-03-19 22:40:02 CET
Speaking with some others it seems that dumpkeys is pretty much expected to fail.

As I'm no csh expert, would you be able to find a good setup for this file? It may involve looking at the sh equiv. and formulating a working system.

If you can do that, I'll happily include it. Failing that I'd be tempted to just remove the file completely.
Comment 2 Martin Whitaker 2012-03-19 23:27:28 CET
I think you could safely remove the lines quoted above, i.e. from

  # the BackSpace key sends ^? or ^H, depending on config

to the end of the file. In most circumstances csh will get the correct bindings from termcap/terminfo, and for the odd situation where it doesn't, the user can always fix it up themselves (it's unlikely any novice users will be using csh).

The sh equivalent doesn't try to do anything about the backspace key, which suggests it isn't necessary.
Comment 3 Marja Van Waes 2012-05-26 13:06:14 CEST
Hi,

This bug was filed against cauldron, but we do not have cauldron at the moment.

Please report whether this bug is still valid for Mageia 2.

Thanks :)

Cheers,
marja

Keywords: (none) => NEEDINFO

Comment 4 Martin Whitaker 2012-05-27 10:29:42 CEST
Yes, still valid.

Keywords: NEEDINFO => (none)

Comment 5 Martin Whitaker 2012-12-20 22:33:46 CET
Any chance of applying the fix I suggested in comment 2? It's annoying to have to do this on three different machines each time I test a new release.
Thierry Vignaud 2012-12-21 07:11:26 CET

Keywords: (none) => Junior_job, PATCH

Comment 6 Christiaan Welvaart 2012-12-21 14:34:52 CET
For me the setting in "else" is correct, so no issues when dumpkeys doesn't work. But indeed it is apparently not needed: when I disable this code and log into a VC the Backspace and Delete keys work.

CC: (none) => cjw

Comment 7 Remco Rijnders 2012-12-23 11:24:53 CET
@martin, I have removed the lines in question from the package. Hopefully this resolves this issue for you. Updated package is initscripts-9.41-3.mga3

@other packagers Cc'ed on this report: This was slightly harder than I expected to fix. I unpacked the initscripts-mgaconf.patch.xz file, manually took out the lines in the mega patch file, repackaged the file, and mgarepo uploaded it. In case this is not the correct approach, please educate me accordingly.

Status: NEW => RESOLVED
Resolution: (none) => FIXED

Comment 8 Martin Whitaker 2012-12-23 15:02:39 CET
Hi Remco,

Thanks for trying to fix this - unfortunately it doesn't seem to have worked. Having taken a quick look in the SVN repository, I think the problem is that you haven't updated the SOURCES/sha1.lst file to point to the new mega patch binary file - but maybe one of the other packagers will be able to give better advice.

Status: RESOLVED => REOPENED
Resolution: FIXED => (none)

Comment 9 Remco Rijnders 2012-12-23 16:03:15 CET
Yipes... that's pretty poor of me. Please try again with -4.

Status: REOPENED => RESOLVED
Resolution: (none) => FIXED

Comment 10 Martin Whitaker 2012-12-23 18:11:09 CET
That's fixed it. Thanks for doing this!
Comment 11 Martin Whitaker 2013-01-26 16:45:30 CET
This fix doesn't appear to have made it into Mageia-3 beta 2.

Status: RESOLVED => REOPENED
Resolution: FIXED => (none)

Comment 12 Colin Guthrie 2013-01-29 10:50:06 CET
@Remco, Oh sorry, I've only just noticed now your comments here (blame the madness of the xmas period!)

(In reply to comment #7)
> @other packagers Cc'ed on this report: This was slightly harder than I expected
> to fix. I unpacked the initscripts-mgaconf.patch.xz file, manually took out the
> lines in the mega patch file, repackaged the file, and mgarepo uploaded it. In
> case this is not the correct approach, please educate me accordingly.

If you are not working directly in the git tree that we use to manage this tarball generation, then I wouldn't touch it, but instead add extra patches outside of it as per any other packages. When we periodically sync, we'll simply include any non-git patches into git. The process is pretty convoluted to be honest and the patching is a pain, hence why we don't update it crazy often. 
As the main tarball is created automatically from git repos, it will simply be overwritten when we rebase our initscripts on upstream redhat ones etc.

I'll add some notes to the .spec.


As for the fix, am I right in saying we should just remove the "else" section?
Comment 13 Colin Guthrie 2013-01-29 11:14:41 CET
Can you double check I've done the right thing here?

http://svnweb.mageia.org/packages?view=revision&revision=393116
Comment 14 Martin Whitaker 2013-01-29 23:09:10 CET
@Colin, not quite, all of this should be removed:

  # the BackSpace key sends ^? or ^H, depending on config
  setenv BSNUM 14
  setenv BACKSPACE `dumpkeys |& grep "^keycode  $BSNUM" | awk '{print $4}'`
  if ($BACKSPACE == "BackSpace") then
     bindkey "^?" delete-char
     bindkey "^H" backward-delete-char
  else
     bindkey "^?" backward-delete-char
     bindkey "^H" delete-char
  endif

As you noted in comment #1, dumpkeys is expected to fail, so using its output to make any decision is asking for trouble!
Comment 15 Dan Fandrich 2013-07-26 00:55:01 CEST
This bug seems to have been dropped mid-way, so I extended the patch to completely remove dumpkeys and committed to Cauldron and mga2.

CC: (none) => dan

Comment 16 Dan Fandrich 2013-08-03 00:58:50 CEST
initscripts-9.34-20.1.mga2 is in updates_testing and available to test.
Comment 17 Samuel Verschelde 2013-08-26 15:58:15 CEST
To Martin Whitaker, could you test the initscripts package from the core/updates_testing media and confirm it solves your problem? Then Dan Fandrich will be able to handle the update candidate to the QA Team.

Thanks!

CC: (none) => stormi

Comment 18 Martin Whitaker 2013-08-26 19:43:27 CEST
On running an update, I found that this change has already made it into core/updates in initscripts-9.34-20.2.mga2. I can confirm this version solves the issue.
Comment 19 Samuel Verschelde 2013-08-27 09:33:02 CEST
Thanks

Status: REOPENED => RESOLVED
Resolution: (none) => FIXED


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