1
Goal: Provide more info when chown_tty() phase of login fails (see #332198).
3
Related: #332198 (helps to debug)
5
Status wrt upstream: Not forwarded (dunno if there's any point in this).
7
This patch increases verbosity of is_my_tty() routine which is called
8
from chown_tty() which in turn is part of login sequence. Submitter of
9
the bug #332198 sometimes gets telnet session refused, but message in
10
syslog is not at all helpful:
11
> ... login[453]: unable to determine TTY name, got /dev/pts/1
12
and in fact it's misleading, because tty name is detected OK, it's
13
is_my_tty() which is failing for a reason yet unknown (I suspect
14
corruption of utmp file).
16
Index: shadow-4.1.0/libmisc/chowntty.c
17
===================================================================
18
--- shadow-4.1.0.orig/libmisc/chowntty.c
19
+++ shadow-4.1.0/libmisc/chowntty.c
24
+#include <sys/sysmacros.h>
26
* is_my_tty -- determine if "tty" is the same as TTY stdin is using
30
struct stat by_name, by_fd;
32
- if (stat (tty, &by_name) || fstat (0, &by_fd))
33
+ if (stat (tty, &by_name)) {
34
+ /* Can use neither strerror() nor "%m" sequence -- first
35
+ * is locale-dependent (while SYSLOG isn't) and for second
36
+ * the SYSLOG macro isn't errno-transparent. --xrgtn */
38
+ SYSLOG ((LOG_WARN, "can't stat(`%s'): errno %i\n", tty, e));
42
- if (by_name.st_rdev != by_fd.st_rdev)
43
+ if (fstat (0, &by_fd)) {
45
+ SYSLOG ((LOG_WARN, "can't fstat(stdin): errno %i\n", e));
50
+ if (by_name.st_rdev != by_fd.st_rdev) {
52
+ "`%s'.st_rdev(%u,%u) != stdin.st_rdev(%u,%u)\n",
54
+ /* XXX: dev_t is 64bit, gnu_dev_mXXor are used
55
+ * which are GNU extn */
56
+ major(by_name.st_rdev), minor(by_name.st_rdev),
57
+ major(by_fd.st_rdev), minor(by_fd.st_rdev)));