The function get_terminal_name iterates through standard file
descriptors until it finds a terminal. This means that it's not
guaranteed that STDIN_FILENO (i.e. 0) is actually a terminal.
Do not modify permissions on possible files. Instead, retrieve
the file descriptor which was used by get_terminal_name as well.
Proof of Concept (as root):
1. Create a temporary file with a mode different than TTYPERM.
```
install -m 700 /dev/null /tmp/test
ls -l /tmp/test
-rwx------ 1 root root 0 Sep 21 20:15 /tmp/test
```
2. Run login within a terminal with adjusted stdin.
```
login < /tmp/test
host login:
Hangup
```
3. Check permissions of input file.
```
ls -l /tmp/test
-rw------- 1 root root 0 Sep 21 20:15 /tmp/test
```