From 868d352ff1c8f8140c7e412f34e65b6f415b7670 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Mon, 18 Jan 2021 22:02:33 +0000 Subject: Deploy mate-desktop/caja-extensions to github.com/mate-desktop/caja-extensions.git:gh-pages --- .../index.html | 97 ++ .../report-618ffa.html | 1023 ++++++++++++++++++++ .../report-c93de3.html | 1023 ++++++++++++++++++++ .../scanview.css | 62 ++ .../sorttable.js | 492 ++++++++++ 5 files changed, 2697 insertions(+) create mode 100644 2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/index.html create mode 100644 2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-618ffa.html create mode 100644 2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-c93de3.html create mode 100644 2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/scanview.css create mode 100644 2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/sorttable.js (limited to '2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec') diff --git a/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/index.html b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/index.html new file mode 100644 index 0000000..7e57682 --- /dev/null +++ b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/index.html @@ -0,0 +1,97 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@c2225914fbb4
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 11.0.0 (Fedora 11.0.0-2.fc33) +
Date:Mon Jan 4 13:32:50 2021
+

Bug Summary

+ + + + +
Bug TypeQuantityDisplay?
All Bugs2
Security
Potential insecure memory buffer bounds restriction in call 'strcpy'2
+

Reports

+ + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'caja-open-terminal.cappend_sftp_info2931View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'caja-open-terminal.cappend_sftp_info2941View Report
+ + diff --git a/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-618ffa.html b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-618ffa.html new file mode 100644 index 0000000..0db35da --- /dev/null +++ b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-618ffa.html @@ -0,0 +1,1023 @@ + + + +caja-open-terminal.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:caja-open-terminal.c
Warning:line 293, column 2
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name caja-open-terminal.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D HAVE_CONFIG_H -I . -I .. -D G_DISABLE_DEPRECATED -D GDK_PIXBUF_DISABLE_DEPRECATED -D MATELOCALEDIR="/usr/local/share/locale" -I .. -D G_LOG_DOMAIN="Caja-Open-Terminal" -D DATADIR="/usr/local/share" -I /usr/include/caja -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/open-terminal -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -o /rootdir/html-report/2021-01-04-133250-6297-1 -x c caja-open-terminal.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * caja-open-terminal.c
3 *
4 * Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Author: Christian Neumair <chris@gnome-de.org>
21 *
22 */
23
24#ifdef HAVE_CONFIG_H1
25 #include <config.h> /* for GETTEXT_PACKAGE */
26#endif
27
28#include "caja-open-terminal.h"
29
30#include <libcaja-extension/caja-menu-provider.h>
31#include <libcaja-extension/caja-configurable.h>
32
33#include <glib/gi18n-lib.h>
34#include <gtk/gtkicontheme.h>
35#include <gtk/gtkwidget.h>
36#include <gtk/gtkmain.h>
37
38#include <libmate-desktop/mate-desktop-item.h>
39#include <gio/gio.h>
40
41#include <errno(*__errno_location ()).h>
42#include <fcntl.h>
43#include <string.h> /* for strcmp, strdup, ... */
44#include <unistd.h> /* for chdir */
45#include <stdlib.h> /* for atoi */
46#include <sys/stat.h>
47
48#define COT_SCHEMA"org.mate.caja-open-terminal" "org.mate.caja-open-terminal"
49#define COT_DESKTOP_KEY"desktop-opens-home-dir" "desktop-opens-home-dir"
50#define CAJA_SCHEMA"org.mate.caja.preferences" "org.mate.caja.preferences"
51#define CAJA_DESKTOP_KEY"desktop-is-home-dir" "desktop-is-home-dir"
52#define TERM_SCHEMA"org.mate.applications-terminal" "org.mate.applications-terminal"
53#define TERM_EXEC_KEY"exec" "exec"
54
55static void caja_open_terminal_instance_init (CajaOpenTerminal *cvs);
56static void caja_open_terminal_class_init (CajaOpenTerminalClass *class);
57
58static GType terminal_type = 0;
59
60typedef enum {
61 FILE_INFO_LOCAL,
62 FILE_INFO_DESKTOP,
63 FILE_INFO_SFTP,
64 FILE_INFO_OTHER
65} TerminalFileInfo;
66
67static TerminalFileInfo
68get_terminal_file_info (CajaFileInfo *file_info)
69{
70 TerminalFileInfo ret;
71 char *uri;
72 char *uri_scheme;
73
74 uri = caja_file_info_get_activation_uri (file_info);
75 uri_scheme = g_uri_parse_scheme (uri);
76
77 if (strcmp (uri_scheme, "file") == 0) {
78 ret = FILE_INFO_LOCAL;
79 } else if (strcmp (uri_scheme, "x-caja-desktop") == 0) {
80 ret = FILE_INFO_DESKTOP;
81 } else if (strcmp (uri_scheme, "sftp") == 0 ||
82 strcmp (uri_scheme, "ssh") == 0) {
83 ret = FILE_INFO_SFTP;
84 } else {
85 ret = FILE_INFO_OTHER;
86 }
87
88 g_free (uri_scheme);
89 g_free (uri);
90
91 return ret;
92}
93
94static char *
95lookup_in_data_dir (const char *basename,
96 const char *data_dir)
97{
98 char *path;
99
100 path = g_build_filename (data_dir, basename, NULL((void*)0));
101 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
102 g_free (path);
103 return NULL((void*)0);
104 }
105
106 return path;
107}
108
109static char *
110lookup_in_data_dirs (const char *basename)
111{
112 const char * const *system_data_dirs;
113 const char *user_data_dir;
114 char *retval;
115 int i;
116
117 user_data_dir = g_get_user_data_dir ();
118 system_data_dirs = g_get_system_data_dirs ();
119
120 if ((retval = lookup_in_data_dir (basename, user_data_dir))) {
121 return retval;
122 }
123
124 for (i = 0; system_data_dirs[i]; i++) {
125 if ((retval = lookup_in_data_dir (basename, system_data_dirs[i])))
126 return retval;
127 }
128
129 return NULL((void*)0);
130}
131
132static inline gboolean
133desktop_opens_home_dir (void)
134{
135 gboolean result;
136 GSettings* settings;
137
138 settings = g_settings_new (COT_SCHEMA"org.mate.caja-open-terminal");
139 result = g_settings_get_boolean (settings, COT_DESKTOP_KEY"desktop-opens-home-dir");
140 g_object_unref (settings);
141 return result;
142}
143
144static inline gboolean
145set_desktop_opens_home_dir (gboolean val)
146{
147 gboolean result;
148 GSettings* settings;
149
150 settings = g_settings_new (COT_SCHEMA"org.mate.caja-open-terminal");
151 result = g_settings_set_boolean (settings, COT_DESKTOP_KEY"desktop-opens-home-dir", val);
152 g_object_unref (settings);
153 return result;
154}
155
156static inline gboolean
157desktop_is_home_dir (void)
158{
159 gboolean result;
160 GSettings* settings;
161
162 settings = g_settings_new (CAJA_SCHEMA"org.mate.caja.preferences");
163 result = g_settings_get_boolean (settings, CAJA_DESKTOP_KEY"desktop-is-home-dir");
164 g_object_unref (settings);
165 return result;
166}
167
168static inline gchar*
169default_terminal_application (void)
170{
171 gchar *result;
172 GSettings* settings;
173
174 settings = g_settings_new (TERM_SCHEMA"org.mate.applications-terminal");
175 result = g_settings_get_string (settings, TERM_EXEC_KEY"exec");
176 g_object_unref (settings);
177
178 if (result == NULL((void*)0) || strlen (result) == 0) {
179 g_free (result);
180 result = g_strdup ("mate-terminal");
181 }
182
183 return result;
184}
185
186static inline gboolean
187set_default_terminal_application (const gchar* exec)
188{
189 gboolean result;
190 GSettings* settings;
191
192 settings = g_settings_new (TERM_SCHEMA"org.mate.applications-terminal");
193 result = g_settings_set_string (settings, TERM_EXEC_KEY"exec", exec);
194 g_object_unref (settings);
195 return result;
196}
197
198static void
199parse_sftp_uri (GFile *file, char **host, guint *port, char **user,
200 char **path)
201{
202 char *uri = g_file_get_uri (file);
203 char *u, *h, *s, *p;
204 char *h_end;
205
206 g_assert (uri != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (uri != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 206, ((const char
*) (__func__)), "uri != NULL"); } while (0)
;
207
208 u = strchr(uri, ':');
209 g_assert (u != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (u != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 209, ((const char
*) (__func__)), "u != NULL"); } while (0)
;
210 u += 3; /* Skip over :// to userid */
211
212 p = strchr (u, '/');
213 h = strchr(u, '@');
214
215 if (h && ((p == NULL((void*)0)) || (h < p))) {
216 *h='\0';
217 h++;
218 } else {
219 h = u;
220 u = NULL((void*)0);
221 }
222
223 s = strchr(h, ':');
224
225 if (s && (p == NULL((void*)0) || s < p)) {
226 h_end = s;
227 *s = '\0';
228 s++;
229 } else {
230 h_end = p;
231 s = NULL((void*)0);
232 }
233
234 if (h_end == NULL((void*)0)) {
235 h_end = h + strlen(h);
236 }
237
238 *user = g_strdup(u);
239 *port = s == NULL((void*)0) ? 0 : atoi(s); /* FIXME: getservbyname ? */
240 *path = g_uri_unescape_string (p, "/");
241 *h_end = '\0';
242 *host = g_strdup(h);
243
244 g_free (uri);
245}
246
247static void
248append_sftp_info (char **terminal_exec,
249 CajaFileInfo *file_info)
250{
251 GFile *vfs_uri;
252 char *host_name, *path, *user_name;
253 char *user_host, *cmd, *quoted_cmd;
254 char *host_port_switch;
255 char *quoted_path;
256 char *remote_cmd;
257 char *quoted_remote_cmd;
258 guint host_port;
259
260 g_assert (terminal_exec != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (terminal_exec != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 260, ((const char
*) (__func__)), "terminal_exec != NULL"); } while (0)
;
261 g_assert (file_info != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (file_info != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 261, ((const char
*) (__func__)), "file_info != NULL"); } while (0)
;
262
263
264 vfs_uri = g_file_new_for_uri (caja_file_info_get_activation_uri (file_info));
265 g_assert (vfs_uri != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (vfs_uri != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 265, ((const char
*) (__func__)), "vfs_uri != NULL"); } while (0)
;
266
267 g_assert (g_file_has_uri_scheme(vfs_uri, "sftp")==TRUE ||do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (g_file_has_uri_scheme(vfs_uri, "sftp")==(!(0)) || g_file_has_uri_scheme
(vfs_uri, "ssh")==(!(0))) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 268, ((const char
*) (__func__)), "g_file_has_uri_scheme(vfs_uri, \"sftp\")==TRUE || g_file_has_uri_scheme(vfs_uri, \"ssh\")==TRUE"
); } while (0)
268 g_file_has_uri_scheme(vfs_uri, "ssh")==TRUE)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (g_file_has_uri_scheme(vfs_uri, "sftp")==(!(0)) || g_file_has_uri_scheme
(vfs_uri, "ssh")==(!(0))) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 268, ((const char
*) (__func__)), "g_file_has_uri_scheme(vfs_uri, \"sftp\")==TRUE || g_file_has_uri_scheme(vfs_uri, \"ssh\")==TRUE"
); } while (0)
;
269
270 parse_sftp_uri (vfs_uri, &host_name, &host_port, &user_name, &path);
271
272 if (host_port == 0) {
273 host_port_switch = g_strdup ("");
274 } else {
275 host_port_switch = g_strdup_printf ("-p %d", host_port);
276 }
277
278 if (user_name != NULL((void*)0)) {
279 user_host = g_strdup_printf ("%s@%s", user_name, host_name);
280 } else {
281 user_host = g_strdup (host_name);
282 }
283
284 quoted_path = g_shell_quote (path);
285 remote_cmd = g_strdup_printf ("cd %s && $SHELL -l", quoted_path);
286 quoted_remote_cmd = g_shell_quote (remote_cmd);
287
288 cmd = g_strdup_printf ("ssh %s %s -t %s", user_host, host_port_switch, quoted_remote_cmd);
289 quoted_cmd = g_shell_quote (cmd);
290 g_free (cmd);
291
292 *terminal_exec = g_realloc (*terminal_exec, strlen (*terminal_exec) + strlen (quoted_cmd) + 4 + 1);
293 strcpy (*terminal_exec + strlen (*terminal_exec), " -e ");
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
294 strcpy (*terminal_exec + strlen (*terminal_exec), quoted_cmd);
295
296 g_free (host_name);
297 g_free (user_name);
298 g_free (host_port_switch);
299 g_free (path);
300 g_free (quoted_path);
301
302 g_free (remote_cmd);
303 g_free (quoted_remote_cmd);
304 g_free (quoted_cmd);
305 g_free (user_host);
306 g_object_unref (vfs_uri);
307}
308
309static void
310open_terminal_callback (CajaMenuItem *item,
311 CajaFileInfo *file_info)
312{
313 GdkDisplay *display;
314 const gchar *display_str;
315 const gchar *old_display_str;
316 gchar *uri;
317 gchar **argv, *terminal_exec;
318 gchar *working_directory;
319 gchar *dfile;
320 MateDesktopItem *ditem;
321 GdkScreen *screen;
322
323 terminal_exec = default_terminal_application();
324
325 switch (get_terminal_file_info (file_info)) {
326 case FILE_INFO_LOCAL:
327 uri = caja_file_info_get_activation_uri (file_info);
328 if (uri != NULL((void*)0)) {
329 working_directory = g_filename_from_uri (uri, NULL((void*)0), NULL((void*)0));
330 } else {
331 working_directory = g_strdup (g_get_home_dir ());
332 }
333 g_free (uri);
334 break;
335
336 case FILE_INFO_DESKTOP:
337 if (desktop_is_home_dir () || desktop_opens_home_dir ()) {
338 working_directory = g_strdup (g_get_home_dir ());
339 } else {
340 working_directory = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
341 }
342 break;
343
344 case FILE_INFO_SFTP:
345 working_directory = NULL((void*)0);
346 append_sftp_info (&terminal_exec, file_info);
347 break;
348
349 case FILE_INFO_OTHER:
350 default:
351 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 351, ((const char*) (__func__)), ((void*)0)); } while (0)
;
352 }
353
354 if (g_str_has_prefix (terminal_exec, "mate-terminal")) {
355 dfile = lookup_in_data_dirs ("applications/mate-terminal.desktop");
356 } else {
357 dfile = NULL((void*)0);
358 }
359
360 g_shell_parse_argv (terminal_exec, NULL((void*)0), &argv, NULL((void*)0));
361
362 display_str = NULL((void*)0);
363 old_display_str = g_getenv ("DISPLAY");
364
365 screen = g_object_get_data (G_OBJECT (item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
, "CajaOpenTerminal::screen");
366 display = gdk_screen_get_display (screen);
367 if (screen != NULL((void*)0)) {
368 display_str = gdk_display_get_name (display);
369 g_setenv ("DISPLAY", display_str, TRUE(!(0)));
370 }
371
372 if (dfile != NULL((void*)0)) {
373 int orig_cwd = -1;
374
375 do {
376 orig_cwd = open (".", O_RDONLY00);
377 } while (orig_cwd == -1 && errno(*__errno_location ()) == EINTR4);
378
379 if (orig_cwd == -1) {
380 g_message ("CajaOpenTerminal: Failed to open current Caja working directory.");
381 } else if (working_directory != NULL((void*)0)) {
382
383 if (chdir (working_directory) == -1) {
384 int ret;
385
386 g_message ("CajaOpenTerminal: Failed to change Caja working directory to \"%s\".",
387 working_directory);
388
389 do {
390 ret = close (orig_cwd);
391 } while (ret == -1 && errno(*__errno_location ()) == EINTR4);
392
393 if (ret == -1) {
394 g_message ("CajaOpenTerminal: Failed to close() current Caja working directory.");
395 }
396
397 orig_cwd = -1;
398 }
399 }
400
401 ditem = mate_desktop_item_new_from_file (dfile, 0, NULL((void*)0));
402
403 mate_desktop_item_set_string (ditem, "Exec", terminal_exec);
404 if (gtk_get_current_event_time () > 0) {
405 mate_desktop_item_set_launch_time (ditem, gtk_get_current_event_time ());
406 }
407 mate_desktop_item_launch (ditem, NULL((void*)0), MATE_DESKTOP_ITEM_LAUNCH_USE_CURRENT_DIR, NULL((void*)0));
408 mate_desktop_item_unref (ditem);
409 g_free (dfile);
410
411 if (orig_cwd != -1) {
412 int ret;
413
414 ret = fchdir (orig_cwd);
415 if (ret == -1) {
416 g_message ("CajaOpenTerminal: Failed to change back Caja working directory to original location after changing it to \"%s\".",
417 working_directory);
418 }
419
420 do {
421 ret = close (orig_cwd);
422 } while (ret == -1 && errno(*__errno_location ()) == EINTR4);
423
424 if (ret == -1) {
425 g_message ("CajaOpenTerminal: Failed to close Caja working directory.");
426 }
427 }
428 } else {
429 g_spawn_async (working_directory,
430 argv,
431 NULL((void*)0),
432 G_SPAWN_SEARCH_PATH,
433 NULL((void*)0),
434 NULL((void*)0),
435 NULL((void*)0),
436 NULL((void*)0));
437 }
438
439 g_setenv ("DISPLAY", old_display_str, TRUE(!(0)));
440
441 g_strfreev (argv);
442 g_free (terminal_exec);
443 g_free (working_directory);
444}
445
446static CajaMenuItem *
447open_terminal_menu_item_new (CajaFileInfo *file_info,
448 TerminalFileInfo terminal_file_info,
449 GdkScreen *screen,
450 gboolean is_file_item)
451{
452 CajaMenuItem *ret;
453 const char *name;
454 const char *tooltip;
455
456 switch (terminal_file_info) {
457 case FILE_INFO_LOCAL:
458 case FILE_INFO_SFTP:
459 name = _("Open in _Terminal")((char *) g_dgettext ("caja-extensions", "Open in _Terminal")
)
;
460 if (is_file_item) {
461 tooltip = _("Open the currently selected folder in a terminal")((char *) g_dgettext ("caja-extensions", "Open the currently selected folder in a terminal"
))
;
462 } else {
463 tooltip = _("Open the currently open folder in a terminal")((char *) g_dgettext ("caja-extensions", "Open the currently open folder in a terminal"
))
;
464 }
465 break;
466
467 case FILE_INFO_DESKTOP:
468 if (desktop_opens_home_dir ()) {
469 name = _("Open _Terminal")((char *) g_dgettext ("caja-extensions", "Open _Terminal"));
470 tooltip = _("Open a terminal")((char *) g_dgettext ("caja-extensions", "Open a terminal"));
471 } else {
472 name = _("Open in _Terminal")((char *) g_dgettext ("caja-extensions", "Open in _Terminal")
)
;
473 tooltip = _("Open the currently open folder in a terminal")((char *) g_dgettext ("caja-extensions", "Open the currently open folder in a terminal"
))
;
474 }
475 break;
476
477 case FILE_INFO_OTHER:
478 default:
479 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 479, ((const char*) (__func__)), ((void*)0)); } while (0)
;
480 }
481
482 ret = caja_menu_item_new ("CajaOpenTerminal::open_terminal",
483 name, tooltip, "terminal");
484
485 g_object_set_data (G_OBJECT (ret)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
ret)), (((GType) ((20) << (2))))))))
,
486 "CajaOpenTerminal::screen",
487 screen);
488
489 g_object_set_data_full (G_OBJECT (ret)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
ret)), (((GType) ((20) << (2))))))))
, "file-info",
490 g_object_ref (file_info),
491 (GDestroyNotify) g_object_unref);
492 g_signal_connect (ret, "activate",g_signal_connect_data ((ret), ("activate"), (((GCallback) (open_terminal_callback
))), (file_info), ((void*)0), (GConnectFlags) 0)
493 G_CALLBACK (open_terminal_callback),g_signal_connect_data ((ret), ("activate"), (((GCallback) (open_terminal_callback
))), (file_info), ((void*)0), (GConnectFlags) 0)
494 file_info)g_signal_connect_data ((ret), ("activate"), (((GCallback) (open_terminal_callback
))), (file_info), ((void*)0), (GConnectFlags) 0)
;
495
496 return ret;
497}
498
499static GList *
500caja_open_terminal_get_background_items (CajaMenuProvider *provider,
501 GtkWidget *window,
502 CajaFileInfo *file_info)
503{
504 CajaMenuItem *item;
505 TerminalFileInfo terminal_file_info;
506
507 terminal_file_info = get_terminal_file_info (file_info);
508 switch (terminal_file_info) {
509 case FILE_INFO_LOCAL:
510 case FILE_INFO_DESKTOP:
511 case FILE_INFO_SFTP:
512 item = open_terminal_menu_item_new (file_info, terminal_file_info, gtk_widget_get_screen (window), FALSE(0));
513 return g_list_append (NULL((void*)0), item);
514
515 case FILE_INFO_OTHER:
516 return NULL((void*)0);
517
518 default:
519 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 519, ((const char*) (__func__)), ((void*)0)); } while (0)
;
520 }
521}
522
523static GList *
524caja_open_terminal_get_file_items (CajaMenuProvider *provider,
525 GtkWidget *window,
526 GList *files)
527{
528 CajaMenuItem *item;
529 TerminalFileInfo terminal_file_info;
530
531 if (g_list_length (files) != 1 ||
532 (!caja_file_info_is_directory (files->data) &&
533 caja_file_info_get_file_type (files->data) != G_FILE_TYPE_SHORTCUT &&
534 caja_file_info_get_file_type (files->data) != G_FILE_TYPE_MOUNTABLE)) {
535 return NULL((void*)0);
536 }
537
538 terminal_file_info = get_terminal_file_info (files->data);
539 switch (terminal_file_info) {
540 case FILE_INFO_LOCAL:
541 case FILE_INFO_SFTP:
542 item = open_terminal_menu_item_new (files->data, terminal_file_info, gtk_widget_get_screen (window), TRUE(!(0)));
543 return g_list_append (NULL((void*)0), item);
544
545 case FILE_INFO_DESKTOP:
546 case FILE_INFO_OTHER:
547 return NULL((void*)0);
548
549 default:
550 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 550, ((const char*) (__func__)), ((void*)0)); } while (0)
;
551 }
552}
553
554static void
555caja_open_terminal_run_config (CajaConfigurable *provider)
556{
557 GtkWidget *extconf_dialog, *extconf_content, *extconf_desktophomedir, *extconf_inform1, *extconf_inform2, *extconf_exec;
558 gchar * terminal;
559
560 extconf_dialog = gtk_dialog_new ();
561 extconf_content = gtk_dialog_get_content_area (GTK_DIALOG (extconf_dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_dialog_get_type ()))))))
);
562
563 extconf_desktophomedir = gtk_check_button_new_with_label (_("Open at Home if trying to open on desktop")((char *) g_dgettext ("caja-extensions", "Open at Home if trying to open on desktop"
))
);
564 extconf_exec = gtk_entry_new ();
565 extconf_inform1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
566 extconf_inform2 = gtk_label_new (_("Terminal application:")((char *) g_dgettext ("caja-extensions", "Terminal application:"
))
);
567
568 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (extconf_desktophomedir)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_desktophomedir)), ((gtk_toggle_button_get_type (
)))))))
, desktop_opens_home_dir ());
569
570 terminal = default_terminal_application();
571 gtk_entry_set_text (GTK_ENTRY (extconf_exec)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_exec)), ((gtk_entry_get_type ()))))))
, terminal);
572 g_free (terminal);
573
574 gtk_container_add (GTK_CONTAINER (extconf_inform1)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_inform1)), ((gtk_container_get_type ()))))))
, extconf_inform2);
575 gtk_widget_show (extconf_inform2);
576 gtk_container_add (GTK_CONTAINER (extconf_inform1)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_inform1)), ((gtk_container_get_type ()))))))
, extconf_exec);
577 gtk_widget_show (extconf_exec);
578 gtk_box_set_child_packing (GTK_BOX (extconf_inform1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((extconf_inform1
)), ((gtk_box_get_type ()))))))
, extconf_exec, FALSE(0), FALSE(0), 0, GTK_PACK_END);
579
580 gtk_container_add (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, extconf_desktophomedir);
581 gtk_widget_show (extconf_desktophomedir);
582 gtk_container_add (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, extconf_inform1);
583 gtk_widget_show (extconf_inform1);
584 gtk_container_add (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, extconf_exec);
585 gtk_widget_show (extconf_exec);
586 gtk_dialog_add_buttons (GTK_DIALOG (extconf_dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_dialog_get_type ()))))))
, _("Close")((char *) g_dgettext ("caja-extensions", "Close")), GTK_RESPONSE_OK, NULL((void*)0));
587
588 gtk_container_set_border_width (GTK_CONTAINER (extconf_inform1)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_inform1)), ((gtk_container_get_type ()))))))
, 6);
589 gtk_container_set_border_width (GTK_CONTAINER (extconf_dialog)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_dialog)), ((gtk_container_get_type ()))))))
, 6);
590 gtk_container_set_border_width (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, 6);
591
592 gtk_window_set_title (GTK_WINDOW (extconf_dialog)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_window_get_type ()))))))
, _("open-terminal Configuration")((char *) g_dgettext ("caja-extensions", "open-terminal Configuration"
))
);
593 gtk_dialog_run (GTK_DIALOG (extconf_dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_dialog_get_type ()))))))
);
594
595 set_default_terminal_application (gtk_entry_get_text (GTK_ENTRY (extconf_exec)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_exec)), ((gtk_entry_get_type ()))))))
));
596 set_desktop_opens_home_dir (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (extconf_desktophomedir)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_desktophomedir)), ((gtk_toggle_button_get_type (
)))))))
));
597
598 gtk_widget_destroy (GTK_WIDGET (extconf_dialog)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_widget_get_type ()))))))
);
599}
600
601static void
602caja_open_terminal_menu_provider_iface_init (CajaMenuProviderIface *iface)
603{
604 iface->get_background_items = caja_open_terminal_get_background_items;
605 iface->get_file_items = caja_open_terminal_get_file_items;
606}
607
608static void
609caja_open_terminal_configurable_iface_init (CajaConfigurableIface *iface)
610{
611 iface->run_config = caja_open_terminal_run_config;
612}
613
614static void
615caja_open_terminal_instance_init (CajaOpenTerminal *cvs)
616{
617}
618
619static void
620caja_open_terminal_class_init (CajaOpenTerminalClass *class)
621{
622}
623
624GType
625caja_open_terminal_get_type (void)
626{
627 return terminal_type;
628}
629
630void
631caja_open_terminal_register_type (GTypeModule *module)
632{
633 static const GTypeInfo info = {
634 sizeof (CajaOpenTerminalClass),
635 (GBaseInitFunc) NULL((void*)0),
636 (GBaseFinalizeFunc) NULL((void*)0),
637 (GClassInitFunc) caja_open_terminal_class_init,
638 NULL((void*)0),
639 NULL((void*)0),
640 sizeof (CajaOpenTerminal),
641 0,
642 (GInstanceInitFunc) caja_open_terminal_instance_init,
643 };
644
645 static const GInterfaceInfo menu_provider_iface_info = {
646 (GInterfaceInitFunc) caja_open_terminal_menu_provider_iface_init,
647 NULL((void*)0),
648 NULL((void*)0)
649 };
650
651 static const GInterfaceInfo configurable_iface_info = {
652 (GInterfaceInitFunc) caja_open_terminal_configurable_iface_init,
653 NULL((void*)0),
654 NULL((void*)0)
655 };
656
657 terminal_type = g_type_module_register_type (module,
658 G_TYPE_OBJECT((GType) ((20) << (2))),
659 "CajaOpenTerminal",
660 &info, 0);
661
662 g_type_module_add_interface (module,
663 terminal_type,
664 CAJA_TYPE_MENU_PROVIDER(caja_menu_provider_get_type ()),
665 &menu_provider_iface_info);
666
667 g_type_module_add_interface (module,
668 terminal_type,
669 CAJA_TYPE_CONFIGURABLE(caja_configurable_get_type ()),
670 &configurable_iface_info);
671}
diff --git a/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-c93de3.html b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-c93de3.html new file mode 100644 index 0000000..f7f094b --- /dev/null +++ b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/report-c93de3.html @@ -0,0 +1,1023 @@ + + + +caja-open-terminal.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:caja-open-terminal.c
Warning:line 294, column 2
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name caja-open-terminal.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D HAVE_CONFIG_H -I . -I .. -D G_DISABLE_DEPRECATED -D GDK_PIXBUF_DISABLE_DEPRECATED -D MATELOCALEDIR="/usr/local/share/locale" -I .. -D G_LOG_DOMAIN="Caja-Open-Terminal" -D DATADIR="/usr/local/share" -I /usr/include/caja -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/mate-desktop-2.0 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wno-sign-compare -fdebug-compilation-dir /rootdir/open-terminal -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -o /rootdir/html-report/2021-01-04-133250-6297-1 -x c caja-open-terminal.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * caja-open-terminal.c
3 *
4 * Copyright (C) 2004, 2005 Free Software Foundation, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Author: Christian Neumair <chris@gnome-de.org>
21 *
22 */
23
24#ifdef HAVE_CONFIG_H1
25 #include <config.h> /* for GETTEXT_PACKAGE */
26#endif
27
28#include "caja-open-terminal.h"
29
30#include <libcaja-extension/caja-menu-provider.h>
31#include <libcaja-extension/caja-configurable.h>
32
33#include <glib/gi18n-lib.h>
34#include <gtk/gtkicontheme.h>
35#include <gtk/gtkwidget.h>
36#include <gtk/gtkmain.h>
37
38#include <libmate-desktop/mate-desktop-item.h>
39#include <gio/gio.h>
40
41#include <errno(*__errno_location ()).h>
42#include <fcntl.h>
43#include <string.h> /* for strcmp, strdup, ... */
44#include <unistd.h> /* for chdir */
45#include <stdlib.h> /* for atoi */
46#include <sys/stat.h>
47
48#define COT_SCHEMA"org.mate.caja-open-terminal" "org.mate.caja-open-terminal"
49#define COT_DESKTOP_KEY"desktop-opens-home-dir" "desktop-opens-home-dir"
50#define CAJA_SCHEMA"org.mate.caja.preferences" "org.mate.caja.preferences"
51#define CAJA_DESKTOP_KEY"desktop-is-home-dir" "desktop-is-home-dir"
52#define TERM_SCHEMA"org.mate.applications-terminal" "org.mate.applications-terminal"
53#define TERM_EXEC_KEY"exec" "exec"
54
55static void caja_open_terminal_instance_init (CajaOpenTerminal *cvs);
56static void caja_open_terminal_class_init (CajaOpenTerminalClass *class);
57
58static GType terminal_type = 0;
59
60typedef enum {
61 FILE_INFO_LOCAL,
62 FILE_INFO_DESKTOP,
63 FILE_INFO_SFTP,
64 FILE_INFO_OTHER
65} TerminalFileInfo;
66
67static TerminalFileInfo
68get_terminal_file_info (CajaFileInfo *file_info)
69{
70 TerminalFileInfo ret;
71 char *uri;
72 char *uri_scheme;
73
74 uri = caja_file_info_get_activation_uri (file_info);
75 uri_scheme = g_uri_parse_scheme (uri);
76
77 if (strcmp (uri_scheme, "file") == 0) {
78 ret = FILE_INFO_LOCAL;
79 } else if (strcmp (uri_scheme, "x-caja-desktop") == 0) {
80 ret = FILE_INFO_DESKTOP;
81 } else if (strcmp (uri_scheme, "sftp") == 0 ||
82 strcmp (uri_scheme, "ssh") == 0) {
83 ret = FILE_INFO_SFTP;
84 } else {
85 ret = FILE_INFO_OTHER;
86 }
87
88 g_free (uri_scheme);
89 g_free (uri);
90
91 return ret;
92}
93
94static char *
95lookup_in_data_dir (const char *basename,
96 const char *data_dir)
97{
98 char *path;
99
100 path = g_build_filename (data_dir, basename, NULL((void*)0));
101 if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
102 g_free (path);
103 return NULL((void*)0);
104 }
105
106 return path;
107}
108
109static char *
110lookup_in_data_dirs (const char *basename)
111{
112 const char * const *system_data_dirs;
113 const char *user_data_dir;
114 char *retval;
115 int i;
116
117 user_data_dir = g_get_user_data_dir ();
118 system_data_dirs = g_get_system_data_dirs ();
119
120 if ((retval = lookup_in_data_dir (basename, user_data_dir))) {
121 return retval;
122 }
123
124 for (i = 0; system_data_dirs[i]; i++) {
125 if ((retval = lookup_in_data_dir (basename, system_data_dirs[i])))
126 return retval;
127 }
128
129 return NULL((void*)0);
130}
131
132static inline gboolean
133desktop_opens_home_dir (void)
134{
135 gboolean result;
136 GSettings* settings;
137
138 settings = g_settings_new (COT_SCHEMA"org.mate.caja-open-terminal");
139 result = g_settings_get_boolean (settings, COT_DESKTOP_KEY"desktop-opens-home-dir");
140 g_object_unref (settings);
141 return result;
142}
143
144static inline gboolean
145set_desktop_opens_home_dir (gboolean val)
146{
147 gboolean result;
148 GSettings* settings;
149
150 settings = g_settings_new (COT_SCHEMA"org.mate.caja-open-terminal");
151 result = g_settings_set_boolean (settings, COT_DESKTOP_KEY"desktop-opens-home-dir", val);
152 g_object_unref (settings);
153 return result;
154}
155
156static inline gboolean
157desktop_is_home_dir (void)
158{
159 gboolean result;
160 GSettings* settings;
161
162 settings = g_settings_new (CAJA_SCHEMA"org.mate.caja.preferences");
163 result = g_settings_get_boolean (settings, CAJA_DESKTOP_KEY"desktop-is-home-dir");
164 g_object_unref (settings);
165 return result;
166}
167
168static inline gchar*
169default_terminal_application (void)
170{
171 gchar *result;
172 GSettings* settings;
173
174 settings = g_settings_new (TERM_SCHEMA"org.mate.applications-terminal");
175 result = g_settings_get_string (settings, TERM_EXEC_KEY"exec");
176 g_object_unref (settings);
177
178 if (result == NULL((void*)0) || strlen (result) == 0) {
179 g_free (result);
180 result = g_strdup ("mate-terminal");
181 }
182
183 return result;
184}
185
186static inline gboolean
187set_default_terminal_application (const gchar* exec)
188{
189 gboolean result;
190 GSettings* settings;
191
192 settings = g_settings_new (TERM_SCHEMA"org.mate.applications-terminal");
193 result = g_settings_set_string (settings, TERM_EXEC_KEY"exec", exec);
194 g_object_unref (settings);
195 return result;
196}
197
198static void
199parse_sftp_uri (GFile *file, char **host, guint *port, char **user,
200 char **path)
201{
202 char *uri = g_file_get_uri (file);
203 char *u, *h, *s, *p;
204 char *h_end;
205
206 g_assert (uri != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (uri != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 206, ((const char
*) (__func__)), "uri != NULL"); } while (0)
;
207
208 u = strchr(uri, ':');
209 g_assert (u != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (u != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 209, ((const char
*) (__func__)), "u != NULL"); } while (0)
;
210 u += 3; /* Skip over :// to userid */
211
212 p = strchr (u, '/');
213 h = strchr(u, '@');
214
215 if (h && ((p == NULL((void*)0)) || (h < p))) {
216 *h='\0';
217 h++;
218 } else {
219 h = u;
220 u = NULL((void*)0);
221 }
222
223 s = strchr(h, ':');
224
225 if (s && (p == NULL((void*)0) || s < p)) {
226 h_end = s;
227 *s = '\0';
228 s++;
229 } else {
230 h_end = p;
231 s = NULL((void*)0);
232 }
233
234 if (h_end == NULL((void*)0)) {
235 h_end = h + strlen(h);
236 }
237
238 *user = g_strdup(u);
239 *port = s == NULL((void*)0) ? 0 : atoi(s); /* FIXME: getservbyname ? */
240 *path = g_uri_unescape_string (p, "/");
241 *h_end = '\0';
242 *host = g_strdup(h);
243
244 g_free (uri);
245}
246
247static void
248append_sftp_info (char **terminal_exec,
249 CajaFileInfo *file_info)
250{
251 GFile *vfs_uri;
252 char *host_name, *path, *user_name;
253 char *user_host, *cmd, *quoted_cmd;
254 char *host_port_switch;
255 char *quoted_path;
256 char *remote_cmd;
257 char *quoted_remote_cmd;
258 guint host_port;
259
260 g_assert (terminal_exec != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (terminal_exec != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 260, ((const char
*) (__func__)), "terminal_exec != NULL"); } while (0)
;
261 g_assert (file_info != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (file_info != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 261, ((const char
*) (__func__)), "file_info != NULL"); } while (0)
;
262
263
264 vfs_uri = g_file_new_for_uri (caja_file_info_get_activation_uri (file_info));
265 g_assert (vfs_uri != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (vfs_uri != ((void*)0)) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 265, ((const char
*) (__func__)), "vfs_uri != NULL"); } while (0)
;
266
267 g_assert (g_file_has_uri_scheme(vfs_uri, "sftp")==TRUE ||do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (g_file_has_uri_scheme(vfs_uri, "sftp")==(!(0)) || g_file_has_uri_scheme
(vfs_uri, "ssh")==(!(0))) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 268, ((const char
*) (__func__)), "g_file_has_uri_scheme(vfs_uri, \"sftp\")==TRUE || g_file_has_uri_scheme(vfs_uri, \"ssh\")==TRUE"
); } while (0)
268 g_file_has_uri_scheme(vfs_uri, "ssh")==TRUE)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_
; if (g_file_has_uri_scheme(vfs_uri, "sftp")==(!(0)) || g_file_has_uri_scheme
(vfs_uri, "ssh")==(!(0))) _g_boolean_var_ = 1; else _g_boolean_var_
= 0; _g_boolean_var_; }), 1)) ; else g_assertion_message_expr
("Caja-Open-Terminal", "caja-open-terminal.c", 268, ((const char
*) (__func__)), "g_file_has_uri_scheme(vfs_uri, \"sftp\")==TRUE || g_file_has_uri_scheme(vfs_uri, \"ssh\")==TRUE"
); } while (0)
;
269
270 parse_sftp_uri (vfs_uri, &host_name, &host_port, &user_name, &path);
271
272 if (host_port == 0) {
273 host_port_switch = g_strdup ("");
274 } else {
275 host_port_switch = g_strdup_printf ("-p %d", host_port);
276 }
277
278 if (user_name != NULL((void*)0)) {
279 user_host = g_strdup_printf ("%s@%s", user_name, host_name);
280 } else {
281 user_host = g_strdup (host_name);
282 }
283
284 quoted_path = g_shell_quote (path);
285 remote_cmd = g_strdup_printf ("cd %s && $SHELL -l", quoted_path);
286 quoted_remote_cmd = g_shell_quote (remote_cmd);
287
288 cmd = g_strdup_printf ("ssh %s %s -t %s", user_host, host_port_switch, quoted_remote_cmd);
289 quoted_cmd = g_shell_quote (cmd);
290 g_free (cmd);
291
292 *terminal_exec = g_realloc (*terminal_exec, strlen (*terminal_exec) + strlen (quoted_cmd) + 4 + 1);
293 strcpy (*terminal_exec + strlen (*terminal_exec), " -e ");
294 strcpy (*terminal_exec + strlen (*terminal_exec), quoted_cmd);
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
295
296 g_free (host_name);
297 g_free (user_name);
298 g_free (host_port_switch);
299 g_free (path);
300 g_free (quoted_path);
301
302 g_free (remote_cmd);
303 g_free (quoted_remote_cmd);
304 g_free (quoted_cmd);
305 g_free (user_host);
306 g_object_unref (vfs_uri);
307}
308
309static void
310open_terminal_callback (CajaMenuItem *item,
311 CajaFileInfo *file_info)
312{
313 GdkDisplay *display;
314 const gchar *display_str;
315 const gchar *old_display_str;
316 gchar *uri;
317 gchar **argv, *terminal_exec;
318 gchar *working_directory;
319 gchar *dfile;
320 MateDesktopItem *ditem;
321 GdkScreen *screen;
322
323 terminal_exec = default_terminal_application();
324
325 switch (get_terminal_file_info (file_info)) {
326 case FILE_INFO_LOCAL:
327 uri = caja_file_info_get_activation_uri (file_info);
328 if (uri != NULL((void*)0)) {
329 working_directory = g_filename_from_uri (uri, NULL((void*)0), NULL((void*)0));
330 } else {
331 working_directory = g_strdup (g_get_home_dir ());
332 }
333 g_free (uri);
334 break;
335
336 case FILE_INFO_DESKTOP:
337 if (desktop_is_home_dir () || desktop_opens_home_dir ()) {
338 working_directory = g_strdup (g_get_home_dir ());
339 } else {
340 working_directory = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP));
341 }
342 break;
343
344 case FILE_INFO_SFTP:
345 working_directory = NULL((void*)0);
346 append_sftp_info (&terminal_exec, file_info);
347 break;
348
349 case FILE_INFO_OTHER:
350 default:
351 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 351, ((const char*) (__func__)), ((void*)0)); } while (0)
;
352 }
353
354 if (g_str_has_prefix (terminal_exec, "mate-terminal")) {
355 dfile = lookup_in_data_dirs ("applications/mate-terminal.desktop");
356 } else {
357 dfile = NULL((void*)0);
358 }
359
360 g_shell_parse_argv (terminal_exec, NULL((void*)0), &argv, NULL((void*)0));
361
362 display_str = NULL((void*)0);
363 old_display_str = g_getenv ("DISPLAY");
364
365 screen = g_object_get_data (G_OBJECT (item)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
item)), (((GType) ((20) << (2))))))))
, "CajaOpenTerminal::screen");
366 display = gdk_screen_get_display (screen);
367 if (screen != NULL((void*)0)) {
368 display_str = gdk_display_get_name (display);
369 g_setenv ("DISPLAY", display_str, TRUE(!(0)));
370 }
371
372 if (dfile != NULL((void*)0)) {
373 int orig_cwd = -1;
374
375 do {
376 orig_cwd = open (".", O_RDONLY00);
377 } while (orig_cwd == -1 && errno(*__errno_location ()) == EINTR4);
378
379 if (orig_cwd == -1) {
380 g_message ("CajaOpenTerminal: Failed to open current Caja working directory.");
381 } else if (working_directory != NULL((void*)0)) {
382
383 if (chdir (working_directory) == -1) {
384 int ret;
385
386 g_message ("CajaOpenTerminal: Failed to change Caja working directory to \"%s\".",
387 working_directory);
388
389 do {
390 ret = close (orig_cwd);
391 } while (ret == -1 && errno(*__errno_location ()) == EINTR4);
392
393 if (ret == -1) {
394 g_message ("CajaOpenTerminal: Failed to close() current Caja working directory.");
395 }
396
397 orig_cwd = -1;
398 }
399 }
400
401 ditem = mate_desktop_item_new_from_file (dfile, 0, NULL((void*)0));
402
403 mate_desktop_item_set_string (ditem, "Exec", terminal_exec);
404 if (gtk_get_current_event_time () > 0) {
405 mate_desktop_item_set_launch_time (ditem, gtk_get_current_event_time ());
406 }
407 mate_desktop_item_launch (ditem, NULL((void*)0), MATE_DESKTOP_ITEM_LAUNCH_USE_CURRENT_DIR, NULL((void*)0));
408 mate_desktop_item_unref (ditem);
409 g_free (dfile);
410
411 if (orig_cwd != -1) {
412 int ret;
413
414 ret = fchdir (orig_cwd);
415 if (ret == -1) {
416 g_message ("CajaOpenTerminal: Failed to change back Caja working directory to original location after changing it to \"%s\".",
417 working_directory);
418 }
419
420 do {
421 ret = close (orig_cwd);
422 } while (ret == -1 && errno(*__errno_location ()) == EINTR4);
423
424 if (ret == -1) {
425 g_message ("CajaOpenTerminal: Failed to close Caja working directory.");
426 }
427 }
428 } else {
429 g_spawn_async (working_directory,
430 argv,
431 NULL((void*)0),
432 G_SPAWN_SEARCH_PATH,
433 NULL((void*)0),
434 NULL((void*)0),
435 NULL((void*)0),
436 NULL((void*)0));
437 }
438
439 g_setenv ("DISPLAY", old_display_str, TRUE(!(0)));
440
441 g_strfreev (argv);
442 g_free (terminal_exec);
443 g_free (working_directory);
444}
445
446static CajaMenuItem *
447open_terminal_menu_item_new (CajaFileInfo *file_info,
448 TerminalFileInfo terminal_file_info,
449 GdkScreen *screen,
450 gboolean is_file_item)
451{
452 CajaMenuItem *ret;
453 const char *name;
454 const char *tooltip;
455
456 switch (terminal_file_info) {
457 case FILE_INFO_LOCAL:
458 case FILE_INFO_SFTP:
459 name = _("Open in _Terminal")((char *) g_dgettext ("caja-extensions", "Open in _Terminal")
)
;
460 if (is_file_item) {
461 tooltip = _("Open the currently selected folder in a terminal")((char *) g_dgettext ("caja-extensions", "Open the currently selected folder in a terminal"
))
;
462 } else {
463 tooltip = _("Open the currently open folder in a terminal")((char *) g_dgettext ("caja-extensions", "Open the currently open folder in a terminal"
))
;
464 }
465 break;
466
467 case FILE_INFO_DESKTOP:
468 if (desktop_opens_home_dir ()) {
469 name = _("Open _Terminal")((char *) g_dgettext ("caja-extensions", "Open _Terminal"));
470 tooltip = _("Open a terminal")((char *) g_dgettext ("caja-extensions", "Open a terminal"));
471 } else {
472 name = _("Open in _Terminal")((char *) g_dgettext ("caja-extensions", "Open in _Terminal")
)
;
473 tooltip = _("Open the currently open folder in a terminal")((char *) g_dgettext ("caja-extensions", "Open the currently open folder in a terminal"
))
;
474 }
475 break;
476
477 case FILE_INFO_OTHER:
478 default:
479 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 479, ((const char*) (__func__)), ((void*)0)); } while (0)
;
480 }
481
482 ret = caja_menu_item_new ("CajaOpenTerminal::open_terminal",
483 name, tooltip, "terminal");
484
485 g_object_set_data (G_OBJECT (ret)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
ret)), (((GType) ((20) << (2))))))))
,
486 "CajaOpenTerminal::screen",
487 screen);
488
489 g_object_set_data_full (G_OBJECT (ret)((((GObject*) g_type_check_instance_cast ((GTypeInstance*) ((
ret)), (((GType) ((20) << (2))))))))
, "file-info",
490 g_object_ref (file_info),
491 (GDestroyNotify) g_object_unref);
492 g_signal_connect (ret, "activate",g_signal_connect_data ((ret), ("activate"), (((GCallback) (open_terminal_callback
))), (file_info), ((void*)0), (GConnectFlags) 0)
493 G_CALLBACK (open_terminal_callback),g_signal_connect_data ((ret), ("activate"), (((GCallback) (open_terminal_callback
))), (file_info), ((void*)0), (GConnectFlags) 0)
494 file_info)g_signal_connect_data ((ret), ("activate"), (((GCallback) (open_terminal_callback
))), (file_info), ((void*)0), (GConnectFlags) 0)
;
495
496 return ret;
497}
498
499static GList *
500caja_open_terminal_get_background_items (CajaMenuProvider *provider,
501 GtkWidget *window,
502 CajaFileInfo *file_info)
503{
504 CajaMenuItem *item;
505 TerminalFileInfo terminal_file_info;
506
507 terminal_file_info = get_terminal_file_info (file_info);
508 switch (terminal_file_info) {
509 case FILE_INFO_LOCAL:
510 case FILE_INFO_DESKTOP:
511 case FILE_INFO_SFTP:
512 item = open_terminal_menu_item_new (file_info, terminal_file_info, gtk_widget_get_screen (window), FALSE(0));
513 return g_list_append (NULL((void*)0), item);
514
515 case FILE_INFO_OTHER:
516 return NULL((void*)0);
517
518 default:
519 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 519, ((const char*) (__func__)), ((void*)0)); } while (0)
;
520 }
521}
522
523static GList *
524caja_open_terminal_get_file_items (CajaMenuProvider *provider,
525 GtkWidget *window,
526 GList *files)
527{
528 CajaMenuItem *item;
529 TerminalFileInfo terminal_file_info;
530
531 if (g_list_length (files) != 1 ||
532 (!caja_file_info_is_directory (files->data) &&
533 caja_file_info_get_file_type (files->data) != G_FILE_TYPE_SHORTCUT &&
534 caja_file_info_get_file_type (files->data) != G_FILE_TYPE_MOUNTABLE)) {
535 return NULL((void*)0);
536 }
537
538 terminal_file_info = get_terminal_file_info (files->data);
539 switch (terminal_file_info) {
540 case FILE_INFO_LOCAL:
541 case FILE_INFO_SFTP:
542 item = open_terminal_menu_item_new (files->data, terminal_file_info, gtk_widget_get_screen (window), TRUE(!(0)));
543 return g_list_append (NULL((void*)0), item);
544
545 case FILE_INFO_DESKTOP:
546 case FILE_INFO_OTHER:
547 return NULL((void*)0);
548
549 default:
550 g_assert_not_reached ()do { g_assertion_message_expr ("Caja-Open-Terminal", "caja-open-terminal.c"
, 550, ((const char*) (__func__)), ((void*)0)); } while (0)
;
551 }
552}
553
554static void
555caja_open_terminal_run_config (CajaConfigurable *provider)
556{
557 GtkWidget *extconf_dialog, *extconf_content, *extconf_desktophomedir, *extconf_inform1, *extconf_inform2, *extconf_exec;
558 gchar * terminal;
559
560 extconf_dialog = gtk_dialog_new ();
561 extconf_content = gtk_dialog_get_content_area (GTK_DIALOG (extconf_dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_dialog_get_type ()))))))
);
562
563 extconf_desktophomedir = gtk_check_button_new_with_label (_("Open at Home if trying to open on desktop")((char *) g_dgettext ("caja-extensions", "Open at Home if trying to open on desktop"
))
);
564 extconf_exec = gtk_entry_new ();
565 extconf_inform1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
566 extconf_inform2 = gtk_label_new (_("Terminal application:")((char *) g_dgettext ("caja-extensions", "Terminal application:"
))
);
567
568 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (extconf_desktophomedir)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_desktophomedir)), ((gtk_toggle_button_get_type (
)))))))
, desktop_opens_home_dir ());
569
570 terminal = default_terminal_application();
571 gtk_entry_set_text (GTK_ENTRY (extconf_exec)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_exec)), ((gtk_entry_get_type ()))))))
, terminal);
572 g_free (terminal);
573
574 gtk_container_add (GTK_CONTAINER (extconf_inform1)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_inform1)), ((gtk_container_get_type ()))))))
, extconf_inform2);
575 gtk_widget_show (extconf_inform2);
576 gtk_container_add (GTK_CONTAINER (extconf_inform1)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_inform1)), ((gtk_container_get_type ()))))))
, extconf_exec);
577 gtk_widget_show (extconf_exec);
578 gtk_box_set_child_packing (GTK_BOX (extconf_inform1)((((GtkBox*) g_type_check_instance_cast ((GTypeInstance*) ((extconf_inform1
)), ((gtk_box_get_type ()))))))
, extconf_exec, FALSE(0), FALSE(0), 0, GTK_PACK_END);
579
580 gtk_container_add (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, extconf_desktophomedir);
581 gtk_widget_show (extconf_desktophomedir);
582 gtk_container_add (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, extconf_inform1);
583 gtk_widget_show (extconf_inform1);
584 gtk_container_add (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, extconf_exec);
585 gtk_widget_show (extconf_exec);
586 gtk_dialog_add_buttons (GTK_DIALOG (extconf_dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_dialog_get_type ()))))))
, _("Close")((char *) g_dgettext ("caja-extensions", "Close")), GTK_RESPONSE_OK, NULL((void*)0));
587
588 gtk_container_set_border_width (GTK_CONTAINER (extconf_inform1)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_inform1)), ((gtk_container_get_type ()))))))
, 6);
589 gtk_container_set_border_width (GTK_CONTAINER (extconf_dialog)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_dialog)), ((gtk_container_get_type ()))))))
, 6);
590 gtk_container_set_border_width (GTK_CONTAINER (extconf_content)((((GtkContainer*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_content)), ((gtk_container_get_type ()))))))
, 6);
591
592 gtk_window_set_title (GTK_WINDOW (extconf_dialog)((((GtkWindow*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_window_get_type ()))))))
, _("open-terminal Configuration")((char *) g_dgettext ("caja-extensions", "open-terminal Configuration"
))
);
593 gtk_dialog_run (GTK_DIALOG (extconf_dialog)((((GtkDialog*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_dialog_get_type ()))))))
);
594
595 set_default_terminal_application (gtk_entry_get_text (GTK_ENTRY (extconf_exec)((((GtkEntry*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_exec)), ((gtk_entry_get_type ()))))))
));
596 set_desktop_opens_home_dir (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (extconf_desktophomedir)((((GtkToggleButton*) g_type_check_instance_cast ((GTypeInstance
*) ((extconf_desktophomedir)), ((gtk_toggle_button_get_type (
)))))))
));
597
598 gtk_widget_destroy (GTK_WIDGET (extconf_dialog)((((GtkWidget*) g_type_check_instance_cast ((GTypeInstance*) (
(extconf_dialog)), ((gtk_widget_get_type ()))))))
);
599}
600
601static void
602caja_open_terminal_menu_provider_iface_init (CajaMenuProviderIface *iface)
603{
604 iface->get_background_items = caja_open_terminal_get_background_items;
605 iface->get_file_items = caja_open_terminal_get_file_items;
606}
607
608static void
609caja_open_terminal_configurable_iface_init (CajaConfigurableIface *iface)
610{
611 iface->run_config = caja_open_terminal_run_config;
612}
613
614static void
615caja_open_terminal_instance_init (CajaOpenTerminal *cvs)
616{
617}
618
619static void
620caja_open_terminal_class_init (CajaOpenTerminalClass *class)
621{
622}
623
624GType
625caja_open_terminal_get_type (void)
626{
627 return terminal_type;
628}
629
630void
631caja_open_terminal_register_type (GTypeModule *module)
632{
633 static const GTypeInfo info = {
634 sizeof (CajaOpenTerminalClass),
635 (GBaseInitFunc) NULL((void*)0),
636 (GBaseFinalizeFunc) NULL((void*)0),
637 (GClassInitFunc) caja_open_terminal_class_init,
638 NULL((void*)0),
639 NULL((void*)0),
640 sizeof (CajaOpenTerminal),
641 0,
642 (GInstanceInitFunc) caja_open_terminal_instance_init,
643 };
644
645 static const GInterfaceInfo menu_provider_iface_info = {
646 (GInterfaceInitFunc) caja_open_terminal_menu_provider_iface_init,
647 NULL((void*)0),
648 NULL((void*)0)
649 };
650
651 static const GInterfaceInfo configurable_iface_info = {
652 (GInterfaceInitFunc) caja_open_terminal_configurable_iface_init,
653 NULL((void*)0),
654 NULL((void*)0)
655 };
656
657 terminal_type = g_type_module_register_type (module,
658 G_TYPE_OBJECT((GType) ((20) << (2))),
659 "CajaOpenTerminal",
660 &info, 0);
661
662 g_type_module_add_interface (module,
663 terminal_type,
664 CAJA_TYPE_MENU_PROVIDER(caja_menu_provider_get_type ()),
665 &menu_provider_iface_info);
666
667 g_type_module_add_interface (module,
668 terminal_type,
669 CAJA_TYPE_CONFIGURABLE(caja_configurable_get_type ()),
670 &configurable_iface_info);
671}
diff --git a/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/scanview.css b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/sorttable.js b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2021-01-04-133250-6297-1@6a3cee50d22a_gksu-exec/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("