diff --git a/sysutils/screen49/Makefile b/sysutils/screen49/Makefile index a7173267826b..580f13c0a7c1 100644 --- a/sysutils/screen49/Makefile +++ b/sysutils/screen49/Makefile @@ -1,123 +1,123 @@ PORTNAME= screen PORTVERSION= 4.9.1 -PORTREVISION= 5 +PORTREVISION= 6 CATEGORIES= sysutils MASTER_SITES= GNU \ ftp://ftp.gnu.org/gnu/screen/ \ ftp://gnu.mirror.iweb.com/screen/ \ http://gnu.mirror.iweb.com/screen/ \ http://mirror.sdunix.com/gnu/ \ ftp://mirrors.kernel.org/gnu/screen/ \ http://cschubert.com/distfiles/ \ LOCAL/cy .if !defined(MASTERDIR) PKGNAMESUFFIX= 49 CONFLICTS= screen-* .endif MAINTAINER= cy@FreeBSD.org COMMENT= Multi-screen window manager WWW= https://www.gnu.org/software/screen/ CONFLICTS+= screen-devel* LICENSE= GPLv3 OPTIONS_DEFINE= INFO NETHACK XTERM_256 SYSTEM_SCREENRC MULTIUSER \ NOSOCKETDIR OPTIONS_DEFAULT= INFO NETHACK XTERM_256 SOCKETS SYSTEM_SCREENRC \ NCURSES_DEFAULT MULTIUSER OPTIONS_SINGLE= IPC NCURSES OPTIONS_SINGLE_IPC= SOCKETS NAMED_PIPES OPTIONS_SINGLE_NCURSES= NCURSES_DEFAULT NCURSES_BASE NCURSES_PORT NETHACK_DESC= Enable nethack-style messages XTERM_256_DESC= Enable support for 256 colour xterm SOCKETS_DESC= Use new (4.2.1+) sockets for IPC (default) NAMED_PIPES_DESC= Use legacy (4.0.3) named pipes for IPC (override) SYSTEM_SCREENRC_DESC= Install system screenrc with helpful status line MULTIUSER_DESC= Install setuid-root screen to support multiuser MULTIUSER_PLIST_SUB= MULTISUID="@(,,4555) " MULTIUSER_PLIST_SUB_OFF=MULTISUID="@(,,0555) " NCURSES_DEFAULT_DESC= Depend on ncurses (ports if installed, otherwise base) NCURSES_BASE_DESC= Depend on ncurses in base NCURSES_PORT_DESC= Depend on devel/ncurses in ports NOSOCKETDIR_DESC= Use ~/.screen instead of socketdir NCURSES_DEFAULT_USES= ncurses NCURSES_BASE_USES= ncurses:base NCURSES_PORT_USES= ncurses:port OPTIONS_SUB= USES= autoreconf:build gmake cpe MAKE_ARGS+= WITH_MAN=1 CPE_VENDOR= gnu .include GNU_CONFIGURE= yes GNU_CONFIGURE_MANPREFIX= ${PREFIX}/share CFLAGS+= -I${NCURSESINC} LDFLAGS+= -L${NCURSESLIB} .if ${PORT_OPTIONS:MINFO} INFO= screen MAKE_ARGS+= WITH_INFO=1 USES+= makeinfo .endif # Enables support for 256 colour xterm. Note that you may need to # set up a custom termcap entry or .screenrc which modifies termcap # to contain the following: Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm # .if ${PORT_OPTIONS:MXTERM_256} CFLAGS+= -DCOLORS256 .endif .if ! ${PORT_OPTIONS:MNETHACK} CFLAGS+= -DNONETHACK .endif .if ${PORT_OPTIONS:MNOSOCKETDIR} CONFIGURE_ARGS+= --disable-socket-dir .endif .if defined(SCREEN_SOCKET_DIR) CONFIGURE_ARGS+= --with-socket-dir=${SCREEN_SOCKET_DIR} .endif post-patch: @${RM} ${WRKSRC}/doc/screen.info* # Bug 191029: Users can choose whether to use sockets or named pipes. # Choose sockets if you don't know what the difference is. # Choose named pipes if your environment is heterogeneous, # using both screen 4.0.3 and 4.2.1. # Bug 191017 pre-configure: cd ${WRKSRC} && ./autogen.sh post-configure-NAMED_PIPES-on: @${ECHO_CMD} '#define NAMEDPIPE 1' >> ${WRKSRC}/config.h @${ECHO_CMD} User selected named pipes override set. ETCDIR?= ${PREFIX}/etc post-install: @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} ${INSTALL_DATA} ${WRKSRC}/etc/etcscreenrc \ ${STAGEDIR}${EXAMPLESDIR}/screenrc.sample-1 ${INSTALL_DATA} ${FILESDIR}/screenrc.sample \ ${STAGEDIR}${EXAMPLESDIR}/screenrc.sample-2 @${MKDIR} ${STAGEDIR}${ETCDIR} .if ${PORT_OPTIONS:MSYSTEM_SCREENRC} ${INSTALL_DATA} ${FILESDIR}/screenrc.sample \ ${STAGEDIR}${ETCDIR}/screenrc.sample .else ${INSTALL_DATA} ${WRKSRC}/etc/etcscreenrc \ ${STAGEDIR}${ETCDIR}/screenrc.sample .endif .include diff --git a/sysutils/screen49/files/patch-attacher.c b/sysutils/screen49/files/patch-attacher.c index 0f89189898e3..c5f670bb6ceb 100644 --- a/sysutils/screen49/files/patch-attacher.c +++ b/sysutils/screen49/files/patch-attacher.c @@ -1,24 +1,93 @@ ---- attacher.c.orig 2003-09-08 07:24:48.000000000 -0700 -+++ attacher.c 2011-01-02 21:42:39.547897531 -0800 -@@ -662,7 +662,7 @@ +--- attacher.c.orig 2023-08-16 00:29:26 UTC ++++ attacher.c +@@ -73,7 +73,6 @@ extern int multiattach, multi_uid, own_uid; + #ifdef MULTIUSER + extern char *multi; + extern int multiattach, multi_uid, own_uid; +-extern int tty_mode, tty_oldmode; + # ifndef USE_SETEUID + static int multipipe[2]; + # endif +@@ -160,9 +159,6 @@ int how; + + if (pipe(multipipe)) + Panic(errno, "pipe"); +- if (chmod(attach_tty, 0666)) +- Panic(errno, "chmod %s", attach_tty); +- tty_oldmode = tty_mode; + eff_uid = -1; /* make UserContext fork */ + real_uid = multi_uid; + if ((ret = UserContext()) <= 0) +@@ -174,11 +170,6 @@ int how; + Panic(errno, "UserContext"); + close(multipipe[1]); + read(multipipe[0], &dummy, 1); +- if (tty_oldmode >= 0) +- { +- chmod(attach_tty, tty_oldmode); +- tty_oldmode = -1; +- } + ret = UserStatus(); + #ifdef LOCK + if (ret == SIG_LOCK) +@@ -224,9 +215,6 @@ int how; + xseteuid(multi_uid); + xseteuid(own_uid); + #endif +- if (chmod(attach_tty, 0666)) +- Panic(errno, "chmod %s", attach_tty); +- tty_oldmode = tty_mode; + } + # endif /* USE_SETEUID */ + #endif /* MULTIUSER */ +@@ -423,13 +411,6 @@ int how; + ContinuePlease = 0; + # ifndef USE_SETEUID + close(multipipe[1]); +-# else +- xseteuid(own_uid); +- if (tty_oldmode >= 0) +- if (chmod(attach_tty, tty_oldmode)) +- Panic(errno, "chmod %s", attach_tty); +- tty_oldmode = -1; +- xseteuid(real_uid); + # endif + } + #endif +@@ -505,14 +486,6 @@ AttacherFinit SIGDEFARG + close(s); + } + } +-#ifdef MULTIUSER +- if (tty_oldmode >= 0) +- { +- if (setuid(own_uid)) +- Panic(errno, "setuid"); +- chmod(attach_tty, tty_oldmode); +- } +-#endif + exit(0); + SIGRETURN; + } +@@ -732,7 +705,7 @@ LockTerminal() printf("\n"); prg = getenv("LOCKPRG"); - if (prg && strcmp(prg, "builtin") && !access(prg, X_OK)) + if (prg && (strcmp(prg, "builtin") || strcmp(prg,"builtin-passwd")) && !access(prg, X_OK)) { signal(SIGCHLD, SIG_DFL); debug1("lockterminal: '%s' seems executable, execl it!\n", prg); -@@ -676,7 +676,11 @@ - setuid(real_uid); /* this should be done already */ +@@ -751,7 +724,11 @@ LockTerminal() + Panic(errno, "setuid"); #endif closeallfiles(0); /* important: /etc/shadow may be open */ - execl(prg, "SCREEN-LOCK", NULL); + if (strcmp(prg,"builtin-passwd")) + /* use system passsword for lock */ + execl(prg, "SCREEN-LOCK", "-p", "-n", NULL); + else + execl(prg, "SCREEN-LOCK", NULL); exit(errno); } if (pid == -1) diff --git a/sysutils/screen49/files/patch-configure.ac b/sysutils/screen49/files/patch-configure.ac index 1f32616b3797..1fc7eb310d6a 100644 --- a/sysutils/screen49/files/patch-configure.ac +++ b/sysutils/screen49/files/patch-configure.ac @@ -1,75 +1,75 @@ ---- configure.ac.orig 2023-08-15 17:29:26.000000000 -0700 -+++ configure.ac 2024-01-02 18:30:11.205776000 -0800 -@@ -669,7 +669,7 @@ +--- configure.ac.orig 2023-08-16 00:29:26 UTC ++++ configure.ac +@@ -669,7 +669,7 @@ olibs="$LIBS" tgetent((char *)0, (char *)0); ],, olibs="$LIBS" -LIBS="-lcurses $olibs" +LIBS="-lcurses $olibs"; CC="$CC -I/usr/local/include" AC_CHECKING(libcurses) AC_TRY_LINK([ #include -@@ -756,19 +756,6 @@ +@@ -756,19 +756,6 @@ fi fi fi -if test "$cross_compiling" = no ; then -AC_CHECKING(for SVR4 ptys) -sysvr4ptys= -if test -c /dev/ptmx ; then -AC_TRY_LINK([ - #include -], [ - ptsname(0);grantpt(0);unlockpt(0); -],[AC_DEFINE(HAVE_SVR4_PTYS) -sysvr4ptys=1]) -fi -fi - AC_CHECK_FUNCS(getpt) dnl check for openpty() -@@ -900,11 +887,11 @@ +@@ -900,11 +887,11 @@ dnl dnl dnl **** utmp handling **** dnl -AC_CHECKING(getutent) +AC_CHECKING(getutxent) AC_TRY_LINK([ #include /* to get time_t on SCO */ #include -#if defined(SVR4) && !defined(DGUX) +#if defined(SVR4) && !defined(DGUX) || defined(__FreeBSD__) #include #define utmp utmpx #else -@@ -917,11 +904,11 @@ +@@ -917,11 +904,11 @@ LIBS="$LIBS -lgen" [int x = DEAD_PROCESS; pututline((struct utmp *)0); getutent();], AC_DEFINE(GETUTENT), olibs="$LIBS" LIBS="$LIBS -lgen" -AC_CHECKING(getutent with -lgen) +AC_CHECKING(getutxent with -lgen) AC_TRY_LINK([ #include #include -#if defined(SVR4) && !defined(DGUX) +#if defined(SVR4) && !defined(DGUX) || defined(__FreeBSD__) #include #define utmp utmpx #else -@@ -931,13 +918,13 @@ +@@ -931,13 +918,13 @@ AC_TRY_LINK([ #define pututline _pututline #endif ], -[int x = DEAD_PROCESS; pututline((struct utmp *)0); getutent();], AC_DEFINE(GETUTENT), LIBS="$olibs") +[int x = DEAD_PROCESS; pututxline((struct utmp *)0); getutxent();], AC_DEFINE(GETUTENT), LIBS="$olibs") ) AC_CHECKING(ut_host) AC_TRY_COMPILE([ #include #include -#if defined(SVR4) && !defined(DGUX) +#if defined(SVR4) && !defined(DGUX) || defined(__FreeBSD__) #include #define utmp utmpx #else diff --git a/sysutils/screen49/files/patch-doc__Makefile.in b/sysutils/screen49/files/patch-doc__Makefile.in index 8666be063fe5..c90450268d09 100644 --- a/sysutils/screen49/files/patch-doc__Makefile.in +++ b/sysutils/screen49/files/patch-doc__Makefile.in @@ -1,34 +1,34 @@ ---- doc/Makefile.in.orig 2014-04-29 20:26:42.618832001 -0700 -+++ doc/Makefile.in 2014-04-29 20:29:26.379384101 -0700 -@@ -31,7 +31,10 @@ - $(MAKEINFO) --no-split $(srcdir)/screen.texinfo -o screen.info +--- doc/Makefile.in.orig 2023-08-16 00:29:26 UTC ++++ doc/Makefile.in +@@ -31,7 +31,10 @@ install: installdirs + $(MAKEINFO) $(srcdir)/screen.texinfo -o screen.info install: installdirs +ifeq (${WITH_MAN},1) $(INSTALL_DATA) $(srcdir)/screen.1 $(DESTDIR)$(mandir)/man1/screen.1 +endif +ifeq (${WITH_INFO},1) -$(MAKE) screen.info -if test -f screen.info; then d=.; else d=$(srcdir); fi; \ if test -f $$d/screen.info; then \ -@@ -40,13 +43,19 @@ - install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/screen.info; \ +@@ -40,13 +43,19 @@ install: installdirs + install-info --info-dir=$(DESTDIR)$(infodir) $$d/screen.info; \ else true; fi; \ fi +endif uninstall: rm -f $(DESTDIR)$(mandir)/man1/screen.1 rm -f $(DESTDIR)$(infodir)/screen.info* installdirs: - $(srcdir)/../etc/mkinstalldirs $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(infodir) +ifeq (${WITH_MAN},1) + $(srcdir)/../etc/mkinstalldirs $(DESTDIR)$(mandir)/man1 +endif +ifeq (${WITH_INFO},1) + $(srcdir)/../etc/mkinstalldirs $(DESTDIR)$(infodir) +endif mostlyclean: -rm -f *.cp *.cps *.fn *.fns *.ky *.kys *.pg *.tp *.vr diff --git a/sysutils/screen49/files/patch-misc.c b/sysutils/screen49/files/patch-misc.c index 1364b230d55a..6ea949fbf7a4 100644 --- a/sysutils/screen49/files/patch-misc.c +++ b/sysutils/screen49/files/patch-misc.c @@ -1,31 +1,31 @@ ---- misc.c.orig 2022-01-28 14:06:02 UTC +--- misc.c.orig 2023-08-16 00:29:26 UTC +++ misc.c @@ -28,8 +28,10 @@ #include #include +#include #include /* mkdir() declaration */ #include +#include #include "config.h" #include "screen.h" -@@ -796,3 +798,17 @@ +@@ -720,3 +722,17 @@ xvsnprintf(char *s, int n, char *fmt, xva_list stack) } #endif + +time_t +SessionCreationTime(fifo) +const char *fifo; +{ + int pid = atoi(fifo); + if (pid <= 0) return 0; + + struct kinfo_proc * kip = kinfo_getproc(pid); + if (kip == 0) return 0; + time_t start = kip->ki_start.tv_sec; + free (kip); + return start; +} diff --git a/sysutils/screen49/files/patch-os.h b/sysutils/screen49/files/patch-os.h index 80e7ec3c0bcb..ca0237af91ac 100644 --- a/sysutils/screen49/files/patch-os.h +++ b/sysutils/screen49/files/patch-os.h @@ -1,33 +1,33 @@ ---- os.h.orig 2019-10-01 15:08:00.000000000 -0700 -+++ os.h 2019-10-28 19:37:41.585526000 -0700 -@@ -250,9 +250,11 @@ +--- os.h.orig 2023-08-16 00:29:26 UTC ++++ os.h +@@ -250,9 +250,11 @@ extern int errno; #endif #if defined(UTMPOK) || defined(BUGGYGETLOGIN) -# if defined(SVR4) && !defined(DGUX) && !defined(__hpux) && !defined(linux) +# if (defined(SVR4) && !defined(DGUX) && !defined(__hpux) && !defined(linux)) || defined(__FreeBSD_version) # include -# define UTMPFILE UTMPX_FILE +# ifdef UTMPX_FILE /* GNU extension */ +# define UTMPFILE UTMPX_FILE +# endif # define utmp utmpx # define getutent getutxent # define getutid getutxid @@ -507,7 +509,7 @@ typedef struct fd_set { int fds_bits[1]; } fd_set; */ #ifndef TERMCAP_BUFSIZE -# define TERMCAP_BUFSIZE 1023 +# define TERMCAP_BUFSIZE 1024 #endif #ifndef MAXPATHLEN -@@ -524,6 +526,6 @@ +@@ -524,6 +526,6 @@ typedef struct fd_set { int fds_bits[1]; } fd_set; /* Changing those you won't be able to attach to your old sessions * when changing those values in official tree don't forget to bump * MSG_VERSION */ -#define MAXTERMLEN 32 +#define MAXTERMLEN 63 #define MAXLOGINLEN 256 diff --git a/sysutils/screen49/files/patch-osdef.h.in b/sysutils/screen49/files/patch-osdef.h.in index 3b32fe80ed81..c8249fc3d3bc 100644 --- a/sysutils/screen49/files/patch-osdef.h.in +++ b/sysutils/screen49/files/patch-osdef.h.in @@ -1,19 +1,19 @@ ---- osdef.h.in.orig 2023-08-15 17:29:26.000000000 -0700 -+++ osdef.h.in 2024-07-17 20:59:56.936179000 -0700 +--- osdef.h.in.orig 2023-08-16 00:29:26 UTC ++++ osdef.h.in @@ -28,6 +28,8 @@ **************************************************************** */ +#include +#if defined(__FreeBSD_version) && __FreeBSD_version < 1500020 extern int printf __P((char *, ...)); extern int fprintf __P((FILE *, char *, ...)); extern int sprintf __P((char *, char *, ...)); -@@ -71,6 +73,7 @@ +@@ -71,6 +73,7 @@ extern void bcopy __P((char *, char *, int)); #else extern void bcopy __P((char *, char *, int)); #endif +#endif /* __FreeBSD_version */ #ifdef BSDWAIT struct rusage; /* for wait3 __P */ diff --git a/sysutils/screen49/files/patch-resize.c b/sysutils/screen49/files/patch-resize.c index a2af125f12ff..216fec9c1ab6 100644 --- a/sysutils/screen49/files/patch-resize.c +++ b/sysutils/screen49/files/patch-resize.c @@ -1,20 +1,20 @@ ---- resize.c.orig Mon Sep 8 07:26:31 2003 -+++ resize.c Mon Dec 1 17:16:29 2003 -@@ -682,6 +682,17 @@ - if (wi == 0) - he = hi = 0; +--- resize.c.orig 2023-08-16 00:29:26 UTC ++++ resize.c +@@ -683,6 +683,17 @@ int wi, he, hi; + he = MAXWIDTH; + } + if (wi > 1000) + { + Msg(0, "Window width too large, truncated"); + wi = 1000; + } + if (he > 1000) + { + Msg(0, "Window height too large, truncated"); + he = 1000; + } + if (p->w_width == wi && p->w_height == he && p->w_histheight == hi) { debug("ChangeWindowSize: No change.\n"); diff --git a/sysutils/screen49/files/patch-screen.c b/sysutils/screen49/files/patch-screen.c index 50b28c02a955..bde83a3b06cc 100644 --- a/sysutils/screen49/files/patch-screen.c +++ b/sysutils/screen49/files/patch-screen.c @@ -1,11 +1,120 @@ ---- screen.c.orig 2017-07-10 12:26:25.000000000 -0700 -+++ screen.c 2017-08-25 20:20:20.471073000 -0700 -@@ -2214,7 +2214,7 @@ +--- screen.c.orig 2023-08-16 00:29:26 UTC ++++ screen.c +@@ -230,8 +230,6 @@ int multiattach; + int multi_uid; + int own_uid; + int multiattach; +-int tty_mode; +-int tty_oldmode = -1; + #endif + + char HostName[MAXSTR]; +@@ -1009,9 +1007,6 @@ int main(int ac, char** av) + + /* ttyname implies isatty */ + SetTtyname(true, &st); +-#ifdef MULTIUSER +- tty_mode = (int)st.st_mode & 0777; +-#endif + + fl = fcntl(0, F_GETFL, 0); + if (fl != -1 && (fl & (O_RDWR|O_RDONLY|O_WRONLY)) == O_RDWR) +@@ -1127,15 +1122,28 @@ int main(int ac, char** av) + #endif + } + +- if (stat(SockPath, &st) == -1) +- Panic(errno, "Cannot access %s", SockPath); +- else +- if (!S_ISDIR(st.st_mode)) ++ if (stat(SockPath, &st) == -1) { ++ if (eff_uid == real_uid) { ++ Panic(errno, "Cannot access %s", SockPath); ++ } else { ++ Panic(0, "Error accessing %s", SockPath); ++ } ++ } else if (!S_ISDIR(st.st_mode)) { ++ if (eff_uid == real_uid || st.st_uid == real_uid) { + Panic(0, "%s is not a directory.", SockPath); ++ } else { ++ Panic(0, "Error accessing %s", SockPath); ++ } ++ } + #ifdef MULTIUSER + if (multi) { +- if ((int)st.st_uid != multi_uid) +- Panic(0, "%s is not the owner of %s.", multi, SockPath); ++ if ((int)st.st_uid != multi_uid) { ++ if (eff_uid == real_uid || st.st_uid == real_uid) { ++ Panic(0, "%s is not the owner of %s.", multi, SockPath); ++ } else { ++ Panic(0, "Error accessing %s", SockPath); ++ } ++ } + } + else + #endif +@@ -1149,9 +1157,13 @@ int main(int ac, char** av) + Panic(0, "You are not the owner of %s.", SockPath); + #endif + } +- +- if ((st.st_mode & 0777) != 0700) +- Panic(0, "Directory %s must have mode 700.", SockPath); ++ if ((st.st_mode & 0777) != 0700) { ++ if (eff_uid == real_uid || st.st_uid == real_uid) { ++ Panic(0, "Directory %s must have mode 700.", SockPath); ++ } else { ++ Panic(0, "Error accessing %s", SockPath); ++ } ++ } + if (SockMatch && index(SockMatch, '/')) + Panic(0, "Bad session name '%s'", SockMatch); + SockName = SockPath + strlen(SockPath) + 1; +@@ -1189,8 +1201,14 @@ int main(int ac, char** av) + else + exit(9 + (fo || oth ? 1 : 0) + fo); + } +- if (fo == 0) +- Panic(0, "No Sockets found in %s.\n", SockPath); ++ if (fo == 0) { ++ if (eff_uid == real_uid || st.st_uid == real_uid) { ++ Panic(0, "No Sockets found in %s.\n", SockPath); ++ } else { ++ Panic(0, "Error accessing %s", SockPath); ++ } ++ } ++ + Msg(0, "%d Socket%s in %s.", fo, fo > 1 ? "s" : "", SockPath); + eexit(0); + } +@@ -2170,20 +2188,6 @@ DEFINE_VARARGS_FN(Panic) + if (D_userpid) + Kill(D_userpid, SIG_BYE); + } +-#ifdef MULTIUSER +- if (tty_oldmode >= 0) { +- +-# ifdef USE_SETEUID +- if (setuid(own_uid)) +- xseteuid(own_uid); /* may be a loop. sigh. */ +-# else +- setuid(own_uid); +-# endif +- +- debug1("Panic: changing back modes from %s\n", attach_tty); +- chmod(attach_tty, tty_oldmode); +- } +-#endif + eexit(1); + } + +@@ -2234,7 +2238,7 @@ static char *pad_expand(char *buf, char *p, int numpad pn2 = pn = p + padlen; r = winmsg_numrend; while (p >= buf) { - if (r && *p != 127 && p - buf == winmsg_rendpos[r - 1]) { + if (r && p - buf == winmsg_rendpos[r - 1]) { winmsg_rendpos[--r] = pn - buf; continue; } diff --git a/sysutils/screen49/files/patch-socket.c b/sysutils/screen49/files/patch-socket.c index cfa52856c2e7..01bd213ae5c4 100644 --- a/sysutils/screen49/files/patch-socket.c +++ b/sysutils/screen49/files/patch-socket.c @@ -1,84 +1,97 @@ ---- socket.c.orig 2022-01-28 14:06:02 UTC +--- socket.c.orig 2025-05-13 14:58:03 UTC +++ socket.c -@@ -141,12 +141,14 @@ - char *firstn = NULL; - int nfound = 0, ngood = 0, ndead = 0, nwipe = 0, npriv = 0; - int nperfect = 0; -+ char timestr[64]; - struct sent - { - struct sent *next; - int mode; - char *name; -- } *slist, **slisttail, *sent, *nsent; -+ time_t time_created; -+ } *slist, **slisttail, *sent, *nsent, *schosen; +@@ -171,8 +171,13 @@ bool *is_sock; + xsetegid(real_gid); + #endif - if (match) - { -@@ -258,8 +260,13 @@ - sent->next = 0; - sent->name = SaveStr(name); - sent->mode = mode; -+ sent->time_created = SessionCreationTime(name); -+ for (slisttail = &slist; *slisttail; slisttail = &((*slisttail)->next)) -+ { -+ if ((*slisttail)->time_created < sent->time_created) break; -+ } -+ sent->next = *slisttail; - *slisttail = sent; -- slisttail = &sent->next; - nfound++; - sockfd = MakeClientSocket(0, *is_sock); - #ifdef USE_SETEUID -@@ -359,34 +366,42 @@ - } - for (sent = slist; sent; sent = sent->next) +- if ((dirp = opendir(SockPath)) == 0) +- Panic(errno, "Cannot opendir %s", SockPath); ++ if ((dirp = opendir(SockPath)) == 0) { ++ if (eff_uid == real_uid) { ++ Panic(errno, "Cannot opendir %s", SockPath); ++ } else { ++ Panic(0, "Error accessing %s", SockPath); ++ } ++ } + + slist = 0; + slisttail = &slist; +@@ -841,6 +846,11 @@ int pid; + return UserStatus(); + } + ++static void KillUnpriv(pid_t pid, int sig) { ++ UserContext(); ++ UserReturn(kill(pid, sig)); ++} ++ + #ifdef hpux + /* + * From: "F. K. Bruner" +@@ -926,14 +936,14 @@ struct win *wi; + { + Msg(errno, "Could not perform necessary sanity checks on pts device."); + close(i); +- Kill(pid, SIG_BYE); ++ KillUnpriv(pid, SIG_BYE); + return -1; + } + if (strcmp(ttyname_in_ns, m->m_tty)) + { + Msg(errno, "Attach: passed fd does not match tty: %s - %s!", ttyname_in_ns, m->m_tty[0] != '\0' ? m->m_tty : "(null)"); + close(i); +- Kill(pid, SIG_BYE); ++ KillUnpriv(pid, SIG_BYE); + return -1; + } + /* m->m_tty so far contains the actual name of the pts device in the +@@ -950,19 +960,19 @@ struct win *wi; { -+ if (sent->time_created == 0) -+ { -+ sprintf(timestr, "??" "?"); -+ } -+ else -+ { -+ strftime(timestr, 64, "%x %X", localtime(&sent->time_created)); -+ } - switch (sent->mode) - { - case 0700: -- printf("\t%s\t(Attached)\n", sent->name); -+ printf("\t%s\t(%s)\t(Attached)\n", sent->name, timestr); - break; - case 0600: -- printf("\t%s\t(Detached)\n", sent->name); -+ printf("\t%s\t(%s)\t(Detached)\n", sent->name, timestr); - break; + Msg(errno, "Attach: passed fd does not match tty: %s - %s!", m->m_tty, myttyname ? myttyname : "NULL"); + close(i); +- Kill(pid, SIG_BYE); ++ KillUnpriv(pid, SIG_BYE); + return -1; + } + } + else if ((i = secopen(m->m_tty, O_RDWR | O_NONBLOCK, 0)) < 0) + { + Msg(errno, "Attach: Could not open %s!", m->m_tty); +- Kill(pid, SIG_BYE); ++ KillUnpriv(pid, SIG_BYE); + return -1; + } #ifdef MULTIUSER - case 0701: -- printf("\t%s\t(Multi, attached)\n", sent->name); -+ printf("\t%s\t(%s)\t(Multi, attached)\n", sent->name, timestr); - break; - case 0601: -- printf("\t%s\t(Multi, detached)\n", sent->name); -+ printf("\t%s\t(%s)\t(Multi, detached)\n", sent->name, timestr); - break; + if (attach) +- Kill(pid, SIGCONT); ++ KillUnpriv(pid, SIGCONT); #endif - case -1: - /* No trigraphs here! */ -- printf("\t%s\t(Dead ?%c?)\n", sent->name, '?'); -+ printf("\t%s\t(%s)\t(Dead ?%c?)\n", sent->name, timestr, '?'); - break; - case -2: -- printf("\t%s\t(Removed)\n", sent->name); -+ printf("\t%s\t(%s)\t(Removed)\n", sent->name, timestr); - break; - case -3: -- printf("\t%s\t(Remote or dead)\n", sent->name); -+ printf("\t%s\t(%s)\t(Remote or dead)\n", sent->name, timestr); - break; - case -4: -- printf("\t%s\t(Private)\n", sent->name); -+ printf("\t%s\t(%s)\t(Private)\n", sent->name, timestr); - break; - } + + #if defined(ultrix) || defined(pyr) || defined(NeXT) +@@ -975,7 +985,7 @@ struct win *wi; + { + write(i, "Attaching from inside of screen?\n", 33); + close(i); +- Kill(pid, SIG_BYE); ++ KillUnpriv(pid, SIG_BYE); + Msg(0, "Attach msg ignored: coming from inside."); + return -1; } +@@ -986,7 +996,7 @@ struct win *wi; + { + write(i, "Access to session denied.\n", 26); + close(i); +- Kill(pid, SIG_BYE); ++ KillUnpriv(pid, SIG_BYE); + Msg(0, "Attach: access denied for user %s.", user); + return -1; + } +@@ -1304,7 +1314,7 @@ ReceiveMsg() + Msg(0, "Query attempt with bad pid(%d)!", m.m.command.apid); + } + else { +- Kill(m.m.command.apid, ++ KillUnpriv(m.m.command.apid, + (queryflag >= 0) + ? SIGCONT + : SIG_BYE); /* Send SIG_BYE if an error happened */ diff --git a/sysutils/screen49/files/patch-termcap.c b/sysutils/screen49/files/patch-termcap.c index cbe7a90f11a2..a7abaa54ce81 100644 --- a/sysutils/screen49/files/patch-termcap.c +++ b/sysutils/screen49/files/patch-termcap.c @@ -1,15 +1,15 @@ ---- termcap.c.orig 2020-02-05 12:09:38.000000000 -0800 -+++ termcap.c 2020-02-11 20:10:12.747990000 -0800 -@@ -361,11 +361,7 @@ +--- termcap.c.orig 2023-08-16 00:29:26 UTC ++++ termcap.c +@@ -361,11 +361,7 @@ int he; if (D_CG0) { if (D_CS0 == 0) -#ifdef TERMINFO - D_CS0 = "\033(%p1%c"; -#else - D_CS0 = "\033(%."; -#endif + D_CS0 = "\033(%p1%c"; /* Old ncurses can't handle %. */ if (D_CE0 == 0) D_CE0 = "\033(B"; D_AC = 0; diff --git a/sysutils/screen49/files/patch-terminfo__checktc.c b/sysutils/screen49/files/patch-terminfo__checktc.c index d4ffb75cc0c1..7c38ac40c386 100644 --- a/sysutils/screen49/files/patch-terminfo__checktc.c +++ b/sysutils/screen49/files/patch-terminfo__checktc.c @@ -1,18 +1,18 @@ ---- terminfo/checktc.c.orig Fri Sep 29 09:13:22 1995 -+++ terminfo/checktc.c Tue Apr 22 20:37:18 2003 -@@ -171,6 +171,7 @@ +--- terminfo/checktc.c.orig 2023-08-16 00:29:26 UTC ++++ terminfo/checktc.c +@@ -171,6 +171,7 @@ char *s; fflush(stdout); } +#ifndef __FreeBSD__ void CPutStr(s, c) char *s; int c; -@@ -178,6 +179,7 @@ +@@ -178,6 +179,7 @@ int c; tputs(tgoto(s, 0, c), 1, putcha); fflush(stdout); } +#endif /* __FreeBSD__ */ void CCPutStr(s, x, y) char *s; diff --git a/sysutils/screen49/files/patch-utmp.c b/sysutils/screen49/files/patch-utmp.c index 0573d96ceab5..e019f8cedc09 100644 --- a/sysutils/screen49/files/patch-utmp.c +++ b/sysutils/screen49/files/patch-utmp.c @@ -1,156 +1,156 @@ ---- utmp.c.orig 2023-08-15 17:29:26.000000000 -0700 -+++ utmp.c 2023-08-19 08:57:48.376313000 -0700 +--- utmp.c.orig 2023-08-16 00:29:26 UTC ++++ utmp.c @@ -26,6 +26,7 @@ **************************************************************** */ +#include #include #include #include -@@ -89,11 +90,13 @@ +@@ -89,11 +90,13 @@ static struct utmp *getutslot __P((slot_t)); static int pututslot __P((slot_t, struct utmp *, char *, struct win *)); static struct utmp *getutslot __P((slot_t)); #ifndef GETUTENT +#if 0 static struct utmp *getutent __P((void)); static void endutent __P((void)); static int initutmp __P((void)); static void setutent __P((void)); #endif +#endif #if defined(linux) && defined(GETUTENT) static struct utmp *xpututline __P((struct utmp *utmp)); # define pututline xpututline -@@ -102,9 +105,7 @@ +@@ -102,9 +105,7 @@ static char UtmpName[] = UTMPFILE; static int utmpok; static char UtmpName[] = UTMPFILE; -#ifndef UTMP_HELPER static int utmpfd = -1; -#endif # if defined(GETUTENT) && (!defined(SVR4) || defined(__hpux)) && ! defined(__CYGWIN__) -@@ -409,12 +410,6 @@ +@@ -409,12 +410,6 @@ struct win *wi; register slot_t slot; struct utmp u; int saved_ut; -#ifdef UTHOST - char *p; - char host[sizeof(D_loginhost) + 15]; -#else - char *host = 0; -#endif /* UTHOST */ wi->w_slot = (slot_t)0; if (!utmpok || wi->w_type != W_TYPE_PTY) -@@ -435,51 +430,13 @@ +@@ -435,51 +430,13 @@ struct win *wi; makeuser(&u, stripdev(wi->w_tty), LoginName, wi->w_pid); #ifdef UTHOST - host[sizeof(host) - 15] = '\0'; - if (display) - { - strncpy(host, D_loginhost, sizeof(host) - 15); - if (D_loginslot != (slot_t)0 && D_loginslot != (slot_t)-1 && host[0] != '\0') - { - /* - * we want to set our ut_host field to something like - * ":ttyhf:s.0" or - * "faui45:s.0" or - * "132.199.81.4:s.0" (even this may hurt..), but not - * "faui45.informati"......:s.0 - * HPUX uses host:0.0, so chop at "." and ":" (Eric Backus) - */ - for (p = host; *p; p++) - if ((*p < '0' || *p > '9') && (*p != '.')) - break; - if (*p) - { - for (p = host; *p; p++) - if (*p == '.' || (*p == ':' && p != host)) - { - *p = '\0'; - break; - } - } - } - else - { - strncpy(host + 1, stripdev(D_usertty), sizeof(host) - 15 - 1); - host[0] = ':'; - } - } - else - strncpy(host, "local", sizeof(host) - 15); - - sprintf(host + strlen(host), ":S.%d", wi->w_number); - debug1("rlogin hostname: '%s'\n", host); - # if !defined(_SEQUENT_) && !defined(sequent) - strncpy(u.ut_host, host, sizeof(u.ut_host)); + if (display) + strncpy(u.ut_host, D_loginhost, sizeof(u.ut_host)); # endif #endif /* UTHOST */ - if (pututslot(slot, &u, host, wi) == 0) + if (pututslot(slot, &u, D_loginhost, wi) == 0) { Msg(errno,"Could not write %s", UtmpName); UT_CLOSE; -@@ -607,7 +564,7 @@ +@@ -607,7 +564,7 @@ struct utmp *u; struct utmp *u; { u->ut_type = DEAD_PROCESS; -#if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__) +#if (!defined(linux) || defined(EMPTY)) && !defined(__CYGWIN__) && !defined(__FreeBSD__) u->ut_exit.e_termination = 0; u->ut_exit.e_exit = 0; #endif -@@ -640,7 +597,11 @@ +@@ -640,7 +597,11 @@ int pid; /* must use temp variable because of NetBSD/sparc64, where * ut_xtime is long(64) but time_t is int(32) */ (void)time(&now); - u->ut_time = now; +#if defined(__FreeBSD_version) && __FreeBSD_version < 900000 + u->ut_time = now; +#else + u->ut_tv.tv_sec = now; +#endif } static slot_t -@@ -670,6 +631,7 @@ +@@ -670,6 +631,7 @@ initutmp() return (utmpfd = open(UtmpName, O_RDWR)) >= 0; } +#if 0 static void setutent() { -@@ -694,6 +656,7 @@ +@@ -694,6 +656,7 @@ getutent() return 0; return &uent; } +#endif static struct utmp * getutslot(slot) -@@ -750,9 +713,13 @@ +@@ -750,9 +713,13 @@ int pid; { time_t now; strncpy(u->ut_line, line, sizeof(u->ut_line)); - strncpy(u->ut_name, user, sizeof(u->ut_name)); + strncpy(u->ut_user, user, sizeof(u->ut_user)); (void)time(&now); - u->ut_time = now; +#if defined(__FreeBSD_version) && __FreeBSD_version < 900000 + u->ut_time = now; +#else + u->ut_tv.tv_sec = now; +#endif } static slot_t