Re: A requirement for the current user to own ttys
- From: Egmont Koblinger <egmont gmail com>
- To: Key Offecka <key offecka gmail com>
- Cc: mc devel <mc-devel gnome org>
- Subject: Re: A requirement for the current user to own ttys
- Date: Fri, 10 Mar 2017 08:30:06 +0100
Hi,
cons.saver, as you apparently know this, is the helper binary responsible for restoring the contents of the Linux console when you quit mc or press Ctrl+O. A helper is required since the Linux console does not have an "alternate screen" that graphical terminal emulators have.
In order to be able to do this, it needs read/write access to /dev/vcsa*.
When you log in on the console, the corresponding /dev/tty* becomes owned by you but /dev/vcsa* don't. I believe the reason behind it is that there is a way to revoke the tty from you, but there is no way to revoke the vcsa access. That is, when you log out, you might keep a background process running which still has access to it via a previously opened file descriptor, and subsequently as someone else logs in, you could spy on the console's contents.
As such, since /dev/vcsa* is not owned by the desired user, cons.saver needs to be setgid tty (or setuid root).
Setuid/setgid apps must have all these kinds of precautions that you're asking about, they need to duplicate the permission checks because they are not being run as the actual real user. It's crucial that someone not actually sitting in front of the tty cannot trick cons.saver into tampering with the tty's contents.
Hope this explains the situation.
I'm not sure why something is checked twice, but it can easily be in order to avoid a race condition (or could easily be a harmless bug as well).
egmont
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]