init: support job output being passed to start/initctl invocation

Bug #327823 reported by gcooper
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
upstart
Triaged
Wishlist
Unassigned
vsftpd (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

When logged in via SSH, instead of the output being directed to the PTY of interest, when a jobfile contains console output it redirects the output to the local console (be it serial, terminal console, etc).

This probably could be solved by simply dup'ing and execve'ing for the file descriptor instances that invoked initctl, or something similar to that, or by looking at getenv("SSH_TTY"), etc to get the appropriate TTY file descriptor set for ssh. Not sure how to do this for telnet, etc though if you follow the latter method.

SSH invocation:

[comet-k5-12:~]$ start console_output
[comet-k5-12:~]$ env
HOSTNAME=comet-k5-12
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=128.107.158.174 34008 22
SSH_TTY=/dev/pts/1
USER=root
MAIL=/var/mail/root
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/binos/bin:/usr/binos/conf:/nfs/nova/tools/0.200806023/powerpc-linux/bin:/nfs/nova/tools/0.200806023/bin
INPUTRC=/etc/inputrc
PWD=/root
PS1=[\h:\w]$
SHLVL=1
HOME=/root
LOGNAME=root
SSH_CONNECTION=128.107.158.174 34008 172.27.242.248 22
_=/bin/env
[comet-k5-12:~]$

Local console:
[comet-k5-12:~]$ env
HOSTNAME=comet-k5-12
TERM=linux
SHELL=/bin/bash
HISTSIZE=1000
USER=root
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/binos/bin:/usr/binos/conf:/nfs/nova/tools/0.200806023/powerpc-linux/bin:/nfs/nova/tools/0.200806023/bin
INPUTRC=/etc/inputrc
PWD=/root
PS1=[\h:\w]$
SHLVL=1
HOME=/root
LOGNAME=root
_=/bin/env
[comet-k5-12:~]$ And then there was Foo

Telnet data:

gcooper@headless-horseman ~ $ telnet comet-k5-12
Trying 172.27.242.248...
Connected to comet-k5-12.
Escape character is '^]'.

Linux 2.6.24.4.59.43.k5 (comet-k5-12) (0)

comet-k5-12 login: root
Password:
Last login: Mon Feb 9 18:02:47 from 171.70.172.107
[comet-k5-12:~]$ env
REMOTEHOST=128.107.158.174
HOSTNAME=comet-k5-12
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
USER=root
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/binos/bin
:/usr/binos/conf:/nfs/nova/tools/0.200806023/powerpc-linux/bin:/nfs/nova/tools/0
.200806023/bin
INPUTRC=/etc/inputrc
PWD=/root
PS1=[\h:\w]$
SHLVL=1
HOME=/root
LOGNAME=root
DISPLAY=localhost:0.0
_=/bin/env
[comet-k5-12:~]$ start console_output
[comet-k5-12:~]$ lsof | grep telnetd
in.telnet 9568 root txt REG 0,13 116010 534187 /usr/sbin/in.telne
td (/dev/root)
[comet-k5-12:~]$ lsof | grep telnet
xinetd 1884 root 5u IPv4 2244 TCP *:telnet (LISTEN)
in.telnet 9568 root cwd DIR 0,13 1190 526749 / (/dev/root)
in.telnet 9568 root rtd DIR 0,13 1190 526749 / (/dev/root)
in.telnet 9568 root txt REG 0,13 116010 534187 /usr/sbin/in.telnetd (/dev/root)
in.telnet 9568 root mem REG 0,13 246796 527265 /lib/libresolv-2.3.4.so (/dev/root)
in.telnet 9568 root mem REG 0,13 58014 527288 /lib/libnss_dns-2.3.4.so (/dev/root)
in.telnet 9568 root mem REG 0,13 186144 527338 /lib/libnss_files-2.3.4.so (/dev/root)
in.telnet 9568 root mem REG 0,13 7891259 527255 /lib/libc-2.3.4.so (/dev/root)
in.telnet 9568 root mem REG 0,13 335307 539802 /usr/lib/libncurses.so.5.4 (/dev/root)
in.telnet 9568 root mem REG 0,13 30370 527336 /lib/libutil-2.3.4.so (/dev/root)
in.telnet 9568 root mem REG 0,13 532536 527340 /lib/ld-2.3.4.so (/dev/root)
in.telnet 9568 root 0u IPv4 7415 TCP 172.27.242.248:telnet->128.107.158.174:36421 (ESTABLISHED)
in.telnet 9568 root 1u IPv4 7415 TCP 172.27.242.248:telnet->128.107.158.174:36421 (ESTABLISHED)
in.telnet 9568 root 2u IPv4 7415 TCP 172.27.242.248:telnet->128.107.158.174:36421 (ESTABLISHED)
in.telnet 9568 root 3u CHR 5,2 176 /dev/ptmx
[comet-k5-12:~]$

Revision history for this message
gcooper (yanegomi-deactivatedaccount) wrote :

Oh yeah, almost forgot the version info:

[comet-k5-12:~]$ init --version
init (upstart 0.5.0)
Copyright (C) 2008 Canonical Ltd.

This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[comet-k5-12:~]$ uname -a
Linux comet-k5-12 2.6.24.4.59.43.k5 #2 Tue Feb 3 16:19:49 PST 2009 ppc ppc ppc GNU/Linux

Revision history for this message
gcooper (yanegomi-deactivatedaccount) wrote :

I think I found the best solution here -- http://linux.die.net/man/4/pts . ptsname(4) is the answer to this problem.

Changed in upstart:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

A much more interesting way would be to take advantage of Lennart's pass-file-descriptor-over-D-Bus patches ;-)

summary: - Support job output being passed to start/initctl invocation
+ init: support job output being passed to start/initctl invocation
Changed in upstart:
status: Confirmed → Triaged
Revision history for this message
Thierry Carrez (ttx) wrote :

Note that this feature would allow vsftpd to start when using a private key. See duplicate bug 604185 for details.

Changed in vsftpd (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.