Hi!

On Fri, Jan 06, 2006 at 06:50:07PM +0100, Christian Perrier wrote:
> I absolutely don't know whether someone is still investigating it. I
> even don't know if it happens with recent releases of shadow.

I suspect it does. Sometimes. Actually I think the bug
is caused by /var/tmp/utmp file being corrupt from time
to time.

> In short, this seems to be a nice piece of nasty nightmare which could
> lie around for a very long time until someone is really  annoyed by
> this again.
> 
> So, what do we do?

I propose to add syslog debug statements in the code
which will provide more information about tty when bug
_happens_. I think we could enable this debugging code
and just distribute the shadow with it compiled in,
because it will increase shadow's verbosity only a bit.

P.S. I have already patched/modified source
(libmisc/chowntty.c) in my working directory of
Tomasz's CVS. Diff against most recent CVS is attached.

You can see that even when error happens the code uses
LOG_DEBUG level.

If you agree upon this behaviour, I'll generate quilt
patch and enable it.

-- 
WBR,
xrgtn
Index: libmisc/chowntty.c
===================================================================
RCS file: /cvsroot/shadow/libmisc/chowntty.c,v
retrieving revision 1.13
diff -u -r1.13 chowntty.c
--- libmisc/chowntty.c  31 Aug 2005 17:24:57 -0000      1.13
+++ libmisc/chowntty.c  6 Jan 2006 22:17:10 -0000
@@ -40,6 +40,7 @@
 #include "defines.h"
 #include <pwd.h>
 #include "getdef.h"
+#include <sys/sysmacros.h>
 /*
  * is_my_tty -- determine if "tty" is the same as TTY stdin is using
  */
@@ -47,12 +48,31 @@
 {
        struct stat by_name, by_fd;
 
-       if (stat (tty, &by_name) || fstat (0, &by_fd))
+       if (stat (tty, &by_name)) {
+               SYSLOG ((LOG_DEBUG,
+                        "can't stat(`%s') - error #%i\n", tty, errno));
+               closelog ();
                return 0;
+       }
 
-       if (by_name.st_rdev != by_fd.st_rdev)
+       if (fstat (0, &by_fd)) {
+               SYSLOG ((LOG_DEBUG,
+                        "can't fstat(stdin) - error #%i\n", errno));
+               closelog ();
                return 0;
-       else
+       }
+
+       if (by_name.st_rdev != by_fd.st_rdev) {
+               SYSLOG ((LOG_DEBUG,
+                        "`%s'.st_rdev(%u,%u) != stdin.st_rdev(%u,%u)\n",
+                        tty,
+                        /* XXX: dev_t is 64bit, gnu_dev_mXXor are used
+                         * which are GNU extn */
+                        major(by_name.st_rdev), minor(by_name.st_rdev),
+                        major(by_fd.st_rdev), minor(by_fd.st_rdev)));
+               closelog ();
+               return 0;
+       } else
                return 1;
 }
 

Reply via email to