util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Walrond <andrew@walrond.org>
To: util-linux@vger.kernel.org
Subject: agetty problem after upgrading v2.19.1 -> v2.20.1
Date: Sat, 3 Dec 2011 17:16:59 +0000	[thread overview]
Message-ID: <20111203171658.GA9780@golden.localdomain> (raw)


After upgrading from v2.19.1 to v2.20.1 I can't login from the terminal anymore and I see lots of these in the syslog:

Dec 03 16:57:11 [agetty] /dev/ttyS0: cannot get controlling tty: Operation not permitted

So having a quick look at the git logs I see this commit

commit 3aa6b68f7e19fa3e1c2bba75bee921a98b7b46af
Author: Werner Fink <werner@suse.de>
Date:   Mon May 9 15:52:36 2011 +0200

    agetty: proper session on the terminal line
    
    Ensure a proper session on the terminal line, that is do a
    vhangup() and become the controlling terminal.  After this
    determine if the terminal line a virtual console by using
    the ioctl TIOCMGET to get the status modem bits of a serial
    line which is a invalid argument on a virtual console.
    
    Signed-off-by: Werner Fink <werner@suse.de>

and these relevant changes:

-           /* Open the tty as standard input. */
+         if (((tid = tcgetsid(fd)) < 0) || (pid != tid)) {
+                 if (ioctl (fd, TIOCSCTTY, 1) == -1)
+                         log_err("/dev/%s: cannot get controlling tty: %m", tty);
+         }
+
+         if (op->flags & F_HANGUP) {
+                 /*
+                  * vhangup() will replace all open file descriptors in the kernel
+                  * that point to our controlling tty by a dummy that will deny
+                  * further reading/writing to our device. It will also reset the
+                  * tty to sane defaults, so we don't have to modify the tty device
+                  * for sane settings. We also get a SIGHUP/SIGCONT.
+                  */
+                 if (vhangup())
+                         log_err("/dev/%s: vhangup() failed: %m", tty);
+                 (void)ioctl(fd, TIOCNOTTY);
+         }
+
+         (void) close(fd);
                close(STDIN_FILENO);
                errno = 0;
 
                debug("open(2)\n");
-           if (open(tty, O_RDWR | O_NONBLOCK, 0) != 0)
-                   log_err(_("/dev/%s: cannot open as standard input: %m"),
-                         tty);
+         if (open(buf, O_RDWR|O_NOCTTY|O_NONBLOCK, 0) != 0)
+                 log_err(_("/dev/%s: cannot open as standard input: %m"), tty);
+         if (((tid = tcgetsid(STDIN_FILENO)) < 0) || (pid != tid)) {
+                 if (ioctl (STDIN_FILENO, TIOCSCTTY, 1) == -1)
+                         log_err("/dev/%s: cannot get controlling tty: %m", tty);
+         }
+

which all looks pretty valid to me, but is obviously the source of my problems.
So, before I do a brain dump and reload the knotty TTY knowledge back in to my brain to investigate, does anything obvious occur to anyone?

TIA

Andrew Walrond

             reply	other threads:[~2011-12-03 17:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-03 17:16 Andrew Walrond [this message]
2011-12-04 12:05 ` agetty problem after upgrading v2.19.1 -> v2.20.1 Andrew Walrond
2011-12-08 12:04   ` Karel Zak
2011-12-08 14:52     ` Andrew Walrond

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111203171658.GA9780@golden.localdomain \
    --to=andrew@walrond.org \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).