summaryrefslogtreecommitdiff
path: root/sysutils/screen49/files/patch-socket.c
blob: cfa52856c2e7685b57177997cbaf17c79e320569 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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;
 	    }
 	}