> From: Christian Weisgerber <na...@mips.inka.de>
> Date: Thu, Jan 3, 2013 at 9:31 PM
> Subject: Re: Unbreak utmp support for rxvt-unicode
> To: David Coppa <dco...@gmail.com>
> Cc: OpenBSD Ports <ports@openbsd.org>, Stuart Henderson
> <st...@openbsd.org>, l...@ecentrum.hu
> 
> 
> David Coppa:
> 
> > Well, a one-line patch only for the check at line 106 (
> > "msg.msg_controllen     >= CMSG_SPACE (sizeof (int))" ) is sufficient
> > to unbreak utmp support...
> >
> > Thoughts?
> 
> Fine by me.
> 
> The logic of CMSG_SPACE() vs. CMSG_LEN() on the receive side isn't
> clear to me either.
> 
> Does anybody understand why the pt_cv_tty_group check fails?

Found it using a stupid trick...

$ cat testgrp.c
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <grp.h>
#include <stdio.h>

int main()
{
  struct stat st;
  struct group *gr;
  char *tty;
  gr = getgrnam("tty");
  tty = ttyname(0);
  fprintf(stdout, "--> tty: %s\n", tty);
  if (gr != 0
      && tty != 0
      && (stat(tty, &st)) == 0
      && st.st_gid == gr->gr_gid) {
    fprintf(stdout, "ok!\n");
    return 0;
  } else {
    fprintf(stdout, "epic fail\n");
    return 1;
  }
}

Output from console:

$ ./testgrp
--> tty: /dev/ttyp9
ok!

Output from 'make configure':

checking for UNIX98 ptys... yes
checking for tty group... --> tty: (null)
epic fail
no


We can change the code into configure, but imho the CONFIGURE_ENV
approach is more maintainable.

Here's the new diff:

Index: Makefile
===================================================================
RCS file: /cvs/ports/x11/rxvt-unicode/Makefile,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile
--- Makefile    29 Dec 2012 13:55:35 -0000      1.22
+++ Makefile    4 Jan 2013 10:02:07 -0000
@@ -3,7 +3,7 @@
 COMMENT =      clone of rxvt with Unicode and Xft support
 
 DISTNAME =     rxvt-unicode-9.16
-REVISION =     0
+REVISION =     1
 CATEGORIES =   x11
 
 EXTRACT_SUFX = .tar.bz2
@@ -34,9 +34,10 @@ CONFIGURE_ARGS =     --enable-256-color \
                        --enable-perl \
                        --enable-pixbuf \
                        --enable-startup-notification \
+                       --enable-utmp \
+                       --enable-wtmp \
                        --with-term=rxvt-256color
-# XXX utmp recording should also be enabled, as per rxvt (which will
-# also require setgid utmp), but this currently fails
+CONFIGURE_ENV +=       pt_cv_tty_group=yes
 
 # missing locale support
 CONFIGURE_ARGS +=      --disable-xim
Index: patches/patch-libptytty_src_fdpass_C
===================================================================
RCS file: patches/patch-libptytty_src_fdpass_C
diff -N patches/patch-libptytty_src_fdpass_C
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-libptytty_src_fdpass_C        4 Jan 2013 10:02:07 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Unbreak utmp support. Fix error:
+"protocol error while reading pty/tty fds from helper process, aborting."
+
+--- libptytty/src/fdpass.C.orig        Sat May 19 03:57:47 2012
++++ libptytty/src/fdpass.C     Wed Jan  2 17:08:40 2013
+@@ -103,7 +103,7 @@ ptytty::recv_fd (int socket)
+ 
+   if (recvmsg (socket, &msg, 0) >  0
+       && data                   == 0
+-      && msg.msg_controllen     >= CMSG_SPACE (sizeof (int)))
++      && msg.msg_controllen     >= CMSG_LEN (sizeof (int)))
+     {
+       cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
+ 
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/x11/rxvt-unicode/pkg/PLIST,v
retrieving revision 1.5
diff -u -p -r1.5 PLIST
--- pkg/PLIST   28 Dec 2012 12:12:38 -0000      1.5
+++ pkg/PLIST   4 Jan 2013 10:02:07 -0000
@@ -1,7 +1,15 @@
 @comment $OpenBSD: PLIST,v 1.5 2012/12/28 12:12:38 sthen Exp $
+@mode g+s
+@group utmp
 @bin bin/urxvt
+@mode
+@group
 @bin bin/urxvtc
+@mode g+s
+@group utmp
 @bin bin/urxvtd
+@mode
+@group
 lib/urxvt/
 lib/urxvt/perl/
 lib/urxvt/perl/background

Reply via email to