pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/34763: rxvt-unicode: Fix compilation for systems without SCM_RIGHTS



The following reply was made to PR pkg/34763; it has been noted by GNATS.

From: Christian Biere <christianbiere%gmx.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: pkg/34763: rxvt-unicode: Fix compilation for systems without 
SCM_RIGHTS
Date: Mon, 9 Oct 2006 19:36:16 +0200

 gnats-admin%netbsd.org@localhost wrote:
 > >Synopsis:       rxvt-unicode: Fix compilation for systems without SCM_RIGHTS
 
 After testing my patch on IRIX 6.5, I found some obvious mistakes in the
 patch and another issue i.e., TIOCSCTTY is undefined on IRIX and definitely
 nowhere found in any header files. This ioctl() or another method is apparently
 not necessary on IRIX as far as I interpret the manpages and the test results.
 I've verified that other terminal emulators use such a #ifdef for TIOCSTTY as
 well.
 
 
 --- configure  2006-02-08 23:48:51.000000000 +0100
 +++ configure  2006-10-09 18:49:02.000000000 +0200
 @@ -11787,7 +11787,6 @@
  {
    msghdr msg;
    iovec iov;
 -  char buf [100];
    char data = 0;
  
    iov.iov_base = &data;
 @@ -11795,6 +11794,9 @@
  
    msg.msg_iov        = &iov;
    msg.msg_iovlen     = 1;
 +
 +#ifdef SCM_RIGHTS
 +  char buf [100];
    msg.msg_control    = buf;
    msg.msg_controllen = sizeof buf;
  
 @@ -11804,6 +11806,11 @@
    cmsg->cmsg_len   = 100;
  
    *(int *)CMSG_DATA (cmsg) = 5;
 +#else /* !SCM_RIGHTS */
 +  int fd;
 +  msg.msg_accrights    = (caddr_t)&fd;
 +  msg.msg_accrightslen = sizeof fd;
 +#endif        /* SCM_RIGHTS */
  
    return sendmsg (3, &msg, 0);
  }
 --- ptytty.m4  2006-02-07 06:31:56.000000000 +0100
 +++ ptytty.m4  2006-10-09 18:49:53.000000000 +0200
 @@ -465,7 +465,6 @@
  {
    msghdr msg;
    iovec iov;
 -  char buf [100];
    char data = 0;
  
    iov.iov_base = &data;
 @@ -473,6 +472,9 @@
  
    msg.msg_iov        = &iov;
    msg.msg_iovlen     = 1;
 +
 +#ifdef SCM_RIGHTS
 +  char buf [100];
    msg.msg_control    = buf;
    msg.msg_controllen = sizeof buf;
  
 @@ -482,6 +484,11 @@
    cmsg->cmsg_len   = 100;
  
    *(int *)CMSG_DATA (cmsg) = 5;
 +#else /* !SCM_RIGHTS */
 +  int fd;
 +  msg.msg_accrights    = (caddr_t)&fd;
 +  msg.msg_accrightslen = sizeof fd;
 +#endif        /* SCM_RIGHTS */
  
    return sendmsg (3, &msg, 0);
  }
 --- src/fdpass.C       2006-06-06 01:01:00.000000000 +0200
 +++ src/fdpass.C       2006-10-09 18:47:25.000000000 +0200
 @@ -33,7 +33,8 @@
  
  #include "libptytty.h"
  
 -#ifndef CMSG_LEN // CMSG_SPACe && CMSG_LEN are rfc2292 extensions to unix
 +#if defined(SCM_RIGHTS) && !defined(CMSG_LEN)
 +// CMSG_SPACe && CMSG_LEN are rfc2292 extensions to unix
  # define CMSG_LEN(len) (sizeof (cmsghdr) + len)
  #endif
  
 @@ -42,7 +43,6 @@
  {
    msghdr msg;
    iovec iov;
 -  char buf [CMSG_LEN (sizeof (int))];
    char data = 0;
  
    iov.iov_base = &data;
 @@ -52,6 +52,9 @@
    msg.msg_namelen    = 0;
    msg.msg_iov        = &iov;
    msg.msg_iovlen     = 1;
 +
 +#ifdef SCM_RIGHTS
 +  char buf [CMSG_LEN (sizeof (int))];
    msg.msg_control    = (void *)buf;
    msg.msg_controllen = sizeof buf;
  
 @@ -63,6 +66,10 @@
    *(int *)CMSG_DATA (cmsg) = fd;
  
    msg.msg_controllen = cmsg->cmsg_len;
 +#else  /* SCM_RIGHTS */
 +  msg.msg_accrights  = (caddr_t)&fd;
 +  msg.msg_accrightslen = sizeof fd;
 +#endif /* !SCM_RIGHTS */
  
    return sendmsg (socket, &msg, 0) >= 0;
  }
 @@ -72,8 +79,8 @@
  {
    msghdr msg;
    iovec iov;
 -  char buf [CMSG_LEN (sizeof (int))];  /* ancillary data buffer */
    char data = 1;
 +  int fd;
  
    iov.iov_base = &data;
    iov.iov_len  = 1;
 @@ -82,6 +89,9 @@
    msg.msg_namelen    = 0;
    msg.msg_iov        = &iov;
    msg.msg_iovlen     = 1;
 +
 +#ifdef SCM_RIGHTS
 +  char buf [CMSG_LEN (sizeof (int))];  /* ancillary data buffer */
    msg.msg_control    = buf;
    msg.msg_controllen = sizeof buf;
  
 @@ -91,15 +101,26 @@
    cmsg->cmsg_len   = CMSG_LEN (sizeof (int));
  
    msg.msg_controllen = cmsg->cmsg_len;
 +#else /* !SCM_RIGHTS */
 +  msg.msg_accrights  = (caddr_t)&fd;
 +  msg.msg_accrightslen = sizeof fd;
 +#endif /* SCM_RIGHTS */
 +
 +  if (recvmsg (socket, &msg, 0) <= 0 || data != 0)
 +     return -1;
  
 -  if (recvmsg (socket, &msg, 0) <= 0
 -      || data               != 0
 -      || msg.msg_controllen < CMSG_LEN (sizeof (int))
 +#ifdef SCM_RIGHTS
 +  if (msg.msg_controllen < CMSG_LEN (sizeof (int))
        || cmsg->cmsg_level   != SOL_SOCKET
        || cmsg->cmsg_type    != SCM_RIGHTS
        || cmsg->cmsg_len     < CMSG_LEN (sizeof (int)))
      return -1;
  
 -  return *(int *)CMSG_DATA (cmsg);
 -}
 +  fd = *(int *)CMSG_DATA (cmsg);
 +#else /* SCM_RIGHTS */
 +  if (!msg.msg_accrights || msg.msg_accrightslen != sizeof fd)
 +    return -1;
 +#endif /* !SCM_RIGHTS */
  
 +  return fd;
 +}
 --- src/ptytty.C       2006-02-20 23:41:16.000000000 +0100
 +++ src/ptytty.C       2006-10-09 19:10:17.000000000 +0200
 @@ -233,7 +233,9 @@
      }
  #endif
  
 +#ifdef TIOCSCTTY
    ioctl (fd_tty, TIOCSCTTY, NULL);
 +#endif
  
    int fd = open ("/dev/tty", O_WRONLY);
    if (fd < 0)
 



Home | Main Index | Thread Index | Old Index