ports/142763: [PATCH] misc/dtach Make socket executable if client attached, take maintainership
Rob Farmer
rfarmer at predatorlabs.net
Wed Jan 13 03:50:01 UTC 2010
>Number: 142763
>Category: ports
>Synopsis: [PATCH] misc/dtach Make socket executable if client attached, take maintainership
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Wed Jan 13 03:50:00 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Rob Farmer
>Release: 9.0-CURRENT
>Organization:
>Environment:
FreeBSD amethyst.predatorlabs.net 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r202069: Mon Jan 11 00:32:29 PST 2010 rfarmer at amethyst.predatorlabs.net:/usr/obj/usr/src/sys/AMETHYST i386
>Description:
* Make socket executable if client attached (useful for scripts), obtained from upstream issue tracker
* Take maintainership
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
diff -ruN dtach.old/Makefile dtach/Makefile
--- dtach.old/Makefile 2010-01-12 10:30:00.000000000 -0800
+++ dtach/Makefile 2010-01-12 10:33:02.000000000 -0800
@@ -7,10 +7,11 @@
PORTNAME= dtach
PORTVERSION= 0.8
+PORTREVISION= 1
CATEGORIES= misc
MASTER_SITES= SF
-MAINTAINER= ports at FreeBSD.org
+MAINTAINER= rfarmer at predatorlabs.net
COMMENT= Emulates the detach feature of screen
GNU_CONFIGURE= yes
diff -ruN dtach.old/files/patch-master.c dtach/files/patch-master.c
--- dtach.old/files/patch-master.c 1969-12-31 16:00:00.000000000 -0800
+++ dtach/files/patch-master.c 2010-01-12 10:32:10.000000000 -0800
@@ -0,0 +1,65 @@
+--- master.c.orig 2008-01-30 21:59:54.000000000 -0800
++++ master.c 2010-01-12 10:30:56.000000000 -0800
+@@ -53,6 +53,8 @@
+ static struct client *clients;
+ /* The pseudo-terminal created for the child process. */
+ static struct pty the_pty;
++/* The mode of the socket */
++static mode_t socket_mode;
+
+ #ifndef HAVE_FORKPTY
+ pid_t forkpty(int *amaster, char *name, struct termios *termp,
+@@ -66,6 +68,19 @@
+ unlink(sockname);
+ }
+
++/* Check the actual mode of the socket */
++static void
++check_socket_mode(int has_attached_client)
++{
++ if (has_attached_client && ((socket_mode & 0100) != 0100)) {
++ socket_mode |= 0100;
++ chmod(sockname, socket_mode);
++ } else if (!has_attached_client && ((socket_mode & 0100) == 0100)) {
++ socket_mode &= ~0100;
++ chmod(sockname, socket_mode);
++ }
++}
++
+ /* Signal */
+ static RETSIGTYPE
+ die(int sig)
+@@ -206,7 +221,8 @@
+ return -1;
+ }
+ /* chmod it to prevent any suprises */
+- if (chmod(name, 0600) < 0)
++ socket_mode = 0600;
++ if (chmod(name, socket_mode) < 0)
+ {
+ close(s);
+ return -1;
+@@ -454,6 +470,8 @@
+ /* Loop forever. */
+ while (1)
+ {
++ int has_attached_client = 0;
++
+ /* Re-initialize the file descriptor set for select. */
+ FD_ZERO(&readfds);
+ FD_SET(s, &readfds);
+@@ -480,8 +498,14 @@
+ FD_SET(p->fd, &readfds);
+ if (p->fd > highest_fd)
+ highest_fd = p->fd;
++
++ if (p->attached) {
++ has_attached_client = 1;
++ }
+ }
+
++ check_socket_mode(has_attached_client);
++
+ /* Wait for something to happen. */
+ if (select(highest_fd + 1, &readfds, NULL, NULL, NULL) < 0)
+ {
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list