From nobody Wed Aug 16 13:52:44 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RQqMc3Xsdz4qhb0; Wed, 16 Aug 2023 13:52:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RQqMc2yTLz4bgG; Wed, 16 Aug 2023 13:52:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692193964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ooz1YUj50M+7KOntGb+lVSp42C11VYXriYWNOVjQnU4=; b=PUl3tqt8GbJr1WoDOR27iqhA15cPm5GCAZCMwjrpB2vWNo/+fB7LpmjsSllWC0w7kn43TY 1d0PpLsDMtIMOmgnM4GUPT1zt5j38WaG0wXbtzZi3t4v0iaU72m/L+c5NKiJVf5tiLBEnN taSBFQKGDAtvWfJwhrxb9SMHCb4Lj1dDRj8iw4j1qdlvgOqUIj8TSYlwzYDDsEBSP5PvqB LuLlAfulbcq6eo5pKEp+ji2U5Khc4f0U1/ktI04JaqhBDy+dqyxn8jB8bFG2PUjY9XUfuW xaI/axmUSWhkDdvYLppkidw5EHE9PyRoMZgRViceY0fFLeInrHdjwvs56l2e6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692193964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ooz1YUj50M+7KOntGb+lVSp42C11VYXriYWNOVjQnU4=; b=CnIvxVWhE0zefwfoYVEL7WasDZk70APXX7BVaW1tKKw0WvfN/1ZBIkbMwv9C+dxvH6aCSg Q0jm8iaM9jjZU2uWwv7Fwc8ZOPlpu0tkFtBlxc8q70JwCpJfzSb+XxiQcnBS75LbiqhEiG f0hhDhKxWb49xABHobL6IDWwZsZE3lj+a+UEuNeoDHPFIR15KCMHV+wjtUe0og75jTvfYP rrqIStVh2okn7oGNZX8XXODz1oXv8u7a7hEE4O+ok3amphEYoMUyXpY1IGZqAsG0nVvboy 9VCMmQ0CvN5BQM/KuepNWIO9/w4NGmkopBMA8gesv0CpH+4kXc1VtObnFWWvoQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692193964; a=rsa-sha256; cv=none; b=rrF5vbGEY7zXvKgWLMQzq90qmzXk3Dk7UpCR5ssQ33UWucY4Hrhy8AWpnqn4NtjHmiLmWG Txe8S1sLrEMPEQUNcO+W0iHnqV935CpSJP5gEbSikv1VZMWKt31mSWyniVofOFa/fFYrdr J7r/kMQGy0f/qstHNGnrWlHV6oPNMQdjXR+NNROVZWMsmwfnxComeyWMOHN5g6wbYPT+72 plpsK6SywqEdG4QfFJPVg/jGqui0Yr2Ro2F+1jv11rYsmEMRWshEJLMe4aCM9dIZd9VLkP mMK6wWFo/SO0fEiCpKXJtwWtNCnEH+zpOGvvWEoY0BgMCy9zwPAhS0mcJ+eL6A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RQqMc21cRztch; Wed, 16 Aug 2023 13:52:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37GDqiHx057630; Wed, 16 Aug 2023 13:52:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37GDqik0057627; Wed, 16 Aug 2023 13:52:44 GMT (envelope-from git) Date: Wed, 16 Aug 2023 13:52:44 GMT Message-Id: <202308161352.37GDqik0057627@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Rodrigo Osorio Subject: git: 7418bfa0e658 - main - sysutils/screen: Add session creation time when list active sessions List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rodrigo X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7418bfa0e65838e7f94bd82d1e02c5aac79b0555 Auto-Submitted: auto-generated The branch main has been updated by rodrigo: URL: https://cgit.FreeBSD.org/ports/commit/?id=7418bfa0e65838e7f94bd82d1e02c5aac79b0555 commit 7418bfa0e65838e7f94bd82d1e02c5aac79b0555 Author: Rodrigo Osorio AuthorDate: 2023-08-15 11:19:35 +0000 Commit: Rodrigo Osorio CommitDate: 2023-08-16 13:52:05 +0000 sysutils/screen: Add session creation time when list active sessions Reimplement Debian patches to display screen session creation time and sort the list of sessions by date. Output example for 'screen -ls' command --------------------------------------- There is a screen on: 14059.pts-7.1302amd64-head (08/15/23 10:02:52) (Attached) 1 Socket in /tmp/screens/S-root. Reviewed by: cy Differential Revision: https://reviews.freebsd.org/D41469 --- sysutils/screen/Makefile | 2 +- sysutils/screen/files/patch-doc_screen.1 | 11 +++++ sysutils/screen/files/patch-extern.h | 8 +++ sysutils/screen/files/patch-misc.c | 31 ++++++++++++ sysutils/screen/files/patch-socket.c | 84 ++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 1 deletion(-) diff --git a/sysutils/screen/Makefile b/sysutils/screen/Makefile index 050b2c503fff..a75a39f3146b 100644 --- a/sysutils/screen/Makefile +++ b/sysutils/screen/Makefile @@ -1,6 +1,6 @@ PORTNAME= screen PORTVERSION= 4.9.0 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= sysutils MASTER_SITES= GNU \ ftp://ftp.gnu.org/gnu/screen/ \ diff --git a/sysutils/screen/files/patch-doc_screen.1 b/sysutils/screen/files/patch-doc_screen.1 new file mode 100644 index 000000000000..59077d7be443 --- /dev/null +++ b/sysutils/screen/files/patch-doc_screen.1 @@ -0,0 +1,11 @@ +--- doc/screen.1.orig 2023-08-15 11:01:59 UTC ++++ doc/screen.1 +@@ -241,7 +241,7 @@ + .IR screen , + but prints a list of + .I pid.tty.host +-strings identifying your ++strings and creation timestamps identifying your + .I screen + sessions. + Sessions marked `detached' can be resumed with \*Qscreen \-r\*U. Those marked diff --git a/sysutils/screen/files/patch-extern.h b/sysutils/screen/files/patch-extern.h new file mode 100644 index 000000000000..99e9063cdd0f --- /dev/null +++ b/sysutils/screen/files/patch-extern.h @@ -0,0 +1,8 @@ +--- extern.h.orig 2023-08-15 08:44:47 UTC ++++ extern.h +@@ -512,3 +512,5 @@ + /* layout.c */ + extern void RemoveLayout __P((struct layout *)); + extern int LayoutDumpCanvas __P((struct canvas *, char *)); ++ ++extern time_t SessionCreationTime __P((const char *)); diff --git a/sysutils/screen/files/patch-misc.c b/sysutils/screen/files/patch-misc.c new file mode 100644 index 000000000000..1364b230d55a --- /dev/null +++ b/sysutils/screen/files/patch-misc.c @@ -0,0 +1,31 @@ +--- misc.c.orig 2022-01-28 14:06:02 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 @@ + } + + #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/screen/files/patch-socket.c b/sysutils/screen/files/patch-socket.c new file mode 100644 index 000000000000..cfa52856c2e7 --- /dev/null +++ b/sysutils/screen/files/patch-socket.c @@ -0,0 +1,84 @@ +--- socket.c.orig 2022-01-28 14:06:02 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; + + 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 (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; + #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; + #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; + } + }