In article <
u0b14a-...@wilbur.25thandClement.com>,
William Ahern <
wil...@wilbur.25thandClement.com> wrote:
...
>> IIUC, with the current behavior only programs you've executed from the
>> same terminal could do that. Or if the shell changes the controlling tty
I was in the process of composing one of my (all too common on the modern
Usenet) "You [*] are totally missing the point" responses, ...
[*] "you" meaning most of the later responders on this thread, not you,
William, specifically.
... When it occurred to me that the issue here is that in the olden days,
people's terminals (i.e., their /dev/...tty device) were generally world
writable - because back in those olden times, the "write" program actually
opened up and wrote to the user's terminal device. And the "mesg" utility
worked by actually changing the perms on said device. And the default
setting for "mesg" was "y". None of these things are (in any significant
sense) true today.
But in that environment, where anybody could (usually, i.e., if you had
"mesg y" in effect) open up your terminal device, then clearly it doesn't
make sense to allow anyone who can open up your tty to be able to force
keystrokes into it. And, as the first response on this thread noted, the
semantics of TIOCSTI were set way back then, in those earlier times, and
haven't been updated (much) since then.
In conclusion, I would suggest that the right way to do this is to:
A) Require read/write access on the tty (which seems to be the case).
B) (Optionally) also require that the tty be owned by you ("you" being the
one issuing the TIOCSTI call).
Together, that ought to remove the requirement of being root.
--
"Remember when teachers, public employees, Planned Parenthood, NPR and PBS
crashed the stock market, wiped out half of our 401Ks, took trillions in
TARP money, spilled oil in the Gulf of Mexico, gave themselves billions in
bonuses, and paid no taxes? Yeah, me neither."