Files
2024-09-05 16:44:50 -04:00

77 lines
2.1 KiB
Diff

Apple's screen.c changes between upstream screen-4.0.3
and their release of screen, called screen-24.
You can view the screen-24 source at
https://opensource.apple.com/tarballs/screen/
Upstream screen-4.0.3 is released under the GPLv2,
so Apple's changes (this patch) is a derivative work and
also licensed under the GPLv2.
This patch was then rebased against the latest upstream
GNU Screen, which was version 4.6.2 and no longer required
many of Apple's changes. This was done by David Gilman
for MacPorts.
This patch is maintained separately from the window.c
changes since vproc.h and _CS_DARWIN_USER_TEMP_DIR require
macOS 10.5 or later.
--- screen.c 2024-08-28 15:55:03.000000000 -0400
+++ screen.c 2024-08-31 09:03:10.596073100 -0400
@@ -57,10 +57,19 @@
#include "list_generic.h"
#include "mark.h"
#include "utmp.h"
#include "winmsg.h"
+#ifdef __APPLE__
+#include <err.h>
+#include <TargetConditionals.h>
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
+#include <vproc.h>
+#include "vproc_priv.h"
+#endif
+#endif
+
extern char **environ;
int force_vt = 1;
int VBellWait;
int MsgWait;
@@ -906,11 +915,20 @@
exit(0);
} else if (rflag || xflag) {
if (Attach(MSG_ATTACH)) {
Attacher();
/* NOTREACHED */
+#ifdef __APPLE__
+ } else if (!multi && real_uid == eff_uid) {
+ static char DarwinSockDir[PATH_MAX];
+ if (confstr(_CS_DARWIN_USER_TEMP_DIR, DarwinSockDir, sizeof(DarwinSockDir))) {
+ strlcat(DarwinSockDir, ".screen", sizeof(DarwinSockDir));
+ SocketDir = DarwinSockDir;
+ }
}
+#endif /* __APPLE__ */
+
if (multiattach)
Panic(0, "Can't create sessions of other users.");
} else if (dflag && !mflag) {
SetTtyname(false, &st);
Attach(MSG_DETACH);
@@ -984,10 +1002,15 @@
} else
n = dup(attach_fd);
} else
n = -1;
+#if defined(__APPLE__) && !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
+ if (_vprocmgr_detach_from_console(0) != NULL)
+ errx(1, "can't detach from console");
+#endif
+
/*
* This guarantees that the session owner is listed, even when we
* start detached. From now on we should not refer to 'LoginName'
* any more, use users->u_name instead.
*/