On 09/16/2010 04:01 PM, Mats Erik Andersson wrote:
Hello again,

a new observation from my bug chasing.

The assumptions made in "lib/login_tty.c", which are set
on display as inherited from Solaris, these prerequisites
are __NOT__ sufficient for OpenBSD. The reason is clearly
displayed in tty(4) of OpenBSD origin. Only after an ioctl
call with TIOCSCTTY is the controlling terminal established.

Thanks for chasing this.

+#if __OpenBSD__
+# include<sys/ioctl.h>
+#endif
+
  int
  login_tty (int slave_fd)
  {
@@ -53,6 +57,11 @@ login_tty (int slave_fd)
      close (dummy_fd);
    }

+#if __OpenBSD__
+  /* Needed to activate the controlling terminal, see tty(4).  */
+  ioctl (slave_fd, TIOCSCTTY, NULL);
+#endif

Rather than hard-coding this for just __OpenBSD__, wouldn't it be better to have a configure-time check for ioctl, and:

#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if !HAVE_FUNC_IOCTL || !defined TIOCSCTTY
# define ioctl(a, b, c) /* ignored */
#endif


so that in the function body, we can just blindly call this without #ifdefs:

  ioctl (slave_fd, TIOCSCTTY, NULL);

--
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Reply via email to