Hi,
attached is a patch with a couple of related fixes to TTY
handling.
The patch was need to make DFB work in my setup when running
DFB
applications both as root and as unprivileged user and both
from the
physical terminal (/dev/tty1) and SSH login shell. Part of
it is, I'm
sorry to say, reversal of changes I suggested (these two
revisions:
http://directfb
.org/index.php/viewcvs.cgi/DirectFB/systems/fbdev/fbdev.c.di
ff?r1=1.49&r2=1.51).
Here's more detailed description of the changes:
* Previously, the process attached itself to a new
controlling TTY
only if vt_switch option was on. This patch changes it to
always
(unless VT handling is completely disabled, of course)
attach the
process to the TTY being used by the app as the new
controlling TTY.
This is because we always need some controlling TTY, without
it, there
could be SIGHUP/SIGCONT signals (see e.g. my post about
re-adding
setpgid() call). Note that the patch moves TIOCSCTTY call
outside
of "if vt-switch" branch, but completely removes
TIOCNOTTY - - that's
because the latter is not needed, setsid() already detached
the
process from controlling TTY. So "vt-switch" now
only
controls "physical" change of the currently active
console.
* /dev/tty? files are opened with O_NOCTTY. Linux kernel has
a feature
that if a process without controlling TTY opens a TTY
device, it's
made its controlling TTY, unless you use O_NOCTTY, so this
change
ensure that we only attach to the desired TTY explicitly
using
TIOCSCTTY.
* Moved TIOCSCTTY before KBSETMODE use, otherwise non-root
users get
EPERM from KBSETMODE ioctl(), because you can't do that
operation on
anything other than your controlling TTY normally.
* Removed setpgid() calls, because they interfered with
setsid() later
and weren't really necessary now that other cTTY problems
were fixed.
Ditto for the removed dfb_vt_detach() call (I couldn't find
any
information about why it was there in the first place, but
everything
works without it as far as I can tell).
I'm not sure if you'll want to include it in 1.0.0: on one
hand, it
fixes a serious problem with running as non-root user, on
the other
hand, it's not trivial change and may have some consequences
I
missed. I'd certainly appreciate a review of the patch, I'm
still
quite unfamiliar with the DFB code.
Regards,
Vaclav
--
PGP key: 0x465264C9, available from http://pgp.mit.edu/
_______________________________________________
directfb-dev mailing list
directfb-dev directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/
directfb-dev
|