/[packages]/updates/5/w3m/current/SOURCES/0001-implements-simple-session-management.patch
ViewVC logotype

Contents of /updates/5/w3m/current/SOURCES/0001-implements-simple-session-management.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1185998 - (show annotations) (download)
Wed Dec 27 22:39:26 2017 UTC (6 years, 3 months ago) by luigiwalser
File size: 5635 byte(s)
sync with cauldron to fix security issues (mga#19811)
1 From 8efbb1f90525d91c0f0bac38a678dd8d5f81d723 Mon Sep 17 00:00:00 2001
2 From: Thomas Blume <Thomas.Blume@suse.com>
3 Date: Thu, 24 Nov 2016 14:27:18 +0100
4 Subject: [PATCH] implements simple session management
5
6 added new option "-session=<sessionname>"
7
8 port of: w3m-0.4.1-session-mgmt.dif
9 ---
10 fm.h | 1 +
11 history.c | 22 ++++++++++++++++++++--
12 main.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
13 3 files changed, 84 insertions(+), 3 deletions(-)
14
15 diff --git a/fm.h b/fm.h
16 index 2227ec4..c016693 100644
17 --- a/fm.h
18 +++ b/fm.h
19 @@ -959,6 +959,7 @@ global int emacs_like_lineedit init(FALSE);
20 global int vi_prec_num init(FALSE);
21 global int label_topline init(FALSE);
22 global int nextpage_topline init(FALSE);
23 +global char *Session init(NULL);
24 global char *displayTitleTerm init(NULL);
25 global int displayLink init(FALSE);
26 global int displayLinkNumber init(FALSE);
27 diff --git a/history.c b/history.c
28 index f2a00b4..471059e 100644
29 --- a/history.c
30 +++ b/history.c
31 @@ -1,5 +1,6 @@
32 /* $Id: history.c,v 1.11 2003/09/26 17:59:51 ukai Exp $ */
33 #include "fm.h"
34 +#include <errno.h>
35
36 #ifdef USE_HISTORY
37 Buffer *
38 @@ -36,11 +37,21 @@ loadHistory(Hist *hist)
39 {
40 FILE *f;
41 Str line;
42 +#define FNAMELEN 255
43 + char fname[FNAMELEN+1] = HISTORY_FILE;
44 +
45
46 if (hist == NULL)
47 return;
48 - if ((f = fopen(rcFile(HISTORY_FILE), "rt")) == NULL)
49 + if (Session) {
50 + strncat(fname, ".", FNAMELEN -6 - strlen(fname));
51 + strncat(fname, Session, FNAMELEN -6 - strlen(fname));
52 + }
53 + if ((f = fopen(rcFile(fname), "rt")) == NULL) {
54 + if (errno != ENOENT)
55 + perror("error reading history file");
56 return;
57 + }
58
59 while (!feof(f)) {
60 line = Strfgets(f);
61 @@ -61,6 +72,8 @@ saveHistory(Hist *hist, size_t size)
62 HistItem *item;
63 char *tmpf;
64 int rename_ret;
65 +#define FNAMELEN 255
66 + char fname[FNAMELEN+1] = HISTORY_FILE;
67
68 if (hist == NULL || hist->list == NULL)
69 return;
70 @@ -80,7 +93,12 @@ saveHistory(Hist *hist, size_t size)
71 disp_err_message("Can't save history", FALSE);
72 return;
73 }
74 - rename_ret = rename(tmpf, rcFile(HISTORY_FILE));
75 +
76 + if (Session) {
77 + strncat(fname, ".", FNAMELEN -6 - strlen(fname));
78 + strncat(fname, Session, FNAMELEN -6 - strlen(fname));
79 + }
80 + rename_ret = rename(tmpf, rcFile(fname));
81 if (rename_ret != 0) {
82 disp_err_message("Can't save history", FALSE);
83 return;
84 diff --git a/main.c b/main.c
85 index 85b0003..fdc5429 100644
86 --- a/main.c
87 +++ b/main.c
88 @@ -7,6 +7,7 @@
89 #include <sys/stat.h>
90 #include <sys/types.h>
91 #include <unistd.h>
92 +#include <errno.h>
93 #include <fcntl.h>
94 #if defined(HAVE_WAITPID) || defined(HAVE_WAIT3)
95 #include <sys/wait.h>
96 @@ -242,6 +243,7 @@ fusage(FILE * f, int err)
97 fprintf(f, " -header string insert string as a header\n");
98 fprintf(f, " +<num> goto <num> line\n");
99 fprintf(f, " -num show line number\n");
100 + fprintf(f, " -session=<id> use session <id>\n");
101 fprintf(f, " -no-proxy don't use proxy\n");
102 #ifdef INET6
103 fprintf(f, " -4 IPv4 only (-o dns_order=4)\n");
104 @@ -283,6 +285,8 @@ static char *getCodePage(void);
105 #endif
106 #endif
107
108 +char *loadBufferInfo(void);
109 +
110 static GC_warn_proc orig_GC_warn_proc = NULL;
111 #define GC_WARN_KEEP_MAX (20)
112
113 @@ -750,6 +754,8 @@ main(int argc, char **argv, char **envp)
114 squeezeBlankLine = TRUE;
115 else if (!strcmp("-X", argv[i]))
116 Do_not_use_ti_te = TRUE;
117 + else if (!strncmp("-session=", argv[i], 9))
118 + Session = argv[i] + 9;
119 else if (!strcmp("-title", argv[i]))
120 displayTitleTerm = getenv("TERM");
121 else if (!strncmp("-title=", argv[i], 7))
122 @@ -800,6 +806,22 @@ main(int argc, char **argv, char **envp)
123 i++;
124 }
125
126 + /* if last session has been saved, get last URL */
127 + {
128 + char * str; /* we blantantly skip the release of this memory --
129 + this seems to be the way to do things in w3m anyway
130 + ...*/
131 + if (Session && (str = loadBufferInfo()) != NULL ) {
132 + /* The URL from last session overrides the URL(s) from the command
133 + * line */
134 + load_argv[0] = str;
135 + load_argc = 1;
136 + }
137 + }
138 +#ifdef USE_HISTORY
139 + loadHistory(URLHist);
140 +#endif /* not USE_HISTORY */
141 +
142 #ifdef __WATT32__
143 if (w3m_debug)
144 dbug_init();
145 @@ -1478,14 +1500,54 @@ tmpClearBuffer(Buffer *buf)
146 static Str currentURL(void);
147
148 #ifdef USE_BUFINFO
149 +char *
150 +loadBufferInfo()
151 +{
152 + FILE *fp;
153 + Str line;
154 + char *str;
155 +#define FNAMELEN 255
156 + char fname[FNAMELEN+1] = "bufinfo";
157 +
158 + if (Session) {
159 + strncat(fname, ".", FNAMELEN -6 - strlen(fname));
160 + strncat(fname, Session, FNAMELEN -6 - strlen(fname));
161 + }
162 + if ((fp = fopen(rcFile(fname), "r")) == NULL) {
163 + if (errno != ENOENT)
164 + perror("error reading bufinfo file");
165 + return NULL;
166 + }
167 + line = Strfgets(fp);
168 + Strchop(line);
169 + Strremovefirstspaces(line);
170 + Strremovetrailingspaces(line);
171 + fclose(fp);
172 + if (line->length == 0) {
173 + str=NULL;
174 + } else {
175 + str=allocStr(line->ptr, -1);
176 + }
177 + Strclear(line);
178 + Strfree(line);
179 + return str;
180 +}
181 +
182 void
183 saveBufferInfo()
184 {
185 FILE *fp;
186 +#define FNAMELEN 255
187 + char fname[FNAMELEN+1] = "bufinfo";
188
189 if (w3m_dump)
190 return;
191 - if ((fp = fopen(rcFile("bufinfo"), "w")) == NULL) {
192 + if (Session) {
193 + strncat(fname, ".", FNAMELEN -6 - strlen(fname));
194 + strncat(fname, Session, FNAMELEN -6 - strlen(fname));
195 + }
196 + if ((fp = fopen(rcFile(fname), "w")) == NULL) {
197 + perror("error writing bufinfo file");
198 return;
199 }
200 fprintf(fp, "%s\n", currentURL()->ptr);
201 --
202 2.6.6
203

  ViewVC Help
Powered by ViewVC 1.1.30