cu doesn't connect properly to a serial console
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
uucp (Debian) |
Fix Released
|
Unknown
|
|||
uucp (Ubuntu) |
Triaged
|
Medium
|
Unassigned |
Bug Description
almost entirely default install of xubuntu 12.10; note that i'm running a 3.7 kernel (because of Bug #1085115), but the problem is the same with the default kernel. if i boot this box in openbsd or netbsd, cu will connect just fine.
i need to access a terminal on another host, which is directly connected with a serial cable.
$ sudo uname -a
Linux iugo 3.7.0-4-generic #12~lp1085115v1 SMP Fri Nov 30 20:57:19 UTC 2012 i686 i686 i686 GNU/Linux
$ sudo dmesg|grep tty
[ 0.000000] console [tty0] enabled
[ 0.663436] 00:06: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 0.683785] 00:07: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
i am assuming a standard 16550 uart buffer is handled by the main kernel, and hardware support is not an issue here.
$ sudo ls -al /dev/ttyS?
crw-rw---- 1 root dialout 4, 64 Dec 8 10:05 /dev/ttyS0
crw-rw---- 1 root dialout 4, 65 Dec 8 10:05 /dev/ttyS1
crw-rw---- 1 root dialout 4, 66 Dec 8 10:05 /dev/ttyS2
crw-rw---- 1 root dialout 4, 67 Dec 8 10:05 /dev/ttyS3
crw-rw---- 1 root dialout 4, 68 Dec 8 10:05 /dev/ttyS4
crw-rw---- 1 root dialout 4, 69 Dec 8 10:05 /dev/ttyS5
crw-rw---- 1 root dialout 4, 70 Dec 8 10:05 /dev/ttyS6
crw-rw---- 1 root dialout 4, 71 Dec 8 10:05 /dev/ttyS7
crw-rw---- 1 root dialout 4, 72 Dec 8 10:05 /dev/ttyS8
crw-rw---- 1 root dialout 4, 73 Dec 8 10:05 /dev/ttyS9
$ sudo cat /proc/tty/
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0 DSR
1: uart:16550A port:000002F8 irq:3 tx:0 rx:0
$ sudo cat /etc/group|grep koen
adm:x:4:koen
tty:x:5:koen,root
uucp:x:10:koen,root
dialout:
cdrom:x:24:koen
sudo:x:27:koen
audio:x:
dip:x:30:koen
video:x:44:koen
plugdev:x:46:koen
fuse:x:104:koen
lpadmin:x:107:koen
scanner:x:116:koen
koen:x:1000:
$ sudo which cu
/usr/bin/cu
$ cu -l /dev/ttyS0 -s 115200
Connected.
note that cu always says "Connected.", this doesn't mean anything; also note that the baudrate, parity, et cetera... are correct; the cable is healthy and connected to the right serial port.
$ sudo cu -l /dev/ttyS0 -s 115200
/usr/bin/cu: open (/dev/ttyS0): Permission denied
/usr/bin/cu: /dev/ttyS0: Line in use
$ sudo su -
# cu -l /dev/ttyS0 -s 115200
/usr/bin/cu: open (/dev/ttyS1): Permission denied
/usr/bin/cu: /dev/ttyS1: Line in use
if i make user 'root' part of the mandatory group 'dialout', it doesn't make any difference anymore whether i try this with an uid of 0 or not.
to rule things out, i made a polkit action definition for this. logs confirmed the action definition worked. i tried the above scenarios with polkit's pkexec. it didn't make any difference.
to rule things out, i tried making a pam exception for this (capabilities), by adding some lines to /etc/security/
to rule things out, i started fiddling with /bin/stty (which shouldn't be needed). it didn't make any difference. for the record:
$ sudo stty -a
speed 38400 baud; rows 43; columns 124; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S;
susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
$ sudo stty -g
6d02:5:
$ sudo stty -F /dev/ttyS0 speed
115200
apparently baudrate was set by cu.
$ strace -f -ff -o STRACE_CU cu -l /dev/ttyS0 -s 115200
Connected.
~.
Disconnected.
i was able to abort the terminal normally, with "~."...
$ ls STRACE_CU.*
STRACE_CU.3139
STRACE_CU.3140
$ cat STRACE_CU.*|grep EPERM
ioctl(3, TIOCSCTTY) = -1 EPERM (Operation not permitted)
full traces below...
$ cu -l /dev/ttyS0 -s 115200 --debug all
cu: fconn_open: Opening port /dev/ttyS0 (speed 115200)
cu: fconn_set: Changing setting to 0, 0, 2
Connected.
~.cu: Exit status 0
cu: fconn_close: Closing connection
ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: cu 1.07-20build2
ProcVersionSign
Uname: Linux 3.7.0-4-generic i686
ApportVersion: 2.6.1-0ubuntu9
Architecture: i386
Date: Fri Dec 28 15:05:24 2012
InstallationDate: Installed on 2012-11-29 (28 days ago)
InstallationMedia: Xubuntu 12.10 "Quantal Quetzal" - Release i386 (20121017.1)
MarkForUpload: True
SourcePackage: uucp
UpgradeStatus: No upgrade log present (probably fresh install)
Changed in uucp (Debian): | |
status: | Unknown → New |
Changed in uucp (Debian): | |
status: | New → Fix Released |
$ cat STRACE_CU.3139 "/usr/bin/ cu", ["cu", "-l", "/dev/ttyS0", "-s", "115200"], [/* 50 vars */]) = 0 "/etc/ld. so.nohwcap" , F_OK) = -1 ENOENT (No such file or directory) PROT_WRITE, MAP_PRIVATE| MAP_ANONYMOUS, -1, 0) = 0xb7790000 "/etc/ld. so.preload" , R_OK) = -1 ENOENT (No such file or directory) etc/ld. so.cache" , O_RDONLY|O_CLOEXEC) = 4 S_IFREG| 0644, st_size=72636, ...}) = 0 "/etc/ld. so.nohwcap" , F_OK) = -1 ENOENT (No such file or directory) lib/i386- linux-gnu/ libc.so. 6", O_RDONLY|O_CLOEXEC) = 4 1\1\1\0\ 0\0\0\0\ 0\0\0\0\ 3\0\3\0\ 1\0\0\0000\ 226\1\0004\ 0\0\0". .., 512) = 512 S_IFREG| 0755, st_size=1730024, ...}) = 0 PROT_EXEC, MAP_PRIVATE| MAP_DENYWRITE, 4, 0) = 0xb75d4000 0xb7777000, 4096, PROT_NONE) = 0 PROT_WRITE, MAP_PRIVATE| MAP_FIXED| MAP_DENYWRITE, 4, 0x1a3) = 0xb7778000 PROT_WRITE, MAP_PRIVATE| MAP_FIXED| MAP_ANONYMOUS, -1, 0) = 0xb777b000 PROT_WRITE, MAP_PRIVATE| MAP_ANONYMOUS, -1, 0) = 0xb75d3000 area({entry_ number: -1 -> 6, base_addr: 0xb75d3900, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 0xb7778000, 8192, PROT_READ) = 0 0xb77b3000, 4096, PROT_READ) = 0 etc/uucp/ config" , O_RDONLY) = 4 S_IFREG| 0644, st_size=461, ...}) = 0 PROT_WRITE, MAP_PRIVATE| MAP_ANONYMOUS, -1, 0) = 0xb778f000 etc/uucp/ Sysfiles" , O_RDONLY) = -1 ENOENT (No such file or directory) RLIMIT_ NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0
execve(
brk(0) = 0x88ca000
access(
mmap2(NULL, 8192, PROT_READ|
access(
open("/
fstat64(4, {st_mode=
mmap2(NULL, 72636, PROT_READ, MAP_PRIVATE, 4, 0) = 0xb777e000
close(4) = 0
access(
open("/
read(4, "\177ELF\
fstat64(4, {st_mode=
mmap2(NULL, 1743580, PROT_READ|
mprotect(
mmap2(0xb7778000, 12288, PROT_READ|
mmap2(0xb777b000, 10972, PROT_READ|
close(4) = 0
mmap2(NULL, 4096, PROT_READ|
set_thread_
mprotect(
mprotect(0x806e000, 4096, PROT_READ) = 0
mprotect(
munmap(0xb777e000, 72636) = 0
brk(0) = 0x88ca000
brk(0x88eb000) = 0x88eb000
open("/
fstat64(4, {st_mode=
mmap2(NULL, 4096, PROT_READ|
read(4, "#\n# config\tThis is the configura"..., 4096) = 461
read(4, "", 4096) = 0
close(4) = 0
munmap(0xb778f000, 4096) = 0
open("/
getpid() = 3139
getrlimit(
close(3) = 0
close(4) = -1 EBADF (Bad file descriptor)
close(5) = -1 EBADF (Bad file descriptor)
close(6) = -1 EBADF (Bad file descriptor)
close(7) = -1 EBADF (Bad file descriptor)
close(8) = -1 EBADF (Bad file descriptor)
close(9) = -1 EBADF (Bad file descriptor)
close(10) = -1 EBADF (Bad file descriptor)
close(11) = -1 EBADF (Bad file descriptor)
close(12) = -1 EBADF (Bad file descriptor)
close(13) = -1 EBADF (Bad file descriptor)
close(14) ...