~xnox/ubuntu/quantal/shadow/clear-locks

« back to all changes in this revision

Viewing changes to debian/patches/579_chowntty_debug

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2009-05-05 09:45:21 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090505094521-wpk2wn3q7957tlah
Tags: 1:4.1.3.1-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Ubuntu specific:
    + debian/login.defs: use SHA512 by default for password crypt routine.
  - debian/patches/stdout-encrypted-password.patch: chpasswd can report
    password hashes on stdout (debian bug 505640).
  - debian/login.pam: Enable SELinux support (debian bug 527106).
  - debian/securetty.linux: support Freescale MX-series (debian bug 527095).
* Add debian/patches/300_lastlog_failure: fixed upstream (debian bug 524873).
* Drop debian/patches/593_omit_lastchange_field_if_clock_is_misset: fixed
  upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Goal: Provide more info when chown_tty() phase of login fails (see #332198).
2
 
 
3
 
Related: #332198 (helps to debug)
4
 
 
5
 
Status wrt upstream: Not forwarded (dunno if there's any point in this).
6
 
 
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).
15
 
 
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
20
 
@@ -40,6 +40,7 @@
21
 
 #include "defines.h"
22
 
 #include <pwd.h>
23
 
 #include "getdef.h"
24
 
+#include <sys/sysmacros.h>
25
 
 /*
26
 
  * is_my_tty -- determine if "tty" is the same as TTY stdin is using
27
 
  */
28
 
@@ -47,12 +48,31 @@
29
 
 {
30
 
        struct stat by_name, by_fd;
31
 
 
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 */
37
 
+               int e = errno;
38
 
+               SYSLOG ((LOG_WARN, "can't stat(`%s'): errno %i\n", tty, e));
39
 
                return 0;
40
 
+       }
41
 
 
42
 
-       if (by_name.st_rdev != by_fd.st_rdev)
43
 
+       if (fstat (0, &by_fd)) {
44
 
+               int e = errno;
45
 
+               SYSLOG ((LOG_WARN, "can't fstat(stdin): errno %i\n", e));
46
 
                return 0;
47
 
-       else
48
 
+       }
49
 
+
50
 
+       if (by_name.st_rdev != by_fd.st_rdev) {
51
 
+               SYSLOG ((LOG_WARN,
52
 
+                        "`%s'.st_rdev(%u,%u) != stdin.st_rdev(%u,%u)\n",
53
 
+                        tty,
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)));
58
 
+               return 0;
59
 
+       } else
60
 
                return 1;
61
 
 }
62