Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved]Weird tty behavior
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
ShadowHawk92
n00b
n00b


Joined: 04 Mar 2013
Posts: 14
Location: Texas, USA

PostPosted: Sat Apr 20, 2013 8:41 pm    Post subject: [Solved]Weird tty behavior Reply with quote

I'm having some weird behavior related to tty.
NOTE: I am running KDE 4.10.1 with Konsole 4.10.1

The first problem I realized was this topic, but I marked it solved when I found a workaround and there were no responses.

The second problem I noticed is that when I'm logged in as root, if I run man, instead of accepting input and scrolling pages (or whatever I told it to do) the key code would be displayed where the page number was.
I.E. I hit [Down] to scroll down one line, but instead...
Code:
lines 1-57

turns into
Code:
:^[0B

I can backspace it away, and I can type, but It captures all my keyboard input and I cannot close the man page. I even just tried it in a tmux shell run as sudo, and I could not even 'C-a x' which should force tmux to close the terminal.

The third problem, that I just noticed the other day, is that gnupg doesn't work. When I run gpg I get the following:
Code:
 % gpg --gen-key
gpg (GnuPG) 2.0.19; Copyright (C) 2012 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: cannot open `/dev/tty': Permission denied

If I run the command as root the behavior varies depending on the kernel console= option:
If kernel... console=tty1 then I can see the output and type input into tty1 (Ctl-Alt-F1)
If I do not specify console= then I cannot see the output or input in any of the 6 tty's or the pts I ran the command in. I believe I discussed having similar behavior in the above thread.

I have no idea what is happening, or what information is relevant, so I'll give some of my system information here, more info available on request.

Computer: Toshiba Satellite C675
Processor: Intel Pentium CPU B960 @ 2.20GHz
Kernel: ck-sources 3.7.10 Custom compiled - No genkernel
I'm running a custom generated initramfs and custom init script. I can give information about the initramfs if need be.

Any and all suggestions & help appreciated.

~ShadowHawk92

Solved After a reboot, even Konsole seems to be working fine. Thanks for the help!


Last edited by ShadowHawk92 on Thu Apr 25, 2013 6:30 pm; edited 1 time in total
Back to top
View user's profile Send private message
BradN
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2391
Location: Wisconsin (USA)

PostPosted: Sun Apr 21, 2013 1:57 am    Post subject: Reply with quote

Sounds possibly like a missing kernel config option - try turning on more options related to tty handling. I doubt something like that would be broken in udev but there's a side chance of that as well.

Has the problem recently appeared (if so, any system package upgrades that might have affected it?) or could it have been like that a while?
Back to top
View user's profile Send private message
ShadowHawk92
n00b
n00b


Joined: 04 Mar 2013
Posts: 14
Location: Texas, USA

PostPosted: Sun Apr 21, 2013 4:32 am    Post subject: Reply with quote

BradN,

I've had the problem since installing KDE. Actually the man page problem happens even in tty. I've upgraded Udev since initial install and the problem persisted. sys-fs/udev is version 200, virtual/udev is 197.3.

A quick search for tty in the kernel menu config shows everything with tty in the name being =n. The problem is that I don't know what needs to be changed.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sun Apr 21, 2013 3:31 pm    Post subject: Re: Weird tty behavior Reply with quote

ShadowHawk92 wrote:
The second problem I noticed is that when I'm logged in as root, if I run man, instead of accepting input and scrolling pages (or whatever I told it to do) the key code would be displayed where the page number was.

ShadowHawk92 ... I think there may a number of seperate issues here, and for that reason its difficult from your report to point at the 'cause' and provide a solution.

My first stab in the dark would be to ask if you've tried another terminal, and if the same issues can be reproduced, this would rule out kconsole, and narrow down the scope. Also, can it be reproduced in the console?

ShadowHawk92 wrote:
I can backspace it away, and I can type, but It captures all my keyboard input and I cannot close the man page. I even just tried it in a tmux shell run as sudo, and I could not even 'C-a x' which should force tmux to close the terminal.

Your shell will interpret the keycodes sent via the keyboard in a certain way, ^? or ^H (for stty erase) being one example. This is true for other keys such as 'page up', 'end', etc. So, does the keymap you provide represent the keyboard, and does KDE (in whatever "keyboard" preferences) show the same keymap, ie: keymap=us. Also, when using tmux the terminal is being reported to tmux, so what does kconsole say is the TERM and what does tmux think it is? The value of TERM will effect the termcap used, and so how the shell understands keyboard input.

ShadowHawk92 wrote:
The third problem, that I just noticed the other day, is that gnupg doesn't work. When I run gpg I get the following:
Code:
% gpg --gen-key
gpg (GnuPG) 2.0.19; Copyright (C) 2012 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: cannot open `/dev/tty': Permission denied

Does the following produce the same error?

Code:
% GPG_TTY=$(tty) gpg --gen-key

Infact ... what does the output of 'tty' show?

ShadowHawk92 wrote:
If I run the command as root the behavior varies depending on the kernel console= option: If kernel... console=tty1 then I can see the output and type input into tty1 (Ctl-Alt-F1)
If I do not specify console= then I cannot see the output or input in any of the 6 tty's or the pts I ran the command in. I believe I discussed having similar behavior in the above thread.

Why are you passing console=tty1? ... unless you need to send to a serial line then using console= is not necessary.

ShadowHawk92 wrote:
I have no idea what is happening, or what information is relevant, so I'll give some of my system information here, more info available on request.

Its really hard to see what might be the issue, you should probably post your kernel config, and init from the initramfs. CONFIG_UNIX98_PTYS is enabled?

best ... khay
Back to top
View user's profile Send private message
ShadowHawk92
n00b
n00b


Joined: 04 Mar 2013
Posts: 14
Location: Texas, USA

PostPosted: Mon Apr 22, 2013 4:13 pm    Post subject: Reply with quote

I'm having to type this from my phone, I appolagize for spelling errors in advance.

Khayyam,

The problem with man pages is reproducable in a tty. I went ahead and installed another terminal emulator anyway (yakuake) to test in also.

Running
Code:
sudo man gpg

in yakuake (without tmux) had the same input error. Before I gave it any input there was just a colon where the page numbers should have been. Giving it input showed me the key codes after the colon instead of scrolling.

In konsole TERM=xterm;
in yakuake TERM=xterm;
in tmux TERM=screen-256color

In tmux, konsole, and yakuake
Code:
% GPG_TTY=$(tty) gpg --gen-key
...
gpg: cannot open '/dev/tty': Permission denied


Code:
% tty
/dev/pts/#

Currently Konsole is pts/2 and yakuake is pts/1. TMUX grabs the next available pts also. So if I ran it now it would be pts/3.

CONFIG_UNIX98_PTYS=y.

console=tty1 is from http://en.gentoo-wiki.com/wiki/Fbsplash although I removed it trying to figure this out.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Mon Apr 22, 2013 8:53 pm    Post subject: Reply with quote

ShadowHawk92 wrote:
Code:
% GPG_TTY=$(tty) gpg --gen-key
...
gpg: cannot open '/dev/tty': Permission denied

ShadowHawk92 ... can you check what the permissions of /dev/tty are ... they should be ugo+rw.

ShadowHawk92 wrote:
console=tty1 is from http://en.gentoo-wiki.com/wiki/Fbsplash although I removed it trying to figure this out.

So your initramfs is that built with genkernel with the suggested changes from the wiki.com howto? Have you tried to boot without this, and with a non modified kernel? I suspect this to be the prime candidate for why the tty is not rw for your user, and that the subseqent issues are the result.

best ... khay
Back to top
View user's profile Send private message
ShadowHawk92
n00b
n00b


Joined: 04 Mar 2013
Posts: 14
Location: Texas, USA

PostPosted: Mon Apr 22, 2013 11:14 pm    Post subject: Reply with quote

Code:
% ls -l /dev/tty
crw-rw---- 1 root root 5, 1 Apr 22 13:05 /dev/tty


My initramfs is not built with genkernel, it is most similar to this with the fbsplash modifications I linked to earlier. I also added GnuPG 1.4.11 to the initramfs. I can download gentoo-sources and compile it with genkernel, but my whole hard drive is encrypted with boot on a usb drive so I have to have an initramfs to decrypt the hard drive. Actually, genkernel has support for a cryptsetup, gpg, lvm initramfs so I may be able to genkernel a working initramfs and try that.

I tried (just for kicks)
Code:
sudo chmod ugo+rw /dev/tty

I took a screenshot of the result. You can see it prints a message, then just hangs. This makes me think it may not be the tty permissions that are the problem.

I'm emerging genkernel and gentoo-sources now. Will (try) to use genkernel to compile the kernel and the initramfs and will report back with the results.
Also if you want I can post my current initramfs init script.
Back to top
View user's profile Send private message
ShadowHawk92
n00b
n00b


Joined: 04 Mar 2013
Posts: 14
Location: Texas, USA

PostPosted: Thu Apr 25, 2013 5:17 pm    Post subject: Finally got Gentoo-sources working Reply with quote

I forgot how much kernel customization I had to do to get my system set up. Any how, a large number of kernel compiles and reboots later I finally got a genkerneled gentoo-sources bootable, albeit with my custom initramfs and I'm having the same problem.
So the kernel isn't the problem.

I have a line in my initramfs:
Code:
cp -a /dev/console /dev/tty

So that gpg will work in the initramfs. I'm wondering if this is the problem so I devised another work-around that I'm about to try.

Also, because of my setup, I don't think a genkernel initramfs will ever work right, but I can use the shell when it fails to (hopefully) boot, and test that.

I'll let you know what I find out, but any other suggestions would be greatly appreciated.

- Shadow

EDIT:Removing the above line from initramfs fixed all the problems and created a new one (or emphasized an old one I hadn't noticed.)
But first, to clarify, the problem with man pages works, gpg --gen-key works, and sudo works without the -S option; all in tty, pts, and tmux.

The (new) Problem: On login, yakuake starts automatically and grabs pts/0. However, something else (I don't know what) grabs pts/1. If I start Konsole, it grabs pts/2.
Konsole (pts/2) can't read in my password. I can't use sudo, or su. I can use Ctl-C and exit the password prompt from sudo, but not su.
Code:
[ ryan@CommanderShepard ] (pts/2) ~/
% ls -l /dev/pts
total 0
crw------- 1 ryan tty 136, 0 Apr 25 12:44 0
crw--w---- 1 ryan tty 136, 1 Apr 25 12:28 1
crw------- 1 ryan tty 136, 2 Apr 25 12:47 2

[ ryan@CommanderShepard ] (pts/2) ~/
% chmod g-w /dev/pts/1

[ ryan@CommanderShepard ] (pts/2) ~/
% ls -l /dev/pts           
total 0
crw------- 1 ryan tty 136, 0 Apr 25 12:44 0
crw------- 1 ryan tty 136, 1 Apr 25 12:28 1
crw------- 1 ryan tty 136, 2 Apr 25 12:49 2
[ ryan@CommanderShepard ] (pts/2) ~/
% sudo echo 'Hello World!'
Password:
Pauses for audience applause, not a sausage
Password:

When I change the permissions of pts/1, pts/2 works fine, so I imagine if I can figure out what is grabbing pts/1 I can fix the problem.

Any ideas?
/Edit
Edit2: lsof is your best friend.
Code:
% lsof | grep pts
kded4     2141            ryan   17u      CHR              136,1       0t0       4 /dev/pts/1
QInotifyF 2141 2225       ryan   17u      CHR              136,1       0t0       4 /dev/pts/1
QProcessM 2141 2779       ryan   17u      CHR              136,1       0t0       4 /dev/pts/1

I still don't know why it's setting the permissions wrong though.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Sat Apr 27, 2013 5:38 pm    Post subject: Reply with quote

ShadowHawk92 ...

see the following link

best ... khay
Back to top
View user's profile Send private message
ShadowHawk92
n00b
n00b


Joined: 04 Mar 2013
Posts: 14
Location: Texas, USA

PostPosted: Tue Apr 30, 2013 3:05 pm    Post subject: Reply with quote

Thanks Khayyam.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum